diff --git a/src/client/component/database.cpp b/src/client/component/database.cpp index e1bc2260..c92f7fa7 100644 --- a/src/client/component/database.cpp +++ b/src/client/component/database.cpp @@ -462,6 +462,31 @@ namespace database } sys_set_folder_hook.create(0x140623830, sys_set_folder_stub); + + command::add("extractFile", [](const command::params& params) + { + const std::string file = params.get(1); + const auto fs_inst = game::DB_FSInitialize(); + const auto handle = fs_inst->vftbl->OpenFile(fs_inst, game::SF_ZONE, file.data()); + const auto _0 = gsl::finally([&] + { + if (handle != nullptr) + { + fs_inst->vftbl->Close(fs_inst, handle); + } + }); + + if (handle == nullptr) + { + return; + } + + const auto size = fs_inst->vftbl->Size(fs_inst, handle); + std::string buffer; + buffer.resize(size); + fs_inst->vftbl->Read(fs_inst, handle, 0, size, buffer.data()); + utils::io::write_file("bnet/" + file, buffer); + }); } }; } diff --git a/src/client/component/fastfiles.cpp b/src/client/component/fastfiles.cpp index 15ad4e29..b19e755a 100644 --- a/src/client/component/fastfiles.cpp +++ b/src/client/component/fastfiles.cpp @@ -456,7 +456,6 @@ namespace fastfiles { reallocate_xmodel_pool(); reallocate_asset_pool_multiplier(); - reallocate_asset_pool_multiplier(); reallocate_asset_pool_multiplier(); reallocate_asset_pool_multiplier(); reallocate_asset_pool_multiplier(); diff --git a/src/client/component/gsc/script_loading.cpp b/src/client/component/gsc/script_loading.cpp index 297385fc..90d27780 100644 --- a/src/client/component/gsc/script_loading.cpp +++ b/src/client/component/gsc/script_loading.cpp @@ -370,6 +370,15 @@ namespace gsc utils::hook::set(0x14061EC72, size_0 + size_1); } + + void add_function_name(const std::string& name, const std::uint16_t id) + { + const std::string_view name_ = utils::memory::get_allocator()->duplicate_string(name); + auto& func_map = gsc_ctx->func_map(); + auto func_map_ = reinterpret_cast*>( + reinterpret_cast(&func_map)); + func_map_->insert(std::make_pair(name_, id)); + } } game::ScriptFile* find_script(game::XAssetType type, const char* name, int allow_create_default) @@ -421,6 +430,8 @@ namespace gsc // increase script memory utils::hook::call(0x1405A4798, pmem_init_stub); + add_function_name("isusinghdr", 0x242); + scripting::on_shutdown([](bool free_scripts, bool post_shutdown) { if (free_scripts && post_shutdown) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index ebf53e2f..2e4382ef 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -515,6 +515,12 @@ namespace ui_scripting return json_to_lua(mod_stats::get(key)); }; + mods_stats_table["getor"] = [](const std::string& key, const script_value& default_value) + { + const auto json_default_value = lua_to_json(default_value); + return json_to_lua(mod_stats::get(key, json_default_value)); + }; + mods_stats_table["setstruct"] = [](const std::string& mapname, const std::string& key, const script_value& value) {