diff --git a/src/component/fastfiles.cpp b/src/component/fastfiles.cpp new file mode 100644 index 00000000..42d0b782 --- /dev/null +++ b/src/component/fastfiles.cpp @@ -0,0 +1,73 @@ +#include +#include "loader/component_loader.hpp" +#include "fastfiles.hpp" + +#include "command.hpp" +#include "game_console.hpp" + +#include +#include + +namespace fastfiles +{ + static utils::concurrency::container current_fastfile; + + namespace + { + utils::hook::detour db_try_load_x_file_internal_hook; + + void db_try_load_x_file_internal(const char* zone_name, const int flags) + { + game_console::print(game_console::con_type_info, "Loading fastfile %s\n", zone_name); + current_fastfile.access([&](std::string& fastfile) + { + fastfile = zone_name; + }); + return db_try_load_x_file_internal_hook.invoke(zone_name, flags); + } + } + + std::string get_current_fastfile() + { + std::string fastfile_copy; + current_fastfile.access([&](std::string& fastfile) + { + fastfile_copy = fastfile; + }); + return fastfile_copy; + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + db_try_load_x_file_internal_hook.create(game::base_address + 0x4173B0, &db_try_load_x_file_internal); + + command::add("loadzone", [](const command::params& params) + { + if (params.size() < 2) + { + game_console::print(game_console::con_type_info, "usage: loadzone \n"); + return; + } + + game::XZoneInfo info{}; + info.name = params.get(1); + info.allocFlags = 1; + info.freeFlags = 0; + game::DB_LoadXAssets(&info, 1u, game::DBSyncMode::DB_LOAD_SYNC); + }); + + command::add("g_poolSizes", []() + { + for (auto i = 0; i < game::ASSET_TYPE_COUNT; i++) + { + game_console::print(game_console::con_type_info, "g_poolSize[%i]: %i // %s\n", i, game::g_poolSize[i], game::g_assetNames[i]); + } + }); + } + }; +} + +REGISTER_COMPONENT(fastfiles::component) diff --git a/src/component/fastfiles.hpp b/src/component/fastfiles.hpp new file mode 100644 index 00000000..ac26d2ec --- /dev/null +++ b/src/component/fastfiles.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include "game/game.hpp" + +namespace fastfiles +{ + std::string get_current_fastfile(); +} diff --git a/src/component/lui.cpp b/src/component/lui.cpp new file mode 100644 index 00000000..cf2b9ba9 --- /dev/null +++ b/src/component/lui.cpp @@ -0,0 +1,43 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" + +#include "command.hpp" +#include "game_console.hpp" + +#include + +namespace lui +{ + class component final : public component_interface + { + public: + void post_unpack() override + { + command::add("lui_open", [](const command::params& params) + { + if (params.size() <= 1) + { + game_console::print(game_console::con_type_info, "usage: lui_open \n"); + return; + } + + game::LUI_OpenMenu(0, params[1], 0, 0, 0); + }); + + command::add("lui_open_popup", [](const command::params& params) + { + if (params.size() <= 1) + { + game_console::print(game_console::con_type_info, "usage: lui_open_popup \n"); + return; + } + + game::LUI_OpenMenu(0, params[1], 1, 0, 0); + }); + } + }; +} + +REGISTER_COMPONENT(lui::component) diff --git a/src/game/structs.hpp b/src/game/structs.hpp index 91a32cb4..4546f81d 100644 --- a/src/game/structs.hpp +++ b/src/game/structs.hpp @@ -538,6 +538,23 @@ namespace game unsigned int nextPoolEntry; }; + enum DBSyncMode + { + DB_LOAD_ASYNC = 0x0, + DB_LOAD_SYNC = 0x1, + DB_LOAD_ASYNC_WAIT_ALLOC = 0x2, + DB_LOAD_ASYNC_FORCE_FREE = 0x3, + DB_LOAD_ASYNC_NO_SYNC_THREADS = 0x4, + DB_LOAD_SYNC_SKIP_ALWAYS_LOADED = 0x5, + }; + + struct XZoneInfo + { + const char* name; + int allocFlags; + int freeFlags; + }; + enum scr_string_t { scr_string_t_dummy = 0x0, diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index fa47c1d1..07ea0f20 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -16,7 +16,8 @@ namespace game WEAK symbol DB_EnumXAssets_Internal{0x4129F0}; - WEAK symbol DB_GetXAssetName{0x3E4090}; + WEAK symbol DB_GetXAssetName{0x3E4090}; + WEAK symbol DB_LoadXAssets{0x414FF0}; WEAK symbol Dvar_FindVar{0x618F90}; WEAK symbol Dvar_GetCombinedString{0x5A75D0}; @@ -40,6 +41,8 @@ namespace game WEAK symbol I_CleanStr{0x620660}; + WEAK symbol LUI_OpenMenu{0x5F0EE0}; + WEAK symbol Material_RegisterHandle{0x759BA0}; WEAK symbol Scr_AllocVector{0x5C3220}; @@ -75,6 +78,7 @@ namespace game WEAK symbol cmd_args{0xAD17A60}; WEAK symbol g_assetNames{0xBEF280}; + WEAK symbol g_poolSize{0xBF2E40}; WEAK symbol g_entities{0x52DDDA0};