diff --git a/src/client/component/fastfiles.cpp b/src/client/component/fastfiles.cpp index 7b67f301..bfcc6c80 100644 --- a/src/client/component/fastfiles.cpp +++ b/src/client/component/fastfiles.cpp @@ -430,6 +430,12 @@ namespace fastfiles } } + const std::string name_ = name; + if (name_.starts_with("mp_")) + { + add_custom_level_load_zone(load, "common_mp", 0x40000); + } + if (is_builtin_map) { const auto name_ = "h2_mod_patch_"s + name; @@ -450,6 +456,18 @@ namespace fastfiles { game::DB_LoadXAssets(info, zone_count, game::DB_LOAD_ASYNC); } + + void db_find_aipaths_stub(game::XAssetType type, const char* name, int allow_create_default) + { + if (game::DB_XAssetExists(type, name)) + { + game::DB_FindXAssetHeader(type, name, allow_create_default); + } + else + { + console::warn("No aipaths found for this map\n"); + } + } } bool exists(const std::string& zone) @@ -526,6 +544,11 @@ namespace fastfiles // Load assets from 2nd phase (common_specialops, addon map) with DB_LOAD_SYNC utils::hook::call(0x140414EA1, db_load_xassets_stub); + // Allow loading mp maps + utils::hook::set(0x140609630, 0xC300B0); + // Don't sys_error if aipaths are missing + utils::hook::call(0x140522299, db_find_aipaths_stub); + command::add("loadzone", [](const command::params& params) { if (params.size() < 2) diff --git a/src/client/component/scripting.cpp b/src/client/component/scripting.cpp index 9177f60a..e47cfb37 100644 --- a/src/client/component/scripting.cpp +++ b/src/client/component/scripting.cpp @@ -7,6 +7,7 @@ #include "scheduler.hpp" #include "scripting.hpp" #include "gsc.hpp" +#include "console.hpp" #include "game/scripting/event.hpp" #include "game/scripting/functions.hpp" @@ -274,6 +275,17 @@ namespace scripting scr_get_dvar_int_hook.invoke(); } + + void* get_spawn_point_stub() + { + const auto spawn_point = utils::hook::invoke(0x1404B1670); + if (spawn_point == nullptr) + { + console::warn("No spawnpoint found for this map, using (0, 0, 0)\n"); + return &game::g_entities[0]; + } + return spawn_point; + } } std::string get_token_single(unsigned int id) @@ -324,6 +336,8 @@ namespace scripting scr_get_dvar_int_hook.create(0x1404F0730, scr_get_dvar_int_stub); + utils::hook::call(0x1404B07D2, get_spawn_point_stub); + scheduler::loop([]() { lua::engine::run_frame();