Mod stats + mod_pre_gfx
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "fastfiles.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "imagefiles.hpp"
|
||||
#include "weapon.hpp"
|
||||
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
@ -27,10 +28,12 @@ namespace fastfiles
|
||||
game::dvar_t* g_dump_scripts;
|
||||
|
||||
std::vector<HANDLE> fastfile_handles;
|
||||
bool is_mod_pre_gfx = false;
|
||||
|
||||
void db_try_load_x_file_internal(const char* zone_name, const int flags)
|
||||
{
|
||||
console::info("Loading fastfile %s\n", zone_name);
|
||||
is_mod_pre_gfx = zone_name == "mod_pre_gfx"s;
|
||||
current_fastfile.access([&](std::string& fastfile)
|
||||
{
|
||||
fastfile = zone_name;
|
||||
@ -346,7 +349,9 @@ namespace fastfiles
|
||||
|
||||
// code_pre_gfx
|
||||
|
||||
try_load_zone("h1_mod_code_pre_gfx", true);
|
||||
weapon::clear_modifed_enums();
|
||||
try_load_zone("mod_pre_gfx", true);
|
||||
try_load_zone("h1_mod_pre_gfx", true);
|
||||
|
||||
game::DB_LoadXAssets(data.data(), static_cast<std::uint32_t>(data.size()), syncMode);
|
||||
}
|
||||
@ -960,6 +965,24 @@ namespace fastfiles
|
||||
mp::reallocate_asset_pools();
|
||||
}
|
||||
}
|
||||
|
||||
utils::hook::detour db_link_x_asset_entry_hook;
|
||||
game::XAssetEntry* db_link_x_asset_entry_stub(game::XAssetType type, game::XAssetHeader* header)
|
||||
{
|
||||
if (!is_mod_pre_gfx)
|
||||
{
|
||||
return db_link_x_asset_entry_hook.invoke<game::XAssetEntry*>(type, header);
|
||||
}
|
||||
|
||||
static game::XAssetEntry entry{};
|
||||
|
||||
if (type != game::ASSET_TYPE_STRINGTABLE)
|
||||
{
|
||||
return &entry;
|
||||
}
|
||||
|
||||
return db_link_x_asset_entry_hook.invoke<game::XAssetEntry*>(type, header);
|
||||
}
|
||||
}
|
||||
|
||||
bool exists(const std::string& zone, bool ignore_usermap)
|
||||
@ -1055,6 +1078,11 @@ namespace fastfiles
|
||||
db_unload_x_zones_hook.create(SELECT_VALUE(0x1F6040_b,
|
||||
0x39B3C0_b), db_unload_x_zones_stub);
|
||||
|
||||
if (!game::environment::is_sp())
|
||||
{
|
||||
db_link_x_asset_entry_hook.create(0x396E80_b, db_link_x_asset_entry_stub);
|
||||
}
|
||||
|
||||
g_dump_scripts = dvars::register_bool("g_dumpScripts", false, game::DVAR_FLAG_NONE, "Dump GSC scripts");
|
||||
|
||||
reallocate_asset_pools();
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "materials.hpp"
|
||||
#include "mods.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "game/demonware/services.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/io.hpp>
|
||||
@ -55,6 +56,11 @@ namespace mods
|
||||
if (game::environment::is_mp())
|
||||
{
|
||||
command::execute("vid_restart");
|
||||
scheduler::once([]
|
||||
{
|
||||
demonware::set_storage_path(mod_path.value_or(""));
|
||||
utils::hook::invoke<void>(0x4E6B60_b, 0); // read stats
|
||||
}, scheduler::main);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ namespace party
|
||||
std::vector<usermap_file> mod_files =
|
||||
{
|
||||
{".ff", "modHash", false},
|
||||
{"_pre_gfx.ff", "modpregfxhash", false},
|
||||
{".pak", "modpakhash", true},
|
||||
};
|
||||
|
||||
|
@ -138,6 +138,7 @@ namespace weapon
|
||||
}
|
||||
|
||||
utils::memory::allocator ddl_allocator;
|
||||
std::unordered_set<void*> modified_enums;
|
||||
|
||||
std::vector<const char*> get_stringtable_entries(const std::string& name)
|
||||
{
|
||||
@ -194,8 +195,6 @@ namespace weapon
|
||||
|
||||
void load_ddl_asset_stub(game::DDLRoot** asset)
|
||||
{
|
||||
static std::unordered_set<void*> modified_enums;
|
||||
|
||||
const auto root = *asset;
|
||||
if (!root->ddlDef)
|
||||
{
|
||||
@ -215,14 +214,14 @@ namespace weapon
|
||||
|
||||
if ((enum_->name == "WeaponStats"s || enum_->name == "Weapon"s))
|
||||
{
|
||||
static const auto weapons = get_stringtable_entries("mp/customWeapons.csv");
|
||||
const auto weapons = get_stringtable_entries("mp/customweapons.csv");
|
||||
add_entries_to_enum(enum_, weapons);
|
||||
modified_enums.insert(enum_);
|
||||
}
|
||||
|
||||
if (enum_->name == "AttachmentBase"s)
|
||||
{
|
||||
static const auto attachments = get_stringtable_entries("mp/customAttachments.csv");
|
||||
const auto attachments = get_stringtable_entries("mp/customattachments.csv");
|
||||
add_entries_to_enum(enum_, attachments);
|
||||
modified_enums.insert(enum_);
|
||||
}
|
||||
@ -235,6 +234,11 @@ namespace weapon
|
||||
}
|
||||
}
|
||||
|
||||
void clear_modifed_enums()
|
||||
{
|
||||
modified_enums.clear();
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
|
6
src/client/component/weapon.hpp
Normal file
6
src/client/component/weapon.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace weapon
|
||||
{
|
||||
void clear_modifed_enums();
|
||||
}
|
Reference in New Issue
Block a user