Merge branch 'develop' into confirmation-v2

This commit is contained in:
m
2022-12-22 07:10:33 -06:00
18 changed files with 52 additions and 22 deletions

View File

@ -67,9 +67,12 @@ namespace discord
if (game::environment::is_mp())
{
static char clean_gametype[0x80] = {0};
const auto gametype = game::UI_GetGameTypeDisplayName(
game::Dvar_FindVar("g_gametype")->current.string);
strcpy_s(details, 0x80, utils::string::va("%s on %s", gametype, mapname));
utils::string::strip(gametype,
clean_gametype, sizeof(clean_gametype));
strcpy_s(details, 0x80, utils::string::va("%s on %s", clean_gametype, mapname));
static char clean_hostname[0x80] = {0};
utils::string::strip(game::Dvar_FindVar("sv_hostname")->current.string,

View File

@ -174,7 +174,15 @@ namespace download
const auto& result = data.value();
if (result.code != CURLE_OK)
{
menu_error(utils::string::va("Download failed: %s (%i)\n", curl_easy_strerror(result.code), result.code));
menu_error(utils::string::va("Download failed: %s (%i)\n",
curl_easy_strerror(result.code), result.code));
return;
}
if (result.response_code >= 400)
{
menu_error(utils::string::va("Download failed: Server returned bad response code %i\n",
result.response_code));
return;
}

View File

@ -167,6 +167,10 @@ namespace fastfiles
{
const auto language = game::SEH_GetCurrentLanguageCode();
try_load_zone(language + "_"s + name, false);
if (game::environment::is_mp())
{
try_load_zone(language + "_"s + name + "_mp"s, false);
}
}
if (!fastfiles::exists(name))
@ -256,7 +260,7 @@ namespace fastfiles
{
if (!mod_dir.empty())
{
const auto path = utils::string::va("%s\\%s\\%s",
const auto path = utils::string::va("%s\\%s\\%s",
dir.data(), mod_dir.data(), base_filename);
if (utils::io::file_exists(path))
@ -309,7 +313,7 @@ namespace fastfiles
return fastfiles::usermap_exists(file);
}
template <typename T>
template <typename T>
inline void merge(std::vector<T>* target, T* source, size_t length)
{
if (source)
@ -321,7 +325,7 @@ namespace fastfiles
}
}
template <typename T>
template <typename T>
inline void merge(std::vector<T>* target, std::vector<T> source)
{
for (auto& entry : source)
@ -450,7 +454,7 @@ namespace fastfiles
});
}
void enum_assets(const game::XAssetType type,
void enum_assets(const game::XAssetType type,
const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride)
{
game::DB_EnumXAssets_Internal(type, static_cast<void(*)(game::XAssetHeader, void*)>([](game::XAssetHeader header, void* data)
@ -524,7 +528,7 @@ namespace fastfiles
{
utils::hook::nop(0x368153_b, 2); // DB_InflateInit
}
if (game::environment::is_sp())
{
// Allow loading mp maps

View File

@ -12,7 +12,7 @@ namespace map_patches
public:
void post_unpack() override
{
if (!game::environment::is_mp())
if (game::environment::is_sp())
{
return;
}

View File

@ -183,6 +183,8 @@ namespace party
cl_disconnect_hook.invoke<void>(show_main_menu);
}
std::unordered_map<std::string, std::string> hash_cache;
std::string get_file_hash(const std::string& file)
{
if (!utils::io::file_exists(file))
@ -190,8 +192,15 @@ namespace party
return {};
}
const auto iter = hash_cache.find(file);
if (iter != hash_cache.end())
{
return iter->second;
}
const auto data = utils::io::read_file(file);
const auto sha = utils::cryptography::sha1::compute(data, true);
hash_cache[file] = sha;
return sha;
}
@ -450,6 +459,8 @@ namespace party
return;
}
fastfiles::set_usermap(mapname);
for (const auto& [ext, key, opt] : usermap_files)
{
char buffer[0x100] = {0};
@ -493,6 +504,7 @@ namespace party
fastfiles::set_usermap(map);
}
hash_cache.clear();
current_sv_mapname = map;
utils::hook::invoke<void>(0x54BBB0_b, map, a2, a3, a4, a5);
}