Dont load localized zone on custom maps

This commit is contained in:
fed 2022-10-09 20:51:19 +02:00
parent 7ca9eeffa1
commit 4e348abaf1
4 changed files with 49 additions and 3 deletions

View File

@ -57,8 +57,17 @@ namespace discord
{
static char details[0x80] = {0};
const auto map = game::Dvar_FindVar("mapname")->current.string;
const auto mapname = game::UI_SafeTranslateString(
utils::string::va("PRESENCE_%s%s", SELECT_VALUE("SP_", ""), map));
const auto key = utils::string::va("PRESENCE_%s%s", SELECT_VALUE("SP_", ""), map);
const char* mapname = nullptr;
if (game::DB_XAssetExists(game::ASSET_TYPE_LOCALIZE, key) && !game::DB_IsXAssetDefault(game::ASSET_TYPE_LOCALIZE, key))
{
mapname = game::UI_SafeTranslateString(key);
}
else
{
mapname = map;
}
if (game::environment::is_mp())
{

View File

@ -313,6 +313,29 @@ namespace fastfiles
utils::hook::invoke<void>(0x39CA90_b, a1);
}
void db_level_load_add_zone_stub(void* load, const char* name, const unsigned int alloc_flags,
const size_t size_est)
{
auto is_builtin_map = false;
for (auto map = &game::maps[0]; map->unk; ++map)
{
if (!std::strcmp(map->name, name))
{
is_builtin_map = true;
break;
}
}
if (is_builtin_map)
{
game::DB_LevelLoadAddZone(load, name, alloc_flags, size_est);
}
else
{
game::DB_LevelLoadAddZone(load, name, alloc_flags | game::DB_ZONE_CUSTOM, size_est);
}
}
}
bool exists(const std::string& zone)
@ -402,6 +425,9 @@ namespace fastfiles
{
utils::hook::nop(0x398061_b, 15);
utils::hook::jump(0x398061_b, utils::hook::assemble(mp::skip_extra_zones_stub), true);
// dont load localized zone for custom maps
utils::hook::call(0x394A99_b, db_level_load_add_zone_stub);
}
// prevent mod.ff from loading lua files

View File

@ -1536,6 +1536,13 @@ namespace game
unsigned int data;
};
struct map_t
{
const char* name;
int id;
int unk;
};
namespace mp
{
struct cachedSnapshot_t

View File

@ -182,6 +182,8 @@ namespace game
WEAK symbol<int(XAssetType type)> DB_GetXAssetTypeSize{0x0, 0x0};
WEAK symbol<XAssetHeader(XAssetType type, const char* name,
int createDefault)> DB_FindXAssetHeader{0x1F1120, 0x3950C0};
WEAK symbol<void(void* levelLoad, const char* name,
const unsigned int allocFlags, const unsigned __int64 sizeEst)> DB_LevelLoadAddZone{0x0, 0x396B50};
WEAK symbol<int(XAssetType type, const char* name)> DB_IsXAssetDefault{0x1F25A0, 0x3968C0};
WEAK symbol<int(XAssetType type, const char* name)> DB_XAssetExists{0x1F6290, 0x39B7B0};
@ -277,7 +279,7 @@ namespace game
// TODO: move to dvars.cpp when done
WEAK symbol<dvar_t> fs_gameDirVal{0x0, 0x2EC86B8};
WEAK symbol<int> g_poolSize{0x0, 0x0};
WEAK symbol<int> g_poolSize{0x0, 0x10B3C80};
WEAK symbol<int> g_compressor{0x2574804, 0x3962804};
WEAK symbol<scrVarGlob_t> scr_VarGlob{0xBD80E00, 0xB138180};
@ -301,6 +303,8 @@ namespace game
WEAK symbol<int> level_time{0x56DBAA0, 0x7361F9C};
WEAK symbol<map_t> maps{0x7CE5A0, 0x926C80};
namespace mp
{
WEAK symbol<gentity_s> g_entities{0x0, 0x71F19E0};