diff --git a/src/common/branding.h b/src/common/branding.h index bec02aa..c88a22f 100644 --- a/src/common/branding.h +++ b/src/common/branding.h @@ -1,8 +1,6 @@ #pragma once -#include -#include "version.h" - +#include "config.h" namespace branding { enum Game @@ -52,7 +50,17 @@ inline const char *GetBrandingString(Game game, Mode mode) break; } - _snprintf_s(brandingBuffer, sizeof(brandingBuffer), "CoDxe - %s %s " __DATE__ " " __TIME__, gameName, modeName); + if (Config::active_mod.empty()) + { + _snprintf_s(brandingBuffer, sizeof(brandingBuffer), "CoDxe - %s %s\nBuild: " __DATE__ " " __TIME__, gameName, + modeName); + } + else + { + _snprintf_s(brandingBuffer, sizeof(brandingBuffer), + "CoDxe - %s %s\nBuild: " __DATE__ " " __TIME__ "\nActive mod: %s", gameName, modeName, + Config::active_mod.c_str()); + } return brandingBuffer; } diff --git a/src/common/config.cpp b/src/common/config.cpp index 2531c39..40bb156 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -9,6 +9,11 @@ const char *CONFIG_PATH = "game:\\_codxe\\codxe.json"; const char *MOD_DIR = "game:\\_codxe\\mods"; const char *DUMP_DIR = "game:\\_codxe\\dump"; +// Default values +std::string Config::active_mod = ""; +bool Config::dump_rawfile = false; +bool Config::dump_map_ents = false; + bool DirectoryExists(const char *path) { DWORD attrs = GetFileAttributesA(path); @@ -37,15 +42,26 @@ bool ReadFileToString(const char *path, std::string &outString) return file.read(&outString[0], size).good(); } -void DbgPrintConfig(const Config &config) +Config::Config() +{ + DbgPrint("[codxe][Config] Loading configuration from: %s\n", CONFIG_PATH); + + if (!LoadFromFile(CONFIG_PATH)) + { + DbgPrint("[codxe][Config] Failed to load config file, using defaults\n"); + } +} + +Config::~Config() { - DbgPrint("Configuration:\n"); - DbgPrint("Active Mod: %s\n", config.active_mod.c_str()); - DbgPrint("Dump Raw Scripts: %s\n", config.dump_raw ? "true" : "false"); - DbgPrint("Dump Map Entities: %s\n", config.dump_map_ents ? "true" : "false"); + // Reset to defaults on cleanup + active_mod = ""; + dump_rawfile = false; + dump_map_ents = false; + DbgPrint("[codxe][Config] Configuration unloaded\n"); } -bool LoadConfigFromJson(const char *jsonBuffer, DWORD bufferSize, Config &outConfig) +bool Config::LoadFromJson(const char *jsonBuffer, DWORD bufferSize) { HJSONREADER hJsonReader = XJSONCreateReader(); if (!hJsonReader) @@ -78,35 +94,55 @@ bool LoadConfigFromJson(const char *jsonBuffer, DWORD bufferSize, Config &outCon XJSONGetTokenValue(hJsonReader, valueBuffer, ARRAYSIZE(valueBuffer)); char narrowValue[256]; wcstombs(narrowValue, valueBuffer, sizeof(narrowValue)); - outConfig.active_mod = narrowValue; + active_mod = narrowValue; } - else if (wcscmp(propertyName, L"dump_raw") == 0) + else if (wcscmp(propertyName, L"dump_rawfile") == 0) { - outConfig.dump_raw = (jsonTokenType == Json_True); + dump_rawfile = (jsonTokenType == Json_True); } else if (wcscmp(propertyName, L"dump_map_ents") == 0) { - outConfig.dump_map_ents = (jsonTokenType == Json_True); + dump_map_ents = (jsonTokenType == Json_True); } else { - DbgPrint("WARNING: Ignoring unknown property in config: %ls\n", propertyName); + DbgPrint("[codxe][Config] WARNING: Ignoring unknown property: %ls\n", propertyName); } } } XJSONCloseReader(hJsonReader); - DbgPrintConfig(outConfig); + DbgPrint("[codxe][Config] Configuration loaded:\n"); + DbgPrint(" Active Mod: %s\n", active_mod.c_str()); + DbgPrint(" Dump Raw Scripts: %s\n", dump_rawfile ? "true" : "false"); + DbgPrint(" Dump Map Entities: %s\n", dump_map_ents ? "true" : "false"); return true; } -bool LoadConfigFromFile(const char *path, Config &outConfig) +bool Config::LoadFromFile(const char *path) { std::string jsonContent; if (!ReadFileToString(path, jsonContent)) return false; - return LoadConfigFromJson(jsonContent.c_str(), static_cast(jsonContent.size()), outConfig); + return LoadFromJson(jsonContent.c_str(), static_cast(jsonContent.size())); +} + +// Helper method - requires logic beyond simple field access +std::string Config::GetModBasePath() +{ + if (active_mod.empty()) + { + return ""; + } + + std::string mod_base_path = std::string(MOD_DIR) + "\\" + active_mod; + if (!DirectoryExists(mod_base_path.c_str())) + { + DbgPrint("[codxe][Config] Active mod directory does not exist: %s\n", mod_base_path.c_str()); + return ""; + } + return mod_base_path; } diff --git a/src/common/config.h b/src/common/config.h index 688c8f3..36d3e91 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -10,30 +10,24 @@ bool DirectoryExists(const char *path); bool FileExists(const char *path); bool ReadFileToString(const char *path, std::string &outString); -struct Config +class Config : public Module { - std::string active_mod; - bool dump_raw; - bool dump_map_ents; + public: + Config(); + ~Config(); - Config() + const char *get_name() override { - active_mod = ""; - dump_raw = false; - dump_map_ents = false; + return "Config"; } - std::string GetModBasePath() - { - std::string mod_base_path = std::string(MOD_DIR) + "\\" + active_mod; - if (!DirectoryExists(mod_base_path.c_str())) - { - DbgPrint("Config: Active mod directory does not exist: %s\n", mod_base_path.c_str()); - return ""; - } - return mod_base_path; - } -}; + static std::string active_mod; + static bool dump_rawfile; + static bool dump_map_ents; -bool LoadConfigFromJson(const char *jsonBuffer, DWORD bufferSize, Config &outConfig); -bool LoadConfigFromFile(const char *path, Config &outConfig); + static std::string GetModBasePath(); + + private: + bool LoadFromJson(const char *jsonBuffer, DWORD bufferSize); + bool LoadFromFile(const char *path); +}; diff --git a/src/game/iw2/mp/components/scr_parser.cpp b/src/game/iw2/mp/components/scr_parser.cpp index 1ce0825..5a53821 100644 --- a/src/game/iw2/mp/components/scr_parser.cpp +++ b/src/game/iw2/mp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw2/mp/main.cpp b/src/game/iw2/mp/main.cpp index 524cec9..87b22ce 100644 --- a/src/game/iw2/mp/main.cpp +++ b/src/game/iw2/mp/main.cpp @@ -10,6 +10,7 @@ namespace mp IW2_MP_Plugin::IW2_MP_Plugin() { DbgPrint("IW2 MP Plugin initialized\n"); + RegisterModule(new Config()); RegisterModule(new scr_parser()); } diff --git a/src/game/iw2/sp/components/scr_parser.cpp b/src/game/iw2/sp/components/scr_parser.cpp index c0b707c..8f49c3a 100644 --- a/src/game/iw2/sp/components/scr_parser.cpp +++ b/src/game/iw2/sp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw2/sp/main.cpp b/src/game/iw2/sp/main.cpp index ab5c609..993895b 100644 --- a/src/game/iw2/sp/main.cpp +++ b/src/game/iw2/sp/main.cpp @@ -10,6 +10,7 @@ namespace sp IW2_SP_Plugin::IW2_SP_Plugin() { DbgPrint("IW2 SP Plugin initialized\n"); + RegisterModule(new Config()); this->RegisterModule(new scr_parser()); } diff --git a/src/game/iw3/mp/components/cmds.cpp b/src/game/iw3/mp/components/cmds.cpp index e1e5ad1..1f46ab2 100644 --- a/src/game/iw3/mp/components/cmds.cpp +++ b/src/game/iw3/mp/components/cmds.cpp @@ -121,11 +121,8 @@ bool Cmd_ExecFromFastFile_Hook(int localClientNum, int controllerIndex, const ch controllerIndex, filename); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw3/mp/components/scr_parser.cpp b/src/game/iw3/mp/components/scr_parser.cpp index 4d56e6c..c0a34af 100644 --- a/src/game/iw3/mp/components/scr_parser.cpp +++ b/src/game/iw3/mp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw3/mp/main.cpp b/src/game/iw3/mp/main.cpp index a8b200b..d4da1fc 100644 --- a/src/game/iw3/mp/main.cpp +++ b/src/game/iw3/mp/main.cpp @@ -9,6 +9,7 @@ #include "components/pm.h" #include "components/scr_parser.h" #include "components/scr_vm_functions.h" +#include "common/config.h" // Structure to hold data for the active keyboard request struct KeyboardRequest @@ -391,12 +392,10 @@ void Load_MapEntsPtr_Hook() std::replace(file_path.begin(), file_path.end(), '/', '\\'); // Replace forward slashes with backslashes filesystem::write_file_to_disk(file_path.c_str(), mapEnts->entityString, mapEnts->numEntityChars); - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - + // Use new ConfigModule API // Load map ents from file // Path to check for existing entity file - std::string raw_file_path = config.GetModBasePath(); + std::string raw_file_path = Config::GetModBasePath(); raw_file_path += std::string("\\") + mapEnts->name; raw_file_path += ".ents"; // IW4x naming convention @@ -465,10 +464,8 @@ bool R_StreamLoadHighMipReplacement(const char *filename, unsigned int bytesToRe auto image = asset->entry.asset.header.image; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - std::string replacement_path = config.GetModBasePath() + "\\highmip" + "\\" + asset_name + ".dds"; + // Use new ConfigModule API + std::string replacement_path = Config::GetModBasePath() + "\\highmip" + "\\" + asset_name + ".dds"; std::ifstream file(replacement_path, std::ios::binary | std::ios::ate); if (!file) { @@ -1202,10 +1199,7 @@ void Image_Replace_Cube(GfxImage *image, const DDSImage &ddsImage) void Image_Replace(GfxImage *image) { - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - const std::string replacement_base_dir = config.GetModBasePath() + "\\images"; + const std::string replacement_base_dir = Config::GetModBasePath() + "\\images"; const std::string replacement_path = replacement_base_dir + "\\" + image->name + ".dds"; if (!filesystem::file_exists(replacement_path)) @@ -1539,6 +1533,8 @@ IW3_MP_Plugin::IW3_MP_Plugin() { DbgPrint("Initializing MP\n"); + RegisterModule(new Config()); + RegisterModule(new cg()); RegisterModule(new cj_tas()); RegisterModule(new clipmap()); diff --git a/src/game/iw3/sp/components/scr_parser.cpp b/src/game/iw3/sp/components/scr_parser.cpp index ef656e3..47e12fb 100644 --- a/src/game/iw3/sp/components/scr_parser.cpp +++ b/src/game/iw3/sp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw3/sp/main.cpp b/src/game/iw3/sp/main.cpp index 9394811..c156a0a 100644 --- a/src/game/iw3/sp/main.cpp +++ b/src/game/iw3/sp/main.cpp @@ -142,6 +142,7 @@ void Cmd_Dumpraw_f() IW3_SP_Plugin::IW3_SP_Plugin() { DbgPrint("IW3 SP: Plugin loaded\n"); + RegisterModule(new Config()); RegisterModule(new scr_parser()); CL_GamepadButtonEvent_Detour = Detour(CL_GamepadButtonEvent, CL_GamepadButtonEvent_Hook); diff --git a/src/game/iw4/mp/components/scr_parser.cpp b/src/game/iw4/mp/components/scr_parser.cpp index 44ed775..19a76e8 100644 --- a/src/game/iw4/mp/components/scr_parser.cpp +++ b/src/game/iw4/mp/components/scr_parser.cpp @@ -12,10 +12,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename) auto callOriginal = [&]() { return Scr_AddSourceBuffer_Detour.GetOriginal()(filename, extFilename); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { auto contents = callOriginal(); // Dump the script to a file @@ -27,7 +24,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename) } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw4/mp/main.cpp b/src/game/iw4/mp/main.cpp index 97d55b2..58559ee 100644 --- a/src/game/iw4/mp/main.cpp +++ b/src/game/iw4/mp/main.cpp @@ -19,6 +19,7 @@ IW4_MP_Plugin::IW4_MP_Plugin() { DbgPrint("IW4 MP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new Events()); // Must be registered first to ensure hooks are in place RegisterModule(new cg()); RegisterModule(new clipmap()); diff --git a/src/game/iw4/sp/components/clipmap.cpp b/src/game/iw4/sp/components/clipmap.cpp index 7e62558..f155db9 100644 --- a/src/game/iw4/sp/components/clipmap.cpp +++ b/src/game/iw4/sp/components/clipmap.cpp @@ -15,13 +15,10 @@ void Load_clipMap_t_Hook(bool atStreamStart) if (!varclipMap_t || !*varclipMap_t || !(*varclipMap_t)->name || !(*varclipMap_t)->mapEnts) return; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - auto mapEnts = (*varclipMap_t)->mapEnts; // Dump map entities if enabled - if (config.dump_map_ents) + if (Config::dump_map_ents) { std::string dumpPath = va("%s\\%s.ents", DUMP_DIR, mapEnts->name); // IW4x naming convention std::replace(dumpPath.begin(), dumpPath.end(), '/', '\\'); @@ -30,7 +27,7 @@ void Load_clipMap_t_Hook(bool atStreamStart) } // Check for mod override - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return; diff --git a/src/game/iw4/sp/components/scr_parser.cpp b/src/game/iw4/sp/components/scr_parser.cpp index 7e764b2..fca1299 100644 --- a/src/game/iw4/sp/components/scr_parser.cpp +++ b/src/game/iw4/sp/components/scr_parser.cpp @@ -12,10 +12,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename) auto callOriginal = [&]() { return Scr_AddSourceBuffer_Detour.GetOriginal()(filename, extFilename); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { auto contents = callOriginal(); // Dump the script to a file @@ -27,7 +24,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename) } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/iw4/sp/main.cpp b/src/game/iw4/sp/main.cpp index 3e71329..6e3bee1 100644 --- a/src/game/iw4/sp/main.cpp +++ b/src/game/iw4/sp/main.cpp @@ -34,6 +34,7 @@ IW4_SP_Plugin::IW4_SP_Plugin() RemoveIdleGunSway(); DbgPrint("IW4 SP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new cg()); RegisterModule(new clipmap()); RegisterModule(new g_client_fields()); diff --git a/src/game/iw5/mp/main.cpp b/src/game/iw5/mp/main.cpp index 10e1be4..4e2a058 100644 --- a/src/game/iw5/mp/main.cpp +++ b/src/game/iw5/mp/main.cpp @@ -139,9 +139,7 @@ XAssetHeader *DB_FindXAssetHeader_Hook(XAssetType type, const char *name, int al { if (type == ASSET_TYPE_SCRIPTFILE) { - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); std::string overridePath = modBasePath + "\\" + name + ".gscbin"; std::replace(overridePath.begin(), overridePath.end(), '/', '\\'); @@ -203,6 +201,7 @@ IW5_MP_Plugin::IW5_MP_Plugin() { DbgPrint("IW5 MP Plugin initialized\n"); + RegisterModule(new Config()); RegisterModule(new Branding()); RegisterModule(new patches()); RegisterModule(new PlayerMovement()); diff --git a/src/game/qos/mp/components/scr_parser.cpp b/src/game/qos/mp/components/scr_parser.cpp index d7e01af..119a3bb 100644 --- a/src/game/qos/mp/components/scr_parser.cpp +++ b/src/game/qos/mp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/qos/mp/main.cpp b/src/game/qos/mp/main.cpp index 727f3c4..2d12768 100644 --- a/src/game/qos/mp/main.cpp +++ b/src/game/qos/mp/main.cpp @@ -11,6 +11,7 @@ namespace mp QOS_MP_Plugin::QOS_MP_Plugin() { DbgPrint("QOS SP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new g_scr_main()); RegisterModule(new scr_parser()); } diff --git a/src/game/qos/sp/components/scr_parser.cpp b/src/game/qos/sp/components/scr_parser.cpp index 8108426..891e4d4 100644 --- a/src/game/qos/sp/components/scr_parser.cpp +++ b/src/game/qos/sp/components/scr_parser.cpp @@ -15,10 +15,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -35,7 +32,7 @@ char *Scr_AddSourceBuffer_Hook(const char *filename, const char *extFilename, co } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/qos/sp/main.cpp b/src/game/qos/sp/main.cpp index 35daea6..844b9e8 100644 --- a/src/game/qos/sp/main.cpp +++ b/src/game/qos/sp/main.cpp @@ -9,6 +9,7 @@ namespace sp QOS_SP_Plugin::QOS_SP_Plugin() { DbgPrint("QOS SP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new scr_parser()); } diff --git a/src/game/t4/mp/components/gsc_loader.cpp b/src/game/t4/mp/components/gsc_loader.cpp index 56c8e9c..49120d5 100644 --- a/src/game/t4/mp/components/gsc_loader.cpp +++ b/src/game/t4/mp/components/gsc_loader.cpp @@ -16,10 +16,7 @@ char *GSCLoader::Scr_AddSourceBuffer_Hook(scriptInstance_t a1, const char *filen codePos, archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { auto contents = callOriginal(); // Dump the script to a file @@ -31,7 +28,7 @@ char *GSCLoader::Scr_AddSourceBuffer_Hook(scriptInstance_t a1, const char *filen } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/t4/mp/components/map.cpp b/src/game/t4/mp/components/map.cpp index 4a70b33..1770455 100644 --- a/src/game/t4/mp/components/map.cpp +++ b/src/game/t4/mp/components/map.cpp @@ -16,11 +16,8 @@ void Load_clipMap_t_Hook(bool atStreamStart) auto mapEnts = (*varclipMap_t)->mapEnts; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - // Dump map entities if enabled - if (config.dump_map_ents) + if (Config::dump_map_ents) { std::string dumpPath = va("%s\\%s.ents", DUMP_DIR, mapEnts->name); // IW4x naming convention std::replace(dumpPath.begin(), dumpPath.end(), '/', '\\'); @@ -29,7 +26,7 @@ void Load_clipMap_t_Hook(bool atStreamStart) } // Check for mod override - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return; diff --git a/src/game/t4/mp/main.cpp b/src/game/t4/mp/main.cpp index 625a0c1..a133433 100644 --- a/src/game/t4/mp/main.cpp +++ b/src/game/t4/mp/main.cpp @@ -20,6 +20,7 @@ namespace mp T4_MP_Plugin::T4_MP_Plugin() { DbgPrint("T4 MP: Plugin loaded\n"); + RegisterModule(new Config()); RegisterModule(new Branding()); RegisterModule(new BrushCollision()); RegisterModule(new cg()); diff --git a/src/game/t4/sp/components/clipmap.cpp b/src/game/t4/sp/components/clipmap.cpp index b41ba8c..42c59c4 100644 --- a/src/game/t4/sp/components/clipmap.cpp +++ b/src/game/t4/sp/components/clipmap.cpp @@ -15,13 +15,10 @@ void Load_clipMap_t_Hook(bool atStreamStart) if (!varclipMap_t || !*varclipMap_t || !(*varclipMap_t)->name || !(*varclipMap_t)->mapEnts) return; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - auto mapEnts = (*varclipMap_t)->mapEnts; // Dump map entities if enabled - if (config.dump_map_ents) + if (Config::dump_map_ents) { std::string dumpPath = va("%s\\%s.ents", DUMP_DIR, mapEnts->name); // IW4x naming convention std::replace(dumpPath.begin(), dumpPath.end(), '/', '\\'); @@ -30,7 +27,7 @@ void Load_clipMap_t_Hook(bool atStreamStart) } // Check for mod override - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return; diff --git a/src/game/t4/sp/components/scr_parser.cpp b/src/game/t4/sp/components/scr_parser.cpp index 1bca0f5..1006609 100644 --- a/src/game/t4/sp/components/scr_parser.cpp +++ b/src/game/t4/sp/components/scr_parser.cpp @@ -16,10 +16,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons codePos, archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -36,7 +33,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/t4/sp/main.cpp b/src/game/t4/sp/main.cpp index a3b3ba8..e291db9 100644 --- a/src/game/t4/sp/main.cpp +++ b/src/game/t4/sp/main.cpp @@ -17,6 +17,7 @@ T4_SP_Plugin::T4_SP_Plugin() { DbgPrint("T4 SP: Plugin loaded\n"); + RegisterModule(new Config()); RegisterModule(new clipmap()); RegisterModule(new g_scr_main()); // Needs to be registered before g_client_script_cmd RegisterModule(new g_client_fields()); diff --git a/src/game/t5/mp/components/scr_parser.cpp b/src/game/t5/mp/components/scr_parser.cpp index 0c6a76b..6da8023 100644 --- a/src/game/t5/mp/components/scr_parser.cpp +++ b/src/game/t5/mp/components/scr_parser.cpp @@ -16,10 +16,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons codePos, archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -36,7 +33,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/t5/mp/main.cpp b/src/game/t5/mp/main.cpp index 09136bc..bfb0dec 100644 --- a/src/game/t5/mp/main.cpp +++ b/src/game/t5/mp/main.cpp @@ -10,6 +10,7 @@ namespace mp T5_MP_Plugin::T5_MP_Plugin() { DbgPrint("T5 MP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new scr_parser()); } diff --git a/src/game/t5/sp/components/scr_parser.cpp b/src/game/t5/sp/components/scr_parser.cpp index ddf1933..c20933d 100644 --- a/src/game/t5/sp/components/scr_parser.cpp +++ b/src/game/t5/sp/components/scr_parser.cpp @@ -16,10 +16,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons codePos, archive); }; - Config config; - LoadConfigFromFile(CONFIG_PATH, config); - - if (config.dump_raw) + if (Config::dump_rawfile) { DbgPrint("GSCLoader: Dumping script %s\n", extFilename); auto contents = callOriginal(); @@ -36,7 +33,7 @@ char *Scr_AddSourceBuffer_Hook(scriptInstance_t inst, const char *filename, cons } // Check if mod is active - std::string modBasePath = config.GetModBasePath(); + std::string modBasePath = Config::GetModBasePath(); if (modBasePath.empty()) return callOriginal(); diff --git a/src/game/t5/sp/main.cpp b/src/game/t5/sp/main.cpp index b23b041..dcb73bd 100644 --- a/src/game/t5/sp/main.cpp +++ b/src/game/t5/sp/main.cpp @@ -10,6 +10,7 @@ namespace sp T5_SP_Plugin::T5_SP_Plugin() { DbgPrint("T5 SP: Registering modules\n"); + RegisterModule(new Config()); RegisterModule(new scr_parser()); }