diff --git a/src/client/component/mapents.cpp b/src/client/component/mapents.cpp index f05f92f5..00616167 100644 --- a/src/client/component/mapents.cpp +++ b/src/client/component/mapents.cpp @@ -226,7 +226,8 @@ namespace mapents std::optional get_mapents_data(std::string* real_path = nullptr) { std::string data{}; - if (filesystem::read_file("addon_map_ents/"s + addon_mapname->current.string + ".mapents"s, &data, real_path)) + if (addon_mapname->current.string != ""s && + filesystem::read_file("addon_map_ents/"s + addon_mapname->current.string + ".mapents"s, &data, real_path)) { return {data}; } @@ -271,10 +272,7 @@ namespace mapents game::XAssetHeader db_find_xasset_header_stub(game::XAssetType type, const char* name, int allow_create_default) { - const auto _0 = gsl::finally([]() - { - game::Dvar_SetFromStringFromSource("addon_mapname", "", game::DVAR_SOURCE_INTERNAL); - }); + const auto _0 = gsl::finally(&mapents::clear_dvars); const auto mapents = allocator.allocate(); mapents->name = allocator.duplicate_string(name); @@ -313,9 +311,13 @@ namespace mapents } } + void clear_dvars() + { + game::Dvar_SetString(addon_mapname, ""); + } + void clear() { - game::Dvar_SetFromStringFromSource("addon_mapname", "", game::DVAR_SOURCE_INTERNAL); allocator.clear(); } diff --git a/src/client/component/mapents.hpp b/src/client/component/mapents.hpp index b17247ca..8b19d317 100644 --- a/src/client/component/mapents.hpp +++ b/src/client/component/mapents.hpp @@ -3,4 +3,5 @@ namespace mapents { void clear(); + void clear_dvars(); } diff --git a/src/client/component/mods.cpp b/src/client/component/mods.cpp index 565bd869..c427229b 100644 --- a/src/client/component/mods.cpp +++ b/src/client/component/mods.cpp @@ -30,6 +30,7 @@ namespace mods { materials::clear(); fonts::clear(); + mapents::clear_dvars(); } mapents::clear(); diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 15af7244..1ece7892 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -57,6 +57,7 @@ namespace game WEAK symbol Dvar_ValueToString{0x14061B8F0}; WEAK symbol Dvar_SetCommand{0x14061A5C0}; WEAK symbol Dvar_SetFromStringFromSource{0x14061A910}; + WEAK symbol Dvar_SetString{0x14061ABF0}; WEAK symbol generateHashValue{0x140343D20};