From 7a33fe42e8a5cc3e456970e75bdfe6e0241b4923 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 18 Jan 2022 11:10:53 +0000 Subject: [PATCH 01/52] :rotating_light: Fix DB_EnumXAssetEntries :zap: --- .../Modules/AssetInterfaces/IMaterial.cpp | 35 ++++++++++--------- src/Game/Functions.cpp | 22 +++++++++--- src/Game/Functions.hpp | 11 ++++++ src/Game/Structs.hpp | 13 +++++++ 4 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 89abca3d..23f63ef2 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -250,28 +250,31 @@ namespace Assets if (iw4TechSet) { Game::DB_EnumXAssetEntries(Game::XAssetType::ASSET_TYPE_MATERIAL, [asset, iw4TechSet](Game::XAssetEntry* entry) + { + if (!replacementFound) { - if (!replacementFound) + Game::XAssetHeader header = entry->asset.header; + + if (header.material->techniqueSet == iw4TechSet->asset.header.techniqueSet) { - Game::XAssetHeader header = entry->asset.header; + Components::Logger::Print("Material %s with techset %s has been mapped to %s (last chance!), taking the sort key of material %s\n", + asset->info.name, asset->techniqueSet->name, + header.material->techniqueSet->name, header.material->info.name); - if (header.material->techniqueSet == iw4TechSet->asset.header.techniqueSet) - { - Components::Logger::Print("Material %s with techset %s has been mapped to %s (last chance!), taking the sort key of material %s\n", asset->info.name, asset->techniqueSet->name, header.material->techniqueSet->name, header.material->info.name); - asset->info.sortKey = header.material->info.sortKey; - asset->techniqueSet = iw4TechSet->asset.header.techniqueSet; + asset->info.sortKey = header.material->info.sortKey; + asset->techniqueSet = iw4TechSet->asset.header.techniqueSet; - // this is terrible! - asset->stateBitsCount = header.material->stateBitsCount; - asset->stateBitsTable = header.material->stateBitsTable; - std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48); - asset->constantCount = header.material->constantCount; - asset->constantTable = header.material->constantTable; + // this is terrible! + asset->stateBitsCount = header.material->stateBitsCount; + asset->stateBitsTable = header.material->stateBitsTable; + std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48); + asset->constantCount = header.material->constantCount; + asset->constantTable = header.material->constantTable; - replacementFound = true; - } + replacementFound = true; } - }, false, false); + } + }, false, false); if (!replacementFound) { diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 86d8b5c5..39c91002 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -336,6 +336,9 @@ namespace Game Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads = Sys_SuspendOtherThreads_t(0x45A190); Sys_ListFiles_t Sys_ListFiles = Sys_ListFiles_t(0x45A660); Sys_Milliseconds_t Sys_Milliseconds = Sys_Milliseconds_t(0x42A660); + Sys_LockWrite_t Sys_LockWrite = Sys_LockWrite_t(0x435880); + Sys_TempPriorityAtLeastNormalBegin_t Sys_TempPriorityAtLeastNormalBegin = Sys_TempPriorityAtLeastNormalBegin_t(0x478680); + Sys_TempPriorityEnd_t Sys_TempPriorityEnd = Sys_TempPriorityEnd_t(0x4DCF00); TeleportPlayer_t TeleportPlayer = TeleportPlayer_t(0x496850); @@ -493,6 +496,16 @@ namespace Game GraphFloat* aaInputGraph = reinterpret_cast(0x7A2FC0); + FastCriticalSection* db_hashCritSect = reinterpret_cast(0x16B8A54); + + void Sys_UnlockWrite(FastCriticalSection* critSect) + { + assert(critSect->writeCount > 0); + + InterlockedDecrement(&critSect->writeCount); + Sys_TempPriorityEnd(&critSect->tempPriority); + } + XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) { int elSize = DB_GetXAssetSizeHandlers[type](); @@ -609,10 +622,8 @@ namespace Game void DB_EnumXAssetEntries(XAssetType type, std::function callback, bool overrides, bool lock) { - volatile long* lockVar = reinterpret_cast(0x16B8A54); - if (lock) InterlockedIncrement(lockVar); - - while (lock && *reinterpret_cast(0x16B8A58)) std::this_thread::sleep_for(1ms); + if (lock) + Sys_LockWrite(db_hashCritSect); const auto pool = Components::Maps::GetAssetEntryPool(); for(auto hash = 0; hash < 37000; hash++) @@ -641,7 +652,8 @@ namespace Game } } - if(lock) InterlockedDecrement(lockVar); + if(lock) + Sys_UnlockWrite(db_hashCritSect); } // this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 7da47215..127e606d 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -804,6 +804,15 @@ namespace Game typedef int(__cdecl * Sys_Milliseconds_t)(); extern Sys_Milliseconds_t Sys_Milliseconds; + typedef void(__cdecl * Sys_LockWrite_t)(FastCriticalSection* critSect); + extern Sys_LockWrite_t Sys_LockWrite; + + typedef void(__cdecl * Sys_TempPriorityAtLeastNormalBegin_t)(TempPriority*); + extern Sys_TempPriorityAtLeastNormalBegin_t Sys_TempPriorityAtLeastNormalBegin; + + typedef void(__cdecl * Sys_TempPriorityEnd_t)(TempPriority*); + extern Sys_TempPriorityEnd_t Sys_TempPriorityEnd; + typedef void(__cdecl * TeleportPlayer_t)(gentity_t* entity, float* pos, float* orientation); extern TeleportPlayer_t TeleportPlayer; @@ -1013,6 +1022,8 @@ namespace Game constexpr auto AIM_ASSIST_GRAPH_COUNT = 4u; extern GraphFloat* aaInputGraph; + void Sys_UnlockWrite(FastCriticalSection*); + XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); void Menu_FreeItemMemory(Game::itemDef_s* item); void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 8a74e54d..a0ea28a9 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -6961,6 +6961,19 @@ namespace Game PM_EFF_STANCE_COUNT = 4 }; + struct TempPriority + { + void* threadHandle; + int oldPriority; + }; + + struct FastCriticalSection + { + volatile long readCount; + volatile long writeCount; + TempPriority tempPriority; + }; + #pragma endregion #ifndef IDA From d756e8626bc965669cc162c3b0065a202e64ba4d Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 18 Jan 2022 16:24:52 +0000 Subject: [PATCH 02/52] Reorder functions in the files --- src/Game/Functions.cpp | 4 ++-- src/Game/Functions.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 34d78e01..6f949634 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -502,6 +502,8 @@ namespace Game FastCriticalSection* db_hashCritSect = reinterpret_cast(0x16B8A54); + vec3_t* CorrectSolidDeltas = reinterpret_cast(0x739BB8); // Count 26 + void Sys_UnlockWrite(FastCriticalSection* critSect) { assert(critSect->writeCount > 0); @@ -510,8 +512,6 @@ namespace Game Sys_TempPriorityEnd(&critSect->tempPriority); } - vec3_t* CorrectSolidDeltas = reinterpret_cast(0x739BB8); // Count 26 - XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) { int elSize = DB_GetXAssetSizeHandlers[type](); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 13514b23..9d49115a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1032,10 +1032,10 @@ namespace Game constexpr auto AIM_ASSIST_GRAPH_COUNT = 4u; extern GraphFloat* aaInputGraph; - void Sys_UnlockWrite(FastCriticalSection*); - extern vec3_t* CorrectSolidDeltas; + void Sys_UnlockWrite(FastCriticalSection*); + XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); void Menu_FreeItemMemory(Game::itemDef_s* item); void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1); From 93cb764c23c693f68a0c6a83f5e39dc8469de0cb Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 19 Jan 2022 19:32:49 +0000 Subject: [PATCH 03/52] :lock: Used the wrong locks :lock: --- .../Modules/AssetInterfaces/IMaterial.cpp | 6 +++--- src/Components/Modules/ZoneBuilder.cpp | 2 +- src/Game/Functions.cpp | 20 ++++++++++--------- src/Game/Functions.hpp | 5 +++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 23f63ef2..637064b7 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -199,7 +199,7 @@ namespace Assets replacementFound = true; } } - }, false, false); + }, false); if (!replacementFound) { @@ -236,7 +236,7 @@ namespace Assets replacementFound = true; } } - }, false, false); + }, false); } if (!replacementFound && asset->techniqueSet) @@ -274,7 +274,7 @@ namespace Assets replacementFound = true; } } - }, false, false); + }, false); if (!replacementFound) { diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index a9a38a33..c48132f9 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -981,7 +981,7 @@ namespace Components replacementFound = true; } } - }, false, false); + }, false); if (replacementFound) return ret; return ""; diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 6f949634..43a9fe55 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -504,12 +504,16 @@ namespace Game vec3_t* CorrectSolidDeltas = reinterpret_cast(0x739BB8); // Count 26 - void Sys_UnlockWrite(FastCriticalSection* critSect) + void Sys_LockRead(FastCriticalSection* critSect) { - assert(critSect->writeCount > 0); + InterlockedIncrement(&critSect->readCount); + while (critSect->writeCount) std::this_thread::sleep_for(1ms); + } - InterlockedDecrement(&critSect->writeCount); - Sys_TempPriorityEnd(&critSect->tempPriority); + void Sys_UnlockRead(FastCriticalSection* critSect) + { + assert(critSect->readCount > 0); + InterlockedDecrement(&critSect->readCount); } XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) @@ -626,10 +630,9 @@ namespace Game return false; } - void DB_EnumXAssetEntries(XAssetType type, std::function callback, bool overrides, bool lock) + void DB_EnumXAssetEntries(XAssetType type, std::function callback, bool overrides) { - if (lock) - Sys_LockWrite(db_hashCritSect); + Sys_LockRead(db_hashCritSect); const auto pool = Components::Maps::GetAssetEntryPool(); for(auto hash = 0; hash < 37000; hash++) @@ -658,8 +661,7 @@ namespace Game } } - if(lock) - Sys_UnlockWrite(db_hashCritSect); + Sys_UnlockRead(db_hashCritSect); } // this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 9d49115a..78281dab 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1034,7 +1034,8 @@ namespace Game extern vec3_t* CorrectSolidDeltas; - void Sys_UnlockWrite(FastCriticalSection*); + void Sys_LockRead(FastCriticalSection* critSect); + void Sys_UnlockRead(FastCriticalSection* critSect); XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); void Menu_FreeItemMemory(Game::itemDef_s* item); @@ -1049,7 +1050,7 @@ namespace Game XAssetType DB_GetXAssetNameType(const char* name); int DB_GetZoneIndex(const std::string& name); bool DB_IsZoneLoaded(const char* zone); - void DB_EnumXAssetEntries(XAssetType type, std::function callback, bool overrides, bool lock); + void DB_EnumXAssetEntries(XAssetType type, std::function callback, bool overrides); XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType type); XAssetEntry* DB_FindXAssetEntry(XAssetType type, const char* name); From ac7cd528a1b908f5d14dd14b2355eb51f41fbdeb Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 19 Jan 2022 19:41:35 +0000 Subject: [PATCH 04/52] Forgot to export the lock :lock: --- src/Game/Functions.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 78281dab..37f26b5a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1034,6 +1034,8 @@ namespace Game extern vec3_t* CorrectSolidDeltas; + extern FastCriticalSection* db_hashCritSect; + void Sys_LockRead(FastCriticalSection* critSect); void Sys_UnlockRead(FastCriticalSection* critSect); From 3bb39483dc1bcf8107b2eba1a6af49c1b63bc830 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 27 Jan 2022 17:11:21 +0000 Subject: [PATCH 05/52] Use zone allocator instead of static mem allocator --- src/Components/Modules/AntiCheat.cpp | 2 +- .../Modules/AssetInterfaces/IFont_s.cpp | 43 +++++++++++-------- src/Utils/Memory.hpp | 2 + 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index 01dbea5c..af7b678d 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -634,7 +634,7 @@ namespace Components LUID luid; TOKEN_PRIVILEGES tp = { 0 }; DWORD cb = sizeof(TOKEN_PRIVILEGES); - if (!LookupPrivilegeValueA(nullptr, SE_DEBUG_NAME, &luid)) return; + if (!LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &luid)) return; tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index a820011f..edeb572b 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -53,15 +53,15 @@ namespace Assets auto& glyph = glyphs[i++]; glyph.letter = ch; - glyph.s0 = x / static_cast(pw); - glyph.s1 = (x + gw) / static_cast(pw); - glyph.t0 = y / static_cast(ph); - glyph.t1 = (y + gh) / static_cast(ph); + glyph.s0 = static_cast(x / pw); + glyph.s1 = static_cast((x + gw) / pw); + glyph.t0 = static_cast(y / ph); + glyph.t1 = static_cast((y + gh) / ph); glyph.pixelWidth = static_cast(gw); glyph.pixelHeight = static_cast(gh); glyph.x0 = static_cast(x0); glyph.y0 = static_cast(y0 + yOffset); - glyph.dx = static_cast(roundf(scale * advance)); + glyph.dx = static_cast(std::roundf(scale * advance)); // Advance to next col x = x + gw + 1; @@ -92,7 +92,7 @@ namespace Assets } } - void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone*) + void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { Components::FileSystem::File fontDefFile(Utils::String::VA("%s.json", name.data())); Components::FileSystem::File fontFile(Utils::String::VA("%s.ttf", name.data())); @@ -105,11 +105,13 @@ namespace Assets if (!errors.empty()) { Components::Logger::Error("Font define %s is broken: %s.", name.data(), errors.data()); + return; } if (!fontDef.is_object()) { Components::Logger::Error("Font define %s is invaild.", name.data(), errors.data()); + return; } int w = fontDef["textureWidth"].int_value(); @@ -118,22 +120,28 @@ namespace Assets int size = fontDef["size"].int_value(); int yOffset = fontDef["yOffset"].int_value(); - uint8_t* pixels = Utils::Memory::AllocateArray(w * h); + auto* pixels = builder->getAllocator()->allocateArray(w * h); // Setup assets - auto* texName = Utils::Memory::DuplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */)); - auto* fontName = Utils::Memory::DuplicateString(name.data()); - auto* glowMaterialName = Utils::Memory::DuplicateString(Utils::String::VA("%s_glow", name.data())); + const auto* texName = builder->getAllocator()->duplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */)); + const auto* fontName = builder->getAllocator()->duplicateString(name.data()); + const auto* glowMaterialName = builder->getAllocator()->duplicateString(Utils::String::VA("%s_glow", name.data())); + + auto* image = builder->getAllocator()->allocate(); + std::memcpy(image, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image, sizeof(Game::GfxImage)); - auto* image = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image); image->name = texName; - - auto* material = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material); - material->textureTable = Utils::Memory::Duplicate(material->textureTable); + + auto* material = builder->getAllocator()->allocate(); + std::memcpy(material, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material, sizeof(Game::Material)); + + material->textureTable = builder->getAllocator()->allocate(); material->textureTable->u.image = image; material->info.name = fontName; - auto* glowMaterial = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material); + auto* glowMaterial = builder->getAllocator()->allocate(); + std::memcpy(glowMaterial, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material, sizeof(Game::Material)); + glowMaterial->textureTable = material->textureTable; glowMaterial->info.name = glowMaterialName; @@ -161,14 +169,14 @@ namespace Assets charset.push_back(i); } - auto* font = Utils::Memory::Allocate(); + auto* font = builder->getAllocator()->allocate(); font->fontName = fontName; font->pixelHeight = size; font->material = material; font->glowMaterial = glowMaterial; font->glyphCount = charset.size(); - font->glyphs = Utils::Memory::AllocateArray(charset.size()); + font->glyphs = builder->getAllocator()->allocateArray(charset.size()); // Generate glyph data int result = PackFonts(reinterpret_cast(fontFile.getBuffer().data()), charset, font->glyphs, static_cast(size), pixels, w, h, yOffset); @@ -239,7 +247,6 @@ namespace Assets } Utils::IO::WriteFile(Utils::String::VA("userraw\\images\\%s.iwi", texName), outIwi); - Utils::Memory::Free(pixels); } } diff --git a/src/Utils/Memory.hpp b/src/Utils/Memory.hpp index f5eb5e50..88bb7007 100644 --- a/src/Utils/Memory.hpp +++ b/src/Utils/Memory.hpp @@ -81,10 +81,12 @@ namespace Utils this->pool.push_back(data); return data; } + template inline T* allocate() { return this->allocateArray(1); } + template inline T* allocateArray(size_t count = 1) { return static_cast(this->allocate(count * sizeof(T))); From 48f7cc2d4646ae5f702c566c0919832928588ee4 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 27 Jan 2022 17:16:40 +0000 Subject: [PATCH 06/52] Fix compilation --- src/Components/Modules/AntiCheat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index af7b678d..01dbea5c 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -634,7 +634,7 @@ namespace Components LUID luid; TOKEN_PRIVILEGES tp = { 0 }; DWORD cb = sizeof(TOKEN_PRIVILEGES); - if (!LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &luid)) return; + if (!LookupPrivilegeValueA(nullptr, SE_DEBUG_NAME, &luid)) return; tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; From 39f2f4ff6245e459c21eb0847b64251d7a033bc7 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 3 Feb 2022 12:44:35 +0100 Subject: [PATCH 07/52] Fix gamepad vars --- src/Components/Modules/Dvar.cpp | 85 ++++++++++++++++++++---------- src/Components/Modules/Dvar.hpp | 11 ++-- src/Components/Modules/Gamepad.cpp | 8 +-- src/Components/Modules/Gamepad.hpp | 2 +- src/Game/Functions.hpp | 6 +-- 5 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 1279840b..5fa042c7 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -8,24 +8,39 @@ namespace Components Dvar::Var::Var(const std::string& dvarName) : Var() { this->dvar = Game::Dvar_FindVar(dvarName.data()); + this->dvarName = dvarName; + } - if (!this->dvar) + void Dvar::Var::registerDvar() + { + assert(!this->dvarName.empty() && this->dvar == nullptr); + + auto* dvar = Game::Dvar_FindVar(this->dvarName.data()); + + // If the dvar can't be found it will be registered as an empty string dvar + if (dvar == nullptr) { - // Quick-register the dvar - Game::Dvar_SetStringByName(dvarName.data(), ""); - this->dvar = Game::Dvar_FindVar(dvarName.data()); + this->dvar = const_cast(Game::Dvar_SetFromStringByNameFromSource(this->dvarName.data(), "", + Game::DvarSetSource::DVAR_SOURCE_INTERNAL)); + } + else + { + this->dvar = dvar; } } template <> Game::dvar_t* Dvar::Var::get() { + if (this->dvar == nullptr) + this->registerDvar(); + return this->dvar; } template <> const char* Dvar::Var::get() { if (this->dvar == nullptr) - return ""; + this->registerDvar(); if (this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM) @@ -39,7 +54,10 @@ namespace Components template <> int Dvar::Var::get() { - if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM) + if (this->dvar == nullptr) + this->registerDvar(); + + if (this->dvar->type == Game::dvar_type::DVAR_TYPE_INT || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM) { return this->dvar->current.integer; } @@ -49,34 +67,51 @@ namespace Components template <> unsigned int Dvar::Var::get() { - return static_cast(this->get()); - } + if (this->dvar == nullptr) + this->registerDvar(); - template <> float Dvar::Var::get() - { - if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT) + if (this->dvar->type == Game::dvar_type::DVAR_TYPE_INT) { - return this->dvar->current.value; + return this->dvar->current.unsignedInt; } return 0; } + template <> float Dvar::Var::get() + { + if (this->dvar == nullptr) + this->registerDvar(); + + if (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT) + { + return this->dvar->current.value; + } + + return 0.f; + } + template <> float* Dvar::Var::get() { - static float val[4] = { 0 }; + static Game::vec4_t vector{ 0.f, 0.f, 0.f, 0.f }; + + if (this->dvar == nullptr) + this->registerDvar(); if (this->dvar && (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_2 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_3 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_4)) { return this->dvar->current.vector; } - return val; + return vector; } template <> bool Dvar::Var::get() { - if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL) + if (this->dvar == nullptr) + this->registerDvar(); + + if (this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL) { return this->dvar->current.enabled; } @@ -89,11 +124,6 @@ namespace Components return this->get(); } - void Dvar::Var::set(char* string) - { - this->set(const_cast(string)); - } - void Dvar::Var::set(const char* string) { assert(this->dvar->type == Game::DVAR_TYPE_STRING); @@ -242,7 +272,7 @@ namespace Components return Dvar::Register(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).get(); } - Game::dvar_t* Dvar::SetFromStringByNameSafeExternal(const char* dvar, const char* value) + void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string) { static const char* exceptions[] = { @@ -258,18 +288,19 @@ namespace Components for (int i = 0; i < ARRAYSIZE(exceptions); ++i) { - if (Utils::String::ToLower(dvar) == Utils::String::ToLower(exceptions[i])) + if (Utils::String::ToLower(dvarName) == Utils::String::ToLower(exceptions[i])) { - return Game::Dvar_SetFromStringByName(dvar, value); + Game::Dvar_SetFromStringByNameFromSource(dvarName, string, Game::DvarSetSource::DVAR_SOURCE_INTERNAL); + return; } } - return Dvar::SetFromStringByNameExternal(dvar, value); + return Dvar::SetFromStringByNameExternal(dvarName, string); } - Game::dvar_t* Dvar::SetFromStringByNameExternal(const char* dvar, const char* value) + void Dvar::SetFromStringByNameExternal(const char* dvarName, const char* string) { - return Game::Dvar_SetFromStringByNameFromSource(dvar, value, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL); + Game::Dvar_SetFromStringByNameFromSource(dvarName, string, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL); } void Dvar::SaveArchiveDvar(const Game::dvar_t* var) @@ -349,7 +380,7 @@ namespace Components Utils::Hook(0x63CDB5, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick(); Utils::Hook(0x635E47, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick(); - // SetDvar + // Script_SetDvar Utils::Hook(0x63444C, Dvar::SetFromStringByNameSafeExternal, HOOK_CALL).install()->quick(); // Slider diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index b29ef1bd..5d90de11 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -18,14 +18,14 @@ namespace Components { public: Var() : dvar(nullptr) {}; - Var(const Var &obj) { this->dvar = obj.dvar; }; - Var(Game::dvar_t* _dvar) : dvar(_dvar) {}; + Var(const Var& obj) { this->dvar = obj.dvar; this->dvarName = obj.dvarName; }; + Var(Game::dvar_t* _dvar) : dvar(_dvar), dvarName(_dvar->name) {}; Var(DWORD ppdvar) : Var(*reinterpret_cast(ppdvar)) {}; Var(const std::string& dvarName); + void registerDvar(); template T get(); - void set(char* string); void set(const char* string); void set(const std::string& string); @@ -38,6 +38,7 @@ namespace Components void setRaw(bool enabled); private: + std::string dvarName; Game::dvar_t* dvar; }; @@ -58,8 +59,8 @@ namespace Components static Game::dvar_t* RegisterName(const char* name, const char* defaultVal, Game::dvar_flag flag, const char* description); - static Game::dvar_t* SetFromStringByNameExternal(const char* dvar, const char* value); - static Game::dvar_t* SetFromStringByNameSafeExternal(const char* dvar, const char* value); + static void SetFromStringByNameExternal(const char* dvar, const char* value); + static void SetFromStringByNameSafeExternal(const char* dvar, const char* value); static void SaveArchiveDvar(const Game::dvar_t* var); static void DvarSetFromStringByNameStub(const char* dvarName, const char* value); diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index e85e61dd..7e6f677c 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1731,7 +1731,7 @@ namespace Components gpad_button_deadzone = Dvar::Register("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad button deadzone threshhold"); gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); - gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, INT32_MAX, Game::DVAR_FLAG_NONE, "Time to hold the 'use' button on gamepads to activate use"); + gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, std::numeric_limits::max(), Game::DVAR_FLAG_NONE, "Time to hold the 'use' button on gamepads to activate use"); gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad lockon aim assist enabled"); gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad slowdown aim assist enabled"); @@ -1762,10 +1762,10 @@ namespace Components aim_lockon_strength = Dvar::Var("aim_lockon_strength"); } - void Gamepad::IN_Init_Hk() + void Gamepad::CG_RegisterDvars_Hk() { // Call original method - Utils::Hook::Call(0x45D620)(); + Utils::Hook::Call(0x4F8DC0)(); InitDvars(); } @@ -1908,7 +1908,7 @@ namespace Components return; // Initialize gamepad environment - Utils::Hook(0x467C03, IN_Init_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x4059FE, CG_RegisterDvars_Hk, HOOK_CALL).install()->quick(); // package the forward and right move components in the move buttons Utils::Hook(0x60E38D, MSG_WriteDeltaUsercmdKeyStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/Gamepad.hpp b/src/Components/Modules/Gamepad.hpp index 5c55325c..de0c16e0 100644 --- a/src/Components/Modules/Gamepad.hpp +++ b/src/Components/Modules/Gamepad.hpp @@ -187,7 +187,7 @@ namespace Components static void Scores_Toggle_f(Command::Params* params); static void InitDvars(); - static void IN_Init_Hk(); + static void CG_RegisterDvars_Hk(); static const char* GetGamePadCommand(const char* command); static int Key_GetCommandAssignmentInternal_Hk(const char* cmd, int(*keys)[2]); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 9e7b7132..045e2193 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -256,10 +256,10 @@ namespace Game typedef dvar_t* (__cdecl * Dvar_RegisterColor_t)(const char* name, float r, float g, float b, float a, int flags, const char* description); extern Dvar_RegisterColor_t Dvar_RegisterColor; - typedef dvar_t* (__cdecl * Dvar_SetFromStringByName_t)(const char* cvar, const char* value); + typedef void(__cdecl * Dvar_SetFromStringByName_t)(const char* dvarName, const char* string); extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName; - typedef dvar_t* (__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* cvar, const char* value, DvarSetSource source); + typedef const dvar_t* (__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source); extern Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource; typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value); @@ -286,7 +286,7 @@ namespace Game typedef char* (__cdecl* Dvar_InfoString_Big_t)(int typeMask); extern Dvar_InfoString_Big_t Dvar_InfoString_Big; - typedef dvar_t* (__cdecl * Dvar_SetCommand_t)(const char* name, const char* value); + typedef void(__cdecl * Dvar_SetCommand_t)(const char* dvarName, const char* string); extern Dvar_SetCommand_t Dvar_SetCommand; typedef const char* (__cdecl * Dvar_DisplayableValue_t)(const dvar_t* cvar); From 39812a93705f8e98de7b3312303c13bbc17e00f5 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 3 Feb 2022 13:08:25 +0100 Subject: [PATCH 08/52] I forgot I'm not a Java programmer --- src/Components/Modules/Dvar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5fa042c7..057bc52b 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -15,17 +15,17 @@ namespace Components { assert(!this->dvarName.empty() && this->dvar == nullptr); - auto* dvar = Game::Dvar_FindVar(this->dvarName.data()); + auto* var = Game::Dvar_FindVar(this->dvarName.data()); // If the dvar can't be found it will be registered as an empty string dvar - if (dvar == nullptr) + if (var == nullptr) { this->dvar = const_cast(Game::Dvar_SetFromStringByNameFromSource(this->dvarName.data(), "", Game::DvarSetSource::DVAR_SOURCE_INTERNAL)); } else { - this->dvar = dvar; + this->dvar = var; } } From bc68a05b8dbfb9dd605f72ce2e341a176c731377 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 6 Feb 2022 22:22:04 +0000 Subject: [PATCH 09/52] Change param name --- src/Components/Modules/Dvar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 057bc52b..fefb92f6 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -5,10 +5,10 @@ namespace Components Utils::Signal Dvar::RegistrationSignal; const char* Dvar::ArchiveDvarPath = "userraw/archivedvars.cfg"; - Dvar::Var::Var(const std::string& dvarName) : Var() + Dvar::Var::Var(const std::string& _dvarName) : Var() { - this->dvar = Game::Dvar_FindVar(dvarName.data()); - this->dvarName = dvarName; + this->dvar = Game::Dvar_FindVar(_dvarName.data()); + this->dvarName = _dvarName; } void Dvar::Var::registerDvar() From 060cb1d0a05866d6a30df319dece11c5abd285c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Feb 2022 17:18:18 +0000 Subject: [PATCH 10/52] Bump deps/libtommath from `bea9270` to `04e9d1e` Bumps [deps/libtommath](https://github.com/libtom/libtommath) from `bea9270` to `04e9d1e`. - [Release notes](https://github.com/libtom/libtommath/releases) - [Commits](https://github.com/libtom/libtommath/compare/bea9270646303baf683f4ba2ddf0d70721f0e55d...04e9d1e7a0493910b2eb5e757d623870692ada04) --- updated-dependencies: - dependency-name: deps/libtommath dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/libtommath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/libtommath b/deps/libtommath index bea92706..04e9d1e7 160000 --- a/deps/libtommath +++ b/deps/libtommath @@ -1 +1 @@ -Subproject commit bea9270646303baf683f4ba2ddf0d70721f0e55d +Subproject commit 04e9d1e7a0493910b2eb5e757d623870692ada04 From 53ebf0d91e9feeb1bb888bddc73b3c581ae71509 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 19 Feb 2022 23:06:56 +0000 Subject: [PATCH 11/52] Make pr ready to be merged --- src/Components/Modules/Dvar.cpp | 37 ++++++++++----------------------- src/Components/Modules/Dvar.hpp | 6 ++---- src/Game/Functions.hpp | 8 +++---- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index fefb92f6..e2b163a0 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -5,42 +5,27 @@ namespace Components Utils::Signal Dvar::RegistrationSignal; const char* Dvar::ArchiveDvarPath = "userraw/archivedvars.cfg"; - Dvar::Var::Var(const std::string& _dvarName) : Var() + Dvar::Var::Var(const std::string& dvarName) : Var() { - this->dvar = Game::Dvar_FindVar(_dvarName.data()); - this->dvarName = _dvarName; - } - - void Dvar::Var::registerDvar() - { - assert(!this->dvarName.empty() && this->dvar == nullptr); - - auto* var = Game::Dvar_FindVar(this->dvarName.data()); + this->dvar = Game::Dvar_FindVar(dvarName.data()); // If the dvar can't be found it will be registered as an empty string dvar - if (var == nullptr) + if (this->dvar == nullptr) { - this->dvar = const_cast(Game::Dvar_SetFromStringByNameFromSource(this->dvarName.data(), "", + this->dvar = const_cast(Game::Dvar_SetFromStringByNameFromSource(dvarName.data(), "", Game::DvarSetSource::DVAR_SOURCE_INTERNAL)); - } - else - { - this->dvar = var; } } template <> Game::dvar_t* Dvar::Var::get() { - if (this->dvar == nullptr) - this->registerDvar(); - return this->dvar; } template <> const char* Dvar::Var::get() { if (this->dvar == nullptr) - this->registerDvar(); + return ""; if (this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM) @@ -55,7 +40,7 @@ namespace Components template <> int Dvar::Var::get() { if (this->dvar == nullptr) - this->registerDvar(); + return 0; if (this->dvar->type == Game::dvar_type::DVAR_TYPE_INT || this->dvar->type == Game::dvar_type::DVAR_TYPE_ENUM) { @@ -68,20 +53,20 @@ namespace Components template <> unsigned int Dvar::Var::get() { if (this->dvar == nullptr) - this->registerDvar(); + return 0u; if (this->dvar->type == Game::dvar_type::DVAR_TYPE_INT) { return this->dvar->current.unsignedInt; } - return 0; + return 0u; } template <> float Dvar::Var::get() { if (this->dvar == nullptr) - this->registerDvar(); + return 0.f; if (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT) { @@ -96,7 +81,7 @@ namespace Components static Game::vec4_t vector{ 0.f, 0.f, 0.f, 0.f }; if (this->dvar == nullptr) - this->registerDvar(); + return vector; if (this->dvar && (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_2 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_3 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_4)) { @@ -109,7 +94,7 @@ namespace Components template <> bool Dvar::Var::get() { if (this->dvar == nullptr) - this->registerDvar(); + return false; if (this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL) { diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index 5d90de11..8f87eaf5 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -18,12 +18,11 @@ namespace Components { public: Var() : dvar(nullptr) {}; - Var(const Var& obj) { this->dvar = obj.dvar; this->dvarName = obj.dvarName; }; - Var(Game::dvar_t* _dvar) : dvar(_dvar), dvarName(_dvar->name) {}; + Var(const Var& obj) { this->dvar = obj.dvar; }; + Var(Game::dvar_t* _dvar) : dvar(_dvar) {}; Var(DWORD ppdvar) : Var(*reinterpret_cast(ppdvar)) {}; Var(const std::string& dvarName); - void registerDvar(); template T get(); void set(const char* string); @@ -38,7 +37,6 @@ namespace Components void setRaw(bool enabled); private: - std::string dvarName; Game::dvar_t* dvar; }; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 045e2193..5991519b 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -265,16 +265,16 @@ namespace Game typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value); extern Dvar_SetStringByName_t Dvar_SetStringByName; - typedef void (__cdecl * Dvar_SetString_t)(dvar_t* cvar, const char* value); + typedef void (__cdecl * Dvar_SetString_t)(const dvar_t* cvar, const char* value); extern Dvar_SetString_t Dvar_SetString; - typedef void (__cdecl * Dvar_SetBool_t)(dvar_t* cvar, bool enabled); + typedef void (__cdecl * Dvar_SetBool_t)(const dvar_t* cvar, bool enabled); extern Dvar_SetBool_t Dvar_SetBool; - typedef void (__cdecl * Dvar_SetFloat_t)(dvar_t* cvar, float value); + typedef void (__cdecl * Dvar_SetFloat_t)(const dvar_t* cvar, float value); extern Dvar_SetFloat_t Dvar_SetFloat; - typedef void (__cdecl * Dvar_SetInt_t)(dvar_t* cvar, int integer); + typedef void (__cdecl * Dvar_SetInt_t)(const dvar_t* cvar, int integer); extern Dvar_SetInt_t Dvar_SetInt; typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color); From 7b91b9c781895236b0b12e3168efccbe149e0461 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 19 Feb 2022 23:10:35 +0000 Subject: [PATCH 12/52] make code more readable --- src/Components/Modules/Dvar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index e2b163a0..d5ec5fea 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -83,7 +83,8 @@ namespace Components if (this->dvar == nullptr) return vector; - if (this->dvar && (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_2 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_3 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_4)) + if (this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_2 || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_3 + || this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT_4) { return this->dvar->current.vector; } @@ -280,7 +281,7 @@ namespace Components } } - return Dvar::SetFromStringByNameExternal(dvarName, string); + Dvar::SetFromStringByNameExternal(dvarName, string); } void Dvar::SetFromStringByNameExternal(const char* dvarName, const char* string) From a5cc395b652650514eadb3ce7653ed3e3d22456b Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 26 Feb 2022 22:50:53 +0000 Subject: [PATCH 13/52] Refactor some utils --- src/Components/Modules/Auth.cpp | 15 ++++++++------- src/Components/Modules/Bots.cpp | 2 +- src/Components/Modules/Changelog.cpp | 2 +- src/Components/Modules/Dedicated.cpp | 4 ++-- src/Components/Modules/Maps.cpp | 2 +- src/Components/Modules/Node.cpp | 2 +- src/Components/Modules/ServerInfo.cpp | 2 +- src/Components/Modules/ServerList.cpp | 4 ++-- src/Game/Functions.hpp | 2 +- src/Utils/CSV.cpp | 2 +- src/Utils/InfoString.cpp | 25 ++++++++++++++----------- src/Utils/InfoString.hpp | 2 -- src/Utils/String.cpp | 21 +++++++-------------- src/Utils/String.hpp | 2 +- 14 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index e090e1bb..3c06bf72 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -8,7 +8,8 @@ namespace Components Utils::Cryptography::Token Auth::ComputeToken; Utils::Cryptography::ECC::Key Auth::GuidKey; - std::vector Auth::BannedUids = { + std::vector Auth::BannedUids = + { 0xf4d2c30b712ac6e3, 0xf7e33c4081337fa3, 0x6f5597f103cc50e9 @@ -179,8 +180,8 @@ namespace Components Utils::InfoString infostr(params[2]); // Read the required data - std::string steamId = infostr.get("xuid"); - std::string challenge = infostr.get("challenge"); + const auto& steamId = infostr.get("xuid"); + const auto& challenge = infostr.get("challenge"); if (steamId.empty() || challenge.empty()) { @@ -189,12 +190,12 @@ namespace Components } // Parse the id - unsigned __int64 xuid = strtoull(steamId.data(), nullptr, 16); + const auto xuid = strtoull(steamId.data(), nullptr, 16); SteamID guid; guid.bits = xuid; - if (Bans::IsBanned({ guid, address.getIP() })) + if (Bans::IsBanned({guid, address.getIP()})) { Network::Send(address, "error\nEXE_ERR_BANNED_PERM"); return; @@ -223,8 +224,8 @@ namespace Components } // Verify the security level - uint32_t ourLevel = static_cast(Dvar::Var("sv_securityLevel").get()); - uint32_t userLevel = Auth::GetZeroBits(connectData.token(), connectData.publickey()); + auto ourLevel = Dvar::Var("sv_securityLevel").get(); + auto userLevel = Auth::GetZeroBits(connectData.token(), connectData.publickey()); if (userLevel < ourLevel) { diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 15e36cfb..f6b5061e 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -96,7 +96,7 @@ namespace Components if (bots.exists()) { - std::vector names = Utils::String::Explode(bots.getBuffer(), '\n'); + std::vector names = Utils::String::Split(bots.getBuffer(), '\n'); for (auto name : names) { diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 059ef0bb..b88513a1 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -19,7 +19,7 @@ namespace Components data = "^1Unable to get changelog."; } - Changelog::Lines = Utils::String::Explode(data, '\n'); + Changelog::Lines = Utils::String::Split(data, '\n'); for (auto& line : Changelog::Lines) { diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index dc856792..6414aeda 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -124,7 +124,7 @@ namespace Components { auto rotation = Dvar::Var("sv_mapRotation").get(); - const auto tokens = Utils::String::Explode(rotation, ' '); + const auto tokens = Utils::String::Split(rotation, ' '); std::vector> mapRotationPair; for (auto i = 0u; i < (tokens.size() - 1); i += 2) @@ -207,7 +207,7 @@ namespace Components auto rotation = Dvar::Var("sv_mapRotationCurrent").get(); - auto tokens = Utils::String::Explode(rotation, ' '); + auto tokens = Utils::String::Split(rotation, ' '); for (unsigned int i = 0; i < (tokens.size() - 1); i += 2) { diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index a6081034..7a91f2ef 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -357,7 +357,7 @@ namespace Components { if (arena->keys[j] == "dependency"s) { - return Utils::String::Explode(arena->values[j], ' '); + return Utils::String::Split(arena->values[j], ' '); } } } diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 2d60d147..bc1af6dc 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -60,7 +60,7 @@ namespace Components std::string nodes = Utils::Cache::GetFile("/iw4/nodes.txt"); if (nodes.empty()) return; - auto nodeList = Utils::String::Explode(nodes, '\n'); + auto nodeList = Utils::String::Split(nodes, '\n'); for (auto& node : nodeList) { Utils::String::Replace(node, "\r", ""); diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index 04f08bb5..bfd9281d 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -264,7 +264,7 @@ namespace Components Dvar::Var("uiSi_ModName").set(info.get("fs_game").data() + 5); } - auto lines = Utils::String::Explode(data, '\n'); + auto lines = Utils::String::Split(data, '\n'); if (lines.size() <= 1) return; diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 166f444f..ce43bdc7 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -539,8 +539,8 @@ namespace Components bool ServerList::CompareVersion(const std::string& version1, const std::string& version2) { - std::vector subVersions1 = Utils::String::Explode(version1, '.'); - std::vector subVersions2 = Utils::String::Explode(version2, '.'); + std::vector subVersions1 = Utils::String::Split(version1, '.'); + std::vector subVersions2 = Utils::String::Split(version2, '.'); while (subVersions1.size() >= 3) subVersions1.pop_back(); while (subVersions2.size() >= 3) subVersions2.pop_back(); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 9e7b7132..d6b83c52 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -283,7 +283,7 @@ namespace Game typedef dvar_t* (__cdecl * Dvar_FindVar_t)(const char *dvarName); extern Dvar_FindVar_t Dvar_FindVar; - typedef char* (__cdecl* Dvar_InfoString_Big_t)(int typeMask); + typedef char* (__cdecl * Dvar_InfoString_Big_t)(int bit); extern Dvar_InfoString_Big_t Dvar_InfoString_Big; typedef dvar_t* (__cdecl * Dvar_SetCommand_t)(const char* name, const char* value); diff --git a/src/Utils/CSV.cpp b/src/Utils/CSV.cpp index 0b0a02d1..efcfcd28 100644 --- a/src/Utils/CSV.cpp +++ b/src/Utils/CSV.cpp @@ -71,7 +71,7 @@ namespace Utils if (!buffer.empty()) { - auto rows = Utils::String::Explode(buffer, '\n'); + auto rows = Utils::String::Split(buffer, '\n'); for (auto& row : rows) { diff --git a/src/Utils/InfoString.cpp b/src/Utils/InfoString.cpp index 09126843..ba861dac 100644 --- a/src/Utils/InfoString.cpp +++ b/src/Utils/InfoString.cpp @@ -9,9 +9,10 @@ namespace Utils std::string InfoString::get(const std::string& key) { - if (this->keyValuePairs.find(key) != this->keyValuePairs.end()) + const auto value = this->keyValuePairs.find(key); + if (value != this->keyValuePairs.end()) { - return this->keyValuePairs[key]; + return value->second; } return ""; @@ -24,11 +25,13 @@ namespace Utils buffer = buffer.substr(1); } - std::vector KeyValues = Utils::String::Explode(buffer, '\\'); + auto KeyValues = Utils::String::Split(buffer, '\\'); - for (unsigned int i = 0; i < (KeyValues.size() - 1); i += 2) + for (size_t i = 0; !KeyValues.empty() && i < (KeyValues.size() - 1); i += 2) { - this->keyValuePairs[KeyValues[i]] = KeyValues[i + 1]; + const auto& key = KeyValues[i]; + const auto& value = KeyValues[i + 1]; + this->keyValuePairs[key] = value; } } @@ -36,16 +39,16 @@ namespace Utils { std::string infoString; - bool first = true; + auto first = true; - for (auto i = this->keyValuePairs.begin(); i != this->keyValuePairs.end(); ++i) + for (const auto& [key, value] : this->keyValuePairs) { if (first) first = false; else infoString.append("\\"); - infoString.append(i->first); // Key + infoString.append(key); infoString.append("\\"); - infoString.append(i->second); // Value + infoString.append(value); } return infoString; @@ -53,9 +56,9 @@ namespace Utils void InfoString::dump() { - for (auto i = this->keyValuePairs.begin(); i != this->keyValuePairs.end(); ++i) + for (const auto& [key, value] : this->keyValuePairs) { - OutputDebugStringA(Utils::String::VA("%s: %s", i->first.data(), i->second.data())); + OutputDebugStringA(Utils::String::VA("%s: %s\n", key.data(), value.data())); } } diff --git a/src/Utils/InfoString.hpp b/src/Utils/InfoString.hpp index d83edde8..f63c6714 100644 --- a/src/Utils/InfoString.hpp +++ b/src/Utils/InfoString.hpp @@ -7,11 +7,9 @@ namespace Utils public: InfoString() {}; InfoString(const std::string& buffer) : InfoString() { this->parse(buffer); }; - InfoString(const InfoString &obj) : keyValuePairs(obj.keyValuePairs) {}; void set(const std::string& key, const std::string& value); std::string get(const std::string& key); - std::string build(); void dump(); diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index ca2d0664..67d35006 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -62,25 +62,18 @@ namespace Utils return str; } - std::vector Explode(const std::string& str, char delim) + std::vector Split(const std::string& str, const char delim) { - std::vector result; - std::istringstream iss(str); + std::stringstream ss(str); + std::string item; + std::vector elems; - for (std::string token; std::getline(iss, token, delim);) + while (std::getline(ss, item, delim)) { - std::string _entry = std::move(token); - - // Remove trailing 0x0 bytes - while (_entry.size() && !_entry.back()) - { - _entry = _entry.substr(0, _entry.size() - 1); - } - - result.push_back(_entry); + elems.push_back(item); // elems.push_back(std::move(item)); // if C++11 (based on comment from S1x) } - return result; + return elems; } void Replace(std::string &string, const std::string& find, const std::string& replace) diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 2b0ed6d1..3beed27e 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -78,7 +78,7 @@ namespace Utils std::string ToLower(std::string input); std::string ToUpper(std::string input); bool EndsWith(const std::string& haystack, const std::string& needle); - std::vector Explode(const std::string& str, char delim); + std::vector Split(const std::string& str, const char delim); void Replace(std::string &string, const std::string& find, const std::string& replace); bool StartsWith(const std::string& haystack, const std::string& needle); std::string <rim(std::string &s); From 624eba7114aa22bd8469013e159e64bc8cc7ee45 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 26 Feb 2022 23:02:04 +0000 Subject: [PATCH 14/52] Auto keyword --- src/Components/Modules/Auth.cpp | 2 +- src/Components/Modules/ServerList.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 3c06bf72..7af4580e 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -190,7 +190,7 @@ namespace Components } // Parse the id - const auto xuid = strtoull(steamId.data(), nullptr, 16); + const auto xuid = std::strtoull(steamId.data(), nullptr, 16); SteamID guid; guid.bits = xuid; diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index ce43bdc7..f15e09da 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -539,8 +539,8 @@ namespace Components bool ServerList::CompareVersion(const std::string& version1, const std::string& version2) { - std::vector subVersions1 = Utils::String::Split(version1, '.'); - std::vector subVersions2 = Utils::String::Split(version2, '.'); + auto subVersions1 = Utils::String::Split(version1, '.'); + auto subVersions2 = Utils::String::Split(version2, '.'); while (subVersions1.size() >= 3) subVersions1.pop_back(); while (subVersions2.size() >= 3) subVersions2.pop_back(); From f283a52540b2c6c6301f87a052631a601ffefa40 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 26 Feb 2022 23:40:47 +0000 Subject: [PATCH 15/52] Stop formatting nonsense --- src/Utils/String.cpp | 6 +++--- src/Utils/String.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 67d35006..135458a7 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -104,7 +104,7 @@ namespace Utils } // trim from start - std::string <rim(std::string &s) + std::string& LTrim(std::string& s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int val) { @@ -114,7 +114,7 @@ namespace Utils } // trim from end - std::string &RTrim(std::string &s) + std::string& RTrim(std::string& s) { s.erase(std::find_if(s.rbegin(), s.rend(), [](int val) { @@ -124,7 +124,7 @@ namespace Utils } // trim from both ends - std::string &Trim(std::string &s) + std::string& Trim(std::string& s) { return LTrim(RTrim(s)); } diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 3beed27e..8374500a 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -81,9 +81,9 @@ namespace Utils std::vector Split(const std::string& str, const char delim); void Replace(std::string &string, const std::string& find, const std::string& replace); bool StartsWith(const std::string& haystack, const std::string& needle); - std::string <rim(std::string &s); - std::string &RTrim(std::string &s); - std::string &Trim(std::string &s); + std::string& LTrim(std::string& s); + std::string& RTrim(std::string& s); + std::string& Trim(std::string& s); std::string FormatTimeSpan(int milliseconds); std::string FormatBandwidth(size_t bytes, int milliseconds); From c54981c6df59819f0b537a863e855c6df7dffd16 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 12:53:44 +0000 Subject: [PATCH 16/52] ISO Core guidelines --- src/Components/Loader.cpp | 2 +- src/Components/Modules/AntiCheat.cpp | 2 +- src/Components/Modules/ArenaLength.cpp | 2 +- src/Components/Modules/AssetHandler.cpp | 2 +- src/Components/Modules/AssetInterfaces/IComWorld.cpp | 2 +- src/Components/Modules/AssetInterfaces/IFont_s.cpp | 2 +- src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp | 2 +- src/Components/Modules/AssetInterfaces/IFxWorld.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGfxImage.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGfxWorld.cpp | 2 +- src/Components/Modules/AssetInterfaces/ILoadedSound.cpp | 2 +- src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp | 2 +- src/Components/Modules/AssetInterfaces/IMapEnts.cpp | 2 +- src/Components/Modules/AssetInterfaces/IMaterial.cpp | 2 +- .../Modules/AssetInterfaces/IMaterialPixelShader.cpp | 2 +- .../Modules/AssetInterfaces/IMaterialTechniqueSet.cpp | 2 +- .../Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp | 2 +- .../Modules/AssetInterfaces/IMaterialVertexShader.cpp | 2 +- src/Components/Modules/AssetInterfaces/IMenuList.cpp | 2 +- src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp | 2 +- src/Components/Modules/AssetInterfaces/IPhysPreset.cpp | 2 +- src/Components/Modules/AssetInterfaces/IRawFile.cpp | 2 +- src/Components/Modules/AssetInterfaces/ISndCurve.cpp | 2 +- src/Components/Modules/AssetInterfaces/IStringTable.cpp | 2 +- .../Modules/AssetInterfaces/IStructuredDataDefSet.cpp | 2 +- src/Components/Modules/AssetInterfaces/ITracerDef.cpp | 2 +- src/Components/Modules/AssetInterfaces/IWeapon.cpp | 2 +- src/Components/Modules/AssetInterfaces/IXAnimParts.cpp | 2 +- src/Components/Modules/AssetInterfaces/IXModel.cpp | 2 +- src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp | 2 +- src/Components/Modules/AssetInterfaces/IclipMap_t.cpp | 2 +- src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp | 2 +- src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp | 2 +- src/Components/Modules/Auth.cpp | 2 +- src/Components/Modules/Bans.cpp | 2 +- src/Components/Modules/Bots.cpp | 2 +- src/Components/Modules/CardTitles.cpp | 2 +- src/Components/Modules/Changelog.cpp | 2 +- src/Components/Modules/Chat.cpp | 2 +- src/Components/Modules/Clantags.cpp | 2 +- src/Components/Modules/Client.cpp | 2 +- src/Components/Modules/ClientCommand.cpp | 2 +- src/Components/Modules/Command.cpp | 2 +- src/Components/Modules/ConnectProtocol.cpp | 2 +- src/Components/Modules/Console.cpp | 2 +- src/Components/Modules/D3D9Ex.cpp | 2 +- src/Components/Modules/Dedicated.cpp | 2 +- src/Components/Modules/Discovery.cpp | 2 +- src/Components/Modules/Download.cpp | 2 +- src/Components/Modules/Download.hpp | 2 +- src/Components/Modules/Dvar.cpp | 2 +- src/Components/Modules/Elevators.cpp | 2 +- src/Components/Modules/Exception.cpp | 2 +- src/Components/Modules/FastFiles.cpp | 2 +- src/Components/Modules/FileSystem.cpp | 2 +- src/Components/Modules/Flags.cpp | 2 +- src/Components/Modules/FrameTime.cpp | 2 +- src/Components/Modules/Friends.cpp | 2 +- src/Components/Modules/Gamepad.cpp | 2 +- src/Components/Modules/Gametypes.cpp | 2 +- src/Components/Modules/IPCPipe.cpp | 2 +- src/Components/Modules/Lean.cpp | 2 +- src/Components/Modules/Localization.cpp | 2 +- src/Components/Modules/Logger.cpp | 2 +- src/Components/Modules/MapDump.cpp | 2 +- src/Components/Modules/Maps.cpp | 2 +- src/Components/Modules/Materials.cpp | 2 +- src/Components/Modules/Menus.cpp | 2 +- src/Components/Modules/ModList.cpp | 2 +- src/Components/Modules/ModelSurfs.cpp | 2 +- src/Components/Modules/Monitor.cpp | 2 +- src/Components/Modules/Movement.cpp | 2 +- src/Components/Modules/MusicalTalent.cpp | 2 +- src/Components/Modules/Network.cpp | 2 +- src/Components/Modules/News.cpp | 2 +- src/Components/Modules/Node.cpp | 2 +- src/Components/Modules/Party.cpp | 2 +- src/Components/Modules/PlayerName.cpp | 2 +- src/Components/Modules/Playlist.cpp | 2 +- src/Components/Modules/QuickPatch.cpp | 2 +- src/Components/Modules/RCon.cpp | 2 +- src/Components/Modules/RawFiles.cpp | 2 +- src/Components/Modules/Renderer.cpp | 2 +- src/Components/Modules/Scheduler.cpp | 2 +- src/Components/Modules/Script.cpp | 2 +- src/Components/Modules/Script.hpp | 2 +- src/Components/Modules/ServerCommands.cpp | 2 +- src/Components/Modules/ServerInfo.cpp | 2 +- src/Components/Modules/ServerList.cpp | 2 +- src/Components/Modules/Session.cpp | 2 +- src/Components/Modules/Singleton.cpp | 2 +- src/Components/Modules/Slowmotion.cpp | 2 +- src/Components/Modules/SoundMutexFix.cpp | 2 +- src/Components/Modules/StartupMessages.cpp | 2 +- src/Components/Modules/Stats.cpp | 2 +- src/Components/Modules/StringTable.cpp | 2 +- src/Components/Modules/StructuredData.cpp | 2 +- src/Components/Modules/TextRenderer.cpp | 2 +- src/Components/Modules/Theatre.cpp | 2 +- src/Components/Modules/Threading.cpp | 2 +- src/Components/Modules/Toast.cpp | 2 +- src/Components/Modules/UIFeeder.cpp | 2 +- src/Components/Modules/UIScript.cpp | 2 +- src/Components/Modules/Weapon.cpp | 2 +- src/Components/Modules/Window.cpp | 2 +- src/Components/Modules/ZoneBuilder.cpp | 2 +- src/Components/Modules/Zones.cpp | 2 +- src/Game/Functions.cpp | 2 +- src/Steam/Interfaces/SteamFriends.cpp | 2 +- src/Steam/Interfaces/SteamGameServer.cpp | 2 +- src/Steam/Interfaces/SteamMasterServerUpdater.cpp | 2 +- src/Steam/Interfaces/SteamMatchmaking.cpp | 2 +- src/Steam/Interfaces/SteamNetworking.cpp | 2 +- src/Steam/Interfaces/SteamRemoteStorage.cpp | 2 +- src/Steam/Interfaces/SteamUser.cpp | 2 +- src/Steam/Interfaces/SteamUtils.cpp | 2 +- src/Steam/Proxy.cpp | 2 +- src/Steam/Proxy.hpp | 3 ++- src/Steam/Steam.cpp | 2 +- src/Utils/CSV.cpp | 2 +- src/Utils/Cache.cpp | 2 +- src/Utils/Compression.cpp | 2 +- src/Utils/Cryptography.cpp | 2 +- src/Utils/Entities.cpp | 2 +- src/Utils/Hooking.cpp | 2 +- src/Utils/IO.cpp | 2 +- src/Utils/InfoString.cpp | 2 +- src/Utils/Library.cpp | 2 +- src/Utils/Memory.cpp | 2 +- src/Utils/Stream.cpp | 2 +- src/Utils/String.cpp | 2 +- src/Utils/Time.cpp | 2 +- src/Utils/Utils.cpp | 2 +- src/Utils/WebIO.cpp | 2 +- 137 files changed, 138 insertions(+), 137 deletions(-) diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index ec1f5dea..08b4bd6b 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index af7b678d..f4a30e7b 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ArenaLength.cpp b/src/Components/Modules/ArenaLength.cpp index c2efd804..d7a94f09 100644 --- a/src/Components/Modules/ArenaLength.cpp +++ b/src/Components/Modules/ArenaLength.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index cd507f14..b49c16e9 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/AssetInterfaces/IComWorld.cpp b/src/Components/Modules/AssetInterfaces/IComWorld.cpp index a12dd771..b25d832a 100644 --- a/src/Components/Modules/AssetInterfaces/IComWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IComWorld.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_COMMAP_VERSION 0 diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index a820011f..882cccea 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define STB_TRUETYPE_IMPLEMENTATION #include diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index 38928466..92c17ba7 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_FX_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp index 93bbc709..eda6b0ca 100644 --- a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp @@ -1,4 +1,4 @@ -#include "StdInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp index 685ebaa7..513c5df9 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp index 07a79b9c..12a71890 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp index f39a7ea4..06a4b440 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_IMG_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp b/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp index dec55171..b842d9d9 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_LIGHT_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index 7850c41e..b581c8c1 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_GFXMAP_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp index 9dc06fb1..303212f0 100644 --- a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp +++ b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp index f43e8766..9a906b47 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp index ee7f525b..0b639a58 100644 --- a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp +++ b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 89abca3d..20131b6e 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_MAT_VERSION "1" diff --git a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp index ecf6c330..09023c78 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_TECHSET_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp index e390cfa3..0e7e481e 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_TECHSET_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp index fa51a556..d4441653 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_TECHSET_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp index c6d5ee04..ab9bb2c5 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_TECHSET_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IMenuList.cpp b/src/Components/Modules/AssetInterfaces/IMenuList.cpp index ecf0aad4..44c7e5d9 100644 --- a/src/Components/Modules/AssetInterfaces/IMenuList.cpp +++ b/src/Components/Modules/AssetInterfaces/IMenuList.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp index 6c84f43f..ed5c9c0c 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp index cf0df51d..998ba165 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IRawFile.cpp b/src/Components/Modules/AssetInterfaces/IRawFile.cpp index 07904e36..19638490 100644 --- a/src/Components/Modules/AssetInterfaces/IRawFile.cpp +++ b/src/Components/Modules/AssetInterfaces/IRawFile.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp index 1ecca8f0..205fe210 100644 --- a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp +++ b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IStringTable.cpp b/src/Components/Modules/AssetInterfaces/IStringTable.cpp index d58904f8..c6c1d4cc 100644 --- a/src/Components/Modules/AssetInterfaces/IStringTable.cpp +++ b/src/Components/Modules/AssetInterfaces/IStringTable.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp index b0d159a0..d96757a6 100644 --- a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp index 92bcf361..e94fb86a 100644 --- a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp +++ b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IWeapon.cpp b/src/Components/Modules/AssetInterfaces/IWeapon.cpp index 350006d9..abc6f5d3 100644 --- a/src/Components/Modules/AssetInterfaces/IWeapon.cpp +++ b/src/Components/Modules/AssetInterfaces/IWeapon.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp index 4071fb6e..940b5858 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_ANIM_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/IXModel.cpp b/src/Components/Modules/AssetInterfaces/IXModel.cpp index 6f27ab5a..69be49ce 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define IW4X_MODEL_VERSION 5 diff --git a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp index 6c67932b..686eb3b0 100644 --- a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 6ccc39b0..6ba84557 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -1,4 +1,4 @@ -#include "StdInclude.hpp" +#include #define IW4X_CLIPMAP_VERSION 2 diff --git a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp index 1fa5dfcc..09e4d101 100644 --- a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp +++ b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp index f14e00b5..55cdf5d2 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Assets { diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index e090e1bb..71f5aa21 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 6930eb28..38cd20e9 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 15e36cfb..3efa5dfa 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define KEY_MASK_FIRE 1 #define KEY_MASK_SPRINT 2 diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 00120a8f..471dd8ec 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 059ef0bb..df5a5d73 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index 5c849c3b..7d0e9afe 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index 8c6be95a..ff6e2022 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Client.cpp b/src/Components/Modules/Client.cpp index 4f5f9770..fc881a36 100644 --- a/src/Components/Modules/Client.cpp +++ b/src/Components/Modules/Client.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index bb143cd6..1c0c7fa4 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 4bdbb8fc..d3846df5 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 3b716c53..c07d3df8 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 2bd9f68e..18b82ff6 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/D3D9Ex.cpp b/src/Components/Modules/D3D9Ex.cpp index d15f66b9..c78113dd 100644 --- a/src/Components/Modules/D3D9Ex.cpp +++ b/src/Components/Modules/D3D9Ex.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index dc856792..2aa27a9d 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 833b7103..758ef317 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 7d1d6f27..9d803891 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Download.hpp b/src/Components/Modules/Download.hpp index 1894c079..90472069 100644 --- a/src/Components/Modules/Download.hpp +++ b/src/Components/Modules/Download.hpp @@ -1,5 +1,5 @@ #pragma once -#include "Game/Functions.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index d5ec5fea..09054a29 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index 42b80108..9438f9ce 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index d94fd884..3cccc9f9 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index fb7c8939..2170e3c6 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index 68de4044..fface938 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Flags.cpp b/src/Components/Modules/Flags.cpp index d40e5802..2c471dfc 100644 --- a/src/Components/Modules/Flags.cpp +++ b/src/Components/Modules/Flags.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/FrameTime.cpp b/src/Components/Modules/FrameTime.cpp index 69bb3d98..661ea80b 100644 --- a/src/Components/Modules/FrameTime.cpp +++ b/src/Components/Modules/FrameTime.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 194c9676..b1554e73 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 7e6f677c..7e6e8966 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Gametypes.cpp b/src/Components/Modules/Gametypes.cpp index e9d85f3a..c155cf99 100644 --- a/src/Components/Modules/Gametypes.cpp +++ b/src/Components/Modules/Gametypes.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/IPCPipe.cpp b/src/Components/Modules/IPCPipe.cpp index ee50163a..bcd8185b 100644 --- a/src/Components/Modules/IPCPipe.cpp +++ b/src/Components/Modules/IPCPipe.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Lean.cpp b/src/Components/Modules/Lean.cpp index a78111c5..fad47586 100644 --- a/src/Components/Modules/Lean.cpp +++ b/src/Components/Modules/Lean.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 1bdb421c..0bed7bac 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 10a38fc9..75f2ec3b 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/MapDump.cpp b/src/Components/Modules/MapDump.cpp index 1c4e94bf..ba87a6ff 100644 --- a/src/Components/Modules/MapDump.cpp +++ b/src/Components/Modules/MapDump.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 97ec8f61..1820675a 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 9fdd7f96..69176b08 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 6d4fa7c4..9f7faa12 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index dac1ecaa..8935b586 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ModelSurfs.cpp b/src/Components/Modules/ModelSurfs.cpp index 55336ee8..374b028a 100644 --- a/src/Components/Modules/ModelSurfs.cpp +++ b/src/Components/Modules/ModelSurfs.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Monitor.cpp b/src/Components/Modules/Monitor.cpp index 4f0edcb5..c3140377 100644 --- a/src/Components/Modules/Monitor.cpp +++ b/src/Components/Modules/Monitor.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #undef getch #undef ungetch #include diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index f71c9699..ff69c090 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/MusicalTalent.cpp b/src/Components/Modules/MusicalTalent.cpp index 359856ce..7deef61c 100644 --- a/src/Components/Modules/MusicalTalent.cpp +++ b/src/Components/Modules/MusicalTalent.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index e4e39390..18132d2b 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index ac053eb8..ae852e51 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #define NEWS_MOTD_DEFAULT "Welcome to IW4x Multiplayer!" diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 2d60d147..e3abc4e5 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 4d7bc515..afa418ad 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/PlayerName.cpp b/src/Components/Modules/PlayerName.cpp index 79b3758d..793bcc8a 100644 --- a/src/Components/Modules/PlayerName.cpp +++ b/src/Components/Modules/PlayerName.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index c90183cc..e413d534 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index edaafa42..b5b26f93 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index c9d78656..1ab6fc59 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index c6aa9115..30489edf 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 07cc2a65..e79472dc 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Scheduler.cpp b/src/Components/Modules/Scheduler.cpp index 51c4f4e1..22b412c3 100644 --- a/src/Components/Modules/Scheduler.cpp +++ b/src/Components/Modules/Scheduler.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 343ae06a..42b9037c 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Script.hpp b/src/Components/Modules/Script.hpp index c9125831..123c4d6b 100644 --- a/src/Components/Modules/Script.hpp +++ b/src/Components/Modules/Script.hpp @@ -1,5 +1,5 @@ #pragma once -#include "Game/Structs.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 3700527c..471b32a6 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index 04f08bb5..f38cfd6f 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 166f444f..e3fa5fa0 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Session.cpp b/src/Components/Modules/Session.cpp index 842d236c..09efdd1f 100644 --- a/src/Components/Modules/Session.cpp +++ b/src/Components/Modules/Session.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Singleton.cpp b/src/Components/Modules/Singleton.cpp index 8ecae19d..da478a74 100644 --- a/src/Components/Modules/Singleton.cpp +++ b/src/Components/Modules/Singleton.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Slowmotion.cpp b/src/Components/Modules/Slowmotion.cpp index 4879e142..ff80ca1f 100644 --- a/src/Components/Modules/Slowmotion.cpp +++ b/src/Components/Modules/Slowmotion.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/SoundMutexFix.cpp b/src/Components/Modules/SoundMutexFix.cpp index 57518705..69662c7b 100644 --- a/src/Components/Modules/SoundMutexFix.cpp +++ b/src/Components/Modules/SoundMutexFix.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index b7be14b3..3205bfeb 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Stats.cpp b/src/Components/Modules/Stats.cpp index b2621760..cdfab8c9 100644 --- a/src/Components/Modules/Stats.cpp +++ b/src/Components/Modules/Stats.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/StringTable.cpp b/src/Components/Modules/StringTable.cpp index 600e0340..3fd00880 100644 --- a/src/Components/Modules/StringTable.cpp +++ b/src/Components/Modules/StringTable.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index f620ed09..64e3b375 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/TextRenderer.cpp b/src/Components/Modules/TextRenderer.cpp index 599244d8..e5a26a91 100644 --- a/src/Components/Modules/TextRenderer.cpp +++ b/src/Components/Modules/TextRenderer.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Game { diff --git a/src/Components/Modules/Theatre.cpp b/src/Components/Modules/Theatre.cpp index 1d09657c..2e3cdcaa 100644 --- a/src/Components/Modules/Theatre.cpp +++ b/src/Components/Modules/Theatre.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Threading.cpp b/src/Components/Modules/Threading.cpp index 72e11a5a..6ca4b25c 100644 --- a/src/Components/Modules/Threading.cpp +++ b/src/Components/Modules/Threading.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index 9bf5c0f7..eda8240e 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index 4182ddbc..ee3032ab 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/UIScript.cpp b/src/Components/Modules/UIScript.cpp index bc07bd7f..cd9b713c 100644 --- a/src/Components/Modules/UIScript.cpp +++ b/src/Components/Modules/UIScript.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index eb5ae9fd..d526c747 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index 3fd16efe..2a7b07de 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index a9a38a33..d3be354b 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 30572989..da24ffeb 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #pragma optimize( "", off ) namespace Components diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 7ca5f4e4..2e71bf48 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Game { diff --git a/src/Steam/Interfaces/SteamFriends.cpp b/src/Steam/Interfaces/SteamFriends.cpp index 6f1d1c06..6b5fbe27 100644 --- a/src/Steam/Interfaces/SteamFriends.cpp +++ b/src/Steam/Interfaces/SteamFriends.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include using namespace Components; diff --git a/src/Steam/Interfaces/SteamGameServer.cpp b/src/Steam/Interfaces/SteamGameServer.cpp index 26261093..e393d42c 100644 --- a/src/Steam/Interfaces/SteamGameServer.cpp +++ b/src/Steam/Interfaces/SteamGameServer.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamMasterServerUpdater.cpp b/src/Steam/Interfaces/SteamMasterServerUpdater.cpp index 431fd46a..d256ed2a 100644 --- a/src/Steam/Interfaces/SteamMasterServerUpdater.cpp +++ b/src/Steam/Interfaces/SteamMasterServerUpdater.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamMatchmaking.cpp b/src/Steam/Interfaces/SteamMatchmaking.cpp index af228ce2..72e56f94 100644 --- a/src/Steam/Interfaces/SteamMatchmaking.cpp +++ b/src/Steam/Interfaces/SteamMatchmaking.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamNetworking.cpp b/src/Steam/Interfaces/SteamNetworking.cpp index fb98f2d1..b782b5c6 100644 --- a/src/Steam/Interfaces/SteamNetworking.cpp +++ b/src/Steam/Interfaces/SteamNetworking.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamRemoteStorage.cpp b/src/Steam/Interfaces/SteamRemoteStorage.cpp index 0e7192c1..2cbe6620 100644 --- a/src/Steam/Interfaces/SteamRemoteStorage.cpp +++ b/src/Steam/Interfaces/SteamRemoteStorage.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamUser.cpp b/src/Steam/Interfaces/SteamUser.cpp index 81940388..3e95be40 100644 --- a/src/Steam/Interfaces/SteamUser.cpp +++ b/src/Steam/Interfaces/SteamUser.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Interfaces/SteamUtils.cpp b/src/Steam/Interfaces/SteamUtils.cpp index 56bfee0d..93d816d2 100644 --- a/src/Steam/Interfaces/SteamUtils.cpp +++ b/src/Steam/Interfaces/SteamUtils.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include STEAM_IGNORE_WARNINGS_START diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index 2a5a161d..6adc88da 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Steam { diff --git a/src/Steam/Proxy.hpp b/src/Steam/Proxy.hpp index 9a551a74..3e0c84a3 100644 --- a/src/Steam/Proxy.hpp +++ b/src/Steam/Proxy.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #ifdef _WIN64 #define GAMEOVERLAY_LIB "gameoverlayrenderer64.dll" #define STEAMCLIENT_LIB "steamclient64.dll" @@ -10,7 +12,6 @@ #define STEAM_REGISTRY_PATH "Software\\Valve\\Steam" #define STEAM_REGISTRY_PROCESS_PATH "Software\\Valve\\Steam\\ActiveProcess" #endif -#include "STDInclude.hpp" namespace Steam { diff --git a/src/Steam/Steam.cpp b/src/Steam/Steam.cpp index 059c4d9e..23501def 100644 --- a/src/Steam/Steam.cpp +++ b/src/Steam/Steam.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Steam { diff --git a/src/Utils/CSV.cpp b/src/Utils/CSV.cpp index 0b0a02d1..20da0b81 100644 --- a/src/Utils/CSV.cpp +++ b/src/Utils/CSV.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Cache.cpp b/src/Utils/Cache.cpp index 774d938a..cd761d76 100644 --- a/src/Utils/Cache.cpp +++ b/src/Utils/Cache.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Compression.cpp b/src/Utils/Compression.cpp index 34e515eb..581be7e8 100644 --- a/src/Utils/Compression.cpp +++ b/src/Utils/Compression.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Cryptography.cpp b/src/Utils/Cryptography.cpp index 31e0558d..958fe274 100644 --- a/src/Utils/Cryptography.cpp +++ b/src/Utils/Cryptography.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include /// http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/libtomcrypt/doc/libTomCryptDoc.pdf diff --git a/src/Utils/Entities.cpp b/src/Utils/Entities.cpp index c63e891f..04e24761 100644 --- a/src/Utils/Entities.cpp +++ b/src/Utils/Entities.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Hooking.cpp b/src/Utils/Hooking.cpp index bf529da7..c814daa1 100644 --- a/src/Utils/Hooking.cpp +++ b/src/Utils/Hooking.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index c150ff7b..78f8d042 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/InfoString.cpp b/src/Utils/InfoString.cpp index 09126843..6642a7de 100644 --- a/src/Utils/InfoString.cpp +++ b/src/Utils/InfoString.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Library.cpp b/src/Utils/Library.cpp index dd81c29c..0cf9ab67 100644 --- a/src/Utils/Library.cpp +++ b/src/Utils/Library.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Memory.cpp b/src/Utils/Memory.cpp index a69c1173..bba45884 100644 --- a/src/Utils/Memory.cpp +++ b/src/Utils/Memory.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index 92049f59..e3ef1b14 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index ca2d0664..1ad1e574 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #ifdef ENABLE_BASE128 #include "base128.h" #endif diff --git a/src/Utils/Time.cpp b/src/Utils/Time.cpp index 4761f43e..8e257e7d 100644 --- a/src/Utils/Time.cpp +++ b/src/Utils/Time.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index 71d0af14..79f73380 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Utils { diff --git a/src/Utils/WebIO.cpp b/src/Utils/WebIO.cpp index 7c25ebf0..bd5d36e5 100644 --- a/src/Utils/WebIO.cpp +++ b/src/Utils/WebIO.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include #include namespace Utils From 620efbd0683ad82a498cc60202fd8ab49a65fa1d Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 13:40:19 +0000 Subject: [PATCH 17/52] Trigger CI --- src/Components/Modules/Download.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 663cdae7..a8607d00 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -966,7 +966,8 @@ namespace Components Script::AddFunction("HttpGet", [](Game::scr_entref_t) { - if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) return; + if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) + return; const auto* url = Game::Scr_GetString(0); @@ -986,7 +987,8 @@ namespace Components Script::AddFunction("HttpCancel", [](Game::scr_entref_t) { - if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) return; + if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) + return; const auto object = Game::Scr_GetObject(0); for (const auto& download : Download::ScriptDownloads) From 30f47bf2b8ab5c249e007ed12e32e2ba624e33bc Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 13:44:31 +0000 Subject: [PATCH 18/52] Merge develop into script... --- src/Components/Modules/ScriptExtension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/ScriptExtension.cpp b/src/Components/Modules/ScriptExtension.cpp index 7b437b68..9de9a586 100644 --- a/src/Components/Modules/ScriptExtension.cpp +++ b/src/Components/Modules/ScriptExtension.cpp @@ -1,4 +1,4 @@ -#include "STDInclude.hpp" +#include namespace Components { From 204a752a9614c2ad48f5e337726e373021b3b019 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 16:42:53 +0000 Subject: [PATCH 19/52] Refactor utils --- src/Components/Modules/Flags.cpp | 29 +++++++++--------- src/Components/Modules/Flags.hpp | 1 - src/Utils/String.cpp | 52 ++++++++++++++++++++++++-------- src/Utils/String.hpp | 11 ++++--- 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/src/Components/Modules/Flags.cpp b/src/Components/Modules/Flags.cpp index 2c471dfc..e3139910 100644 --- a/src/Components/Modules/Flags.cpp +++ b/src/Components/Modules/Flags.cpp @@ -6,9 +6,15 @@ namespace Components bool Flags::HasFlag(const std::string& flag) { - Flags::ParseFlags(); + static auto parsed = false; - for (auto entry : Flags::EnabledFlags) + if (!parsed) + { + Flags::ParseFlags(); + parsed = true; + } + + for (const auto& entry : Flags::EnabledFlags) { if (Utils::String::ToLower(entry) == Utils::String::ToLower(flag)) { @@ -21,21 +27,20 @@ namespace Components void Flags::ParseFlags() { - static bool flagsParsed = false; - if (flagsParsed) return; - flagsParsed = true; - int numArgs; - LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &numArgs); + auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs); + + assert(Flags::EnabledFlags.empty()); if (argv) { - for (int i = 0; i < numArgs; ++i) + for (auto i = 0; i < numArgs; ++i) { std::wstring wFlag(argv[i]); if (wFlag[0] == L'-') { - Flags::EnabledFlags.push_back(std::string(++wFlag.begin(), wFlag.end())); + wFlag.erase(wFlag.begin()); + Flags::EnabledFlags.push_back(Utils::String::Convert(wFlag)); } } @@ -51,11 +56,5 @@ namespace Components Flags::Flags() { - Flags::ParseFlags(); - } - - Flags::~Flags() - { - Flags::EnabledFlags.clear(); } } diff --git a/src/Components/Modules/Flags.hpp b/src/Components/Modules/Flags.hpp index 823a5ee9..ec35f350 100644 --- a/src/Components/Modules/Flags.hpp +++ b/src/Components/Modules/Flags.hpp @@ -6,7 +6,6 @@ namespace Components { public: Flags(); - ~Flags(); static bool HasFlag(const std::string& flag); diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 85a00e90..422a9158 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -103,30 +103,58 @@ namespace Utils return _isspace_l(c, nullptr); } - // trim from start - std::string <rim(std::string &s) + // Trim from start + std::string& LTrim(std::string& str) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int val) + str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](int val) { return !IsSpace(val); })); - return s; + + return str; } - // trim from end - std::string &RTrim(std::string &s) + // Trim from end + std::string& RTrim(std::string& str) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](int val) + str.erase(std::find_if(str.rbegin(), str.rend(), [](int val) { return !IsSpace(val); - }).base(), s.end()); - return s; + }).base(), str.end()); + + return str; } - // trim from both ends - std::string &Trim(std::string &s) + // Trim from both ends + std::string& Trim(std::string& str) { - return LTrim(RTrim(s)); + return LTrim(RTrim(str)); + } + + std::string Convert(const std::wstring& wstr) + { + std::string result; + result.reserve(wstr.size()); + + for (const auto& chr : wstr) + { + result.push_back(static_cast(chr)); + } + + return result; + } + + std::wstring Convert(const std::string& str) + { + std::wstring result; + result.reserve(str.size()); + + for (const auto& chr : str) + { + result.push_back(static_cast(chr)); + } + + return result; } std::string FormatTimeSpan(int milliseconds) diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 3beed27e..0da5f00b 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -79,11 +79,14 @@ namespace Utils std::string ToUpper(std::string input); bool EndsWith(const std::string& haystack, const std::string& needle); std::vector Split(const std::string& str, const char delim); - void Replace(std::string &string, const std::string& find, const std::string& replace); + void Replace(std::string& string, const std::string& find, const std::string& replace); bool StartsWith(const std::string& haystack, const std::string& needle); - std::string <rim(std::string &s); - std::string &RTrim(std::string &s); - std::string &Trim(std::string &s); + std::string& LTrim(std::string& str); + std::string& RTrim(std::string& str); + std::string& Trim(std::string& str); + + std::string Convert(const std::wstring& wstr); + std::wstring Convert(const std::string& str); std::string FormatTimeSpan(int milliseconds); std::string FormatBandwidth(size_t bytes, int milliseconds); From 99e3920008a736049c47a9289c44ec42e2fead7c Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 16:49:12 +0000 Subject: [PATCH 20/52] Use new funcs in other modules --- src/Utils/Utils.cpp | 2 +- src/Utils/WebIO.cpp | 12 ++++++------ src/Utils/WebIO.hpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index c5b51538..dd84caca 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -10,7 +10,7 @@ namespace Utils if (mimeType) { std::wstring wMimeType(mimeType); - return std::string(wMimeType.begin(), wMimeType.end()); + return String::Convert(wMimeType); } return "application/octet-stream"; diff --git a/src/Utils/WebIO.cpp b/src/Utils/WebIO.cpp index bd5d36e5..b9189215 100644 --- a/src/Utils/WebIO.cpp +++ b/src/Utils/WebIO.cpp @@ -396,7 +396,7 @@ namespace Utils return false; } - void WebIO::formatPath(std::string &path, bool win) + void WebIO::formatPath(std::string& path, bool win) { size_t nPos; std::string find = "\\"; @@ -408,7 +408,7 @@ namespace Utils replace = "\\"; } - while ((nPos = path.find(find)) != std::wstring::npos) + while ((nPos = path.find(find)) != std::string::npos) { path = path.replace(nPos, find.length(), replace); } @@ -445,7 +445,7 @@ namespace Utils return (FtpRenameFileA(this->hConnect, directory.data(), newDir.data()) == TRUE); // According to the internetz, this should work } - bool WebIO::listElements(const std::string& directory, std::vector &list, bool files) + bool WebIO::listElements(const std::string& directory, std::vector& list, bool files) { list.clear(); @@ -483,12 +483,12 @@ namespace Utils return result; } - bool WebIO::listDirectories(const std::string& directory, std::vector &list) + bool WebIO::listDirectories(const std::string& directory, std::vector& list) { return this->listElements(directory, list, false); } - bool WebIO::listFiles(const std::string& directory, std::vector &list) + bool WebIO::listFiles(const std::string& directory, std::vector& list) { return this->listElements(directory, list, true); } @@ -532,7 +532,7 @@ namespace Utils return result; } - bool WebIO::downloadFileData(const std::string& file, std::string &data) + bool WebIO::downloadFileData(const std::string& file, std::string& data) { data.clear(); diff --git a/src/Utils/WebIO.hpp b/src/Utils/WebIO.hpp index b272fdbe..07af0c0f 100644 --- a/src/Utils/WebIO.hpp +++ b/src/Utils/WebIO.hpp @@ -51,8 +51,8 @@ namespace Utils bool deleteDirectory(const std::string& directory); bool renameDirectory(const std::string& directory, const std::string& newDir); - bool listDirectories(const std::string& directory, std::vector &list); - bool listFiles(const std::string& directory, std::vector &list); + bool listDirectories(const std::string& directory, std::vector& list); + bool listFiles(const std::string& directory, std::vector& list); bool deleteFile(const std::string& file); bool renameFile(const std::string& file, const std::string& newFile); @@ -60,7 +60,7 @@ namespace Utils bool downloadFile(const std::string& file, const std::string& localfile); bool uploadFileData(const std::string& file,const std::string& data); - bool downloadFileData(const std::string& file, std::string &data); + bool downloadFileData(const std::string& file, std::string& data); void setProgressCallback(Utils::Slot callback); void cancelDownload() { this->cancel = true; } @@ -104,7 +104,7 @@ namespace Utils std::string execute(const char* command, const std::string& body, WebIO::Params headers = WebIO::Params(), bool* success = nullptr); - bool listElements(const std::string& directory, std::vector &list, bool files); + bool listElements(const std::string& directory, std::vector& list, bool files); void openSession(const std::string& useragent); void closeSession(); @@ -112,6 +112,6 @@ namespace Utils bool openConnection(); void closeConnection(); - void formatPath(std::string &path, bool win); /* if (win == true): / -> \\ */ + void formatPath(std::string& path, bool win); /* if (win == true): / -> \\ */ }; } From 41ff80759d5ec93aca44dec3db12284a6b491ca1 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 27 Feb 2022 17:36:13 +0000 Subject: [PATCH 21/52] Follow advice from a friendly guy --- src/Components/Modules/Bots.cpp | 29 +++++++++++++++++------------ src/Components/Modules/Bots.hpp | 1 + src/Game/Functions.cpp | 1 + src/Game/Functions.hpp | 3 +++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index a6709023..f8ebd34e 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -2,6 +2,7 @@ namespace Components { + Game::dvar_t* Bots::TestClientsActivate; std::vector Bots::BotNames; struct BotMovementInfo @@ -10,7 +11,6 @@ namespace Components int8_t forward; int8_t right; uint16_t weapon; - bool active; }; static BotMovementInfo g_botai[18]; @@ -160,7 +160,6 @@ namespace Components g_botai[entref.entnum] = {0}; g_botai[entref.entnum].weapon = 1; - g_botai[entref.entnum].active = false; }); Script::AddFunction("BotWeapon", [](Game::scr_entref_t entref) // Usage: BotWeapon(); @@ -184,7 +183,6 @@ namespace Components const auto weapId = Game::G_GetWeaponIndexForName(weapon); g_botai[entref.entnum].weapon = static_cast(weapId); - g_botai[entref.entnum].active = true; }); Script::AddFunction("BotAction", [](Game::scr_entref_t entref) // Usage: BotAction(); @@ -222,7 +220,6 @@ namespace Components else g_botai[entref.entnum].buttons &= ~(BotActions[i].key); - g_botai[entref.entnum].active = true; return; } @@ -248,7 +245,6 @@ namespace Components g_botai[entref.entnum].forward = static_cast(forwardInt); g_botai[entref.entnum].right = static_cast(rightInt); - g_botai[entref.entnum].active = true; }); } @@ -259,10 +255,6 @@ namespace Components const auto entnum = cl->gentity->s.number; - // Keep test client functionality - if (!g_botai[entnum].active) - return; - Game::usercmd_s ucmd = {0}; ucmd.serverTime = *Game::svs_time; @@ -280,7 +272,12 @@ namespace Components { __asm { - call SV_BotUserMove + push eax + mov eax, Bots::TestClientsActivate + cmp byte ptr [eax + 0x10], 0x1 + pop eax + + jz enableBots pushad @@ -289,20 +286,28 @@ namespace Components add esp, 4 popad + + ret + + enableBots: + call SV_BotUserMove ret } } Bots::Bots() { + Bots::TestClientsActivate = Game::Dvar_RegisterBool("testClients_activate", true, + Game::dvar_flag::DVAR_FLAG_NONE, "Testclients will retain their native functionality."); + // Replace connect string Utils::Hook::Set(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\""); // Intercept sprintf for the connect string Utils::Hook(0x48ADAB, Bots::BuildConnectString, HOOK_CALL).install()->quick(); - Utils::Hook(0x627021, SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); - Utils::Hook(0x627241, SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x627021, Bots::SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x627241, Bots::SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); // Zero the bot command array for (auto i = 0u; i < std::extent_v; i++) diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index 8391e584..e6a6ee22 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -22,6 +22,7 @@ namespace Components }; private: + static Game::dvar_t* TestClientsActivate; static std::vector BotNames; static int BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index e6db78b8..4ffba042 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -323,6 +323,7 @@ namespace Game StringTable_HashString_t StringTable_HashString = StringTable_HashString_t(0x475EB0); SV_AddTestClient_t SV_AddTestClient = SV_AddTestClient_t(0x48AD30); + SV_IsTestClient_t SV_IsTestClient = SV_IsTestClient_t(0x4D6E40); SV_GameClientNum_Score_t SV_GameClientNum_Score = SV_GameClientNum_Score_t(0x469AC0); SV_GameSendServerCommand_t SV_GameSendServerCommand = SV_GameSendServerCommand_t(0x4BC3A0); SV_Cmd_TokenizeString_t SV_Cmd_TokenizeString = SV_Cmd_TokenizeString_t(0x4B5780); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 41dfd7df..ac4a336d 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -768,6 +768,9 @@ namespace Game typedef gentity_t*(__cdecl* SV_AddTestClient_t)(); extern SV_AddTestClient_t SV_AddTestClient; + typedef int(__cdecl * SV_IsTestClient_t)(int clientNum); + extern SV_IsTestClient_t SV_IsTestClient; + typedef int(__cdecl* SV_GameClientNum_Score_t)(int clientID); extern SV_GameClientNum_Score_t SV_GameClientNum_Score; From 8847b362a7afe98509ecb7bc7cd48623d5837d89 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 2 Mar 2022 10:10:03 +0000 Subject: [PATCH 22/52] Use c++ template function for vsnprintf --- src/Components/Modules/Script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 6c47788a..3520065e 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -193,7 +193,7 @@ namespace Components char msgbuf[1024] = {0}; va_list va; va_start(va, message); - vsnprintf_s(msgbuf, sizeof(msgbuf), _TRUNCATE, message, va); + _vsnprintf_s(msgbuf, _TRUNCATE, message, va); va_end(va); Game::Scr_ShutdownAllocNode(); From 9e207b3c9a00044b23aad68df96b2f2fa7568935 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 2 Mar 2022 11:46:02 +0000 Subject: [PATCH 23/52] Clamp ping instead of throwing error --- src/Components/Modules/Bots.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index f8ebd34e..cdab519a 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -119,13 +119,9 @@ namespace Components { Script::AddFunction("SetPing", [](Game::scr_entref_t entref) // gsc: self SetPing() { - const auto ping = Game::Scr_GetInt(0); + auto ping = Game::Scr_GetInt(0); - if (ping < 0 || ping > 999) - { - Game::Scr_ParamError(0, "^1SetPing: Ping needs to be between 0 and 999!\n"); - return; - } + ping = std::clamp(ping, 0, 999); const auto* ent = Game::GetPlayerEntity(entref); auto* client = Script::GetClient(ent); From e210d29a9d50448b0841c41d0565e5bb4a4908ac Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 2 Mar 2022 12:18:24 +0000 Subject: [PATCH 24/52] Remove appvejor as it is not needed anymore --- README.md | 1 - appveyor.yml | 34 ---------------------------------- 2 files changed, 35 deletions(-) delete mode 100644 appveyor.yml diff --git a/README.md b/README.md index dfb2fcbc..fb5dc10a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ![stars](https://img.shields.io/github/stars/IW4x/iw4x-client.svg) ![issues](https://img.shields.io/github/issues/IW4x/iw4x-client.svg) [![build](https://github.com/XLabsProject/iw4x-client/workflows/Build/badge.svg)](https://github.com/XLabsProject/iw4x-client/actions) -[![build status](https://ci.appveyor.com/api/projects/status/rvljq0ooxen0oexm/branch/develop?svg=true)](https://ci.appveyor.com/project/iw4x/iw4x-client/branch/develop) [![discord](https://img.shields.io/endpoint?url=https://momo5502.com/iw4x/members-badge.php)](https://discord.gg/sKeVmR3) [![patreon](https://img.shields.io/badge/patreon-support-blue.svg?logo=patreon)](https://www.patreon.com/xlabsproject) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 2f9649cd..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,34 +0,0 @@ -# AppVeyor CI configuration - -version: "#{build} ({branch})" - -environment: - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PREMAKE_ACTION: vs2022 - -configuration: - - Debug - - Release - -platform: Win32 - -install: - - ps: | - Write-Host "Updating version information..." -ForegroundColor Cyan - - Update-AppveyorBuild -Version $(& tools/premake5.exe version | select -Last 1) - - git submodule update --init --recursive - - ps: | - Write-Host "Generating project files with premake..." -ForegroundColor Cyan - & "./tools/premake5.exe" $env:PREMAKE_ACTION - Write-Host "Generated" -ForegroundColor Green - -build: - project: build/iw4x.sln - parallel: true - verbosity: minimal - -artifacts: - - path: build/bin/**/*.dll - - path: build/bin/**/*.pdb From d0c88843cb10378cdef7664d2206d13040901347 Mon Sep 17 00:00:00 2001 From: Edo Date: Thu, 3 Mar 2022 12:40:29 +0000 Subject: [PATCH 25/52] Update Functions.hpp --- src/Game/Functions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index ac4a336d..b00e3a45 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -804,7 +804,7 @@ namespace Game typedef client_t*(__cdecl * SV_GetPlayerByNum_t)(); extern SV_GetPlayerByNum_t SV_GetPlayerByNum; - typedef int(__cdecl * Sys_Error_t)(const char* error, ...); + typedef void(__cdecl * Sys_Error_t)(const char* error, ...); extern Sys_Error_t Sys_Error; typedef void(__cdecl * Sys_FreeFileList_t)(char** list); From 5a2c0b565da99c527aef61647298b04f90246de8 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 3 Mar 2022 16:37:18 +0000 Subject: [PATCH 26/52] Do not lookup rcon dvars every single time we need them --- src/Components/Modules/RCon.cpp | 11 +++++++---- src/Components/Modules/RCon.hpp | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..064b15d2 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -7,6 +7,9 @@ namespace Components std::string RCon::Password; + Dvar::Var RCon::RconPassword; + Dvar::Var RCon::RconLogRequests; + RCon::RCon() { Command::Add("rcon", [](Command::Params* params) @@ -75,8 +78,8 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - Dvar::Register("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); + RCon::RconLogRequests = Dvar::Register("rcon_logRequests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data) @@ -100,7 +103,7 @@ namespace Components password.erase(password.begin()); } - std::string svPassword = Dvar::Var("rcon_password").get(); + const std::string svPassword = RCon::RconPassword.get(); if (svPassword.empty()) { @@ -114,7 +117,7 @@ namespace Components outputBuffer.clear(); #ifndef DEBUG - if (Dvar::Var("log_rcon_requests").get()) + if (RCon::RconLogRequests.get()) #endif { Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); diff --git a/src/Components/Modules/RCon.hpp b/src/Components/Modules/RCon.hpp index 1cc486e5..b5ec83cd 100644 --- a/src/Components/Modules/RCon.hpp +++ b/src/Components/Modules/RCon.hpp @@ -25,5 +25,8 @@ namespace Components // For sr0's fucking rcon command // Son of a bitch! Annoying me day and night with that shit... static std::string Password; + + static Dvar::Var RconPassword; + static Dvar::Var RconLogRequests; }; } From 74ed534bf63dd32fa05373e51df8134b834f435d Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 3 Mar 2022 17:43:22 +0000 Subject: [PATCH 27/52] snake case var --- src/Components/Modules/RCon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 064b15d2..8d506708 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -79,7 +79,7 @@ namespace Components Dvar::OnInit([]() { RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - RCon::RconLogRequests = Dvar::Register("rcon_logRequests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconLogRequests = Dvar::Register("rcon_log_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data) From 0cf2ac2853fbc0c06221d96f9b65a25de86b70be Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 7 Mar 2022 22:35:12 +0000 Subject: [PATCH 28/52] Disable warning, fix naming inconsistency for component & remove unused code Rename Slowmotion.cpp to SlowMotion.cpp Rename Slowmotion.hpp to SlowMotion.hpp Modify comments and remove unused code --- .../Modules/{Slowmotion.cpp => SlowMotion.cpp} | 2 +- .../Modules/{Slowmotion.hpp => SlowMotion.hpp} | 0 src/STDInclude.hpp | 10 ++-------- 3 files changed, 3 insertions(+), 9 deletions(-) rename src/Components/Modules/{Slowmotion.cpp => SlowMotion.cpp} (99%) rename src/Components/Modules/{Slowmotion.hpp => SlowMotion.hpp} (100%) diff --git a/src/Components/Modules/Slowmotion.cpp b/src/Components/Modules/SlowMotion.cpp similarity index 99% rename from src/Components/Modules/Slowmotion.cpp rename to src/Components/Modules/SlowMotion.cpp index ff80ca1f..268a2a0a 100644 --- a/src/Components/Modules/Slowmotion.cpp +++ b/src/Components/Modules/SlowMotion.cpp @@ -91,4 +91,4 @@ namespace Components Utils::Hook(0x4A54ED, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4A54FB, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick(); } -} \ No newline at end of file +} diff --git a/src/Components/Modules/Slowmotion.hpp b/src/Components/Modules/SlowMotion.hpp similarity index 100% rename from src/Components/Modules/Slowmotion.hpp rename to src/Components/Modules/SlowMotion.hpp diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 4ae48092..bdec22d1 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -54,14 +54,7 @@ #include #pragma comment (lib, "xinput.lib") -// Usefull for debugging -template class Sizer { }; -#define BindNum(x, y) Sizer y; -#define Size_Of(x, y) BindNum(sizeof(x), y) -#define Offset_Of(x, y, z) BindNum(offsetof(x, y), z) - -// Submodules -// Ignore the warnings, it's not our code! +// Ignore the warnings #pragma warning(push) #pragma warning(disable: 4005) #pragma warning(disable: 4091) @@ -79,6 +72,7 @@ template class Sizer { }; #pragma warning(disable: 6258) #pragma warning(disable: 6386) #pragma warning(disable: 6387) +#pragma warning(disable: 26812) #include From 21f0fe8c5ee66f01b6b2c4d7dd806913f9e802e6 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 8 Mar 2022 12:20:28 +0000 Subject: [PATCH 29/52] Fix dvar flags & various dvar improvements --- src/Components/Modules/AssetHandler.cpp | 2 +- src/Components/Modules/Auth.cpp | 2 +- src/Components/Modules/CardTitles.cpp | 2 +- src/Components/Modules/Chat.cpp | 2 +- src/Components/Modules/Clantags.cpp | 2 +- src/Components/Modules/Console.cpp | 7 +-- src/Components/Modules/Console.hpp | 2 +- src/Components/Modules/D3D9Ex.cpp | 2 +- src/Components/Modules/Dedicated.cpp | 14 ++--- src/Components/Modules/Discovery.cpp | 4 +- src/Components/Modules/Download.cpp | 12 ++--- src/Components/Modules/Dvar.cpp | 46 ++++++++-------- src/Components/Modules/Dvar.hpp | 6 +-- src/Components/Modules/Elevators.cpp | 2 +- src/Components/Modules/FastFiles.cpp | 2 +- src/Components/Modules/Friends.cpp | 4 +- src/Components/Modules/Gamepad.cpp | 46 ++++++++-------- src/Components/Modules/Localization.cpp | 2 +- src/Components/Modules/Logger.cpp | 2 +- src/Components/Modules/Maps.cpp | 8 +-- src/Components/Modules/ModList.cpp | 2 +- src/Components/Modules/Movement.cpp | 34 ++++++------ src/Components/Modules/Movement.hpp | 4 +- src/Components/Modules/News.cpp | 4 +- src/Components/Modules/Party.cpp | 18 +++---- src/Components/Modules/PlayerName.cpp | 2 +- src/Components/Modules/QuickPatch.cpp | 18 +++---- src/Components/Modules/QuickPatch.hpp | 2 +- src/Components/Modules/RCon.cpp | 4 +- src/Components/Modules/Renderer.cpp | 12 ++--- src/Components/Modules/ServerList.cpp | 14 ++--- src/Components/Modules/StartupMessages.cpp | 6 +-- src/Components/Modules/TextRenderer.cpp | 14 ++--- src/Components/Modules/Theatre.cpp | 4 +- src/Components/Modules/UIFeeder.cpp | 6 +-- src/Components/Modules/Window.cpp | 4 +- src/Components/Modules/ZoneBuilder.cpp | 2 +- src/Game/Functions.hpp | 38 ++++++------- src/Game/Structs.hpp | 62 +++++++++++----------- 39 files changed, 209 insertions(+), 210 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 98270b52..b3c7057a 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -494,7 +494,7 @@ namespace Components { this->reallocateEntryPool(); - Dvar::Register("r_noVoid", false, Game::DVAR_FLAG_SAVED, "Disable void model (red fx)"); + Dvar::Register("r_noVoid", false, Game::DVAR_ARCHIVE, "Disable void model (red fx)"); AssetHandler::ClearTemporaryAssets(); diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 1ea665f7..9bb70dfa 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -432,7 +432,7 @@ namespace Components Scheduler::OnFrame(Auth::Frame); // Register dvar - Dvar::Register("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_FLAG_SERVERINFO, "Security level for GUID certificates (POW)"); + Dvar::Register("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_SERVERINFO, "Security level for GUID certificates (POW)"); // Install registration hook Utils::Hook(0x6265F9, Auth::DirectConnectStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 471dd8ec..ae052e9d 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -192,7 +192,7 @@ namespace Components { Dvar::OnInit([]() { - CardTitles::CustomTitleDvar = Dvar::Register("customtitle", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "Custom card title"); + CardTitles::CustomTitleDvar = Dvar::Register("customtitle", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "Custom card title"); }); ServerCommands::OnCommand(21, [](Command::Params* params) diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index abe117d8..283455b5 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -316,7 +316,7 @@ namespace Components { Dvar::OnInit([] { - cg_chatWidth = Dvar::Register("cg_chatWidth", 52, 1, std::numeric_limits::max(), Game::DVAR_FLAG_SAVED, "The normalized maximum width of a chat message"); + cg_chatWidth = Dvar::Register("cg_chatWidth", 52, 1, std::numeric_limits::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message"); Chat::AddChatCommands(); }); diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index ff6e2022..6b9e6979 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -75,7 +75,7 @@ namespace Components // Create clantag dvar Dvar::OnInit([]() { - Dvar::Register("clantag", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "If set, your clantag will be shown on the scoreboard."); + Dvar::Register("clantag", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "If set, your clantag will be shown on the scoreboard."); }); // Servercommand hook diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 18b82ff6..c50f723c 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -504,7 +504,8 @@ namespace Components Console::ConsoleThread = std::thread(Console::ConsoleRunner); } - Game::dvar_t* Console::RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description) + Game::dvar_t* Console::RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, + float max, unsigned __int16 flags, const char* description) { static struct { @@ -521,7 +522,7 @@ namespace Components for (int i = 0; i < ARRAYSIZE(patchedColors); ++i) { - if (std::string(name) == patchedColors[i].name) + if (std::strcmp(dvarName, patchedColors[i].name) == 0) { r = patchedColors[i].color[0]; g = patchedColors[i].color[1]; @@ -531,7 +532,7 @@ namespace Components } } - return reinterpret_cast(0x471500)(name, r, g, b, a, min, max, flags, description); + return reinterpret_cast(0x471500)(dvarName, r, g, b, a, min, max, flags, description); } Console::Console() diff --git a/src/Components/Modules/Console.hpp b/src/Components/Modules/Console.hpp index 0ef30bb5..2ca6eb60 100644 --- a/src/Components/Modules/Console.hpp +++ b/src/Components/Modules/Console.hpp @@ -66,6 +66,6 @@ namespace Components static void ToggleConsole(); static char** GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType); - static Game::dvar_t* RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description); + static Game::dvar_t* RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, float max, unsigned __int16 flags, const char* description); }; } diff --git a/src/Components/Modules/D3D9Ex.cpp b/src/Components/Modules/D3D9Ex.cpp index c78113dd..d9222836 100644 --- a/src/Components/Modules/D3D9Ex.cpp +++ b/src/Components/Modules/D3D9Ex.cpp @@ -748,7 +748,7 @@ namespace Components { if (Dedicated::IsEnabled()) return; - Dvar::Register("r_useD3D9Ex", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use extended d3d9 interface!"); + Dvar::Register("r_useD3D9Ex", false, Game::dvar_flag::DVAR_ARCHIVE, "Use extended d3d9 interface!"); // Hook Interface creation Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 3e615dab..8e0bf319 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -275,22 +275,22 @@ namespace Components Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description) { - return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_FLAG_NONE, description); + return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_NONE, description); } Dedicated::Dedicated() { // Map rotation Utils::Hook::Set(0x4152E8, Dedicated::MapRotate); - Dvar::Register("sv_dontrotate", false, Game::dvar_flag::DVAR_FLAG_CHEAT, ""); - Dvar::Register("com_logFilter", true, Game::dvar_flag::DVAR_FLAG_LATCHED, "Removes ~95% of unneeded lines from the log"); + Dvar::Register("sv_dontrotate", false, Game::dvar_flag::DVAR_CHEAT, ""); + Dvar::Register("com_logFilter", true, Game::dvar_flag::DVAR_LATCH, "Removes ~95% of unneeded lines from the log"); if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) { // Make sure all callbacks are handled Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks); - Dvar::Register("sv_lanOnly", false, Game::dvar_flag::DVAR_FLAG_NONE, "Don't act as node"); + Dvar::Register("sv_lanOnly", false, Game::dvar_flag::DVAR_NONE, "Don't act as node"); Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick(); @@ -391,9 +391,9 @@ namespace Components Dvar::OnInit([]() { - Dedicated::SVRandomMapRotation = Dvar::Register("sv_randomMapRotation", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Randomize map rotation when true"); - Dvar::Register("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands"); - Dvar::Register("sv_motd", "", Game::dvar_flag::DVAR_FLAG_NONE, "A custom message of the day for servers"); + Dedicated::SVRandomMapRotation = Dvar::Register("sv_randomMapRotation", false, Game::dvar_flag::DVAR_ARCHIVE, "Randomize map rotation when true"); + Dvar::Register("sv_sayName", "^7Console", Game::dvar_flag::DVAR_NONE, "The name to pose as for 'say' commands"); + Dvar::Register("sv_motd", "", Game::dvar_flag::DVAR_NONE, "A custom message of the day for servers"); // Say command Command::AddSV("say", [](Command::Params* params) diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 758ef317..67833a0f 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -14,8 +14,8 @@ namespace Components Discovery::Discovery() { - Dvar::Register("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_FLAG_SAVED, "Minimum scan range port for local server discovery"); - Dvar::Register("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_FLAG_SAVED, "Maximum scan range port for local server discovery"); + Dvar::Register("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_ARCHIVE, "Minimum scan range port for local server discovery"); + Dvar::Register("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_ARCHIVE, "Maximum scan range port for local server discovery"); // An additional thread prevents lags // Not sure if that's the best way though diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 9d803891..a4ac5727 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -902,9 +902,9 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_dl_progress", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); + Dvar::Register("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_dl_progress", "", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_dl_transRate", "", Game::dvar_flag::DVAR_NONE, ""); }); UIScript::Add("mod_download_cancel", [](UIScript::Token) @@ -915,13 +915,13 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server."); - Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to the base url for the external map download."); + Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server."); + Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_ARCHIVE, "Set to the base url for the external map download."); // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again // not saying we are but ya know... accidents happen // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not - Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Set to true to force the client to run the download server for mods (for mods in private matches)."); + Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches)."); }); Scheduler::OnFrame([]() diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5e6f8a60..fb1b88eb 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -181,24 +181,24 @@ namespace Components } } - template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) + template<> static Dvar::Var Dvar::Register(const char* dvarName, bool value, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterBool(name, value, flag.val, description); + return Game::Dvar_RegisterBool(dvarName, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) + template<> static Dvar::Var Dvar::Register(const char* dvarName, const char* value, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterString(name, value, flag.val, description); + return Game::Dvar_RegisterString(dvarName, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) + template<> static Dvar::Var Dvar::Register(const char* dvarName, int value, int min, int max, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); + return Game::Dvar_RegisterInt(dvarName, value, min, max, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) + template<> static Dvar::Var Dvar::Register(const char* dvarName, float value, float min, float max, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); + return Game::Dvar_RegisterFloat(dvarName, value, min, max, flag.val, description); } void Dvar::OnInit(Utils::Slot callback) @@ -255,7 +255,7 @@ namespace Components } } - return Dvar::Register(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).get(); + return Dvar::Register(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_ARCHIVE).val, description).get(); } void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string) @@ -305,7 +305,7 @@ namespace Components { // Save the dvar original value if it has the archive flag const auto* dvar = Game::Dvar_FindVar(dvarName); - if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_FLAG_SAVED) + if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_ARCHIVE) { Dvar::SaveArchiveDvar(dvar); } @@ -316,25 +316,25 @@ namespace Components Dvar::Dvar() { // set flags of cg_drawFPS to archive - Utils::Hook::Or(0x4F8F69, Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Or(0x4F8F69, Game::dvar_flag::DVAR_ARCHIVE); // un-cheat camera_thirdPersonCrosshairOffset and add archive flags - Utils::Hook::Xor(0x447B41, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x447B41, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_fov and add archive flags - Utils::Hook::Xor(0x4F8E35, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8E35, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_fovscale and add archive flags - Utils::Hook::Xor(0x4F8E68, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8E68, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_debugInfoCornerOffset and add archive flags - Utils::Hook::Xor(0x4F8FC2, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8FC2, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // remove archive flags for cg_hudchatposition - Utils::Hook::Xor(0x4F9992, Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F9992, Game::dvar_flag::DVAR_ARCHIVE); // remove write protection from fs_game - Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED); + Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_WRITEPROTECTED); // set cg_fov max to 90.0 // ...120 because of V2 @@ -346,19 +346,19 @@ namespace Components Utils::Hook::Set(0x408078, &volume); // Uncheat ui_showList - Utils::Hook::Xor(0x6310DC, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Xor(0x6310DC, Game::dvar_flag::DVAR_CHEAT); // Uncheat ui_debugMode - Utils::Hook::Xor(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Xor(0x6312DE, Game::dvar_flag::DVAR_CHEAT); // Hook dvar 'name' registration Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick(); // un-cheat safeArea_* and add archive flags - Utils::Hook::Xor(0x42E3F5, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_horizontal - Utils::Hook::Xor(0x42E423, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_vertical - Utils::Hook::Xor(0x42E398, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_horizontal - Utils::Hook::Xor(0x42E3C4, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_vertical + Utils::Hook::Xor(0x42E3F5, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_horizontal + Utils::Hook::Xor(0x42E423, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_vertical + Utils::Hook::Xor(0x42E398, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_horizontal + Utils::Hook::Xor(0x42E3C4, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_vertical // Don't allow setting cheat protected dvars via menus Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index 8f87eaf5..c140ac73 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -9,7 +9,7 @@ namespace Components { public: Flag(Game::dvar_flag flag) : val(flag) {}; - Flag(int flag) : Flag(static_cast(flag)) {}; + Flag(unsigned __int16 flag) : Flag(static_cast(flag)) {}; Game::dvar_flag val; }; @@ -46,8 +46,8 @@ namespace Components static void OnInit(Utils::Slot callback); // Only strings and bools use this type of declaration - template static Var Register(const char* name, T value, Flag flag, const char* description); - template static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); + template static Var Register(const char* dvarName, T value, Flag flag, const char* description); + template static Var Register(const char* dvarName, T value, T min, T max, Flag flag, const char* description); static void ResetDvarsValue(); diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index 9438f9ce..9a8f5dcd 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -108,7 +108,7 @@ namespace Components }; Elevators::BG_Elevators = Game::Dvar_RegisterEnum("bg_elevators", values, - Elevators::ENABLED, Game::DVAR_FLAG_REPLICATED, "Elevators glitch settings"); + Elevators::ENABLED, Game::DVAR_CODINFO, "Elevators glitch settings"); }); //Replace PM_CorrectAllSolid diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 2170e3c6..148fe107 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -495,7 +495,7 @@ namespace Components FastFiles::FastFiles() { - Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone."); + Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_ARCHIVE, "Display current loaded zone."); // Fix XSurface assets Utils::Hook(0x0048E8A5, FastFiles::Load_XSurfaceArray, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index d8d483ac..d48dffe1 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -578,8 +578,8 @@ namespace Components if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return; - Dvar::Register("cl_anonymous", false, Game::DVAR_FLAG_SAVED, "Enable invisible mode for Steam"); - Dvar::Register("cl_notifyFriendState", true, Game::DVAR_FLAG_SAVED, "Update friends about current game status"); + Dvar::Register("cl_anonymous", false, Game::DVAR_ARCHIVE, "Enable invisible mode for Steam"); + Dvar::Register("cl_notifyFriendState", true, Game::DVAR_ARCHIVE, "Update friends about current game status"); Command::Add("addFriend", [](Command::Params* params) { diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 445868aa..1e4b85a1 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1711,32 +1711,32 @@ namespace Components void Gamepad::InitDvars() { - gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_FLAG_SAVED, "Game pad enabled"); - gpad_debug = Dvar::Register("gpad_debug", false, Game::DVAR_FLAG_NONE, "Game pad debugging"); - gpad_present = Dvar::Register("gpad_present", false, Game::DVAR_FLAG_NONE, "Game pad present"); - gpad_in_use = Dvar::Register("gpad_in_use", false, Game::DVAR_FLAG_NONE, "A game pad is in use"); - gpad_style = Dvar::Register("gpad_style", false, Game::DVAR_FLAG_SAVED, "Switch between Xbox and PS HUD"); - gpad_sticksConfig = Dvar::Register("gpad_sticksConfig", "", Game::DVAR_FLAG_SAVED, "Game pad stick configuration"); - gpad_buttonConfig = Dvar::Register("gpad_buttonConfig", "", Game::DVAR_FLAG_SAVED, "Game pad button configuration"); - gpad_menu_scroll_delay_first = Dvar::Register("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_FLAG_SAVED, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); - gpad_menu_scroll_delay_rest = Dvar::Register("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_FLAG_SAVED, + gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_ARCHIVE, "Game pad enabled"); + gpad_debug = Dvar::Register("gpad_debug", false, Game::DVAR_NONE, "Game pad debugging"); + gpad_present = Dvar::Register("gpad_present", false, Game::DVAR_NONE, "Game pad present"); + gpad_in_use = Dvar::Register("gpad_in_use", false, Game::DVAR_NONE, "A game pad is in use"); + gpad_style = Dvar::Register("gpad_style", false, Game::DVAR_ARCHIVE, "Switch between Xbox and PS HUD"); + gpad_sticksConfig = Dvar::Register("gpad_sticksConfig", "", Game::DVAR_ARCHIVE, "Game pad stick configuration"); + gpad_buttonConfig = Dvar::Register("gpad_buttonConfig", "", Game::DVAR_ARCHIVE, "Game pad button configuration"); + gpad_menu_scroll_delay_first = Dvar::Register("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_ARCHIVE, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); + gpad_menu_scroll_delay_rest = Dvar::Register("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_ARCHIVE, "Menu scroll key-repeat delay, for repeats after the first, in milliseconds"); - gpad_rumble = Dvar::Register("gpad_rumble", true, Game::DVAR_FLAG_SAVED, "Enable game pad rumble"); - gpad_stick_pressed_hysteresis = Dvar::Register("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, + gpad_rumble = Dvar::Register("gpad_rumble", true, Game::DVAR_ARCHIVE, "Enable game pad rumble"); + gpad_stick_pressed_hysteresis = Dvar::Register("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad stick pressed no-change-zone around gpad_stick_pressed to prevent bouncing"); - gpad_stick_pressed = Dvar::Register("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_FLAG_NONE, "Game pad stick pressed threshhold"); - gpad_stick_deadzone_max = Dvar::Register("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum stick deadzone"); - gpad_stick_deadzone_min = Dvar::Register("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad minimum stick deadzone"); - gpad_button_deadzone = Dvar::Register("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad button deadzone threshhold"); - gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); - gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); - gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, std::numeric_limits::max(), Game::DVAR_FLAG_NONE, "Time to hold the 'use' button on gamepads to activate use"); - gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad lockon aim assist enabled"); - gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad slowdown aim assist enabled"); + gpad_stick_pressed = Dvar::Register("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_NONE, "Game pad stick pressed threshhold"); + gpad_stick_deadzone_max = Dvar::Register("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum stick deadzone"); + gpad_stick_deadzone_min = Dvar::Register("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad minimum stick deadzone"); + gpad_button_deadzone = Dvar::Register("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad button deadzone threshhold"); + gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value"); + gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value"); + gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, std::numeric_limits::max(), Game::DVAR_NONE, "Time to hold the 'use' button on gamepads to activate use"); + gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_ARCHIVE, "Game pad lockon aim assist enabled"); + gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_ARCHIVE, "Game pad slowdown aim assist enabled"); - input_viewSensitivity = Dvar::Register("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity"); - input_invertPitch = Dvar::Register("input_invertPitch", false, Game::DVAR_FLAG_SAVED, "Invert gamepad pitch"); - sv_allowAimAssist = Dvar::Register("sv_allowAimAssist", true, Game::DVAR_FLAG_NONE, "Controls whether aim assist features on clients are enabled"); + input_viewSensitivity = Dvar::Register("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_ARCHIVE, "View Sensitivity"); + input_invertPitch = Dvar::Register("input_invertPitch", false, Game::DVAR_ARCHIVE, "Invert gamepad pitch"); + sv_allowAimAssist = Dvar::Register("sv_allowAimAssist", true, Game::DVAR_NONE, "Controls whether aim assist features on clients are enabled"); aim_turnrate_pitch = Dvar::Var("aim_turnrate_pitch"); aim_turnrate_pitch_ads = Dvar::Var("aim_turnrate_pitch_ads"); aim_turnrate_yaw = Dvar::Var("aim_turnrate_yaw"); diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 0bed7bac..3b385506 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -277,7 +277,7 @@ namespace Components // Overwrite SetString Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick(); - Localization::UseLocalization = Dvar::Register("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings"); + Localization::UseLocalization = Dvar::Register("ui_localize", true, Game::dvar_flag::DVAR_NONE, "Use localization strings"); // Generate localized entries for custom classes above 10 AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/) diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 75f2ec3b..06c964f4 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -242,7 +242,7 @@ namespace Components Logger::Logger() { - Dvar::Register("iw4x_onelog", false, Game::dvar_flag::DVAR_FLAG_LATCHED | Game::dvar_flag::DVAR_FLAG_SAVED, "Only write the game log to the 'userraw' OS folder"); + Dvar::Register("iw4x_onelog", false, Game::dvar_flag::DVAR_LATCH | Game::dvar_flag::DVAR_ARCHIVE, "Only write the game log to the 'userraw' OS folder"); Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick(); Logger::PipeOutput(nullptr); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index dc842f4d..f46fdd56 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -544,7 +544,7 @@ namespace Components } } - Dvar::Register(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); + Dvar::Register(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); Maps::DlcPacks.push_back(dlc); Maps::UpdateDlcStatus(); @@ -690,7 +690,7 @@ namespace Components Game::dvar_t* Maps::GetSpecularDvar() { Game::dvar_t*& r_specular = *reinterpret_cast(0x69F0D94); - static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_FLAG_SAVED, "Allows shaders to use phong specular lighting on custom maps"); + static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_ARCHIVE, "Allows shaders to use phong specular lighting on custom maps"); if (Maps::IsCustomMap()) { @@ -769,8 +769,8 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("isDlcInstalled_All", false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("r_listSModels", false, Game::DVAR_FLAG_NONE, "Display a list of visible SModels"); + Dvar::Register("isDlcInstalled_All", false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("r_listSModels", false, Game::DVAR_NONE, "Display a list of visible SModels"); Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} }); Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} }); diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index 8935b586..88e71a05 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -93,7 +93,7 @@ namespace Components if (Dedicated::IsEnabled()) return; ModList::CurrentMod = 0; - Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Perform a vid_restart when loading a mod."); + Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_ARCHIVE, "Perform a vid_restart when loading a mod."); UIScript::Add("LoadMods", ModList::UIScript_LoadMods); UIScript::Add("RunMod", ModList::UIScript_RunMod); diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index a59a00a5..57bfc72f 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -260,20 +260,20 @@ namespace Components } } - Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float value, - float min, float max, int, const char* desc) + Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value, + float min, float max, unsigned __int16 /*flags*/, const char* description) { - Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register(name, value, - min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); + Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register(dvarName, value, + min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description); return Movement::PlayerLastStandCrawlSpeedScale.get(); } - Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* name, float value, - float min, float max, int, const char* desc) + Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, + float min, float max, unsigned __int16 /*flags*/, const char* description) { - Movement::PlayerSpectateSpeedScale = Dvar::Register(name, value, - min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); + Movement::PlayerSpectateSpeedScale = Dvar::Register(dvarName, value, + min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description); return Movement::PlayerSpectateSpeedScale.get(); } @@ -291,36 +291,36 @@ namespace Components }; Movement::PlayerDuckedSpeedScale = Dvar::Register("player_duckedSpeedScale", - 0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The scale applied to the player speed when ducking"); Movement::PlayerProneSpeedScale = Dvar::Register("player_proneSpeedScale", - 0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The scale applied to the player speed when crawling"); // 3arc naming convention Movement::CGUfoScaler = Dvar::Register("cg_ufo_scaler", - 6.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The speed at which ufo camera moves"); Movement::CGNoclipScaler = Dvar::Register("cg_noclip_scaler", - 3.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The speed at which noclip camera moves"); Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces", - bg_bouncesValues, Movement::DISABLED, Game::DVAR_FLAG_REPLICATED, "Bounce glitch settings"); + bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings"); Movement::BGBouncesAllAngles = Dvar::Register("bg_bouncesAllAngles", - false, Game::DVAR_FLAG_REPLICATED, "Force bounce from all angles"); + false, Game::DVAR_CODINFO, "Force bounce from all angles"); Movement::BGRocketJump = Dvar::Register("bg_rocketJump", - false, Game::DVAR_FLAG_REPLICATED, "Enable CoD4 rocket jumps"); + false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps"); Movement::BGPlayerEjection = Dvar::Register("bg_playerEjection", - true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); Movement::BGPlayerCollision = Dvar::Register("bg_playerCollision", - true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); }); // Hook PM_CmdScaleForStance in PM_CmdScale_Walk diff --git a/src/Components/Modules/Movement.hpp b/src/Components/Modules/Movement.hpp index 97243ee2..2b718258 100644 --- a/src/Components/Modules/Movement.hpp +++ b/src/Components/Modules/Movement.hpp @@ -40,7 +40,7 @@ namespace Components static int StuckInClient_Hk(Game::gentity_s* self); static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles); - static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); - static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); + static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); + static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); }; } diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index ae852e51..a377084e 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -39,9 +39,9 @@ namespace Components { if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi? - Dvar::Register("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, ""); + Dvar::Register("g_firstLaunch", true, Game::DVAR_ARCHIVE, ""); - Dvar::Register("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_FLAG_WRITEPROTECTED, "Current version number."); + Dvar::Register("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_WRITEPROTECTED, "Current version number."); UIScript::Add("checkFirstLaunch", [](UIScript::Token) { diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index afa418ad..34049df9 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -79,7 +79,7 @@ namespace Components Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description) { - return Dvar::Register(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get(); + return Dvar::Register(name, 1, 1, max, Game::dvar_flag::DVAR_WRITEPROTECTED | flag, description).get(); } bool Party::PlaylistAwaiting() @@ -150,8 +150,8 @@ namespace Components Party::Party() { - static Game::dvar_t* partyEnable = Dvar::Register("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get(); - Dvar::Register("xblive_privatematch", true, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED, ""); + static Game::dvar_t* partyEnable = Dvar::Register("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_NONE, "Enable party system").get(); + Dvar::Register("xblive_privatematch", true, Game::dvar_flag::DVAR_WRITEPROTECTED, ""); // various changes to SV_DirectConnect-y stuff to allow non-party joinees Utils::Hook::Set(0x460D96, 0x90E9); @@ -249,12 +249,12 @@ namespace Components Utils::Hook::Set(0x5E3772, "sv_maxclients"); // Unlatch maxclient dvars - Utils::Hook::Xor(0x426187, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4D374E, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x5E376A, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4261A1, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4D376D, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x5E3789, Game::dvar_flag::DVAR_FLAG_LATCHED); + Utils::Hook::Xor(0x426187, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4D374E, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x5E376A, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4261A1, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4D376D, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x5E3789, Game::dvar_flag::DVAR_LATCH); // Patch Live_PlayerHasLoopbackAddr //Utils::Hook::Set(0x418F30, 0x90C3C033); diff --git a/src/Components/Modules/PlayerName.cpp b/src/Components/Modules/PlayerName.cpp index 793bcc8a..d90cadf7 100644 --- a/src/Components/Modules/PlayerName.cpp +++ b/src/Components/Modules/PlayerName.cpp @@ -61,7 +61,7 @@ namespace Components PlayerName::PlayerName() { - sv_allowColoredNames = Dvar::Register("sv_allowColoredNames", true, Game::dvar_flag::DVAR_FLAG_NONE, "Allow colored names on the server"); + sv_allowColoredNames = Dvar::Register("sv_allowColoredNames", true, Game::dvar_flag::DVAR_NONE, "Allow colored names on the server"); // Disable SV_UpdateUserinfo_f, to block changing the name ingame Utils::Hook::Set(0x6258D0, 0xC3); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 64ab5efe..38410e9b 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -96,7 +96,7 @@ namespace Components std::string dvarName = args[3]; Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data()); - if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY)))) + if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_WRITEPROTECTED | Game::DVAR_CHEAT | Game::DVAR_READONLY)))) { return; } @@ -238,7 +238,7 @@ namespace Components } } - Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* name, char**, int defaultVal, int flags, const char* description) + Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** /*valueList*/, int defaultIndex, unsigned __int16 flags, const char* description) { static const char* r_aspectRatioEnum[] = { @@ -256,7 +256,7 @@ namespace Components "Screen aspect ratio. Divide the width by the height in order to get the aspect ratio value. For example: 16 / 9 = 1,77"); // register enumeration dvar - return Game::Dvar_RegisterEnum(name, r_aspectRatioEnum, defaultVal, flags, description); + return Game::Dvar_RegisterEnum(dvarName, r_aspectRatioEnum, defaultIndex, flags, description); } void QuickPatch::SetAspectRatio() @@ -353,7 +353,7 @@ namespace Components Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName, float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description) { - return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_FLAG_READONLY, description); + return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_READONLY, description); } QuickPatch::QuickPatch() @@ -374,9 +374,9 @@ namespace Components Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick(); // Intermission time dvar - Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::DVAR_FLAG_REPLICATED | Game::DVAR_FLAG_DEDISAVED, "Time in seconds before match server loads the next map"); + Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_SCRIPTINFO, "Time in seconds before match server loads the next map"); - g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_FLAG_REPLICATED, "Perform antilag"); + g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag"); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick(); @@ -477,7 +477,7 @@ namespace Components // Numerical ping (cg_scoreboardPingText 1) Utils::Hook::Set(0x45888E, 1); - Utils::Hook::Set(0x45888C, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Set(0x45888C, Game::dvar_flag::DVAR_CHEAT); // increase font sizes for chat on higher resolutions static float float13 = 13.0f; @@ -633,7 +633,7 @@ namespace Components }); // Fix mouse pitch adjustments - Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); + Dvar::Register("ui_mousePitch", false, Game::DVAR_ARCHIVE, ""); UIScript::Add("updateui_mousePitch", [](UIScript::Token) { if (Dvar::Var("ui_mousePitch").get()) @@ -859,7 +859,7 @@ namespace Components }); // Dvars - Dvar::Register("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI"); + Dvar::Register("ui_streamFriendly", false, Game::DVAR_ARCHIVE, "Stream friendly UI"); // Debug patches #ifdef DEBUG diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 32c3ed61..6eac85a2 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -28,7 +28,7 @@ namespace Components static void InvalidNameStub(); static Dvar::Var r_customAspectRatio; - static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* name, char** enumValues, int defaultVal, int flags, const char* description); + static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); static void SetAspectRatioStub(); static void SetAspectRatio(); diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 8d506708..8325064f 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -78,8 +78,8 @@ namespace Components Dvar::OnInit([]() { - RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - RCon::RconLogRequests = Dvar::Register("rcon_log_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_NONE, "The password for rcon"); + RCon::RconLogRequests = Dvar::Register("rcon_log_requests", false, Game::dvar_flag::DVAR_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data) diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index e79472dc..efa91e94 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -546,12 +546,12 @@ namespace Components nullptr }; - Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_FLAG_CHEAT, "Draw scene model bounding boxes"); - Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_FLAG_CHEAT, "Draw scene model collisions"); - Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_FLAG_CHEAT, "Draw triggers"); - Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_FLAG_CHEAT, "Draw all model names"); - Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_FLAG_CHEAT, "Draw aabb trees"); - Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_FLAG_SAVED, "r_draw debug functions draw distance, relative to the player"); + Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_CHEAT, "Draw scene model bounding boxes"); + Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_CHEAT, "Draw scene model collisions"); + Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_CHEAT, "Draw triggers"); + Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_CHEAT, "Draw all model names"); + Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_CHEAT, "Draw aabb trees"); + Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_ARCHIVE, "r_draw debug functions draw distance, relative to the player"); }); } diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 94c3e473..aac56a28 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -734,16 +734,16 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist"); - Dvar::Register("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, "Map of the selected server"); + Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_NONE, "Whether a server has been selected in the serverlist"); + Dvar::Register("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_NONE, "Map of the selected server"); - Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server queries per frame"); - Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server query frames per second"); + Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame"); + Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second"); }); // Fix ui_netsource dvar Utils::Hook::Nop(0x4CDEEC, 5); // Don't reset the netsource when gametypes aren't loaded - Dvar::Register("ui_netSource", 1, 0, 2, Game::DVAR_FLAG_SAVED, reinterpret_cast(0x6D9F08)); + Dvar::Register("ui_netSource", 1, 0, 2, Game::DVAR_ARCHIVE, reinterpret_cast(0x6D9F08)); //Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0"); Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0 (0)"); @@ -782,8 +782,8 @@ namespace Components // Set default masterServerName + port and save it #ifdef USE_LEGACY_SERVER_LIST Utils::Hook::Set(0x60AD92, "127.0.0.1"); - Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_FLAG_SAVED); // masterServerName - Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_FLAG_SAVED); // masterPort + Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName + Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort #endif // Add server list feeder diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index 16cf8497..211a0d3f 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -9,9 +9,9 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("ui_startupMessage", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("ui_startupMessageTitle", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("ui_startupNextButtonText", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); + Dvar::Register("ui_startupMessage", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("ui_startupMessageTitle", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("ui_startupNextButtonText", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); }); UIScript::Add("nextStartupMessage", [](UIScript::Token) diff --git a/src/Components/Modules/TextRenderer.cpp b/src/Components/Modules/TextRenderer.cpp index e5a26a91..2a11a676 100644 --- a/src/Components/Modules/TextRenderer.cpp +++ b/src/Components/Modules/TextRenderer.cpp @@ -1598,10 +1598,10 @@ namespace Components { currentColorTable = &colorTableDefault; - cg_newColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use Warfare 2 color code style."); - cg_fontIconAutocomplete = Dvar::Register("cg_fontIconAutocomplete", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Show autocomplete for fonticons when typing."); - cg_fontIconAutocompleteHint = Dvar::Register("cg_fontIconAutocompleteHint", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Show hint text in autocomplete for fonticons."); - sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_FLAG_REPLICATED, "Color for the extended color code."); + cg_newColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_ARCHIVE, "Use Warfare 2 color code style."); + cg_fontIconAutocomplete = Dvar::Register("cg_fontIconAutocomplete", true, Game::dvar_flag::DVAR_ARCHIVE, "Show autocomplete for fonticons when typing."); + cg_fontIconAutocompleteHint = Dvar::Register("cg_fontIconAutocompleteHint", true, Game::dvar_flag::DVAR_ARCHIVE, "Show hint text in autocomplete for fonticons."); + sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_CODINFO, "Color for the extended color code."); // Initialize font icons when initializing UI Utils::Hook(0x4B5422, UI_Init_Hk, HOOK_CALL).install()->quick(); @@ -1616,11 +1616,11 @@ namespace Components Utils::Hook(0x417770, ColorIndex, HOOK_JUMP).install()->quick(); // Add a colorblind mode for team colors - r_colorBlind = Dvar::Register("r_colorBlind", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors"); + r_colorBlind = Dvar::Register("r_colorBlind", false, Game::dvar_flag::DVAR_ARCHIVE, "Use color-blindness-friendly colors"); // A dark red - g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Enemy team color for colorblind mode"); + g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Enemy team color for colorblind mode"); // A bright yellow - g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Ally team color for colorblind mode"); + g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Ally team color for colorblind mode"); // Replace team colors with colorblind team colors when colorblind is enabled Utils::Hook(0x406530, GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/Theatre.cpp b/src/Components/Modules/Theatre.cpp index 2e3cdcaa..84a95284 100644 --- a/src/Components/Modules/Theatre.cpp +++ b/src/Components/Modules/Theatre.cpp @@ -342,8 +342,8 @@ namespace Components Theatre::Theatre() { - Dvar::Register("cl_autoRecord", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Automatically record games."); - Dvar::Register("cl_demosKeep", 30, 1, 999, Game::dvar_flag::DVAR_FLAG_SAVED, "How many demos to keep with autorecord."); + Dvar::Register("cl_autoRecord", true, Game::dvar_flag::DVAR_ARCHIVE, "Automatically record games."); + Dvar::Register("cl_demosKeep", 30, 1, 999, Game::dvar_flag::DVAR_ARCHIVE, "How many demos to keep with autorecord."); Utils::Hook(0x5A8370, Theatre::GamestateWriteStub, HOOK_CALL).install()->quick(); Utils::Hook(0x5A85D2, Theatre::RecordGamestateStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index ee3032ab..b0e554bf 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -383,9 +383,9 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("ui_map_long", "Afghan", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_map_name", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_map_desc", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); + Dvar::Register("ui_map_long", "Afghan", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_map_name", "mp_afghan", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_map_desc", "", Game::dvar_flag::DVAR_NONE, ""); }); // Get feeder item count diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index 2a7b07de..a5669656 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -144,8 +144,8 @@ namespace Components Window::Window() { // Borderless window - Window::NoBorder = Dvar::Register("r_noborder", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Do not use a border in windowed mode"); - Window::NativeCursor = Dvar::Register("ui_nativeCursor", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display native cursor"); + Window::NoBorder = Dvar::Register("r_noborder", true, Game::dvar_flag::DVAR_ARCHIVE, "Do not use a border in windowed mode"); + Window::NativeCursor = Dvar::Register("ui_nativeCursor", false, Game::dvar_flag::DVAR_ARCHIVE, "Display native cursor"); Utils::Hook(0x507643, Window::StyleHookStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index b548ed99..3fa883cb 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1525,7 +1525,7 @@ namespace Components Logger::Print("------------------- END IWI DUMP -------------------\n"); }); - ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register("zb_prefer_disk_assets", false, Game::DVAR_FLAG_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?"); + ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register("zb_prefer_disk_assets", false, Game::DVAR_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?"); } } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 7975d876..f4fefd2d 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -232,67 +232,67 @@ namespace Game typedef void(__cdecl * DB_XModelSurfsFixup_t)(XModel* model); extern DB_XModelSurfsFixup_t DB_XModelSurfsFixup; - typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool defaultVal, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterBool_t)(const char* dvarName, bool value, unsigned __int16 flags, const char* description); extern Dvar_RegisterBool_t Dvar_RegisterBool; - typedef dvar_t* (__cdecl * Dvar_RegisterFloat_t)(const char* name, float defaultVal, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterFloat_t)(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterFloat_t Dvar_RegisterFloat; - typedef dvar_t* (__cdecl * Dvar_RegisterVec2_t)(const char* name, float defx, float defy, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec2_t)(const char* dvarName, float x, float y, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec2_t Dvar_RegisterVec2; - typedef dvar_t* (__cdecl * Dvar_RegisterVec3_t)(const char* name, float defx, float defy, float defz, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec3_t)(const char* dvarName, float x, float y, float z, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec3_t Dvar_RegisterVec3; - typedef dvar_t* (__cdecl * Dvar_RegisterVec4_t)(const char* name, float defx, float defy, float defz, float defw, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec4_t)(const char* dvarName, float x, float y, float z, float w, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec4_t Dvar_RegisterVec4; - typedef dvar_t* (__cdecl * Dvar_RegisterInt_t)(const char* name, int defaultVal, int min, int max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterInt_t)(const char* dvarName, int value, int min, int max, unsigned __int16 flags, const char* description); extern Dvar_RegisterInt_t Dvar_RegisterInt; - typedef dvar_t* (__cdecl * Dvar_RegisterEnum_t)(const char* name, const char** enumValues, int defaultVal, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterEnum_t)(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); extern Dvar_RegisterEnum_t Dvar_RegisterEnum; - typedef dvar_t* (__cdecl * Dvar_RegisterString_t)(const char* name, const char* defaultVal, int, const char*); + typedef dvar_t*(__cdecl * Dvar_RegisterString_t)(const char* dvarName, const char* value, unsigned __int16 flags, const char* description); extern Dvar_RegisterString_t Dvar_RegisterString; - typedef dvar_t* (__cdecl * Dvar_RegisterColor_t)(const char* name, float r, float g, float b, float a, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterColor_t)(const char* dvarName, float r, float g, float b, float a, unsigned __int16 flags, const char* description); extern Dvar_RegisterColor_t Dvar_RegisterColor; typedef void(__cdecl * Dvar_SetFromStringByName_t)(const char* dvarName, const char* string); extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName; - typedef const dvar_t* (__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source); + typedef const dvar_t*(__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source); extern Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource; - typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value); + typedef void(__cdecl * Dvar_SetStringByName_t)(const char* dvarName, const char* value); extern Dvar_SetStringByName_t Dvar_SetStringByName; - typedef void (__cdecl * Dvar_SetString_t)(const dvar_t* cvar, const char* value); + typedef void(__cdecl * Dvar_SetString_t)(const dvar_t* dvar, const char* value); extern Dvar_SetString_t Dvar_SetString; - typedef void (__cdecl * Dvar_SetBool_t)(const dvar_t* cvar, bool enabled); + typedef void(__cdecl * Dvar_SetBool_t)(const dvar_t* dvar, bool enabled); extern Dvar_SetBool_t Dvar_SetBool; - typedef void (__cdecl * Dvar_SetFloat_t)(const dvar_t* cvar, float value); + typedef void(__cdecl * Dvar_SetFloat_t)(const dvar_t* dvar, float value); extern Dvar_SetFloat_t Dvar_SetFloat; - typedef void (__cdecl * Dvar_SetInt_t)(const dvar_t* cvar, int integer); + typedef void(__cdecl * Dvar_SetInt_t)(const dvar_t* dvar, int integer); extern Dvar_SetInt_t Dvar_SetInt; - typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color); + typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* dvarName, float* expandedColor); extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName; - typedef dvar_t* (__cdecl * Dvar_FindVar_t)(const char *dvarName); + typedef dvar_t*(__cdecl * Dvar_FindVar_t)(const char* dvarName); extern Dvar_FindVar_t Dvar_FindVar; - typedef char* (__cdecl * Dvar_InfoString_Big_t)(int bit); + typedef char*(__cdecl * Dvar_InfoString_Big_t)(int bit); extern Dvar_InfoString_Big_t Dvar_InfoString_Big; typedef void(__cdecl * Dvar_SetCommand_t)(const char* dvarName, const char* string); extern Dvar_SetCommand_t Dvar_SetCommand; - typedef const char* (__cdecl * Dvar_DisplayableValue_t)(const dvar_t* cvar); + typedef const char*(__cdecl * Dvar_DisplayableValue_t)(const dvar_t* dvar); extern Dvar_DisplayableValue_t Dvar_DisplayableValue; typedef bool(__cdecl * Encode_Init_t)(const char* ); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index e32dfdca..753fa215 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -74,29 +74,27 @@ namespace Game ASSET_TYPE_INVALID = -1, }; - typedef enum : unsigned int + enum dvar_flag : unsigned __int16 { - DVAR_FLAG_NONE = 0x0, //no flags - DVAR_FLAG_SAVED = 0x1, //saves in config_mp.cfg for clients - DVAR_FLAG_LATCHED = 0x2, //no changing apart from initial value (although it might apply on a map reload, I think) - DVAR_FLAG_CHEAT = 0x4, //cheat - DVAR_FLAG_REPLICATED = 0x8, //on change, this is sent to all clients (if you are host) - DVAR_FLAG_UNKNOWN10 = 0x10, //unknown - DVAR_FLAG_UNKNOWN20 = 0x20, //unknown - DVAR_FLAG_UNKNOWN40 = 0x40, //unknown - DVAR_FLAG_UNKNOWN80 = 0x80, //unknown - DVAR_FLAG_USERCREATED = 0x100, //a 'set' type command created it - DVAR_FLAG_USERINFO = 0x200, //userinfo? - DVAR_FLAG_SERVERINFO = 0x400, //in the getstatus oob - DVAR_FLAG_WRITEPROTECTED = 0x800, //write protected - DVAR_FLAG_UNKNOWN1000 = 0x1000, //unknown - DVAR_FLAG_READONLY = 0x2000, //read only (same as 0x800?) - DVAR_FLAG_UNKNOWN4000 = 0x4000, //unknown - DVAR_FLAG_UNKNOWN8000 = 0x8000, //unknown - DVAR_FLAG_UNKNOWN10000 = 0x10000, //unknown - DVAR_FLAG_DEDISAVED = 0x1000000, //unknown - DVAR_FLAG_NONEXISTENT = 0xFFFFFFFF //no such dvar - } dvar_flag; + DVAR_NONE = 0x0, // No flags + DVAR_ARCHIVE = 0x1, // Set to cause it to be saved to config_mp.cfg of the client + DVAR_LATCH = 0x2, // Will only change when C code next does a Dvar_Get(), so it can't be changed + // without proper initialization. Modified will be set, even though the value hasn't changed yet + DVAR_CHEAT = 0x4, // Can not be changed if cheats are disabled + DVAR_CODINFO = 0x8, // On change, this is sent to all clients (if you are host) + DVAR_SCRIPTINFO = 0x10, + DVAR_UNKNOWN20 = 0x20, + DVAR_CHANGEABLE_RESET = 0x40, + DVAR_UNKNOWN80 = 0x80, + DVAR_EXTERNAL = 0x100, // Created by a set command + DVAR_USERINFO = 0x200, // Sent to server on connect or change + DVAR_SERVERINFO = 0x400, // Sent in response to front end requests + DVAR_WRITEPROTECTED = 0x800, + DVAR_SYSTEMINFO = 0x1000, // These dvars will be duplicated on all clients + DVAR_READONLY = 0x2000, // Read only (same as DVAR_WRITEPROTECTED?) + DVAR_SAVED = 0x4000, + DVAR_AUTOEXEC = 0x8000, + }; enum ImageCategory : char { @@ -3329,14 +3327,14 @@ namespace Game unsigned int unsignedInt; float value; float vector[4]; - const char *string; + const char* string; unsigned char color[4]; }; struct $BFBB53559BEAC4289F32B924847E59CB { int stringCount; - const char **strings; + const char** strings; }; struct $9CA192F9DB66A3CB7E01DE78A0DEA53D @@ -3361,35 +3359,35 @@ namespace Game struct dvar_t { - const char *name; - const char *description; - unsigned int flags; + const char* name; + const char* description; + unsigned __int16 flags; dvar_type type; bool modified; DvarValue current; DvarValue latched; DvarValue reset; DvarLimits domain; - bool(__cdecl *domainFunc)(dvar_t *, DvarValue); + bool(__cdecl * domainFunc)(dvar_t*, DvarValue); dvar_t *hashNext; }; struct StaticDvar { - dvar_t *dvar; - char *dvarName; + dvar_t* dvar; + char* dvarName; }; struct StaticDvarList { int numStaticDvars; - StaticDvar **staticDvars; + StaticDvar** staticDvars; }; struct StringList { int totalStrings; - const char **strings; + const char** strings; }; struct ExpressionSupportingData From 43fa4cd73657ee921fed957400586395c0ff7616 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 8 Mar 2022 12:44:05 +0000 Subject: [PATCH 30/52] Fix flag for scr_dvar --- src/Components/Modules/QuickPatch.cpp | 2 +- src/Components/Modules/ServerList.cpp | 4 ++-- src/Game/Structs.hpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 38410e9b..395ff0ff 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -374,7 +374,7 @@ namespace Components Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick(); // Intermission time dvar - Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_SCRIPTINFO, "Time in seconds before match server loads the next map"); + Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_EXTERNAL, "Time in seconds before match server loads the next map"); g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag"); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index aac56a28..c7cce94f 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -737,8 +737,8 @@ namespace Components Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_NONE, "Whether a server has been selected in the serverlist"); Dvar::Register("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_NONE, "Map of the selected server"); - Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame"); - Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second"); + Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame"); + Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second"); }); // Fix ui_netsource dvar diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 753fa215..bb3751c5 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -76,18 +76,18 @@ namespace Game enum dvar_flag : unsigned __int16 { - DVAR_NONE = 0x0, // No flags - DVAR_ARCHIVE = 0x1, // Set to cause it to be saved to config_mp.cfg of the client - DVAR_LATCH = 0x2, // Will only change when C code next does a Dvar_Get(), so it can't be changed - // without proper initialization. Modified will be set, even though the value hasn't changed yet - DVAR_CHEAT = 0x4, // Can not be changed if cheats are disabled - DVAR_CODINFO = 0x8, // On change, this is sent to all clients (if you are host) + DVAR_NONE = 0x0, // No flags + DVAR_ARCHIVE = 0x1, // Set to cause it to be saved to config_mp.cfg of the client + DVAR_LATCH = 0x2, // Will only change when C code next does a Dvar_Get(), so it can't be changed + // without proper initialization. Modified will be set, even though the value hasn't changed yet + DVAR_CHEAT = 0x4, // Can not be changed if cheats are disabled + DVAR_CODINFO = 0x8, // On change, this is sent to all clients (if you are host) DVAR_SCRIPTINFO = 0x10, DVAR_UNKNOWN20 = 0x20, DVAR_CHANGEABLE_RESET = 0x40, DVAR_UNKNOWN80 = 0x80, - DVAR_EXTERNAL = 0x100, // Created by a set command - DVAR_USERINFO = 0x200, // Sent to server on connect or change + DVAR_EXTERNAL = 0x100, // Created by a set command + DVAR_USERINFO = 0x200, // Sent to server on connect or change DVAR_SERVERINFO = 0x400, // Sent in response to front end requests DVAR_WRITEPROTECTED = 0x800, DVAR_SYSTEMINFO = 0x1000, // These dvars will be duplicated on all clients From 253121696977ec4549215e4d7d40526f6dca2540 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 8 Mar 2022 14:03:38 +0000 Subject: [PATCH 31/52] Document dvar_rom --- src/Game/Structs.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index bb3751c5..25c23fc0 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -85,7 +85,7 @@ namespace Game DVAR_SCRIPTINFO = 0x10, DVAR_UNKNOWN20 = 0x20, DVAR_CHANGEABLE_RESET = 0x40, - DVAR_UNKNOWN80 = 0x80, + DVAR_ROM = 0x80, // Display only, cannot be set by user at all DVAR_EXTERNAL = 0x100, // Created by a set command DVAR_USERINFO = 0x200, // Sent to server on connect or change DVAR_SERVERINFO = 0x400, // Sent in response to front end requests From f3a2d6f40664a4bb8b870084bb209607e60d4dc6 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 8 Mar 2022 14:42:41 +0000 Subject: [PATCH 32/52] Fix some things --- src/Components/Modules/Download.cpp | 8 ++++---- src/Components/Modules/Playlist.cpp | 2 +- src/Components/Modules/QuickPatch.cpp | 2 +- src/Game/Structs.hpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index a4ac5727..02b1de2a 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -918,10 +918,10 @@ namespace Components Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server."); Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_ARCHIVE, "Set to the base url for the external map download."); - // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again - // not saying we are but ya know... accidents happen - // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not - Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches)."); + // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again + // not saying we are but ya know... accidents happen + // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not + Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches)."); }); Scheduler::OnFrame([]() diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index e413d534..09cb8776 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -21,7 +21,7 @@ namespace Components Dvar::Var("xblive_privateserver").set(false); - std::string playlistFilename = Dvar::Var("playlistFilename").get(); + auto playlistFilename = Dvar::Var("playlistFilename").get(); FileSystem::File playlist(playlistFilename); if (playlist.exists()) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 395ff0ff..cf1f517e 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -374,7 +374,7 @@ namespace Components Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick(); // Intermission time dvar - Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_EXTERNAL, "Time in seconds before match server loads the next map"); + Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_NONE, "Time in seconds before match server loads the next map"); g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag"); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 25c23fc0..0b691df5 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -85,12 +85,12 @@ namespace Game DVAR_SCRIPTINFO = 0x10, DVAR_UNKNOWN20 = 0x20, DVAR_CHANGEABLE_RESET = 0x40, - DVAR_ROM = 0x80, // Display only, cannot be set by user at all + DVAR_UNKNOWN80 = 0x80, DVAR_EXTERNAL = 0x100, // Created by a set command DVAR_USERINFO = 0x200, // Sent to server on connect or change DVAR_SERVERINFO = 0x400, // Sent in response to front end requests DVAR_WRITEPROTECTED = 0x800, - DVAR_SYSTEMINFO = 0x1000, // These dvars will be duplicated on all clients + DVAR_SYSTEMINFO = 0x1000, // Will be duplicated on all clients DVAR_READONLY = 0x2000, // Read only (same as DVAR_WRITEPROTECTED?) DVAR_SAVED = 0x4000, DVAR_AUTOEXEC = 0x8000, @@ -3361,7 +3361,7 @@ namespace Game { const char* name; const char* description; - unsigned __int16 flags; + unsigned int flags; dvar_type type; bool modified; DvarValue current; From bc852d884049e1db80cc1e8ecba91cfb2ad4cacd Mon Sep 17 00:00:00 2001 From: FutureRave Date: Fri, 11 Mar 2022 10:42:22 +0000 Subject: [PATCH 33/52] Revert changes to some maths operation --- src/Components/Modules/AssetInterfaces/IFont_s.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index edeb572b..bb53c252 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -53,10 +53,10 @@ namespace Assets auto& glyph = glyphs[i++]; glyph.letter = ch; - glyph.s0 = static_cast(x / pw); - glyph.s1 = static_cast((x + gw) / pw); - glyph.t0 = static_cast(y / ph); - glyph.t1 = static_cast((y + gh) / ph); + glyph.s0 = x / static_cast(pw); + glyph.s1 = (x + gw) / static_cast(pw); + glyph.t0 = y / static_cast(ph); + glyph.t1 = (y + gh) / static_cast(ph); glyph.pixelWidth = static_cast(gw); glyph.pixelHeight = static_cast(gh); glyph.x0 = static_cast(x0); From 7fbfd1037a804d4118cd6ad254a6d8883217810e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 17:21:18 +0000 Subject: [PATCH 34/52] Bump deps/libtommath from `04e9d1e` to `66de864` Bumps [deps/libtommath](https://github.com/libtom/libtommath) from `04e9d1e` to `66de864`. - [Release notes](https://github.com/libtom/libtommath/releases) - [Commits](https://github.com/libtom/libtommath/compare/04e9d1e7a0493910b2eb5e757d623870692ada04...66de86426e9cdb88526974c765108f01554af2b0) --- updated-dependencies: - dependency-name: deps/libtommath dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/libtommath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/libtommath b/deps/libtommath index 04e9d1e7..66de8642 160000 --- a/deps/libtommath +++ b/deps/libtommath @@ -1 +1 @@ -Subproject commit 04e9d1e7a0493910b2eb5e757d623870692ada04 +Subproject commit 66de86426e9cdb88526974c765108f01554af2b0 From a30d200fc15d840c3d93e1587cf559a5ba9ebe32 Mon Sep 17 00:00:00 2001 From: Edo Date: Tue, 15 Mar 2022 18:20:47 +0000 Subject: [PATCH 35/52] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1d949fc..8e16bfe9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check out files - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 @@ -116,4 +116,4 @@ jobs: # run: rsync -avz ./data/ ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }}:${{ env.XLABS_MASTER_PATH }}/iw4x/data/ - name: Publish changes - run: ssh ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }} ${{ secrets.XLABS_MASTER_SSH_CHANGE_PUBLISH_COMMAND }} \ No newline at end of file + run: ssh ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }} ${{ secrets.XLABS_MASTER_SSH_CHANGE_PUBLISH_COMMAND }} From 0068b76d9827f5d51a59e7db2a2741b1bccefdcb Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 15 Mar 2022 22:49:58 +0000 Subject: [PATCH 36/52] Fix a typo in stub & clean-up some things --- src/Components/Modules/Bots.cpp | 6 ++-- src/Components/Modules/Bots.hpp | 2 +- src/Components/Modules/ClientCommand.cpp | 7 ++-- src/Components/Modules/Download.cpp | 4 +-- src/Components/Modules/Script.cpp | 39 ++++++++++++---------- src/Components/Modules/ScriptExtension.cpp | 24 ++++++------- src/Components/Modules/ScriptExtension.hpp | 1 + src/Game/Functions.hpp | 2 +- 8 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index cdab519a..36841f67 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -264,7 +264,7 @@ namespace Components } constexpr auto SV_BotUserMove = 0x626E50; - __declspec(naked) void Bots::SV_UpdateBots_Hk() + __declspec(naked) void Bots::SV_BotUserMove_Hk() { __asm { @@ -302,8 +302,8 @@ namespace Components // Intercept sprintf for the connect string Utils::Hook(0x48ADAB, Bots::BuildConnectString, HOOK_CALL).install()->quick(); - Utils::Hook(0x627021, Bots::SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); - Utils::Hook(0x627241, Bots::SV_UpdateBots_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x627021, Bots::SV_BotUserMove_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x627241, Bots::SV_BotUserMove_Hk, HOOK_CALL).install()->quick(); // Zero the bot command array for (auto i = 0u; i < std::extent_v; i++) diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index e6a6ee22..dcbadc6c 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -32,6 +32,6 @@ namespace Components static void AddMethods(); static void BotAiAction(Game::client_t* cl); - static void SV_UpdateBots_Hk(); + static void SV_BotUserMove_Hk(); }; } diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index 6ad47a0e..eab176f8 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -28,10 +28,11 @@ namespace Components bool ClientCommand::CallbackHandler(Game::gentity_s* ent, const char* cmd) { const auto command = Utils::String::ToLower(cmd); + const auto got = ClientCommand::FunctionMap.find(command); - if (ClientCommand::FunctionMap.find(command) != ClientCommand::FunctionMap.end()) + if (got != ClientCommand::FunctionMap.end()) { - ClientCommand::FunctionMap[command](ent); + got->second(ent); return true; } @@ -42,7 +43,7 @@ namespace Components { const auto command = Utils::String::ToLower(name); - ClientCommand::FunctionMap[command] = callback; + ClientCommand::FunctionMap[command] = std::move(callback); } void ClientCommand::ClientCommandStub(const int clientNum) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 95b96574..39682107 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -966,7 +966,7 @@ namespace Components Script::AddFunction("HttpGet", [](Game::scr_entref_t) { - if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) + if (!Flags::HasFlag("scriptablehttp")) return; const auto* url = Game::Scr_GetString(0); @@ -987,7 +987,7 @@ namespace Components Script::AddFunction("HttpCancel", [](Game::scr_entref_t) { - if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) + if (!Flags::HasFlag("scriptablehttp")) return; const auto object = Game::Scr_GetObject(0); diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 3520065e..acb5ed9e 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -60,18 +60,16 @@ namespace Components if (Game::scrVmPub->debugCode || Game::scrVarPub->developer_script) { Game::RuntimeErrorInternal(23, codePos, index, msg); - - if (!Game::scrVmPub->terminal_error) - return; } else { Logger::Print(23, "%s\n", msg); - // Let's not throw error unless we have to - if (Game::scrVmPub->abort_on_error && !Game::scrVmPub->terminal_error) - return; } + // Let's not throw error unless we have to + if (!Game::scrVmPub->abort_on_error) + return; + if (dialogMessage == nullptr) dialogMessage = ""; @@ -222,7 +220,7 @@ namespace Components } Logger::Print("Finding script handle %s::%s...\n", script.data(), label.data()); - int handle = Game::Scr_GetFunctionHandle(script.data(), label.data()); + const auto handle = Game::Scr_GetFunctionHandle(script.data(), label.data()); if (handle) { Logger::Print("Script handle %s::%s loaded successfully.\n", script.data(), label.data()); @@ -235,7 +233,7 @@ namespace Components void Script::LoadGameType() { - for (auto handle : Script::ScriptHandles) + for (const auto& handle : Script::ScriptHandles) { Game::Scr_FreeThread(Game::Scr_ExecThread(handle, 0)); } @@ -247,7 +245,7 @@ namespace Components { Script::ScriptHandles.clear(); - auto list = FileSystem::GetFileList("scripts/", "gsc"); + const auto list = FileSystem::GetFileList("scripts/", "gsc"); for (auto file : list) { @@ -258,8 +256,12 @@ namespace Components file = file.substr(0, file.size() - 4); } - int handle = Script::LoadScriptAndLabel(file, "init"); - if (handle) Script::ScriptHandles.push_back(handle); + auto handle = Script::LoadScriptAndLabel(file, "init"); + + if (handle) + { + Script::ScriptHandles.push_back(handle); + } else { handle = Script::LoadScriptAndLabel(file, "main"); @@ -339,7 +341,7 @@ namespace Components for (const auto& [key, value] : Script::ScriptBaseProgramNum) { - int codePos = key; + const auto codePos = key; if (codePos > scriptPos) { @@ -403,7 +405,7 @@ namespace Components void Script::OnVMShutdown(Utils::Slot callback) { Script::ScriptBaseProgramNum.clear(); - Script::VMShutdownSignal.connect(callback); + Script::VMShutdownSignal.connect(std::move(callback)); } void Script::ScrShutdownSystemStub(int num) @@ -460,7 +462,7 @@ namespace Components { if (what[0] == '\0' || with[0] == '\0') { - Logger::Print("Warning: Invalid paramters passed to ReplacedFunctions\n"); + Logger::Print("Warning: Invalid parameters passed to ReplacedFunctions\n"); return; } @@ -600,7 +602,7 @@ namespace Components } }); - // Script Storage Funcs + // Script Storage Functions Script::AddFunction("StorageSet", [](Game::scr_entref_t) // gsc: StorageSet(, ); { const auto* key = Game::Scr_GetString(0); @@ -664,7 +666,7 @@ namespace Components return; } - Game::Scr_AddBool(Script::ScriptStorage.count(key)); + Game::Scr_AddBool(static_cast(Script::ScriptStorage.count(key))); // Until C++17 }); Script::AddFunction("StorageClear", [](Game::scr_entref_t) // gsc: StorageClear(); @@ -719,11 +721,12 @@ namespace Components if (!Game::SV_Loaded()) return; - int nowMs = Game::Sys_Milliseconds(); + const auto nowMs = Game::Sys_Milliseconds(); if (Script::LastFrameTime != -1) { - int timeTaken = static_cast((nowMs - Script::LastFrameTime) * Dvar::Var("timescale").get()); + const auto timeScale = Dvar::Var("timescale").get(); + const auto timeTaken = static_cast((nowMs - Script::LastFrameTime) * timeScale); if (timeTaken >= 500) Logger::Print(23, "Hitch warning: %i msec frame time\n", timeTaken); diff --git a/src/Components/Modules/ScriptExtension.cpp b/src/Components/Modules/ScriptExtension.cpp index 9de9a586..66cd38ff 100644 --- a/src/Components/Modules/ScriptExtension.cpp +++ b/src/Components/Modules/ScriptExtension.cpp @@ -2,7 +2,7 @@ namespace Components { - static const char* queryStrings[] = { R"(..)", R"(../)", R"(..\)" }; + const char* ScriptExtension::QueryStrings[] = { R"(..)", R"(../)", R"(..\)" }; void ScriptExtension::AddFunctions() { @@ -26,16 +26,16 @@ namespace Components return; } - for (auto i = 0u; i < ARRAYSIZE(queryStrings); ++i) + for (auto i = 0u; i < ARRAYSIZE(ScriptExtension::QueryStrings); ++i) { - if (std::strstr(path, queryStrings[i]) != nullptr) + if (std::strstr(path, ScriptExtension::QueryStrings[i]) != nullptr) { Logger::Print("^1FileWrite: directory traversal is not allowed!\n"); return; } } - if (mode != "append"s && mode != "write"s) + if (mode != "append" && mode != "write") { Logger::Print("^3FileWrite: mode not defined or was wrong, defaulting to 'write'\n"); mode = "write"; @@ -61,9 +61,9 @@ namespace Components return; } - for (auto i = 0u; i < ARRAYSIZE(queryStrings); ++i) + for (auto i = 0u; i < ARRAYSIZE(ScriptExtension::QueryStrings); ++i) { - if (std::strstr(path, queryStrings[i]) != nullptr) + if (std::strstr(path, ScriptExtension::QueryStrings[i]) != nullptr) { Logger::Print("^1FileRead: directory traversal is not allowed!\n"); return; @@ -89,9 +89,9 @@ namespace Components return; } - for (auto i = 0u; i < ARRAYSIZE(queryStrings); ++i) + for (auto i = 0u; i < ARRAYSIZE(ScriptExtension::QueryStrings); ++i) { - if (std::strstr(path, queryStrings[i]) != nullptr) + if (std::strstr(path, ScriptExtension::QueryStrings[i]) != nullptr) { Logger::Print("^1FileExists: directory traversal is not allowed!\n"); return; @@ -111,9 +111,9 @@ namespace Components return; } - for (auto i = 0u; i < ARRAYSIZE(queryStrings); ++i) + for (auto i = 0u; i < ARRAYSIZE(ScriptExtension::QueryStrings); ++i) { - if (std::strstr(path, queryStrings[i]) != nullptr) + if (std::strstr(path, ScriptExtension::QueryStrings[i]) != nullptr) { Logger::Print("^1fileRemove: directory traversal is not allowed!\n"); return; @@ -137,9 +137,7 @@ namespace Components std::string ip = Game::NET_AdrToString(client->netchan.remoteAddress); - const auto pos = ip.find_first_of(":"); - - if (pos != std::string::npos) + if (const auto pos = ip.find_first_of(":"); pos != std::string::npos) ip.erase(ip.begin() + pos, ip.end()); // Erase port Game::Scr_AddString(ip.data()); diff --git a/src/Components/Modules/ScriptExtension.hpp b/src/Components/Modules/ScriptExtension.hpp index 2c64e89a..84eef531 100644 --- a/src/Components/Modules/ScriptExtension.hpp +++ b/src/Components/Modules/ScriptExtension.hpp @@ -8,6 +8,7 @@ namespace Components ScriptExtension(); private: + static const char* QueryStrings[]; static void AddFunctions(); static void AddMethods(); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index ac4a336d..6fa0dfd9 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -681,7 +681,7 @@ namespace Game typedef unsigned int(__cdecl * Scr_GetNumParam_t)(); extern Scr_GetNumParam_t Scr_GetNumParam; - typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char*, const char*); + typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char* filename, const char* name); extern Scr_GetFunctionHandle_t Scr_GetFunctionHandle; typedef int(__cdecl * Scr_ExecThread_t)(int, int); From 7798532ad0c11c348bcd014e140ce1d14609d420 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Tue, 15 Mar 2022 22:52:48 +0000 Subject: [PATCH 37/52] Revert accidental remove of string literal --- src/Components/Modules/ScriptExtension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/ScriptExtension.cpp b/src/Components/Modules/ScriptExtension.cpp index 66cd38ff..e47041e9 100644 --- a/src/Components/Modules/ScriptExtension.cpp +++ b/src/Components/Modules/ScriptExtension.cpp @@ -35,7 +35,7 @@ namespace Components } } - if (mode != "append" && mode != "write") + if (mode != "append"s && mode != "write"s) { Logger::Print("^3FileWrite: mode not defined or was wrong, defaulting to 'write'\n"); mode = "write"; From 809e66cdb1124b5d6cff70f53173c275187b1c55 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Wed, 16 Mar 2022 00:44:59 +0000 Subject: [PATCH 38/52] Remove unnecessary deconstructors --- src/Components/Modules/Bans.cpp | 5 ----- src/Components/Modules/Bans.hpp | 1 - src/Components/Modules/CardTitles.cpp | 8 -------- src/Components/Modules/CardTitles.hpp | 1 - src/Components/Modules/Changelog.cpp | 8 -------- src/Components/Modules/Changelog.hpp | 1 - src/Components/Modules/Chat.cpp | 5 ----- src/Components/Modules/Chat.hpp | 1 - src/Components/Modules/Clantags.cpp | 8 -------- src/Components/Modules/Clantags.hpp | 1 - src/Components/Modules/ClientCommand.cpp | 5 ----- src/Components/Modules/ClientCommand.hpp | 2 +- src/Components/Modules/Command.cpp | 6 ------ src/Components/Modules/Command.hpp | 2 +- src/Components/Modules/Dedicated.cpp | 5 ----- src/Components/Modules/Dedicated.hpp | 1 - src/Components/Modules/Discovery.cpp | 5 ----- src/Components/Modules/Discovery.hpp | 1 - src/Components/Modules/Elevators.cpp | 4 ---- src/Components/Modules/Elevators.hpp | 1 - src/Components/Modules/FastFiles.cpp | 5 ----- src/Components/Modules/FastFiles.hpp | 1 - src/Components/Modules/Flags.cpp | 4 ---- src/Components/Modules/Flags.hpp | 2 +- src/Components/Modules/Menus.cpp | 1 - src/Components/Modules/ModList.cpp | 5 ----- src/Components/Modules/ModList.hpp | 1 - src/Components/Modules/MusicalTalent.cpp | 5 ----- src/Components/Modules/MusicalTalent.hpp | 1 - src/Components/Modules/Network.cpp | 7 ------- src/Components/Modules/Network.hpp | 1 - src/Components/Modules/Party.cpp | 5 ----- src/Components/Modules/Party.hpp | 1 - src/Components/Modules/Playlist.cpp | 7 ------- src/Components/Modules/Playlist.hpp | 1 - src/Components/Modules/RCon.cpp | 5 ----- src/Components/Modules/RCon.hpp | 1 - src/Components/Modules/Script.cpp | 8 -------- src/Components/Modules/ServerCommands.cpp | 5 ----- src/Components/Modules/ServerCommands.hpp | 1 - src/Components/Modules/ServerList.cpp | 13 +++---------- src/Components/Modules/StartupMessages.cpp | 5 ----- src/Components/Modules/StartupMessages.hpp | 1 - src/Components/Modules/Stats.cpp | 5 ----- src/Components/Modules/Stats.hpp | 1 - src/Components/Modules/StringTable.cpp | 5 ----- src/Components/Modules/StringTable.hpp | 1 - src/Components/Modules/StructuredData.cpp | 5 ----- src/Components/Modules/StructuredData.hpp | 1 - src/Components/Modules/Zones.cpp | 5 ----- src/Components/Modules/Zones.hpp | 1 - 51 files changed, 6 insertions(+), 175 deletions(-) diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 38cd20e9..6310ef5c 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -274,9 +274,4 @@ namespace Components Bans::LoadBans(&list); }); } - - Bans::~Bans() - { - - } } diff --git a/src/Components/Modules/Bans.hpp b/src/Components/Modules/Bans.hpp index 1ba76a66..fe5c6410 100644 --- a/src/Components/Modules/Bans.hpp +++ b/src/Components/Modules/Bans.hpp @@ -8,7 +8,6 @@ namespace Components typedef std::pair Entry; Bans(); - ~Bans(); static void BanClientNum(int num, const std::string& reason); static void UnbanClient(SteamID id); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 471dd8ec..5afb8a8b 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -227,12 +227,4 @@ namespace Components AntiCheat::CheckStartupTime(); #endif } - - CardTitles::~CardTitles() - { - for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i) - { - CardTitles::CustomTitles[i].clear(); - } - } } diff --git a/src/Components/Modules/CardTitles.hpp b/src/Components/Modules/CardTitles.hpp index 7f838ef8..0b43bdab 100644 --- a/src/Components/Modules/CardTitles.hpp +++ b/src/Components/Modules/CardTitles.hpp @@ -60,7 +60,6 @@ namespace Components static void ParseCustomTitles(const char * msg); CardTitles(); - ~CardTitles(); private: static CClient * GetClientByIndex(std::uint32_t index); diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 28773007..a6da0d83 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -60,12 +60,4 @@ namespace Components Scheduler::OnFrameAsync(AntiCheat::QuickCodeScanner1); #endif } - - Changelog::~Changelog() - { - { - std::lock_guard _(Changelog::Mutex); - Changelog::Lines.clear(); - } - } } diff --git a/src/Components/Modules/Changelog.hpp b/src/Components/Modules/Changelog.hpp index dd74a8be..b58eb1ca 100644 --- a/src/Components/Modules/Changelog.hpp +++ b/src/Components/Modules/Changelog.hpp @@ -6,7 +6,6 @@ namespace Components { public: Changelog(); - ~Changelog(); static void LoadChangelog(); diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index abe117d8..0300d56c 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -328,9 +328,4 @@ namespace Components // Change logic that does word splitting with new lines for chat messages to support fonticons Utils::Hook(0x592E10, CG_AddToTeamChat_Stub, HOOK_JUMP).install()->quick(); } - - Chat::~Chat() - { - Chat::MuteList.clear(); - } } diff --git a/src/Components/Modules/Chat.hpp b/src/Components/Modules/Chat.hpp index 62bc36aa..134efb37 100644 --- a/src/Components/Modules/Chat.hpp +++ b/src/Components/Modules/Chat.hpp @@ -7,7 +7,6 @@ namespace Components static constexpr auto FONT_ICON_CHAT_WIDTH_CALCULATION_MULTIPLIER = 2.0f; public: Chat(); - ~Chat(); private: static Game::dvar_t** cg_chatHeight; diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index ff6e2022..e2d03cf6 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -101,12 +101,4 @@ namespace Components // Draw clantag before playername Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick(); } - - ClanTags::~ClanTags() - { - for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) - { - ClanTags::Tags[i].clear(); - } - } } diff --git a/src/Components/Modules/Clantags.hpp b/src/Components/Modules/Clantags.hpp index caadbe69..ea7bca39 100644 --- a/src/Components/Modules/Clantags.hpp +++ b/src/Components/Modules/Clantags.hpp @@ -10,7 +10,6 @@ namespace Components static const char* GetUserClantag(std::uint32_t clientnum, const char * playername); ClanTags(); - ~ClanTags(); private: static std::string Tags[18]; diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index 1c0c7fa4..bc0a202f 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -309,9 +309,4 @@ namespace Components ClientCommand::AddCheatCommands(); ClientCommand::AddScriptFunctions(); } - - ClientCommand::~ClientCommand() - { - ClientCommand::FunctionMap.clear(); - } } diff --git a/src/Components/Modules/ClientCommand.hpp b/src/Components/Modules/ClientCommand.hpp index 3c1d1da6..ca9bc2a3 100644 --- a/src/Components/Modules/ClientCommand.hpp +++ b/src/Components/Modules/ClientCommand.hpp @@ -8,7 +8,7 @@ namespace Components typedef void(Callback)(Game::gentity_s* entity); ClientCommand(); - ~ClientCommand(); + static void Add(const char* name, Utils::Slot callback); static bool CheatsOk(const Game::gentity_s* ent); diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index d3846df5..b0d30727 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -168,10 +168,4 @@ namespace Components } }); } - - Command::~Command() - { - Command::FunctionMap.clear(); - Command::FunctionMapSV.clear(); - } } diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 4e07ba87..1b6ccc6d 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -10,6 +10,7 @@ namespace Components public: Params() {}; virtual ~Params() {}; + virtual const char* get(size_t index) = 0; virtual size_t length() = 0; @@ -48,7 +49,6 @@ namespace Components typedef void(Callback)(Command::Params* params); Command(); - ~Command(); static Game::cmd_function_t* Allocate(); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 3e615dab..813621d6 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -519,9 +519,4 @@ namespace Components } }); } - - Dedicated::~Dedicated() - { - - } } diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 78126922..cfcbc539 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -6,7 +6,6 @@ namespace Components { public: Dedicated(); - ~Dedicated(); static SteamID PlayerGuids[18][2]; diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 758ef317..9b3e94ef 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -95,11 +95,6 @@ namespace Components #endif } - Discovery::~Discovery() - { - - } - void Discovery::preDestroy() { Discovery::IsPerforming = false; diff --git a/src/Components/Modules/Discovery.hpp b/src/Components/Modules/Discovery.hpp index 655122bf..63f69b1b 100644 --- a/src/Components/Modules/Discovery.hpp +++ b/src/Components/Modules/Discovery.hpp @@ -6,7 +6,6 @@ namespace Components { public: Discovery(); - ~Discovery(); void preDestroy() override; diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index 9438f9ce..bb998410 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -120,8 +120,4 @@ namespace Components Utils::Hook(0x570E0B, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x570D70, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); } - - Elevators::~Elevators() - { - } } diff --git a/src/Components/Modules/Elevators.hpp b/src/Components/Modules/Elevators.hpp index 02b0b64e..1a096161 100644 --- a/src/Components/Modules/Elevators.hpp +++ b/src/Components/Modules/Elevators.hpp @@ -6,7 +6,6 @@ namespace Components { public: Elevators(); - ~Elevators(); private: enum ElevatorSettings { DISABLED, ENABLED, EASY }; diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 2170e3c6..dbeeb667 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -622,9 +622,4 @@ namespace Components }, HOOK_CALL).install()/*->quick()*/; #endif } - - FastFiles::~FastFiles() - { - FastFiles::ZonePaths.clear(); - } } diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index 38c3e62c..a1b4c235 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -6,7 +6,6 @@ namespace Components { public: FastFiles(); - ~FastFiles(); static void AddZonePath(const std::string& path); static std::string Current(); diff --git a/src/Components/Modules/Flags.cpp b/src/Components/Modules/Flags.cpp index e3139910..0ae96615 100644 --- a/src/Components/Modules/Flags.cpp +++ b/src/Components/Modules/Flags.cpp @@ -53,8 +53,4 @@ namespace Components Flags::EnabledFlags.push_back("stdout"); } } - - Flags::Flags() - { - } } diff --git a/src/Components/Modules/Flags.hpp b/src/Components/Modules/Flags.hpp index ec35f350..b8ee410d 100644 --- a/src/Components/Modules/Flags.hpp +++ b/src/Components/Modules/Flags.hpp @@ -5,7 +5,7 @@ namespace Components class Flags : public Component { public: - Flags(); + Flags() = default; static bool HasFlag(const std::string& flag); diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 9f7faa12..b6c95ea9 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -913,7 +913,6 @@ namespace Components Menus::~Menus() { - Menus::CustomMenus.clear(); Menus::FreeEverything(); } } diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index 8935b586..944aa7b4 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -101,9 +101,4 @@ namespace Components UIFeeder::Add(9.0f, ModList::GetItemCount, ModList::GetItemText, ModList::Select); } - - ModList::~ModList() - { - ModList::Mods.clear(); - } } diff --git a/src/Components/Modules/ModList.hpp b/src/Components/Modules/ModList.hpp index a871fb45..185aaed1 100644 --- a/src/Components/Modules/ModList.hpp +++ b/src/Components/Modules/ModList.hpp @@ -6,7 +6,6 @@ namespace Components { public: ModList(); - ~ModList(); static void RunMod(const std::string& mod); diff --git a/src/Components/Modules/MusicalTalent.cpp b/src/Components/Modules/MusicalTalent.cpp index 7deef61c..9769fcb6 100644 --- a/src/Components/Modules/MusicalTalent.cpp +++ b/src/Components/Modules/MusicalTalent.cpp @@ -39,9 +39,4 @@ namespace Components MusicalTalent::Replace("music_mainmenu_mp", "hz_t_menumusic.mp3"); } - - MusicalTalent::~MusicalTalent() - { - MusicalTalent::SoundAliasList.clear(); - } } diff --git a/src/Components/Modules/MusicalTalent.hpp b/src/Components/Modules/MusicalTalent.hpp index e5bfc181..9d10d3d9 100644 --- a/src/Components/Modules/MusicalTalent.hpp +++ b/src/Components/Modules/MusicalTalent.hpp @@ -6,7 +6,6 @@ namespace Components { public: MusicalTalent(); - ~MusicalTalent(); static void Replace(const std::string& sound, const char* file); diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 18132d2b..cd573569 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -403,11 +403,4 @@ namespace Components Network::SendRaw(address, address.getString()); }); } - - Network::~Network() - { - Network::SelectedPacket.clear(); - Network::PacketHandlers.clear(); - Network::StartupSignal.clear(); - } } diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index f3248817..f3096350 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -52,7 +52,6 @@ namespace Components typedef void(CallbackRaw)(); Network(); - ~Network(); static unsigned short GetPort(); diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index afa418ad..f4bb851e 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -513,9 +513,4 @@ namespace Components Friends::UpdateServer(address, info.get("hostname"), info.get("mapname")); }); } - - Party::~Party() - { - Party::LobbyMap.clear(); - } } diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index 974bdc2f..d8f70cf1 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -6,7 +6,6 @@ namespace Components { public: Party(); - ~Party(); static Network::Address Target(); static void Connect(Network::Address target); diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index e413d534..f2291ebc 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -190,11 +190,4 @@ namespace Components Network::Handle("playlistResponse", PlaylistReponse); Network::Handle("playlistInvalidPassword", PlaylistInvalidPassword); } - - Playlist::~Playlist() - { - Playlist::MapRelocation.clear(); - Playlist::CurrentPlaylistBuffer.clear(); - Playlist::ReceivedPlaylistBuffer.clear(); - } } diff --git a/src/Components/Modules/Playlist.hpp b/src/Components/Modules/Playlist.hpp index c586815f..d8e7a8fb 100644 --- a/src/Components/Modules/Playlist.hpp +++ b/src/Components/Modules/Playlist.hpp @@ -8,7 +8,6 @@ namespace Components typedef void(*Callback)(); Playlist(); - ~Playlist(); static void LoadPlaylist(); diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..5412ec43 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -173,9 +173,4 @@ namespace Components } }); } - - RCon::~RCon() - { - RCon::Password.clear(); - } } diff --git a/src/Components/Modules/RCon.hpp b/src/Components/Modules/RCon.hpp index 1cc486e5..de09bbae 100644 --- a/src/Components/Modules/RCon.hpp +++ b/src/Components/Modules/RCon.hpp @@ -6,7 +6,6 @@ namespace Components { public: RCon(); - ~RCon(); private: class Container diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 42b9037c..5dc331a3 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -705,14 +705,6 @@ namespace Components Script::~Script() { - Script::ScriptName.clear(); - Script::ScriptHandles.clear(); - Script::ScriptNameStack.clear(); - Script::ScriptFunctions.clear(); - Script::ReplacedFunctions.clear(); Script::VMShutdownSignal.clear(); - - Script::ScriptStorage.clear(); - Script::ScriptBaseProgramNum.clear(); } } diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 471b32a6..7f47e086 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -65,9 +65,4 @@ namespace Components // Server command receive hook Utils::Hook(0x59449F, ServerCommands::OnServerCommandStub).install()->quick(); } - - ServerCommands::~ServerCommands() - { - ServerCommands::Commands.clear(); - } } diff --git a/src/Components/Modules/ServerCommands.hpp b/src/Components/Modules/ServerCommands.hpp index 8fc22459..61f823a6 100644 --- a/src/Components/Modules/ServerCommands.hpp +++ b/src/Components/Modules/ServerCommands.hpp @@ -6,7 +6,6 @@ namespace Components { public: ServerCommands(); - ~ServerCommands(); static void OnCommand(std::int32_t cmd, Utils::Slot cb); diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 94c3e473..4ddfa993 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -880,15 +880,8 @@ namespace Components ServerList::~ServerList() { - ServerList::OnlineList.clear(); - ServerList::OfflineList.clear(); - ServerList::FavouriteList.clear(); - ServerList::VisibleList.clear(); - - { - std::lock_guard _(ServerList::RefreshContainer.mutex); - ServerList::RefreshContainer.awatingList = false; - ServerList::RefreshContainer.servers.clear(); - } + std::lock_guard _(ServerList::RefreshContainer.mutex); + ServerList::RefreshContainer.awatingList = false; + ServerList::RefreshContainer.servers.clear(); } } diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index 16cf8497..c274ecfb 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -34,11 +34,6 @@ namespace Components }); } - StartupMessages::~StartupMessages() - { - StartupMessages::MessageList.clear(); - } - void StartupMessages::AddMessage(const std::string& message) { StartupMessages::MessageList.push_back(message); diff --git a/src/Components/Modules/StartupMessages.hpp b/src/Components/Modules/StartupMessages.hpp index 6ecf3cbe..7680c77a 100644 --- a/src/Components/Modules/StartupMessages.hpp +++ b/src/Components/Modules/StartupMessages.hpp @@ -6,7 +6,6 @@ namespace Components { public: StartupMessages(); - ~StartupMessages(); static void AddMessage(const std::string& message); diff --git a/src/Components/Modules/Stats.cpp b/src/Components/Modules/Stats.cpp index cdfab8c9..dc807c37 100644 --- a/src/Components/Modules/Stats.cpp +++ b/src/Components/Modules/Stats.cpp @@ -107,9 +107,4 @@ namespace Components // Write stats to mod folder if a mod is loaded Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick(); } - - Stats::~Stats() - { - - } } diff --git a/src/Components/Modules/Stats.hpp b/src/Components/Modules/Stats.hpp index 6fa5be2c..c4de9fd9 100644 --- a/src/Components/Modules/Stats.hpp +++ b/src/Components/Modules/Stats.hpp @@ -6,7 +6,6 @@ namespace Components { public: Stats(); - ~Stats(); static bool IsMaxLevel(); diff --git a/src/Components/Modules/StringTable.cpp b/src/Components/Modules/StringTable.cpp index 3fd00880..8f1d590d 100644 --- a/src/Components/Modules/StringTable.cpp +++ b/src/Components/Modules/StringTable.cpp @@ -76,9 +76,4 @@ namespace Components return header; }); } - - StringTable::~StringTable() - { - StringTable::StringTableMap.clear(); - } } diff --git a/src/Components/Modules/StringTable.hpp b/src/Components/Modules/StringTable.hpp index 21701b24..118cd076 100644 --- a/src/Components/Modules/StringTable.hpp +++ b/src/Components/Modules/StringTable.hpp @@ -6,7 +6,6 @@ namespace Components { public: StringTable(); - ~StringTable(); private: static std::unordered_map StringTableMap; diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index 64e3b375..983ee2e7 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -311,9 +311,4 @@ namespace Components } }); } - - StructuredData::~StructuredData() - { - StructuredData::MemAllocator.clear(); - } } diff --git a/src/Components/Modules/StructuredData.hpp b/src/Components/Modules/StructuredData.hpp index 8c7a6431..3a1b42f2 100644 --- a/src/Components/Modules/StructuredData.hpp +++ b/src/Components/Modules/StructuredData.hpp @@ -24,7 +24,6 @@ namespace Components }; StructuredData(); - ~StructuredData(); private: static bool UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *oldDef); diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index da24ffeb..24af1db6 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -3696,10 +3696,5 @@ namespace Components Utils::Hook::Set(0x6B9602,0xCCCC); #endif } - - Zones::~Zones() - { - - } } #pragma optimize( "", on ) \ No newline at end of file diff --git a/src/Components/Modules/Zones.hpp b/src/Components/Modules/Zones.hpp index dd1b5df6..615bc450 100644 --- a/src/Components/Modules/Zones.hpp +++ b/src/Components/Modules/Zones.hpp @@ -18,7 +18,6 @@ namespace Components }; Zones(); - ~Zones(); static void SetVersion(int version); From fb68afe19edc24a801c38869029884d2666b14d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Mar 2022 17:19:16 +0000 Subject: [PATCH 39/52] Bump deps/libtomcrypt from `673f5ce` to `06a81ae` Bumps [deps/libtomcrypt](https://github.com/libtom/libtomcrypt) from `673f5ce` to `06a81ae`. - [Release notes](https://github.com/libtom/libtomcrypt/releases) - [Commits](https://github.com/libtom/libtomcrypt/compare/673f5ce29015a9bba3c96792920a10601b5b0718...06a81aeb227424182125363f7554fad5146d6d2a) --- updated-dependencies: - dependency-name: deps/libtomcrypt dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/libtomcrypt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/libtomcrypt b/deps/libtomcrypt index 673f5ce2..06a81aeb 160000 --- a/deps/libtomcrypt +++ b/deps/libtomcrypt @@ -1 +1 @@ -Subproject commit 673f5ce29015a9bba3c96792920a10601b5b0718 +Subproject commit 06a81aeb227424182125363f7554fad5146d6d2a From a41d7356ccef44659cdd48b4ef586229097c417b Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 17 Mar 2022 18:50:20 +0000 Subject: [PATCH 40/52] Refactor command (changes from s1x) --- src/Components/Modules/Auth.cpp | 6 +- src/Components/Modules/Bans.cpp | 6 +- src/Components/Modules/Bots.cpp | 2 +- src/Components/Modules/CardTitles.cpp | 2 +- src/Components/Modules/Chat.cpp | 6 +- src/Components/Modules/Clantags.cpp | 2 +- src/Components/Modules/ClientCommand.cpp | 6 +- src/Components/Modules/Command.cpp | 81 ++++++++++++++--------- src/Components/Modules/Command.hpp | 33 +++++---- src/Components/Modules/Dedicated.cpp | 28 ++------ src/Components/Modules/Dvar.cpp | 17 +++-- src/Components/Modules/Exception.cpp | 2 +- src/Components/Modules/FastFiles.cpp | 2 +- src/Components/Modules/Friends.cpp | 2 +- src/Components/Modules/Gamepad.cpp | 2 +- src/Components/Modules/Logger.cpp | 8 +-- src/Components/Modules/Menus.cpp | 2 +- src/Components/Modules/Node.cpp | 2 +- src/Components/Modules/Party.cpp | 2 +- src/Components/Modules/QuickPatch.cpp | 16 ++--- src/Components/Modules/RCon.cpp | 10 +-- src/Components/Modules/RawFiles.cpp | 2 +- src/Components/Modules/ServerCommands.cpp | 6 +- src/Components/Modules/Weapon.cpp | 5 +- src/Components/Modules/ZoneBuilder.cpp | 10 +-- src/Game/Functions.cpp | 9 +-- src/Game/Functions.hpp | 10 +-- src/Game/Structs.hpp | 15 ++++- 28 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 1ea665f7..02a35b59 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -83,7 +83,7 @@ namespace Components Command::ServerParams params; - if (params.length() < 3) + if (params.size() < 3) { Game::SV_Cmd_EndTokenizedString(); Logger::SoftError("Connecting failed: Command parsing error!"); @@ -170,7 +170,7 @@ namespace Components Command::ServerParams params; // Ensure there are enough params - if (params.length() < 3) + if (params.size() < 3) { Network::Send(address, "error\nInvalid connect string!"); return; @@ -455,7 +455,7 @@ namespace Components { Command::Add("securityLevel", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey()); Logger::Print("Your current security level is %d\n", level); diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 38cd20e9..14eb15b5 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -234,17 +234,17 @@ namespace Components { Command::Add("banclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string reason = "EXE_ERR_BANNED_PERM"; - if (params->length() >= 3) reason = params->join(2); + if (params->size() >= 3) reason = params->join(2); Bans::BanClientNum(atoi(params->get(1)), reason); }); Command::Add("unbanclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string type = params->get(1); diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 78d42d0a..d177c573 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -447,7 +447,7 @@ namespace Components { unsigned int count = 1; - if (params->length() > 1) + if (params->size() > 1) { if (params->get(1) == "all"s) count = static_cast(-1); else count = atoi(params->get(1)); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 471dd8ec..0a47ce91 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -199,7 +199,7 @@ namespace Components { if (params->get(1) == "customTitles"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { CardTitles::ParseCustomTitles(params->get(2)); return true; diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index abe117d8..80740e7c 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -263,7 +263,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s : prevent the player from using the chat\n", cmd); return; @@ -285,7 +285,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s \n%s all = unmute everyone\n", cmd, cmd); return; @@ -299,7 +299,7 @@ namespace Components return; } - if (params->get(1) == "all"s) + if (std::strcmp(params->get(1), "all") == 0) { Logger::Print("All players were unmuted\n"); Chat::UnmuteInternal(0, true); diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index ff6e2022..f78fdbdf 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -83,7 +83,7 @@ namespace Components { if (params->get(1) == "clantags"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { ClanTags::ParseClantags(params->get(2)); return true; diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index 1c0c7fa4..4bdb8b03 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -147,7 +147,7 @@ namespace Components Command::ServerParams params = {}; Game::vec3_t origin, angles{0.f, 0.f, 0.f}; - if (params.length() < 4u || params.length() > 6u) + if (params.size() < 4 || params.size() > 6) { Game::SV_GameSendServerCommand(ent->s.number, 0, Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65)); @@ -159,12 +159,12 @@ namespace Components origin[i] = std::strtof(params.get(i + 1), nullptr); } - if (params.length() >= 5u) + if (params.size() >= 5) { angles[1] = std::strtof(params.get(4), nullptr); // Yaw } - if (params.length() == 6u) + if (params.size() == 6) { angles[0] = std::strtof(params.get(5), nullptr); // Pitch } diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index d3846df5..071be212 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -5,56 +5,72 @@ namespace Components std::unordered_map> Command::FunctionMap; std::unordered_map> Command::FunctionMapSV; - std::string Command::Params::join(size_t startIndex) + std::string Command::Params::join(const int index) { std::string result; - for (size_t i = startIndex; i < this->length(); ++i) + for (auto i = index; i < this->size(); i++) { - if (i > startIndex) result.append(" "); - result.append(this->operator[](i)); + if (i > index) result.append(" "); + result.append(this->get(i)); } return result; } - const char* Command::Params::operator[](size_t index) + Command::ClientParams::ClientParams() + : nesting_(Game::cmd_args->nesting) { - return this->get(index); + assert(Game::cmd_args->nesting < Game::CMD_MAX_NESTING); } - const char* Command::ClientParams::get(size_t index) + int Command::ClientParams::size() { - if (index >= this->length()) return ""; - return Game::cmd_argv[this->commandId][index]; + return Game::cmd_args->argc[this->nesting_]; } - size_t Command::ClientParams::length() + const char* Command::ClientParams::get(const int index) { - return Game::cmd_argc[this->commandId]; + if (index >= this->size()) + { + return ""; + } + + return Game::cmd_args->argv[this->nesting_][index]; } - const char* Command::ServerParams::get(size_t index) + Command::ServerParams::ServerParams() + : nesting_(Game::sv_cmd_args->nesting) { - if (index >= this->length()) return ""; - return Game::cmd_argv_sv[this->commandId][index]; + assert(Game::sv_cmd_args->nesting < Game::CMD_MAX_NESTING); } - size_t Command::ServerParams::length() + int Command::ServerParams::size() { - return Game::cmd_argc_sv[this->commandId]; + return Game::sv_cmd_args->argc[this->nesting_]; + } + + const char* Command::ServerParams::get(const int index) + { + if (index >= this->size()) + { + return ""; + } + + return Game::sv_cmd_args->argv[this->nesting_][index]; } void Command::Add(const char* name, Utils::Slot callback) { - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); + const auto got = Command::FunctionMap.find(command); - if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) + if (got == Command::FunctionMap.end()) { Command::AddRaw(name, Command::MainCallback); } - Command::FunctionMap[command] = callback; + got->second = std::move(callback); } void Command::AddSV(const char* name, Utils::Slot callback) @@ -70,9 +86,10 @@ namespace Components return; } - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); + const auto got = Command::FunctionMapSV.find(command); - if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) + if (got == Command::FunctionMapSV.end()) { Command::AddRawSV(name, Command::MainCallbackSV); @@ -80,7 +97,7 @@ namespace Components Command::AddRaw(name, Game::Cbuf_AddServerText); } - Command::FunctionMapSV[command] = callback; + got->second = std::move(callback); } void Command::AddRaw(const char* name, void(*callback)(), bool key) @@ -134,25 +151,27 @@ namespace Components void Command::MainCallback() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMap.find(command); - if (Command::FunctionMap.find(command) != Command::FunctionMap.end()) + if (got != Command::FunctionMap.end()) { - Command::FunctionMap[command](¶ms); + got->second(¶ms); } } void Command::MainCallbackSV() { - Command::ServerParams params(*Game::cmd_id_sv); + Command::ServerParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMapSV.find(command); - if (Command::FunctionMapSV.find(command) != Command::FunctionMapSV.end()) + if (got != Command::FunctionMapSV.end()) { - Command::FunctionMapSV[command](¶ms); + got->second(¶ms); } } @@ -162,7 +181,7 @@ namespace Components Command::Add("openLink", [](Command::Params* params) { - if (params->length() > 1) + if (params->size() > 1) { Utils::OpenUrl(params->get(1)); } diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 4e07ba87..365555e6 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -9,40 +9,39 @@ namespace Components { public: Params() {}; - virtual ~Params() {}; - virtual const char* get(size_t index) = 0; - virtual size_t length() = 0; - virtual std::string join(size_t startIndex); - virtual const char* operator[](size_t index); + virtual int size() = 0; + virtual const char* get(int index) = 0; + virtual std::string join(int index); + + virtual const char* operator[](const int index) + { + return this->get(index); + } }; class ClientParams : public Params { public: - ClientParams(unsigned int id) : commandId(id) {}; - ClientParams(const ClientParams &obj) : commandId(obj.commandId) {}; - ClientParams() : ClientParams(*Game::cmd_id) {}; + ClientParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; class ServerParams : public Params { public: - ServerParams(unsigned int id) : commandId(id) {}; - ServerParams(const ServerParams &obj) : commandId(obj.commandId) {}; - ServerParams() : ServerParams(*Game::cmd_id_sv) {}; + ServerParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; typedef void(Callback)(Command::Params* params); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 3e615dab..0c20904c 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -398,7 +398,7 @@ namespace Components // Say command Command::AddSV("say", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); std::string name = Dvar::Var("sv_sayName").get(); @@ -418,7 +418,7 @@ namespace Components // Tell command Command::AddSV("tell", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); @@ -439,7 +439,7 @@ namespace Components // Sayraw command Command::AddSV("sayraw", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); @@ -449,33 +449,13 @@ namespace Components // Tellraw command Command::AddSV("tellraw", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data()); }); - - // ! command - Command::AddSV("!", [](Command::Params* params) - { - if (params->length() != 2) return; - - int client = -1; - if (params->get(1) != "all"s) - { - client = atoi(params->get(1)); - - if (client >= *reinterpret_cast(0x31D938C)) - { - Game::Com_Printf(0, "Invalid player.\n"); - return; - } - } - - Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"\"", 106)); - }); }); } } diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5e6f8a60..c9e385ba 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -181,22 +181,22 @@ namespace Components } } - template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterBool(name, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterString(name, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); } @@ -336,10 +336,10 @@ namespace Components // remove write protection from fs_game Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED); - // set cg_fov max to 90.0 - // ...120 because of V2 - static float cgFov90 = 120.0f; - Utils::Hook::Set(0x4F8E28, &cgFov90); + // set cg_fov max to 160.0 + // because that's the max on SP + static float cg_Fov = 160.0f; + Utils::Hook::Set(0x4F8E28, &cg_Fov); // set max volume to 1 static float volume = 1.0f; @@ -385,7 +385,6 @@ namespace Components Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); // If the game closed abruptly, the dvars would not have been restored - Dvar::OnInit([] { Dvar::ResetDvarsValue(); diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index c5b09faf..3700587b 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -234,7 +234,7 @@ namespace Components Game::UI_UpdateArenas(); std::string command; - for (auto i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) + for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) { const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 2170e3c6..6a900ed1 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -594,7 +594,7 @@ namespace Components Command::Add("loadzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XZoneInfo info; info.name = params->get(1); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index d8d483ac..77a8eaa2 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -583,7 +583,7 @@ namespace Components Command::Add("addFriend", [](Command::Params* params) { - if (params->length() < 2u) + if (params->size() < 2u) { Logger::Print("Usage: %s \n", params->get(0)); return; diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 445868aa..5b6de852 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1641,7 +1641,7 @@ namespace Components void Gamepad::Axis_Bind_f(Command::Params* params) { - if (params->length() < 4) + if (params->size() < 4) { Logger::Print("bindaxis \n"); return; diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 75f2ec3b..69a8e9e6 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -261,7 +261,7 @@ namespace Components { Command::AddSV("log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -273,7 +273,7 @@ namespace Components Command::AddSV("log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[0].size()) @@ -312,7 +312,7 @@ namespace Components Command::AddSV("g_log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -324,7 +324,7 @@ namespace Components Command::AddSV("g_log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[1].size()) diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 9f7faa12..f3cf9b05 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -845,7 +845,7 @@ namespace Components Command::Add("openmenu", [](Command::Params* params) { - if (params->length() != 2) + if (params->size() != 2) { Logger::Print("USAGE: openmenu \n"); return; diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 7aa1584b..50797f93 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -377,7 +377,7 @@ namespace Components Command::Add("addnode", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Node::Add({ params->get(1) }); }); } diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index afa418ad..abfe36df 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -261,7 +261,7 @@ namespace Components Command::Add("connect", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { return; } diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 64ab5efe..30543a79 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -86,17 +86,15 @@ namespace Components void QuickPatch::SelectStringTableEntryInDvarStub() { - Command::ClientParams args; + Command::ClientParams params; - if (args.length() >= 4) + if (params.size() >= 4) { - std::string cmd = args[0]; - std::string table = args[1]; - std::string col = args[2]; - std::string dvarName = args[3]; - Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data()); + const auto* dvarName = params[3]; + const auto* dvar = Game::Dvar_FindVar(dvarName); - if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY)))) + if (Command::Find(dvarName) || + (dvar != nullptr && dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY))) { return; } @@ -671,7 +669,7 @@ namespace Components Command::Add("dumptechsets", [](Command::Params* param) { - if (param->length() != 2) + if (param->size() != 2) { Logger::Print("usage: dumptechsets | all\n"); return; diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..e14f0a4f 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -11,15 +11,15 @@ namespace Components { Command::Add("rcon", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; - std::string operation = params->get(1); - if (operation == "login") + const auto* operation = params->get(1); + if (std::strcmp(operation, "login") == 0) { - if (params->length() < 3) return; + if (params->size() < 3) return; RCon::Password = params->get(2); } - else if (operation == "logout") + else if (std::strcmp(operation, "logout") == 0) { RCon::Password.clear(); } diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index 30489edf..108da3e0 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -24,7 +24,7 @@ namespace Components Command::Add("dumpraw", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Specify a filename!\n"); return; diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 471b32a6..3cbbde8b 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -11,11 +11,11 @@ namespace Components bool ServerCommands::OnServerCommand() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - for (auto &serverCommandCB : ServerCommands::Commands) + for (const auto& serverCommandCB : ServerCommands::Commands) { - if (params.length() >= 1) + if (params.size() >= 1) { if (params.get(0)[0] == serverCommandCB.first) { diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index d526c747..e1becfe7 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -37,7 +37,10 @@ namespace Components int Weapon::ParseWeaponConfigStrings() { Command::ClientParams params; - if (params.length() <= 1) return 0; + + if (params.size() <= 1) + return 0; + int index = atoi(params[1]); if (index >= 4139) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index d3be354b..de49b525 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1110,7 +1110,7 @@ namespace Components Command::Add("verifyzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; /* Utils::Hook(0x4AE9C2, [] { Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; @@ -1165,7 +1165,7 @@ namespace Components Command::Add("buildzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string zoneName = params->get(1); Logger::Print("Building zone '%s'...\n", zoneName.data()); @@ -1455,7 +1455,7 @@ namespace Components Command::Add("listassets", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XAssetType type = Game::DB_GetXAssetNameType(params->get(1)); if (type != Game::XAssetType::ASSET_TYPE_INVALID) @@ -1470,7 +1470,7 @@ namespace Components Command::Add("loadtempzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; if (FastFiles::Exists(params->get(1))) { @@ -1502,7 +1502,7 @@ namespace Components Command::Add("iwiDump", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string path = Utils::String::VA("%s\\mods\\%s\\images", Dvar::Var("fs_basepath").get(), params->get(1)); std::vector images = FileSystem::GetSysFileList(path, "iwi", false); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index ad853b8d..0a7e4b89 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -390,13 +390,8 @@ namespace Game XAssetHeader* DB_XAssetPool = reinterpret_cast(0x7998A8); unsigned int* g_poolSize = reinterpret_cast(0x7995E8); - DWORD* cmd_id = reinterpret_cast(0x1AAC5D0); - DWORD* cmd_argc = reinterpret_cast(0x1AAC614); - char*** cmd_argv = reinterpret_cast(0x1AAC634); - - DWORD* cmd_id_sv = reinterpret_cast(0x1ACF8A0); - DWORD* cmd_argc_sv = reinterpret_cast(0x1ACF8E4); - char*** cmd_argv_sv = reinterpret_cast(0x1ACF904); + CmdArgs* cmd_args = reinterpret_cast(0x1AAC5D0); + CmdArgs* sv_cmd_args = reinterpret_cast(0x1ACF8A0); cmd_function_t** cmd_functions = reinterpret_cast(0x1AAC658); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 3940ba99..47635d49 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -921,13 +921,9 @@ namespace Game extern XAssetHeader* DB_XAssetPool; extern unsigned int* g_poolSize; - extern DWORD* cmd_id; - extern DWORD* cmd_argc; - extern char*** cmd_argv; - - extern DWORD* cmd_id_sv; - extern DWORD* cmd_argc_sv; - extern char*** cmd_argv_sv; + constexpr auto CMD_MAX_NESTING = 8; + extern CmdArgs* cmd_args; + extern CmdArgs* sv_cmd_args; extern cmd_function_t** cmd_functions; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 1f8d712d..2ce48006 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -170,8 +170,8 @@ namespace Game typedef enum { CS_FREE = 0x0, - CS_UNKNOWN1 = 0x1, - CS_UNKNOWN2 = 0x2, + CS_ZOMBIE = 0x1, + CS_RECONNECTING = 0x2, CS_CONNECTED = 0x3, CS_CLIENTLOADING = 0x4, CS_ACTIVE = 0x5, @@ -244,6 +244,17 @@ namespace Game struct MenuEventHandlerSet; struct menuDef_t; + struct CmdArgs + { + int nesting; + int localClientNum[8]; + int controllerIndex[8]; + int argc[8]; + const char** argv[8]; + }; + + static_assert(sizeof(CmdArgs) == 132); + typedef struct cmd_function_s { cmd_function_s *next; From 045640d460fc031d4478dd51821b224d81e4c3c6 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 19 Mar 2022 16:38:07 +0000 Subject: [PATCH 41/52] Fix bug --- src/Components/Modules/Command.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 071be212..173ea297 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -63,14 +63,13 @@ namespace Components void Command::Add(const char* name, Utils::Slot callback) { const auto command = Utils::String::ToLower(name); - const auto got = Command::FunctionMap.find(command); - if (got == Command::FunctionMap.end()) + if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) { Command::AddRaw(name, Command::MainCallback); } - got->second = std::move(callback); + Command::FunctionMap[command] = std::move(callback); } void Command::AddSV(const char* name, Utils::Slot callback) @@ -87,9 +86,8 @@ namespace Components } const auto command = Utils::String::ToLower(name); - const auto got = Command::FunctionMapSV.find(command); - if (got == Command::FunctionMapSV.end()) + if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) { Command::AddRawSV(name, Command::MainCallbackSV); @@ -97,7 +95,7 @@ namespace Components Command::AddRaw(name, Game::Cbuf_AddServerText); } - got->second = std::move(callback); + FunctionMapSV[command] = std::move(callback); } void Command::AddRaw(const char* name, void(*callback)(), bool key) From 5e55ba3d1dcebfde4afc738d8f9a20e69b1836d2 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 20 Mar 2022 09:05:45 +0000 Subject: [PATCH 42/52] Refactor quickpatch --- src/Components/Modules/QuickPatch.cpp | 6 ++++-- src/Utils/Library.cpp | 12 +++--------- src/Utils/Library.hpp | 8 ++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 30543a79..35294f96 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -356,8 +356,8 @@ namespace Components QuickPatch::QuickPatch() { - // quit_hard - Command::Add("quit_hard", [](Command::Params*) + // quitHard + Command::Add("quitHard", [](Command::Params*) { int data = false; const Utils::Library ntdll("ntdll.dll"); @@ -841,6 +841,7 @@ namespace Components } }); +#ifdef DEBUG AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/) { if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD) @@ -855,6 +856,7 @@ namespace Components Utils::IO::WriteFile("userraw/logs/matlog.txt", buffer); } }); +#endif // Dvars Dvar::Register("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI"); diff --git a/src/Utils/Library.cpp b/src/Utils/Library.cpp index 0cf9ab67..1b10bf40 100644 --- a/src/Utils/Library.cpp +++ b/src/Utils/Library.cpp @@ -19,15 +19,9 @@ namespace Utils return Library(handle); } - Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy) + Library::Library(const std::string& name, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy) { - this->_module = LoadLibraryExA(buffer.data(), nullptr, 0); - } - - Library::Library(const std::string& buffer) - { - this->_module = GetModuleHandleA(buffer.data()); - this->freeOnDestroy = true; + this->_module = LoadLibraryExA(name.data(), nullptr, 0); } Library::Library(const HMODULE handle) @@ -49,7 +43,7 @@ namespace Utils return this->_module != nullptr; } - HMODULE Library::getModule() + HMODULE Library::getModule() const { return this->_module; } diff --git a/src/Utils/Library.hpp b/src/Utils/Library.hpp index 2262987d..a736b987 100644 --- a/src/Utils/Library.hpp +++ b/src/Utils/Library.hpp @@ -9,14 +9,14 @@ namespace Utils static Library Load(const std::filesystem::path& path); static Library GetByAddress(void* address); - Library() : _module(nullptr), freeOnDestroy(false) {}; - Library(const std::string& buffer, bool freeOnDestroy); - explicit Library(const std::string& name); + Library() : _module(GetModuleHandleA(nullptr)), freeOnDestroy(false) {}; + explicit Library(const std::string& name, bool freeOnDestroy); + explicit Library(const std::string& name) : _module(GetModuleHandleA(name.data())), freeOnDestroy(true) {}; explicit Library(HMODULE handle); ~Library(); bool isValid() const; - HMODULE getModule(); + HMODULE getModule() const; template T getProc(const std::string& process) const From 21de40c48a29cbc5754824203f8f2263394dd2ce Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sun, 20 Mar 2022 11:20:53 +0000 Subject: [PATCH 43/52] Remove redundant clears --- src/Components/Modules/CardTitles.cpp | 5 ----- src/Components/Modules/Clantags.cpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 5afb8a8b..51477a54 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -210,11 +210,6 @@ namespace Components }); - for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i) - { - CardTitles::CustomTitles[i].clear(); - } - Utils::Hook(0x62EB26, CardTitles::GetPlayerCardClientInfoStub).install()->quick(); // Table lookup stuff diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index e2d03cf6..51e25cd7 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -93,11 +93,6 @@ namespace Components return false; }); - for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) - { - ClanTags::Tags[i].clear(); - } - // Draw clantag before playername Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick(); } From c9d53065535a4de3ae369ec07f272515770b978a Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 21 Mar 2022 18:55:35 +0000 Subject: [PATCH 44/52] Address review --- src/Components/Modules/Bots.cpp | 77 +++++++++++++++------- src/Components/Modules/Bots.hpp | 4 +- src/Components/Modules/Dvar.cpp | 1 - src/Components/Modules/ScriptExtension.cpp | 29 +++++++- src/Components/Modules/ScriptExtension.hpp | 1 + src/Game/Functions.cpp | 17 +++++ src/Game/Functions.hpp | 13 +++- 7 files changed, 111 insertions(+), 31 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 36841f67..884c3c10 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -2,7 +2,6 @@ namespace Components { - Game::dvar_t* Bots::TestClientsActivate; std::vector Bots::BotNames; struct BotMovementInfo @@ -11,6 +10,7 @@ namespace Components int8_t forward; int8_t right; uint16_t weapon; + bool active; }; static BotMovementInfo g_botai[18]; @@ -36,7 +36,8 @@ namespace Components { "leanright", Game::usercmdButtonBits::CMD_BUTTON_LEAN_RIGHT }, { "ads", Game::usercmdButtonBits::CMD_BUTTON_ADS }, { "holdbreath", Game::usercmdButtonBits::CMD_BUTTON_BREATH }, - { "use", Game::usercmdButtonBits::CMD_BUTTON_USE_RELOAD | Game::usercmdButtonBits::CMD_BUTTON_ACTIVATE }, + { "usereload", Game::usercmdButtonBits::CMD_BUTTON_USE_RELOAD }, + { "activate", Game::usercmdButtonBits::CMD_BUTTON_ACTIVATE }, { "0", Bots::NUM_0 }, { "1", Bots::NUM_1 }, { "2", Bots::NUM_2 }, @@ -51,7 +52,7 @@ namespace Components int Bots::BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port) { - static auto botId = 0; + static size_t botId = 0; const char* botName; if (Bots::BotNames.empty()) @@ -156,6 +157,7 @@ namespace Components g_botai[entref.entnum] = {0}; g_botai[entref.entnum].weapon = 1; + g_botai[entref.entnum].active = false; }); Script::AddFunction("BotWeapon", [](Game::scr_entref_t entref) // Usage: BotWeapon(); @@ -179,6 +181,7 @@ namespace Components const auto weapId = Game::G_GetWeaponIndexForName(weapon); g_botai[entref.entnum].weapon = static_cast(weapId); + g_botai[entref.entnum].active = true; }); Script::AddFunction("BotAction", [](Game::scr_entref_t entref) // Usage: BotAction(); @@ -216,6 +219,7 @@ namespace Components else g_botai[entref.entnum].buttons &= ~(BotActions[i].key); + g_botai[entref.entnum].active = true; return; } @@ -241,6 +245,7 @@ namespace Components g_botai[entref.entnum].forward = static_cast(forwardInt); g_botai[entref.entnum].right = static_cast(rightInt); + g_botai[entref.entnum].active = true; }); } @@ -251,16 +256,23 @@ namespace Components const auto entnum = cl->gentity->s.number; - Game::usercmd_s ucmd = {0}; + // Keep test client functionality + if (!g_botai[entnum].active) + { + Game::SV_BotUserMove(cl); + return; + } - ucmd.serverTime = *Game::svs_time; + Game::usercmd_s userCmd = {0}; - ucmd.buttons = g_botai[entnum].buttons; - ucmd.forwardmove = g_botai[entnum].forward; - ucmd.rightmove = g_botai[entnum].right; - ucmd.weapon = g_botai[entnum].weapon; + userCmd.serverTime = *Game::svs_time; - Game::SV_ClientThink(cl, &ucmd); + userCmd.buttons = g_botai[entnum].buttons; + userCmd.forwardmove = g_botai[entnum].forward; + userCmd.rightmove = g_botai[entnum].right; + userCmd.weapon = g_botai[entnum].weapon; + + Game::SV_ClientThink(cl, &userCmd); } constexpr auto SV_BotUserMove = 0x626E50; @@ -268,13 +280,6 @@ namespace Components { __asm { - push eax - mov eax, Bots::TestClientsActivate - cmp byte ptr [eax + 0x10], 0x1 - pop eax - - jz enableBots - pushad push edi @@ -282,20 +287,42 @@ namespace Components add esp, 4 popad - ret + } + } - enableBots: - call SV_BotUserMove - ret + void Bots::G_SelectWeaponIndex(int clientNum, int iWeaponIndex) + { + if (g_botai[clientNum].active) + { + g_botai[clientNum].weapon = static_cast(iWeaponIndex); + } + } + + __declspec(naked) void Bots::G_SelectWeaponIndex_Hk() + { + __asm + { + pushad + + push [esp + 0x20 + 0x8] + push [esp + 0x20 + 0x8] + call Bots::G_SelectWeaponIndex + add esp, 0x8 + + popad + + // Code skipped by hook + mov eax, [esp + 0x8] + push eax + + push 0x441B85 + retn } } Bots::Bots() { - Bots::TestClientsActivate = Game::Dvar_RegisterBool("testClients_activate", true, - Game::dvar_flag::DVAR_FLAG_NONE, "Testclients will retain their native functionality."); - // Replace connect string Utils::Hook::Set(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\""); @@ -305,6 +332,8 @@ namespace Components Utils::Hook(0x627021, Bots::SV_BotUserMove_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x627241, Bots::SV_BotUserMove_Hk, HOOK_CALL).install()->quick(); + Utils::Hook(0x441B80, Bots::G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick(); + // Zero the bot command array for (auto i = 0u; i < std::extent_v; i++) { diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index dcbadc6c..ccd1a6ef 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -22,7 +22,6 @@ namespace Components }; private: - static Game::dvar_t* TestClientsActivate; static std::vector BotNames; static int BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port); @@ -33,5 +32,8 @@ namespace Components static void BotAiAction(Game::client_t* cl); static void SV_BotUserMove_Hk(); + + static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex); + static void G_SelectWeaponIndex_Hk(); }; } diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5e6f8a60..7c2d2087 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -385,7 +385,6 @@ namespace Components Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); // If the game closed abruptly, the dvars would not have been restored - Dvar::OnInit([] { Dvar::ResetDvarsValue(); diff --git a/src/Components/Modules/ScriptExtension.cpp b/src/Components/Modules/ScriptExtension.cpp index e47041e9..512c4304 100644 --- a/src/Components/Modules/ScriptExtension.cpp +++ b/src/Components/Modules/ScriptExtension.cpp @@ -7,7 +7,6 @@ namespace Components void ScriptExtension::AddFunctions() { //File functions - Script::AddFunction("FileWrite", [](Game::scr_entref_t) // gsc: FileWrite(, , ) { const auto* path = Game::Scr_GetString(0); @@ -115,7 +114,7 @@ namespace Components { if (std::strstr(path, ScriptExtension::QueryStrings[i]) != nullptr) { - Logger::Print("^1fileRemove: directory traversal is not allowed!\n"); + Logger::Print("^1FileRemove: directory traversal is not allowed!\n"); return; } } @@ -152,9 +151,35 @@ namespace Components }); } + void ScriptExtension::Scr_TableLookupIStringByRow() + { + if (Game::Scr_GetNumParam() < 3) + { + Game::Scr_Error("USAGE: tableLookupIStringByRow( filename, rowNum, returnValueColumnNum )\n"); + return; + } + + const auto* fileName = Game::Scr_GetString(0); + const auto rowNum = Game::Scr_GetInt(1); + const auto returnValueColumnNum = Game::Scr_GetInt(2); + + const auto* table = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_STRINGTABLE, fileName).stringTable; + + if (table == nullptr) + { + Game::Scr_ParamError(0, Utils::String::VA("%s does not exist\n", fileName)); + return; + } + + const auto* value = Game::StringTable_GetColumnValueForRow(table, rowNum, returnValueColumnNum); + Game::Scr_AddIString(value); + } + ScriptExtension::ScriptExtension() { ScriptExtension::AddFunctions(); ScriptExtension::AddMethods(); + // Correct builtin function pointer + Utils::Hook::Set(0x79A90C, ScriptExtension::Scr_TableLookupIStringByRow); } } diff --git a/src/Components/Modules/ScriptExtension.hpp b/src/Components/Modules/ScriptExtension.hpp index 84eef531..6b050159 100644 --- a/src/Components/Modules/ScriptExtension.hpp +++ b/src/Components/Modules/ScriptExtension.hpp @@ -12,5 +12,6 @@ namespace Components static void AddFunctions(); static void AddMethods(); + static void Scr_TableLookupIStringByRow(); }; } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index e8c10b00..47d87d44 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -271,6 +271,7 @@ namespace Game Scr_AddEntity_t Scr_AddEntity = Scr_AddEntity_t(0x4BFB40); Scr_AddString_t Scr_AddString = Scr_AddString_t(0x412310); + Scr_AddIString_t Scr_AddIString = Scr_AddIString_t(0x455F20); Scr_AddInt_t Scr_AddInt = Scr_AddInt_t(0x41D7D0); Scr_AddFloat_t Scr_AddFloat = Scr_AddFloat_t(0x61E860); Scr_AddObject_t Scr_AddObject = Scr_AddObject_t(0x430F40); @@ -320,6 +321,7 @@ namespace Game Steam_JoinLobby_t Steam_JoinLobby = Steam_JoinLobby_t(0x49CF70); StringTable_Lookup_t StringTable_Lookup = StringTable_Lookup_t(0x42F0E0); + StringTable_GetColumnValueForRow_t StringTable_GetColumnValueForRow = StringTable_GetColumnValueForRow_t(0x4F2C80); StringTable_HashString_t StringTable_HashString = StringTable_HashString_t(0x475EB0); SV_AddTestClient_t SV_AddTestClient = SV_AddTestClient_t(0x48AD30); @@ -1591,5 +1593,20 @@ namespace Game } } + constexpr auto SV_BotUserMove_Addr = 0x626E50; + __declspec(naked) void SV_BotUserMove(client_t* /*client*/) + { + __asm + { + pushad + + mov edi, [esp + 0x20 + 0x4] + call SV_BotUserMove_Addr + + popad + ret + } + } + #pragma optimize("", on) } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index fadf46f1..65a4e72f 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -639,12 +639,15 @@ namespace Game typedef void(__cdecl * RemoveRefToObject_t)(unsigned int id); extern RemoveRefToObject_t RemoveRefToObject; - typedef void(__cdecl * Scr_AddEntity_t)(gentity_s const*); + typedef void(__cdecl * Scr_AddEntity_t)(const gentity_s* ent); extern Scr_AddEntity_t Scr_AddEntity; - typedef void(__cdecl * Scr_AddString_t)(const char* str); + typedef void(__cdecl * Scr_AddString_t)(const char* value); extern Scr_AddString_t Scr_AddString; + typedef void(__cdecl * Scr_AddIString_t)(const char* value); + extern Scr_AddIString_t Scr_AddIString; + typedef void(__cdecl * Scr_AddInt_t)(int num); extern Scr_AddInt_t Scr_AddInt; @@ -759,9 +762,12 @@ namespace Game typedef void(__cdecl * Steam_JoinLobby_t)(SteamID, char); extern Steam_JoinLobby_t Steam_JoinLobby; - typedef const char*(__cdecl * StringTable_Lookup_t)(StringTable *table, const int comparisonColumn, const char *value, const int valueColumn); + typedef const char*(__cdecl * StringTable_Lookup_t)(const StringTable *table, const int comparisonColumn, const char *value, const int valueColumn); extern StringTable_Lookup_t StringTable_Lookup; + typedef const char* (__cdecl * StringTable_GetColumnValueForRow_t)(const StringTable* table, int, int column); + extern StringTable_GetColumnValueForRow_t StringTable_GetColumnValueForRow; + typedef int(__cdecl * StringTable_HashString_t)(const char* string); extern StringTable_HashString_t StringTable_HashString; @@ -1108,6 +1114,7 @@ namespace Game void SV_KickClient(client_t* client, const char* reason); void SV_KickClientError(client_t* client, const std::string& reason); + void SV_BotUserMove(client_t* client); void RuntimeErrorInternal(int channel, const char* codePos, unsigned int index, const char* msg); void IncInParam(); From 0a7890a1b72d5ab8cd1e3b6612ea1d88cc165415 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 17:22:25 +0000 Subject: [PATCH 45/52] Bump deps/libtommath from `66de864` to `5108f12` Bumps [deps/libtommath](https://github.com/libtom/libtommath) from `66de864` to `5108f12`. - [Release notes](https://github.com/libtom/libtommath/releases) - [Commits](https://github.com/libtom/libtommath/compare/66de86426e9cdb88526974c765108f01554af2b0...5108f12350b6daa4aa5dbc846517ad1db2f8388a) --- updated-dependencies: - dependency-name: deps/libtommath dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/libtommath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/libtommath b/deps/libtommath index 66de8642..5108f123 160000 --- a/deps/libtommath +++ b/deps/libtommath @@ -1 +1 @@ -Subproject commit 66de86426e9cdb88526974c765108f01554af2b0 +Subproject commit 5108f12350b6daa4aa5dbc846517ad1db2f8388a From 71b49e3201093e786b4570128658a2d8fab611e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 17:21:26 +0000 Subject: [PATCH 46/52] Bump deps/zlib from `2014a99` to `ec3df00` Bumps [deps/zlib](https://github.com/madler/zlib) from `2014a99` to `ec3df00`. - [Release notes](https://github.com/madler/zlib/releases) - [Commits](https://github.com/madler/zlib/compare/2014a993addbc8f1b9785d97f55fd189792c2f78...ec3df00224d4b396e2ac6586ab5d25f673caa4c2) --- updated-dependencies: - dependency-name: deps/zlib dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/zlib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/zlib b/deps/zlib index 2014a993..ec3df002 160000 --- a/deps/zlib +++ b/deps/zlib @@ -1 +1 @@ -Subproject commit 2014a993addbc8f1b9785d97f55fd189792c2f78 +Subproject commit ec3df00224d4b396e2ac6586ab5d25f673caa4c2 From 7e8d14120dfe18faaccddb9d4d0e5a59f4dc5713 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Tue, 5 Apr 2022 11:50:13 +0200 Subject: [PATCH 47/52] Fix Wine --- src/Components/Modules/Flags.cpp | 22 +++++++++++----------- src/Utils/Utils.cpp | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Components/Modules/Flags.cpp b/src/Components/Modules/Flags.cpp index e3139910..761c9e10 100644 --- a/src/Components/Modules/Flags.cpp +++ b/src/Components/Modules/Flags.cpp @@ -6,13 +6,7 @@ namespace Components bool Flags::HasFlag(const std::string& flag) { - static auto parsed = false; - - if (!parsed) - { - Flags::ParseFlags(); - parsed = true; - } + Flags::ParseFlags(); for (const auto& entry : Flags::EnabledFlags) { @@ -27,11 +21,17 @@ namespace Components void Flags::ParseFlags() { + static auto flagsParsed = false; + if (flagsParsed) + { + return; + } + + // Only parse flags once + flagsParsed = true; int numArgs; auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs); - assert(Flags::EnabledFlags.empty()); - if (argv) { for (auto i = 0; i < numArgs; ++i) @@ -40,7 +40,7 @@ namespace Components if (wFlag[0] == L'-') { wFlag.erase(wFlag.begin()); - Flags::EnabledFlags.push_back(Utils::String::Convert(wFlag)); + Flags::EnabledFlags.emplace_back(Utils::String::Convert(wFlag)); } } @@ -50,7 +50,7 @@ namespace Components // Workaround for wine if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout")) { - Flags::EnabledFlags.push_back("stdout"); + Flags::EnabledFlags.emplace_back("stdout"); } } diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index dd84caca..e17480bf 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -107,9 +107,9 @@ namespace Utils void SetEnvironment() { wchar_t exeName[512]; - GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2); + GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t)); - wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); + auto* exeBaseName = wcsrchr(exeName, L'\\'); exeBaseName[0] = L'\0'; SetCurrentDirectoryW(exeName); From 57513c61d9d25083ff49d33554566656b662e5f9 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 6 Apr 2022 21:37:28 +0200 Subject: [PATCH 48/52] Fix dedi --- src/Components/Modules/AssetInterfaces/IComWorld.cpp | 2 +- src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp | 2 +- src/Components/Modules/AssetInterfaces/IFxWorld.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp | 2 +- src/Components/Modules/AssetInterfaces/IGfxImage.cpp | 2 +- src/Components/Modules/AssetInterfaces/IclipMap_t.cpp | 2 +- src/Utils/Library.hpp | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IComWorld.cpp b/src/Components/Modules/AssetInterfaces/IComWorld.cpp index b25d832a..4854c3a6 100644 --- a/src/Components/Modules/AssetInterfaces/IComWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IComWorld.cpp @@ -1,4 +1,4 @@ -#include +#include #define IW4X_COMMAP_VERSION 0 diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index 92c17ba7..0cdd6b3a 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -1,4 +1,4 @@ -#include +#include #define IW4X_FX_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp index eda6b0ca..9473dfd0 100644 --- a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp @@ -1,4 +1,4 @@ -#include +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp index 513c5df9..17c7702e 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp @@ -1,4 +1,4 @@ -#include +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp index 12a71890..04fba9c2 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp @@ -1,4 +1,4 @@ -#include +#include namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp index 06a4b440..f0981c9e 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp @@ -1,4 +1,4 @@ -#include +#include #define IW4X_IMG_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 6ba84557..df933bbc 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -1,4 +1,4 @@ -#include +#include #define IW4X_CLIPMAP_VERSION 2 diff --git a/src/Utils/Library.hpp b/src/Utils/Library.hpp index 2262987d..552c91e2 100644 --- a/src/Utils/Library.hpp +++ b/src/Utils/Library.hpp @@ -10,13 +10,13 @@ namespace Utils static Library GetByAddress(void* address); Library() : _module(nullptr), freeOnDestroy(false) {}; - Library(const std::string& buffer, bool freeOnDestroy); - explicit Library(const std::string& name); + explicit Library(const std::string& name, bool freeOnDestroy); + explicit Library(const std::string& name) : _module(GetModuleHandleA(name.data())), freeOnDestroy(true) {}; explicit Library(HMODULE handle); ~Library(); bool isValid() const; - HMODULE getModule(); + HMODULE getModule() const; template T getProc(const std::string& process) const From 5b9aeb08c67a5f3670096e2ec3f1772137479c6b Mon Sep 17 00:00:00 2001 From: Edo Date: Thu, 7 Apr 2022 10:12:52 +0200 Subject: [PATCH 49/52] Fully reverse changes to library component Still crashes the client apperently --- src/Utils/Library.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/Library.hpp b/src/Utils/Library.hpp index 552c91e2..3ef0db41 100644 --- a/src/Utils/Library.hpp +++ b/src/Utils/Library.hpp @@ -10,7 +10,7 @@ namespace Utils static Library GetByAddress(void* address); Library() : _module(nullptr), freeOnDestroy(false) {}; - explicit Library(const std::string& name, bool freeOnDestroy); + Library(const std::string& name, bool freeOnDestroy); explicit Library(const std::string& name) : _module(GetModuleHandleA(name.data())), freeOnDestroy(true) {}; explicit Library(HMODULE handle); ~Library(); From 538ef7e4914d2dc2bed53cfea17d1127095e75ad Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 7 Apr 2022 11:41:20 +0200 Subject: [PATCH 50/52] Update Premake5 (100% no hacks) --- .github/workflows/build.yml | 12 +- deps/libtomcrypt | 2 +- deps/libtommath | 2 +- deps/premake/dxsdk.lua | 19 ++ deps/premake/json11.lua | 32 +++ deps/premake/libtomcrypt.lua | 59 +++++ deps/premake/libtommath.lua | 50 ++++ deps/premake/minizip.lua | 43 ++++ deps/premake/mongoose.lua | 32 +++ deps/premake/pdcurses.lua | 34 +++ deps/premake/protobuf.lua | 50 ++++ deps/premake/udis86.lua | 35 +++ deps/premake/zlib.lua | 39 ++++ deps/zlib | 2 +- premake/dxsdk.lua | 35 --- premake/json11.lua | 51 ----- premake/libtomcrypt.lua | 62 ----- premake/libtommath.lua | 46 ---- premake/mongoose.lua | 42 ---- premake/pdcurses.lua | 48 ---- premake/protobuf.lua | 68 ------ premake/udis86.lua | 51 ----- premake/zlib.lua | 48 ---- premake5.lua | 215 +++++------------- src/Components/Modules/AssetHandler.cpp | 2 +- .../Modules/AssetInterfaces/IFont_s.cpp | 35 +-- src/Components/Modules/Auth.cpp | 8 +- src/Components/Modules/Bans.cpp | 11 +- src/Components/Modules/Bans.hpp | 1 - src/Components/Modules/Bots.cpp | 2 +- src/Components/Modules/CardTitles.cpp | 17 +- src/Components/Modules/CardTitles.hpp | 1 - src/Components/Modules/Changelog.cpp | 8 - src/Components/Modules/Changelog.hpp | 1 - src/Components/Modules/Chat.cpp | 13 +- src/Components/Modules/Chat.hpp | 1 - src/Components/Modules/Clantags.cpp | 17 +- src/Components/Modules/Clantags.hpp | 1 - src/Components/Modules/ClientCommand.cpp | 11 +- src/Components/Modules/ClientCommand.hpp | 2 +- src/Components/Modules/Command.cpp | 81 ++++--- src/Components/Modules/Command.hpp | 34 ++- src/Components/Modules/Console.cpp | 7 +- src/Components/Modules/Console.hpp | 2 +- src/Components/Modules/D3D9Ex.cpp | 2 +- src/Components/Modules/Dedicated.cpp | 47 +--- src/Components/Modules/Dedicated.hpp | 1 - src/Components/Modules/Discovery.cpp | 9 +- src/Components/Modules/Discovery.hpp | 1 - src/Components/Modules/Download.cpp | 18 +- src/Components/Modules/Dvar.cpp | 55 +++-- src/Components/Modules/Dvar.hpp | 6 +- src/Components/Modules/Elevators.cpp | 6 +- src/Components/Modules/Elevators.hpp | 1 - src/Components/Modules/Exception.cpp | 2 +- src/Components/Modules/FastFiles.cpp | 9 +- src/Components/Modules/FastFiles.hpp | 1 - src/Components/Modules/Flags.cpp | 26 +-- src/Components/Modules/Flags.hpp | 2 +- src/Components/Modules/Friends.cpp | 6 +- src/Components/Modules/Gamepad.cpp | 48 ++-- src/Components/Modules/Localization.cpp | 2 +- src/Components/Modules/Logger.cpp | 10 +- src/Components/Modules/Maps.cpp | 8 +- src/Components/Modules/Menus.cpp | 3 +- src/Components/Modules/ModList.cpp | 7 +- src/Components/Modules/ModList.hpp | 1 - src/Components/Modules/Movement.cpp | 34 +-- src/Components/Modules/Movement.hpp | 4 +- src/Components/Modules/MusicalTalent.cpp | 5 - src/Components/Modules/MusicalTalent.hpp | 1 - src/Components/Modules/Network.cpp | 7 - src/Components/Modules/Network.hpp | 1 - src/Components/Modules/News.cpp | 4 +- src/Components/Modules/Node.cpp | 2 +- src/Components/Modules/Party.cpp | 25 +- src/Components/Modules/Party.hpp | 1 - src/Components/Modules/PlayerName.cpp | 2 +- src/Components/Modules/Playlist.cpp | 9 +- src/Components/Modules/Playlist.hpp | 1 - src/Components/Modules/QuickPatch.cpp | 38 ++-- src/Components/Modules/QuickPatch.hpp | 2 +- src/Components/Modules/RCon.cpp | 26 +-- src/Components/Modules/RCon.hpp | 4 +- src/Components/Modules/RawFiles.cpp | 2 +- src/Components/Modules/Renderer.cpp | 12 +- src/Components/Modules/Script.cpp | 8 - src/Components/Modules/ServerCommands.cpp | 11 +- src/Components/Modules/ServerCommands.hpp | 1 - src/Components/Modules/ServerList.cpp | 27 +-- .../{Slowmotion.cpp => SlowMotion.cpp} | 2 +- .../{Slowmotion.hpp => SlowMotion.hpp} | 0 src/Components/Modules/StartupMessages.cpp | 11 +- src/Components/Modules/StartupMessages.hpp | 1 - src/Components/Modules/Stats.cpp | 5 - src/Components/Modules/Stats.hpp | 1 - src/Components/Modules/StringTable.cpp | 5 - src/Components/Modules/StringTable.hpp | 1 - src/Components/Modules/StructuredData.cpp | 5 - src/Components/Modules/StructuredData.hpp | 1 - src/Components/Modules/TextRenderer.cpp | 14 +- src/Components/Modules/Theatre.cpp | 4 +- src/Components/Modules/UIFeeder.cpp | 6 +- src/Components/Modules/Weapon.cpp | 5 +- src/Components/Modules/Window.cpp | 4 +- src/Components/Modules/ZoneBuilder.cpp | 12 +- src/Components/Modules/Zones.cpp | 5 - src/Components/Modules/Zones.hpp | 1 - src/Game/Functions.cpp | 9 +- src/Game/Functions.hpp | 48 ++-- src/Game/Structs.hpp | 75 +++--- src/STDInclude.hpp | 10 +- src/Utils/Library.cpp | 12 +- src/Utils/Memory.hpp | 2 + src/Utils/Utils.cpp | 4 +- 115 files changed, 864 insertions(+), 1209 deletions(-) create mode 100644 deps/premake/dxsdk.lua create mode 100644 deps/premake/json11.lua create mode 100644 deps/premake/libtomcrypt.lua create mode 100644 deps/premake/libtommath.lua create mode 100644 deps/premake/minizip.lua create mode 100644 deps/premake/mongoose.lua create mode 100644 deps/premake/pdcurses.lua create mode 100644 deps/premake/protobuf.lua create mode 100644 deps/premake/udis86.lua create mode 100644 deps/premake/zlib.lua delete mode 100644 premake/dxsdk.lua delete mode 100644 premake/json11.lua delete mode 100644 premake/libtomcrypt.lua delete mode 100644 premake/libtommath.lua delete mode 100644 premake/mongoose.lua delete mode 100644 premake/pdcurses.lua delete mode 100644 premake/protobuf.lua delete mode 100644 premake/udis86.lua delete mode 100644 premake/zlib.lua rename src/Components/Modules/{Slowmotion.cpp => SlowMotion.cpp} (99%) rename src/Components/Modules/{Slowmotion.hpp => SlowMotion.hpp} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1d949fc..19cd75f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check out files - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true fetch-depth: 0 @@ -39,22 +39,21 @@ jobs: uses: microsoft/setup-msbuild@v1.1 - name: Generate project files - #run: tools/premake5 vs2022 --ci-build --ac-disable run: tools/premake5 vs2022 --ac-disable - name: Set up problem matching uses: ammaraskar/msvc-problem-matcher@master - name: Build ${{matrix.configuration}} binaries - run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} build/iw4x.sln + run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/iw4x.sln - name: Upload ${{matrix.configuration}} binaries uses: actions/upload-artifact@v2 with: name: ${{matrix.configuration}} binaries path: | - build/bin/${{matrix.configuration}}/iw4x.dll - build/bin/${{matrix.configuration}}/iw4x.pdb + build/bin/Win32/${{matrix.configuration}}/iw4x.dll + build/bin/Win32/${{matrix.configuration}}/iw4x.pdb # - name: Upload ${{matrix.configuration}} data artifacts # uses: actions/upload-artifact@v2 @@ -63,7 +62,6 @@ jobs: # path: | # data/* - deploy: name: Deploy artifacts needs: build @@ -116,4 +114,4 @@ jobs: # run: rsync -avz ./data/ ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }}:${{ env.XLABS_MASTER_PATH }}/iw4x/data/ - name: Publish changes - run: ssh ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }} ${{ secrets.XLABS_MASTER_SSH_CHANGE_PUBLISH_COMMAND }} \ No newline at end of file + run: ssh ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }} ${{ secrets.XLABS_MASTER_SSH_CHANGE_PUBLISH_COMMAND }} diff --git a/deps/libtomcrypt b/deps/libtomcrypt index 673f5ce2..06a81aeb 160000 --- a/deps/libtomcrypt +++ b/deps/libtomcrypt @@ -1 +1 @@ -Subproject commit 673f5ce29015a9bba3c96792920a10601b5b0718 +Subproject commit 06a81aeb227424182125363f7554fad5146d6d2a diff --git a/deps/libtommath b/deps/libtommath index 04e9d1e7..5108f123 160000 --- a/deps/libtommath +++ b/deps/libtommath @@ -1 +1 @@ -Subproject commit 04e9d1e7a0493910b2eb5e757d623870692ada04 +Subproject commit 5108f12350b6daa4aa5dbc846517ad1db2f8388a diff --git a/deps/premake/dxsdk.lua b/deps/premake/dxsdk.lua new file mode 100644 index 00000000..2d7be9c9 --- /dev/null +++ b/deps/premake/dxsdk.lua @@ -0,0 +1,19 @@ +dxsdk = { + source = path.join(dependencies.basePath, "dxsdk"), +} + +function dxsdk.import() + libdirs {path.join(dxsdk.source, "Lib/x86")} + dxsdk.includes() +end + +function dxsdk.includes() + includedirs { + path.join(dxsdk.source, "Include"), + } +end + +function dxsdk.project() +end + +table.insert(dependencies, dxsdk) diff --git a/deps/premake/json11.lua b/deps/premake/json11.lua new file mode 100644 index 00000000..3437ba57 --- /dev/null +++ b/deps/premake/json11.lua @@ -0,0 +1,32 @@ +json11 = { + source = path.join(dependencies.basePath, "json11"), +} + +function json11.import() + links {"json11"} + + json11.includes() +end + +function json11.includes() + includedirs {json11.source} +end + +function json11.project() + project "json11" + language "C++" + + files + { + path.join(json11.source, "*.cpp"), + path.join(json11.source, "*.hpp"), + } + + warnings "Off" + + defines {"_LIB"} + removedefines {"_USRDLL", "_DLL"} + kind "StaticLib" +end + +table.insert(dependencies, json11) \ No newline at end of file diff --git a/deps/premake/libtomcrypt.lua b/deps/premake/libtomcrypt.lua new file mode 100644 index 00000000..51860cfa --- /dev/null +++ b/deps/premake/libtomcrypt.lua @@ -0,0 +1,59 @@ +libtomcrypt = { + source = path.join(dependencies.basePath, "libtomcrypt"), +} + +function libtomcrypt.import() + links {"libtomcrypt"} + + libtomcrypt.includes() +end + +function libtomcrypt.includes() + includedirs { + path.join(libtomcrypt.source, "src/headers") + } + + defines { + "LTC_NO_FAST", + "LTC_NO_PROTOTYPES", + "LTC_NO_RSA_BLINDING", + } +end + +function libtomcrypt.project() + project "libtomcrypt" + language "C" + + libtomcrypt.includes() + libtommath.import() + + files { + path.join(libtomcrypt.source, "src/**.c"), + } + + removefiles { + path.join(libtomcrypt.source, "src/**/*tab.c"), + path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"), + } + + defines { + "_CRT_SECURE_NO_WARNINGS", + "LTC_SOURCE", + "_LIB", + "USE_LTM" + } + + removedefines { + "_DLL", + "_USRDLL" + } + + linkoptions { + "-IGNORE:4221" + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, libtomcrypt) diff --git a/deps/premake/libtommath.lua b/deps/premake/libtommath.lua new file mode 100644 index 00000000..e6cc65e2 --- /dev/null +++ b/deps/premake/libtommath.lua @@ -0,0 +1,50 @@ +libtommath = { + source = path.join(dependencies.basePath, "libtommath"), +} + +function libtommath.import() + links {"libtommath"} + + libtommath.includes() +end + +function libtommath.includes() + includedirs { + libtommath.source + } + + defines { + "LTM_DESC", + "__STDC_IEC_559__", + "MP_NO_DEV_URANDOM", + } +end + +function libtommath.project() + project "libtommath" + language "C" + + libtommath.includes() + + files { + path.join(libtommath.source, "*.c"), + } + + defines { + "_LIB" + } + + removedefines { + "_DLL", + "_USRDLL" + } + + linkoptions { + "-IGNORE:4221" + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, libtommath) diff --git a/deps/premake/minizip.lua b/deps/premake/minizip.lua new file mode 100644 index 00000000..755f5dae --- /dev/null +++ b/deps/premake/minizip.lua @@ -0,0 +1,43 @@ +minizip = { + source = path.join(dependencies.basePath, "zlib/contrib/minizip"), +} + +function minizip.import() + links {"minizip"} + zlib.import() + minizip.includes() +end + +function minizip.includes() + includedirs { + minizip.source + } + + zlib.includes() +end + +function minizip.project() + project "minizip" + language "C" + + minizip.includes() + + files { + path.join(minizip.source, "*.h"), + path.join(minizip.source, "*.c"), + } + + removefiles { + path.join(minizip.source, "miniunz.c"), + path.join(minizip.source, "minizip.c"), + } + + defines { + "_CRT_SECURE_NO_DEPRECATE", + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, minizip) diff --git a/deps/premake/mongoose.lua b/deps/premake/mongoose.lua new file mode 100644 index 00000000..01935e94 --- /dev/null +++ b/deps/premake/mongoose.lua @@ -0,0 +1,32 @@ +mongoose = { + source = path.join(dependencies.basePath, "mongoose"), +} + +function mongoose.import() + links {"mongoose"} + + mongoose.includes() +end + +function mongoose.includes() + includedirs {mongoose.source} +end + +function mongoose.project() + project "mongoose" + language "C" + + mongoose.includes() + + files + { + path.join(mongoose.source, "*.c"), + path.join(mongoose.source, "*.h"), + } + + warnings "Off" + + kind "StaticLib" +end + +table.insert(dependencies, mongoose) diff --git a/deps/premake/pdcurses.lua b/deps/premake/pdcurses.lua new file mode 100644 index 00000000..7e427b6e --- /dev/null +++ b/deps/premake/pdcurses.lua @@ -0,0 +1,34 @@ +pdcurses = { + source = path.join(dependencies.basePath, "pdcurses"), +} + +function pdcurses.import() + links {"pdcurses"} + + pdcurses.includes() +end + +function pdcurses.includes() + includedirs {pdcurses.source} +end + +function pdcurses.project() + project "pdcurses" + language "C" + + pdcurses.includes() + + files + { + path.join(pdcurses.source, "pdcurses/*.c"), + path.join(pdcurses.source, "pdcurses/*.h"), + path.join(pdcurses.source, "wincon/*.c"), + path.join(pdcurses.source, "wincon/*.h"), + } + + warnings "Off" + + kind "StaticLib" +end + +table.insert(dependencies, pdcurses) diff --git a/deps/premake/protobuf.lua b/deps/premake/protobuf.lua new file mode 100644 index 00000000..a293576f --- /dev/null +++ b/deps/premake/protobuf.lua @@ -0,0 +1,50 @@ +protobuf = { + source = path.join(dependencies.basePath, "protobuf"), +} + +function protobuf.import() + links {"protobuf"} + + protobuf.includes() +end + +function protobuf.includes() + includedirs { + path.join(protobuf.source, "src"), + } +end + +function protobuf.project() + project "protobuf" + language "C++" + + protobuf.includes() + + files { + path.join(protobuf.source, "src/**.cc"), + "./src/**.proto", + } + + removefiles { + path.join(protobuf.source, "src/**/*test.cc"), + path.join(protobuf.source, "src/google/protobuf/*test*.cc"), + + path.join(protobuf.source, "src/google/protobuf/testing/**.cc"), + path.join(protobuf.source, "src/google/protobuf/compiler/**.cc"), + + path.join(protobuf.source, "src/google/protobuf/arena_nc.cc"), + path.join(protobuf.source, "src/google/protobuf/util/internal/error_listener.cc"), + path.join(protobuf.source, "**/*_gcc.cc"), + } + + rules {"ProtobufCompiler"} + + defines {"_SCL_SECURE_NO_WARNINGS"} + + linkoptions {"-IGNORE:4221"} + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, protobuf) diff --git a/deps/premake/udis86.lua b/deps/premake/udis86.lua new file mode 100644 index 00000000..f4cf46b2 --- /dev/null +++ b/deps/premake/udis86.lua @@ -0,0 +1,35 @@ +udis86 = { + source = path.join(dependencies.basePath, "udis86"), +} + +function udis86.import() + links {"udis86"} + + udis86.includes() +end + +function udis86.includes() + includedirs { + udis86.source, + path.join(udis86.source, "libudis86"), + path.join(dependencies.basePath, "extra/udis86"), + path.join(dependencies.basePath, "extra/udis86/libudis86"), + } +end + +function udis86.project() + project "udis86" + language "C" + + udis86.includes() + + files { + path.join(udis86.source, "libudis86/*.c"), + path.join(dependencies.basePath, "extra/udis86/libudis86/*.c"), + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, udis86) diff --git a/deps/premake/zlib.lua b/deps/premake/zlib.lua new file mode 100644 index 00000000..c166a160 --- /dev/null +++ b/deps/premake/zlib.lua @@ -0,0 +1,39 @@ +zlib = { + source = path.join(dependencies.basePath, "zlib"), +} + +function zlib.import() + links {"zlib"} + zlib.includes() +end + +function zlib.includes() + includedirs { + zlib.source + } + + defines { + "ZLIB_CONST", + } +end + +function zlib.project() + project "zlib" + language "C" + + zlib.includes() + + files { + path.join(zlib.source, "*.h"), + path.join(zlib.source, "*.c"), + } + + defines { + "_CRT_SECURE_NO_DEPRECATE", + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, zlib) diff --git a/deps/zlib b/deps/zlib index 2014a993..ec3df002 160000 --- a/deps/zlib +++ b/deps/zlib @@ -1 +1 @@ -Subproject commit 2014a993addbc8f1b9785d97f55fd189792c2f78 +Subproject commit ec3df00224d4b396e2ac6586ab5d25f673caa4c2 diff --git a/premake/dxsdk.lua b/premake/dxsdk.lua deleted file mode 100644 index 08bcbc1a..00000000 --- a/premake/dxsdk.lua +++ /dev/null @@ -1,35 +0,0 @@ -dxsdk = { - settings = nil -} - -function dxsdk.setup(settings) - if not settings.source then error("Missing source.") end - - dxsdk.settings = settings - - if not dxsdk.settings.defines then dxsdk.settings.defines = {} end -end - -function dxsdk.import() - if not dxsdk.settings then error("You need to call dxsdk.setup first") end - - --filter "platforms:*32" - libdirs { path.join(dxsdk.settings.source, "Lib/x86") } - - --filter "platforms:*64" - -- libdirs { path.join(dxsdk.settings.source, "Lib/x64") } - - --filter {} - - dxsdk.includes() -end - -function dxsdk.includes() - if not dxsdk.settings then error("You need to call dxsdk.setup first") end - - includedirs { path.join(dxsdk.settings.source, "Include") } - defines(dxsdk.settings.defines) -end - -function dxsdk.project() -end \ No newline at end of file diff --git a/premake/json11.lua b/premake/json11.lua deleted file mode 100644 index 325f5240..00000000 --- a/premake/json11.lua +++ /dev/null @@ -1,51 +0,0 @@ -json11 = { - settings = nil, -} - -function json11.setup(settings) - if not settings.source then error("Missing source.") end - - json11.settings = settings -end - -function json11.import() - if not json11.settings then error("Run json11.setup first") end - - links { "json11" } - json11.includes() -end - -function json11.includes() - if not json11.settings then error("Run json11.setup first") end - - includedirs { json11.settings.source } -end - -function json11.project() - if not json11.settings then error("Run json11.setup first") end - - project "json11" - language "C++" - - includedirs - { - json11.settings.source, - } - - files - { - path.join(json11.settings.source, "*.cpp"), - path.join(json11.settings.source, "*.hpp"), - } - removefiles - { - path.join(json11.settings.source, "test*"), - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - defines { "_LIB" } - removedefines { "_USRDLL", "_DLL" } - kind "StaticLib" -end diff --git a/premake/libtomcrypt.lua b/premake/libtomcrypt.lua deleted file mode 100644 index f955b59a..00000000 --- a/premake/libtomcrypt.lua +++ /dev/null @@ -1,62 +0,0 @@ -libtomcrypt = { - settings = nil -} - -function libtomcrypt.setup(settings) - if not settings.source then error("Missing source") end - - libtomcrypt.settings = settings - - if not libtomcrypt.settings.defines then libtomcrypt.settings.defines = {} end -end - -function libtomcrypt.import() - if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end - - links { "libtomcrypt" } - libtomcrypt.includes() -end - -function libtomcrypt.includes() - if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end - - defines(libtomcrypt.settings.defines) - includedirs { path.join(libtomcrypt.settings.source, "src/headers") } -end - -function libtomcrypt.project() - if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end - - project "libtomcrypt" - language "C" - - libtomcrypt.includes() - files - { - path.join(libtomcrypt.settings.source, "src/**.c"), - } - removefiles - { - path.join(libtomcrypt.settings.source, "src/**/*tab.c"), -- included by files as necessary already afaik - path.join(libtomcrypt.settings.source, "src/encauth/ocb3/**.c"), -- fails in Visual Studio with invalid syntax - } - defines - { - "_CRT_SECURE_NO_WARNINGS", - "LTC_SOURCE", -- we are compiling from source code - } - - -- dependencies - if libtommath and libtommath.settings then - defines { "USE_LTM" } - libtommath.import() - end - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - defines { "_LIB" } - removedefines { "_DLL", "_USRDLL" } - linkoptions { "-IGNORE:4221" } - kind "StaticLib" -end diff --git a/premake/libtommath.lua b/premake/libtommath.lua deleted file mode 100644 index 910c1873..00000000 --- a/premake/libtommath.lua +++ /dev/null @@ -1,46 +0,0 @@ -libtommath = { - settings = nil -} - -function libtommath.setup(settings) - if not settings.source then error("Missing source") end - - libtommath.settings = settings - - if not libtommath.settings.defines then libtommath.settings.defines = {} end -end - -function libtommath.import() - if not libtommath.settings then error("Run libtommath.setup first") end - - links { "libtommath" } - libtommath.includes() -end - -function libtommath.includes() - if not libtommath.settings then error("Run libtommath.setup first") end - - defines(libtommath.settings.defines) - includedirs { libtommath.settings.source } -end - -function libtommath.project() - if not libtommath.settings then error("Run libtommath.setup first") end - - project "libtommath" - language "C" - - libtommath.includes() - files - { - path.join(libtommath.settings.source, "*.c"), - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - defines { "_LIB" } - removedefines { "_DLL", "_USRDLL" } - linkoptions { "-IGNORE:4221" } - kind "StaticLib" -end diff --git a/premake/mongoose.lua b/premake/mongoose.lua deleted file mode 100644 index 52e39478..00000000 --- a/premake/mongoose.lua +++ /dev/null @@ -1,42 +0,0 @@ -mongoose = { - settings = nil, -} - -function mongoose.setup(settings) - if not settings.source then error("Missing source.") end - - mongoose.settings = settings -end - -function mongoose.import() - if not mongoose.settings then error("Run mongoose.setup first") end - - links { "mongoose" } - mongoose.includes() -end - -function mongoose.includes() - if not mongoose.settings then error("Run mongoose.setup first") end - - includedirs { mongoose.settings.source } -end - -function mongoose.project() - if not mongoose.settings then error("Run mongoose.setup first") end - - project "mongoose" - language "C" - - mongoose.includes() - files - { - path.join(mongoose.settings.source, "*.c"), - path.join(mongoose.settings.source, "*.h"), - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - -- always build as static lib, as mongoose doesn't export anything - kind "StaticLib" -end diff --git a/premake/pdcurses.lua b/premake/pdcurses.lua deleted file mode 100644 index d8a8cd6d..00000000 --- a/premake/pdcurses.lua +++ /dev/null @@ -1,48 +0,0 @@ -pdcurses = { - settings = nil, -} - -function pdcurses.setup(settings) - if not settings.source then error("Missing source.") end - - pdcurses.settings = settings -end - -function pdcurses.import() - if not pdcurses.settings then error("Run pdcurses.setup first") end - - links { "pdcurses" } - pdcurses.includes() -end - -function pdcurses.includes() - if not pdcurses.settings then error("Run pdcurses.setup first") end - - includedirs { pdcurses.settings.source } -end - -function pdcurses.project() - if not pdcurses.settings then error("Run pdcurses.setup first") end - - project "pdcurses" - language "C" - - includedirs - { - pdcurses.settings.source, - } - - files - { - path.join(pdcurses.settings.source, "pdcurses/*.c"), - path.join(pdcurses.settings.source, "pdcurses/*.h"), - path.join(pdcurses.settings.source, "wincon/*.c"), - path.join(pdcurses.settings.source, "wincon/*.h"), - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - -- always build as static lib, as pdcurses doesn't export anything - kind "StaticLib" -end diff --git a/premake/protobuf.lua b/premake/protobuf.lua deleted file mode 100644 index 256b1b4f..00000000 --- a/premake/protobuf.lua +++ /dev/null @@ -1,68 +0,0 @@ -protobuf = { - settings = nil, -} - -function protobuf.setup(settings) - if not settings.source then error("Missing source.") end - - protobuf.settings = settings -end - -function protobuf.import() - if not protobuf.settings then error("Run protobuf.setup first") end - - links { "protobuf" } - protobuf.includes() -end - -function protobuf.includes() - if not protobuf.settings then error("Run protobuf.setup first") end - - includedirs - { - path.join(protobuf.settings.source, "src"), - } -end - -function protobuf.project() - if not protobuf.settings then error("Run protobuf.setup first") end - - project "protobuf" - language "C++" - - includedirs - { - path.join(protobuf.settings.source, "src"), - } - files - { - path.join(protobuf.settings.source, "src/**.cc"), - "./src/**.proto", - } - removefiles - { - path.join(protobuf.settings.source, "src/**/*test.cc"), - path.join(protobuf.settings.source, "src/google/protobuf/*test*.cc"), - - path.join(protobuf.settings.source, "src/google/protobuf/testing/**.cc"), - path.join(protobuf.settings.source, "src/google/protobuf/compiler/**.cc"), - - path.join(protobuf.settings.source, "src/google/protobuf/arena_nc.cc"), - path.join(protobuf.settings.source, "src/google/protobuf/util/internal/error_listener.cc"), - path.join(protobuf.settings.source, "**/*_gcc.cc"), - } - - -- Generate source code from protobuf definitions - rules { "ProtobufCompiler" } - - -- dependencies - zlib.import() - - -- not our code, ignore POSIX usage warnings for now - defines { "_SCL_SECURE_NO_WARNINGS" } - warnings "Off" - linkoptions { "-IGNORE:4221" } - - -- always build as static lib, as we include our custom classes and therefore can't perform shared linking - kind "StaticLib" -end diff --git a/premake/udis86.lua b/premake/udis86.lua deleted file mode 100644 index 46049fbd..00000000 --- a/premake/udis86.lua +++ /dev/null @@ -1,51 +0,0 @@ -udis86 = { - settings = nil -} - -function udis86.setup(settings) - if not settings.source then error("Missing source.") end - - udis86.settings = settings - - if not udis86.settings.defines then udis86.settings.defines = {} end -end - -function udis86.import() - if not udis86.settings then error("You need to call udis86.setup first") end - - links { "udis86" } - udis86.includes() -end - -function udis86.includes() - if not udis86.settings then error("You need to call udis86.setup first") end - - includedirs - { - udis86.settings.source, - path.join(udis86.settings.source, "libudis86/"), - path.join(udis86.settings.source, "../extra/udis86/"), - path.join(udis86.settings.source, "../extra/udis86/libudis86/") - } - defines(udis86.settings.defines) -end - -function udis86.project() - if not udis86.settings then error("You need to call udis86.setup first") end - - project "udis86" - language "C" - - udis86.includes() - files - { - path.join(udis86.settings.source, "libudis86/*.h"), - path.join(udis86.settings.source, "libudis86/*.c"), - path.join(udis86.settings.source, "../extra/udis86/libudis86/*.c"), - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - kind "StaticLib" -end \ No newline at end of file diff --git a/premake/zlib.lua b/premake/zlib.lua deleted file mode 100644 index 08b55e7a..00000000 --- a/premake/zlib.lua +++ /dev/null @@ -1,48 +0,0 @@ -zlib = { - settings = nil -} - -function zlib.setup(settings) - if not settings.source then error("Missing source.") end - - zlib.settings = settings - - if not zlib.settings.defines then zlib.settings.defines = {} end -end - -function zlib.import() - if not zlib.settings then error("You need to call zlib.setup first") end - - links { "zlib" } - zlib.includes() -end - -function zlib.includes() - if not zlib.settings then error("You need to call zlib.setup first") end - - includedirs { zlib.settings.source } - defines(zlib.settings.defines) -end - -function zlib.project() - if not zlib.settings then error("You need to call zlib.setup first") end - - project "zlib" - language "C" - - zlib.includes() - files - { - path.join(zlib.settings.source, "*.h"), - path.join(zlib.settings.source, "*.c"), - } - defines - { - "_CRT_SECURE_NO_DEPRECATE", - } - - -- not our code, ignore POSIX usage warnings for now - warnings "Off" - - kind "StaticLib" -end \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 9076cd87..e5771089 100644 --- a/premake5.lua +++ b/premake5.lua @@ -3,6 +3,9 @@ gitCurrentBranchCommand = "git symbolic-ref -q --short HEAD" -- Quote the given string input as a C string function cstrquote(value) + if value == nil then + return "\"\"" + end result = value:gsub("\\", "\\\\") result = result:gsub("\"", "\\\"") result = result:gsub("\n", "\\n") @@ -27,18 +30,42 @@ function vertonumarr(value, vernumber) return vernum end --- Option to allow copying the DLL file to a custom folder after build +dependencies = { + basePath = "./deps" +} + +function dependencies.load() + dir = path.join(dependencies.basePath, "premake/*.lua") + deps = os.matchfiles(dir) + + for i, dep in pairs(deps) do + dep = dep:gsub(".lua", "") + require(dep) + end +end + +function dependencies.imports() + for i, proj in pairs(dependencies) do + if type(i) == 'number' then + proj.import() + end + end +end + +function dependencies.projects() + for i, proj in pairs(dependencies) do + if type(i) == 'number' then + proj.project() + end + end +end + newoption { trigger = "copy-to", description = "Optional, copy the DLL to a custom folder after build, define the path here if wanted.", value = "PATH" } -newoption { - trigger = "no-new-structure", - description = "Do not use new virtual path structure (separating headers and source files)." -} - newoption { trigger = "copy-pdb", description = "Copy debug information for binaries as well to the path given via --copy-to." @@ -183,66 +210,7 @@ newaction { end } -depsBasePath = "./deps" - -require "premake/json11" -require "premake/libtomcrypt" -require "premake/libtommath" -require "premake/mongoose" -require "premake/pdcurses" -require "premake/protobuf" -require "premake/zlib" -require "premake/udis86" -require "premake/dxsdk" - -json11.setup -{ - source = path.join(depsBasePath, "json11"), -} -libtomcrypt.setup -{ - defines = { - "LTC_NO_FAST", - "LTC_NO_PROTOTYPES", - "LTC_NO_RSA_BLINDING", - }, - source = path.join(depsBasePath, "libtomcrypt"), -} -libtommath.setup -{ - defines = { - "LTM_DESC", - "__STDC_IEC_559__", - }, - source = path.join(depsBasePath, "libtommath"), -} -mongoose.setup -{ - source = path.join(depsBasePath, "mongoose"), -} -pdcurses.setup -{ - source = path.join(depsBasePath, "pdcurses"), -} -protobuf.setup -{ - source = path.join(depsBasePath, "protobuf"), -} -zlib.setup -{ - defines = { - "ZLIB_CONST" - }, - source = path.join(depsBasePath, "zlib"), -} -udis86.setup -{ - source = path.join(depsBasePath, "udis86"), -} -dxsdk.setup -{ - source = path.join(depsBasePath, "dxsdk"), -} +dependencies.load() workspace "iw4x" startproject "iw4x" @@ -251,13 +219,13 @@ workspace "iw4x" targetdir "%{wks.location}/bin/%{cfg.buildcfg}" buildlog "%{wks.location}/obj/%{cfg.architecture}/%{cfg.buildcfg}/%{prj.name}/%{prj.name}.log" - configurations { "Debug", "Release" } + configurations {"Debug", "Release"} language "C++" cppdialect "C++17" architecture "x86" - platforms "x86" + platforms "Win32" systemversion "latest" symbols "On" @@ -266,18 +234,18 @@ workspace "iw4x" warnings "Extra" characterset "ASCII" - flags { "NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks" } + flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks"} - filter "platforms:x86" + filter "platforms:Win*" defines {"_WINDOWS", "WIN32"} filter {} filter "configurations:Release" - optimize "On" - buildoptions { "/GL" } - linkoptions { "/IGNORE:4702", "/LTCG" } - defines { "NDEBUG" } - flags { "FatalCompileWarnings", "FatalLinkWarnings" } + optimize "Size" + buildoptions {"/GL"} + linkoptions {"/IGNORE:4702", "/LTCG"} + defines {"NDEBUG"} + flags {"FatalCompileWarnings", "FatalLinkWarnings"} if not _OPTIONS["force-unit-tests"] then rtti ("Off") @@ -286,7 +254,7 @@ workspace "iw4x" filter "configurations:Debug" optimize "Debug" - defines { "DEBUG", "_DEBUG" } + defines {"DEBUG", "_DEBUG"} filter {} project "iw4x" @@ -296,7 +264,6 @@ workspace "iw4x" "./src/**.rc", "./src/**.hpp", "./src/**.cpp", - --"./src/**.proto", } includedirs { "%{prj.location}/src", @@ -312,66 +279,32 @@ workspace "iw4x" -- Debug flags if _OPTIONS["ac-disable"] then - defines { "DISABLE_ANTICHEAT" } + defines {"DISABLE_ANTICHEAT"} end if _OPTIONS["ac-debug-detections"] then - defines { "DEBUG_DETECTIONS" } + defines {"DEBUG_DETECTIONS"} end if _OPTIONS["ac-debug-load-library"] then - defines { "DEBUG_LOAD_LIBRARY" } + defines {"DEBUG_LOAD_LIBRARY"} end if _OPTIONS["force-unit-tests"] then - defines { "FORCE_UNIT_TESTS" } + defines {"FORCE_UNIT_TESTS"} end if _OPTIONS["force-minidump-upload"] then - defines { "FORCE_MINIDUMP_UPLOAD" } + defines {"FORCE_MINIDUMP_UPLOAD"} end if _OPTIONS["force-exception-handler"] then - defines { "FORCE_EXCEPTION_HANDLER" } + defines {"FORCE_EXCEPTION_HANDLER"} end if _OPTIONS["iw4x-zones"] then - defines { "GENERATE_IW4X_SPECIFIC_ZONES" } + defines {"GENERATE_IW4X_SPECIFIC_ZONES"} end -- Pre-compiled header pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives pchsource "src/STDInclude.cpp" -- real path - buildoptions { "/Zm200" } - -- Dependency libraries - json11.import() - libtomcrypt.import() - libtommath.import() - mongoose.import() - pdcurses.import() - protobuf.import() - zlib.import() - udis86.import() - dxsdk.import() - - -- fix vpaths for protobuf sources - vpaths - { - ["*"] = { "./src/**" }, - --["Proto/Generated"] = { "**.pb.*" }, -- meh. - } - - -- Virtual paths - if not _OPTIONS["no-new-structure"] then - vpaths - { - ["Headers/*"] = { "./src/**.hpp" }, - ["Sources/*"] = { "./src/**.cpp" }, - ["Resource/*"] = { "./src/**.rc" }, - --["Proto/Definitions/*"] = { "./src/Proto/**.proto" }, - --["Proto/Generated/*"] = { "**.pb.*" }, -- meh. - } - end - - vpaths - { - ["Docs/*"] = { "**.txt","**.md" }, - } + dependencies.imports() -- Pre-build prebuildcommands @@ -400,49 +333,9 @@ workspace "iw4x" } end - --[[ - -- Generate source code from protobuf definitions - rules { "ProtobufCompiler" } - -- Workaround: Consume protobuf generated source files - matches = os.matchfiles(path.join("src/Proto/**.proto")) - for i, srcPath in ipairs(matches) do - basename = path.getbasename(srcPath) - files - { - string.format("%%{prj.location}/src/proto/%s.pb.h", basename), - string.format("%%{prj.location}/src/proto/%s.pb.cc", basename), - } - end - includedirs - { - "%{prj.location}/src/proto", - } - filter "files:**.pb.*" - flags { - "NoPCH", - } - buildoptions { - "/wd4100", -- "Unused formal parameter" - "/wd4389", -- "Signed/Unsigned mismatch" - "/wd6011", -- "Dereferencing NULL pointer" - "/wd4125", -- "Decimal digit terminates octal escape sequence" - } - defines { - "_SCL_SECURE_NO_WARNINGS", - } - filter {} - ]] - - group "External dependencies" - json11.project() - libtomcrypt.project() - libtommath.project() - mongoose.project() - pdcurses.project() - protobuf.project() - zlib.project() - udis86.project() +group "External Dependencies" +dependencies.projects() rule "ProtobufCompiler" display "Protobuf compiler" diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 98270b52..b3c7057a 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -494,7 +494,7 @@ namespace Components { this->reallocateEntryPool(); - Dvar::Register("r_noVoid", false, Game::DVAR_FLAG_SAVED, "Disable void model (red fx)"); + Dvar::Register("r_noVoid", false, Game::DVAR_ARCHIVE, "Disable void model (red fx)"); AssetHandler::ClearTemporaryAssets(); diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index 882cccea..2a2d7fde 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -61,7 +61,7 @@ namespace Assets glyph.pixelHeight = static_cast(gh); glyph.x0 = static_cast(x0); glyph.y0 = static_cast(y0 + yOffset); - glyph.dx = static_cast(roundf(scale * advance)); + glyph.dx = static_cast(std::roundf(scale * advance)); // Advance to next col x = x + gw + 1; @@ -92,7 +92,7 @@ namespace Assets } } - void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone*) + void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { Components::FileSystem::File fontDefFile(Utils::String::VA("%s.json", name.data())); Components::FileSystem::File fontFile(Utils::String::VA("%s.ttf", name.data())); @@ -105,11 +105,13 @@ namespace Assets if (!errors.empty()) { Components::Logger::Error("Font define %s is broken: %s.", name.data(), errors.data()); + return; } if (!fontDef.is_object()) { Components::Logger::Error("Font define %s is invaild.", name.data(), errors.data()); + return; } int w = fontDef["textureWidth"].int_value(); @@ -118,22 +120,28 @@ namespace Assets int size = fontDef["size"].int_value(); int yOffset = fontDef["yOffset"].int_value(); - uint8_t* pixels = Utils::Memory::AllocateArray(w * h); + auto* pixels = builder->getAllocator()->allocateArray(w * h); // Setup assets - auto* texName = Utils::Memory::DuplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */)); - auto* fontName = Utils::Memory::DuplicateString(name.data()); - auto* glowMaterialName = Utils::Memory::DuplicateString(Utils::String::VA("%s_glow", name.data())); + const auto* texName = builder->getAllocator()->duplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */)); + const auto* fontName = builder->getAllocator()->duplicateString(name.data()); + const auto* glowMaterialName = builder->getAllocator()->duplicateString(Utils::String::VA("%s_glow", name.data())); + + auto* image = builder->getAllocator()->allocate(); + std::memcpy(image, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image, sizeof(Game::GfxImage)); - auto* image = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image); image->name = texName; - - auto* material = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material); - material->textureTable = Utils::Memory::Duplicate(material->textureTable); + + auto* material = builder->getAllocator()->allocate(); + std::memcpy(material, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material, sizeof(Game::Material)); + + material->textureTable = builder->getAllocator()->allocate(); material->textureTable->u.image = image; material->info.name = fontName; - auto* glowMaterial = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material); + auto* glowMaterial = builder->getAllocator()->allocate(); + std::memcpy(glowMaterial, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material, sizeof(Game::Material)); + glowMaterial->textureTable = material->textureTable; glowMaterial->info.name = glowMaterialName; @@ -161,14 +169,14 @@ namespace Assets charset.push_back(i); } - auto* font = Utils::Memory::Allocate(); + auto* font = builder->getAllocator()->allocate(); font->fontName = fontName; font->pixelHeight = size; font->material = material; font->glowMaterial = glowMaterial; font->glyphCount = charset.size(); - font->glyphs = Utils::Memory::AllocateArray(charset.size()); + font->glyphs = builder->getAllocator()->allocateArray(charset.size()); // Generate glyph data int result = PackFonts(reinterpret_cast(fontFile.getBuffer().data()), charset, font->glyphs, static_cast(size), pixels, w, h, yOffset); @@ -239,7 +247,6 @@ namespace Assets } Utils::IO::WriteFile(Utils::String::VA("userraw\\images\\%s.iwi", texName), outIwi); - Utils::Memory::Free(pixels); } } diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 1ea665f7..51e0bd29 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -83,7 +83,7 @@ namespace Components Command::ServerParams params; - if (params.length() < 3) + if (params.size() < 3) { Game::SV_Cmd_EndTokenizedString(); Logger::SoftError("Connecting failed: Command parsing error!"); @@ -170,7 +170,7 @@ namespace Components Command::ServerParams params; // Ensure there are enough params - if (params.length() < 3) + if (params.size() < 3) { Network::Send(address, "error\nInvalid connect string!"); return; @@ -432,7 +432,7 @@ namespace Components Scheduler::OnFrame(Auth::Frame); // Register dvar - Dvar::Register("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_FLAG_SERVERINFO, "Security level for GUID certificates (POW)"); + Dvar::Register("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_SERVERINFO, "Security level for GUID certificates (POW)"); // Install registration hook Utils::Hook(0x6265F9, Auth::DirectConnectStub, HOOK_JUMP).install()->quick(); @@ -455,7 +455,7 @@ namespace Components { Command::Add("securityLevel", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey()); Logger::Print("Your current security level is %d\n", level); diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 38cd20e9..d179cc7b 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -234,17 +234,17 @@ namespace Components { Command::Add("banclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string reason = "EXE_ERR_BANNED_PERM"; - if (params->length() >= 3) reason = params->join(2); + if (params->size() >= 3) reason = params->join(2); Bans::BanClientNum(atoi(params->get(1)), reason); }); Command::Add("unbanclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string type = params->get(1); @@ -274,9 +274,4 @@ namespace Components Bans::LoadBans(&list); }); } - - Bans::~Bans() - { - - } } diff --git a/src/Components/Modules/Bans.hpp b/src/Components/Modules/Bans.hpp index 1ba76a66..fe5c6410 100644 --- a/src/Components/Modules/Bans.hpp +++ b/src/Components/Modules/Bans.hpp @@ -8,7 +8,6 @@ namespace Components typedef std::pair Entry; Bans(); - ~Bans(); static void BanClientNum(int num, const std::string& reason); static void UnbanClient(SteamID id); diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 78d42d0a..d177c573 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -447,7 +447,7 @@ namespace Components { unsigned int count = 1; - if (params->length() > 1) + if (params->size() > 1) { if (params->get(1) == "all"s) count = static_cast(-1); else count = atoi(params->get(1)); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 471dd8ec..396eebf5 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -192,14 +192,14 @@ namespace Components { Dvar::OnInit([]() { - CardTitles::CustomTitleDvar = Dvar::Register("customtitle", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "Custom card title"); + CardTitles::CustomTitleDvar = Dvar::Register("customtitle", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "Custom card title"); }); ServerCommands::OnCommand(21, [](Command::Params* params) { if (params->get(1) == "customTitles"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { CardTitles::ParseCustomTitles(params->get(2)); return true; @@ -210,11 +210,6 @@ namespace Components }); - for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i) - { - CardTitles::CustomTitles[i].clear(); - } - Utils::Hook(0x62EB26, CardTitles::GetPlayerCardClientInfoStub).install()->quick(); // Table lookup stuff @@ -227,12 +222,4 @@ namespace Components AntiCheat::CheckStartupTime(); #endif } - - CardTitles::~CardTitles() - { - for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i) - { - CardTitles::CustomTitles[i].clear(); - } - } } diff --git a/src/Components/Modules/CardTitles.hpp b/src/Components/Modules/CardTitles.hpp index 7f838ef8..0b43bdab 100644 --- a/src/Components/Modules/CardTitles.hpp +++ b/src/Components/Modules/CardTitles.hpp @@ -60,7 +60,6 @@ namespace Components static void ParseCustomTitles(const char * msg); CardTitles(); - ~CardTitles(); private: static CClient * GetClientByIndex(std::uint32_t index); diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 28773007..a6da0d83 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -60,12 +60,4 @@ namespace Components Scheduler::OnFrameAsync(AntiCheat::QuickCodeScanner1); #endif } - - Changelog::~Changelog() - { - { - std::lock_guard _(Changelog::Mutex); - Changelog::Lines.clear(); - } - } } diff --git a/src/Components/Modules/Changelog.hpp b/src/Components/Modules/Changelog.hpp index dd74a8be..b58eb1ca 100644 --- a/src/Components/Modules/Changelog.hpp +++ b/src/Components/Modules/Changelog.hpp @@ -6,7 +6,6 @@ namespace Components { public: Changelog(); - ~Changelog(); static void LoadChangelog(); diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index abe117d8..baa00267 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -263,7 +263,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s : prevent the player from using the chat\n", cmd); return; @@ -285,7 +285,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s \n%s all = unmute everyone\n", cmd, cmd); return; @@ -299,7 +299,7 @@ namespace Components return; } - if (params->get(1) == "all"s) + if (std::strcmp(params->get(1), "all") == 0) { Logger::Print("All players were unmuted\n"); Chat::UnmuteInternal(0, true); @@ -316,7 +316,7 @@ namespace Components { Dvar::OnInit([] { - cg_chatWidth = Dvar::Register("cg_chatWidth", 52, 1, std::numeric_limits::max(), Game::DVAR_FLAG_SAVED, "The normalized maximum width of a chat message"); + cg_chatWidth = Dvar::Register("cg_chatWidth", 52, 1, std::numeric_limits::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message"); Chat::AddChatCommands(); }); @@ -328,9 +328,4 @@ namespace Components // Change logic that does word splitting with new lines for chat messages to support fonticons Utils::Hook(0x592E10, CG_AddToTeamChat_Stub, HOOK_JUMP).install()->quick(); } - - Chat::~Chat() - { - Chat::MuteList.clear(); - } } diff --git a/src/Components/Modules/Chat.hpp b/src/Components/Modules/Chat.hpp index 62bc36aa..134efb37 100644 --- a/src/Components/Modules/Chat.hpp +++ b/src/Components/Modules/Chat.hpp @@ -7,7 +7,6 @@ namespace Components static constexpr auto FONT_ICON_CHAT_WIDTH_CALCULATION_MULTIPLIER = 2.0f; public: Chat(); - ~Chat(); private: static Game::dvar_t** cg_chatHeight; diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index ff6e2022..c23a3b62 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -75,7 +75,7 @@ namespace Components // Create clantag dvar Dvar::OnInit([]() { - Dvar::Register("clantag", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "If set, your clantag will be shown on the scoreboard."); + Dvar::Register("clantag", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "If set, your clantag will be shown on the scoreboard."); }); // Servercommand hook @@ -83,7 +83,7 @@ namespace Components { if (params->get(1) == "clantags"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { ClanTags::ParseClantags(params->get(2)); return true; @@ -93,20 +93,7 @@ namespace Components return false; }); - for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) - { - ClanTags::Tags[i].clear(); - } - // Draw clantag before playername Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick(); } - - ClanTags::~ClanTags() - { - for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i) - { - ClanTags::Tags[i].clear(); - } - } } diff --git a/src/Components/Modules/Clantags.hpp b/src/Components/Modules/Clantags.hpp index caadbe69..ea7bca39 100644 --- a/src/Components/Modules/Clantags.hpp +++ b/src/Components/Modules/Clantags.hpp @@ -10,7 +10,6 @@ namespace Components static const char* GetUserClantag(std::uint32_t clientnum, const char * playername); ClanTags(); - ~ClanTags(); private: static std::string Tags[18]; diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index 1c0c7fa4..5f7ef964 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -147,7 +147,7 @@ namespace Components Command::ServerParams params = {}; Game::vec3_t origin, angles{0.f, 0.f, 0.f}; - if (params.length() < 4u || params.length() > 6u) + if (params.size() < 4 || params.size() > 6) { Game::SV_GameSendServerCommand(ent->s.number, 0, Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65)); @@ -159,12 +159,12 @@ namespace Components origin[i] = std::strtof(params.get(i + 1), nullptr); } - if (params.length() >= 5u) + if (params.size() >= 5) { angles[1] = std::strtof(params.get(4), nullptr); // Yaw } - if (params.length() == 6u) + if (params.size() == 6) { angles[0] = std::strtof(params.get(5), nullptr); // Pitch } @@ -309,9 +309,4 @@ namespace Components ClientCommand::AddCheatCommands(); ClientCommand::AddScriptFunctions(); } - - ClientCommand::~ClientCommand() - { - ClientCommand::FunctionMap.clear(); - } } diff --git a/src/Components/Modules/ClientCommand.hpp b/src/Components/Modules/ClientCommand.hpp index 3c1d1da6..ca9bc2a3 100644 --- a/src/Components/Modules/ClientCommand.hpp +++ b/src/Components/Modules/ClientCommand.hpp @@ -8,7 +8,7 @@ namespace Components typedef void(Callback)(Game::gentity_s* entity); ClientCommand(); - ~ClientCommand(); + static void Add(const char* name, Utils::Slot callback); static bool CheatsOk(const Game::gentity_s* ent); diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index d3846df5..cbe13615 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -5,56 +5,71 @@ namespace Components std::unordered_map> Command::FunctionMap; std::unordered_map> Command::FunctionMapSV; - std::string Command::Params::join(size_t startIndex) + std::string Command::Params::join(const int index) { std::string result; - for (size_t i = startIndex; i < this->length(); ++i) + for (auto i = index; i < this->size(); i++) { - if (i > startIndex) result.append(" "); - result.append(this->operator[](i)); + if (i > index) result.append(" "); + result.append(this->get(i)); } return result; } - const char* Command::Params::operator[](size_t index) + Command::ClientParams::ClientParams() + : nesting_(Game::cmd_args->nesting) { - return this->get(index); + assert(Game::cmd_args->nesting < Game::CMD_MAX_NESTING); } - const char* Command::ClientParams::get(size_t index) + int Command::ClientParams::size() { - if (index >= this->length()) return ""; - return Game::cmd_argv[this->commandId][index]; + return Game::cmd_args->argc[this->nesting_]; } - size_t Command::ClientParams::length() + const char* Command::ClientParams::get(const int index) { - return Game::cmd_argc[this->commandId]; + if (index >= this->size()) + { + return ""; + } + + return Game::cmd_args->argv[this->nesting_][index]; } - const char* Command::ServerParams::get(size_t index) + Command::ServerParams::ServerParams() + : nesting_(Game::sv_cmd_args->nesting) { - if (index >= this->length()) return ""; - return Game::cmd_argv_sv[this->commandId][index]; + assert(Game::sv_cmd_args->nesting < Game::CMD_MAX_NESTING); } - size_t Command::ServerParams::length() + int Command::ServerParams::size() { - return Game::cmd_argc_sv[this->commandId]; + return Game::sv_cmd_args->argc[this->nesting_]; + } + + const char* Command::ServerParams::get(const int index) + { + if (index >= this->size()) + { + return ""; + } + + return Game::sv_cmd_args->argv[this->nesting_][index]; } void Command::Add(const char* name, Utils::Slot callback) { - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) { Command::AddRaw(name, Command::MainCallback); } - Command::FunctionMap[command] = callback; + Command::FunctionMap[command] = std::move(callback); } void Command::AddSV(const char* name, Utils::Slot callback) @@ -70,7 +85,7 @@ namespace Components return; } - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) { @@ -80,7 +95,7 @@ namespace Components Command::AddRaw(name, Game::Cbuf_AddServerText); } - Command::FunctionMapSV[command] = callback; + FunctionMapSV[command] = std::move(callback); } void Command::AddRaw(const char* name, void(*callback)(), bool key) @@ -134,25 +149,27 @@ namespace Components void Command::MainCallback() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMap.find(command); - if (Command::FunctionMap.find(command) != Command::FunctionMap.end()) + if (got != Command::FunctionMap.end()) { - Command::FunctionMap[command](¶ms); + got->second(¶ms); } } void Command::MainCallbackSV() { - Command::ServerParams params(*Game::cmd_id_sv); + Command::ServerParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMapSV.find(command); - if (Command::FunctionMapSV.find(command) != Command::FunctionMapSV.end()) + if (got != Command::FunctionMapSV.end()) { - Command::FunctionMapSV[command](¶ms); + got->second(¶ms); } } @@ -162,16 +179,10 @@ namespace Components Command::Add("openLink", [](Command::Params* params) { - if (params->length() > 1) + if (params->size() > 1) { Utils::OpenUrl(params->get(1)); } }); } - - Command::~Command() - { - Command::FunctionMap.clear(); - Command::FunctionMapSV.clear(); - } } diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 4e07ba87..d6379a94 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -9,46 +9,44 @@ namespace Components { public: Params() {}; - virtual ~Params() {}; - virtual const char* get(size_t index) = 0; - virtual size_t length() = 0; - virtual std::string join(size_t startIndex); - virtual const char* operator[](size_t index); + virtual int size() = 0; + virtual const char* get(int index) = 0; + virtual std::string join(int index); + + virtual const char* operator[](const int index) + { + return this->get(index); + } }; class ClientParams : public Params { public: - ClientParams(unsigned int id) : commandId(id) {}; - ClientParams(const ClientParams &obj) : commandId(obj.commandId) {}; - ClientParams() : ClientParams(*Game::cmd_id) {}; + ClientParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; class ServerParams : public Params { public: - ServerParams(unsigned int id) : commandId(id) {}; - ServerParams(const ServerParams &obj) : commandId(obj.commandId) {}; - ServerParams() : ServerParams(*Game::cmd_id_sv) {}; + ServerParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; typedef void(Callback)(Command::Params* params); Command(); - ~Command(); static Game::cmd_function_t* Allocate(); diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 18b82ff6..c50f723c 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -504,7 +504,8 @@ namespace Components Console::ConsoleThread = std::thread(Console::ConsoleRunner); } - Game::dvar_t* Console::RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description) + Game::dvar_t* Console::RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, + float max, unsigned __int16 flags, const char* description) { static struct { @@ -521,7 +522,7 @@ namespace Components for (int i = 0; i < ARRAYSIZE(patchedColors); ++i) { - if (std::string(name) == patchedColors[i].name) + if (std::strcmp(dvarName, patchedColors[i].name) == 0) { r = patchedColors[i].color[0]; g = patchedColors[i].color[1]; @@ -531,7 +532,7 @@ namespace Components } } - return reinterpret_cast(0x471500)(name, r, g, b, a, min, max, flags, description); + return reinterpret_cast(0x471500)(dvarName, r, g, b, a, min, max, flags, description); } Console::Console() diff --git a/src/Components/Modules/Console.hpp b/src/Components/Modules/Console.hpp index 0ef30bb5..2ca6eb60 100644 --- a/src/Components/Modules/Console.hpp +++ b/src/Components/Modules/Console.hpp @@ -66,6 +66,6 @@ namespace Components static void ToggleConsole(); static char** GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType); - static Game::dvar_t* RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description); + static Game::dvar_t* RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, float max, unsigned __int16 flags, const char* description); }; } diff --git a/src/Components/Modules/D3D9Ex.cpp b/src/Components/Modules/D3D9Ex.cpp index c78113dd..d9222836 100644 --- a/src/Components/Modules/D3D9Ex.cpp +++ b/src/Components/Modules/D3D9Ex.cpp @@ -748,7 +748,7 @@ namespace Components { if (Dedicated::IsEnabled()) return; - Dvar::Register("r_useD3D9Ex", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use extended d3d9 interface!"); + Dvar::Register("r_useD3D9Ex", false, Game::dvar_flag::DVAR_ARCHIVE, "Use extended d3d9 interface!"); // Hook Interface creation Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 3e615dab..b56e9ccb 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -275,22 +275,22 @@ namespace Components Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description) { - return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_FLAG_NONE, description); + return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_NONE, description); } Dedicated::Dedicated() { // Map rotation Utils::Hook::Set(0x4152E8, Dedicated::MapRotate); - Dvar::Register("sv_dontrotate", false, Game::dvar_flag::DVAR_FLAG_CHEAT, ""); - Dvar::Register("com_logFilter", true, Game::dvar_flag::DVAR_FLAG_LATCHED, "Removes ~95% of unneeded lines from the log"); + Dvar::Register("sv_dontrotate", false, Game::dvar_flag::DVAR_CHEAT, ""); + Dvar::Register("com_logFilter", true, Game::dvar_flag::DVAR_LATCH, "Removes ~95% of unneeded lines from the log"); if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) { // Make sure all callbacks are handled Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks); - Dvar::Register("sv_lanOnly", false, Game::dvar_flag::DVAR_FLAG_NONE, "Don't act as node"); + Dvar::Register("sv_lanOnly", false, Game::dvar_flag::DVAR_NONE, "Don't act as node"); Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick(); @@ -391,14 +391,14 @@ namespace Components Dvar::OnInit([]() { - Dedicated::SVRandomMapRotation = Dvar::Register("sv_randomMapRotation", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Randomize map rotation when true"); - Dvar::Register("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands"); - Dvar::Register("sv_motd", "", Game::dvar_flag::DVAR_FLAG_NONE, "A custom message of the day for servers"); + Dedicated::SVRandomMapRotation = Dvar::Register("sv_randomMapRotation", false, Game::dvar_flag::DVAR_ARCHIVE, "Randomize map rotation when true"); + Dvar::Register("sv_sayName", "^7Console", Game::dvar_flag::DVAR_NONE, "The name to pose as for 'say' commands"); + Dvar::Register("sv_motd", "", Game::dvar_flag::DVAR_NONE, "A custom message of the day for servers"); // Say command Command::AddSV("say", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); std::string name = Dvar::Var("sv_sayName").get(); @@ -418,7 +418,7 @@ namespace Components // Tell command Command::AddSV("tell", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); @@ -439,7 +439,7 @@ namespace Components // Sayraw command Command::AddSV("sayraw", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); @@ -449,33 +449,13 @@ namespace Components // Tellraw command Command::AddSV("tellraw", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data()); }); - - // ! command - Command::AddSV("!", [](Command::Params* params) - { - if (params->length() != 2) return; - - int client = -1; - if (params->get(1) != "all"s) - { - client = atoi(params->get(1)); - - if (client >= *reinterpret_cast(0x31D938C)) - { - Game::Com_Printf(0, "Invalid player.\n"); - return; - } - } - - Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"\"", 106)); - }); }); } } @@ -519,9 +499,4 @@ namespace Components } }); } - - Dedicated::~Dedicated() - { - - } } diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 78126922..cfcbc539 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -6,7 +6,6 @@ namespace Components { public: Dedicated(); - ~Dedicated(); static SteamID PlayerGuids[18][2]; diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 758ef317..93dbf96f 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -14,8 +14,8 @@ namespace Components Discovery::Discovery() { - Dvar::Register("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_FLAG_SAVED, "Minimum scan range port for local server discovery"); - Dvar::Register("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_FLAG_SAVED, "Maximum scan range port for local server discovery"); + Dvar::Register("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_ARCHIVE, "Minimum scan range port for local server discovery"); + Dvar::Register("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_ARCHIVE, "Maximum scan range port for local server discovery"); // An additional thread prevents lags // Not sure if that's the best way though @@ -95,11 +95,6 @@ namespace Components #endif } - Discovery::~Discovery() - { - - } - void Discovery::preDestroy() { Discovery::IsPerforming = false; diff --git a/src/Components/Modules/Discovery.hpp b/src/Components/Modules/Discovery.hpp index 655122bf..63f69b1b 100644 --- a/src/Components/Modules/Discovery.hpp +++ b/src/Components/Modules/Discovery.hpp @@ -6,7 +6,6 @@ namespace Components { public: Discovery(); - ~Discovery(); void preDestroy() override; diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 9d803891..02b1de2a 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -902,9 +902,9 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_dl_progress", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); + Dvar::Register("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_dl_progress", "", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_dl_transRate", "", Game::dvar_flag::DVAR_NONE, ""); }); UIScript::Add("mod_download_cancel", [](UIScript::Token) @@ -915,13 +915,13 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server."); - Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to the base url for the external map download."); + Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server."); + Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_ARCHIVE, "Set to the base url for the external map download."); - // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again - // not saying we are but ya know... accidents happen - // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not - Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Set to true to force the client to run the download server for mods (for mods in private matches)."); + // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again + // not saying we are but ya know... accidents happen + // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not + Dvar::Register("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches)."); }); Scheduler::OnFrame([]() diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5e6f8a60..99acf132 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -181,24 +181,24 @@ namespace Components } } - template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* dvarName, bool value, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterBool(name, value, flag.val, description); + return Game::Dvar_RegisterBool(dvarName, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* dvarName, const char* value, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterString(name, value, flag.val, description); + return Game::Dvar_RegisterString(dvarName, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* dvarName, int value, int min, int max, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); + return Game::Dvar_RegisterInt(dvarName, value, min, max, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* dvarName, float value, float min, float max, Dvar::Flag flag, const char* description) { - return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); + return Game::Dvar_RegisterFloat(dvarName, value, min, max, flag.val, description); } void Dvar::OnInit(Utils::Slot callback) @@ -255,7 +255,7 @@ namespace Components } } - return Dvar::Register(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).get(); + return Dvar::Register(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_ARCHIVE).val, description).get(); } void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string) @@ -305,7 +305,7 @@ namespace Components { // Save the dvar original value if it has the archive flag const auto* dvar = Game::Dvar_FindVar(dvarName); - if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_FLAG_SAVED) + if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_ARCHIVE) { Dvar::SaveArchiveDvar(dvar); } @@ -316,49 +316,49 @@ namespace Components Dvar::Dvar() { // set flags of cg_drawFPS to archive - Utils::Hook::Or(0x4F8F69, Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Or(0x4F8F69, Game::dvar_flag::DVAR_ARCHIVE); // un-cheat camera_thirdPersonCrosshairOffset and add archive flags - Utils::Hook::Xor(0x447B41, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x447B41, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_fov and add archive flags - Utils::Hook::Xor(0x4F8E35, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8E35, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_fovscale and add archive flags - Utils::Hook::Xor(0x4F8E68, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8E68, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // un-cheat cg_debugInfoCornerOffset and add archive flags - Utils::Hook::Xor(0x4F8FC2, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F8FC2, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); // remove archive flags for cg_hudchatposition - Utils::Hook::Xor(0x4F9992, Game::dvar_flag::DVAR_FLAG_SAVED); + Utils::Hook::Xor(0x4F9992, Game::dvar_flag::DVAR_ARCHIVE); // remove write protection from fs_game - Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED); + Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_WRITEPROTECTED); - // set cg_fov max to 90.0 - // ...120 because of V2 - static float cgFov90 = 120.0f; - Utils::Hook::Set(0x4F8E28, &cgFov90); + // set cg_fov max to 160.0 + // because that's the max on SP + static float cg_Fov = 160.0f; + Utils::Hook::Set(0x4F8E28, &cg_Fov); // set max volume to 1 static float volume = 1.0f; Utils::Hook::Set(0x408078, &volume); // Uncheat ui_showList - Utils::Hook::Xor(0x6310DC, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Xor(0x6310DC, Game::dvar_flag::DVAR_CHEAT); // Uncheat ui_debugMode - Utils::Hook::Xor(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Xor(0x6312DE, Game::dvar_flag::DVAR_CHEAT); // Hook dvar 'name' registration Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick(); // un-cheat safeArea_* and add archive flags - Utils::Hook::Xor(0x42E3F5, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_horizontal - Utils::Hook::Xor(0x42E423, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_vertical - Utils::Hook::Xor(0x42E398, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_horizontal - Utils::Hook::Xor(0x42E3C4, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_vertical + Utils::Hook::Xor(0x42E3F5, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_horizontal + Utils::Hook::Xor(0x42E423, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_vertical + Utils::Hook::Xor(0x42E398, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_horizontal + Utils::Hook::Xor(0x42E3C4, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_vertical // Don't allow setting cheat protected dvars via menus Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick(); @@ -385,7 +385,6 @@ namespace Components Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); // If the game closed abruptly, the dvars would not have been restored - Dvar::OnInit([] { Dvar::ResetDvarsValue(); diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index 8f87eaf5..c140ac73 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -9,7 +9,7 @@ namespace Components { public: Flag(Game::dvar_flag flag) : val(flag) {}; - Flag(int flag) : Flag(static_cast(flag)) {}; + Flag(unsigned __int16 flag) : Flag(static_cast(flag)) {}; Game::dvar_flag val; }; @@ -46,8 +46,8 @@ namespace Components static void OnInit(Utils::Slot callback); // Only strings and bools use this type of declaration - template static Var Register(const char* name, T value, Flag flag, const char* description); - template static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); + template static Var Register(const char* dvarName, T value, Flag flag, const char* description); + template static Var Register(const char* dvarName, T value, T min, T max, Flag flag, const char* description); static void ResetDvarsValue(); diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index 9438f9ce..08dffeb7 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -108,7 +108,7 @@ namespace Components }; Elevators::BG_Elevators = Game::Dvar_RegisterEnum("bg_elevators", values, - Elevators::ENABLED, Game::DVAR_FLAG_REPLICATED, "Elevators glitch settings"); + Elevators::ENABLED, Game::DVAR_CODINFO, "Elevators glitch settings"); }); //Replace PM_CorrectAllSolid @@ -120,8 +120,4 @@ namespace Components Utils::Hook(0x570E0B, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x570D70, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); } - - Elevators::~Elevators() - { - } } diff --git a/src/Components/Modules/Elevators.hpp b/src/Components/Modules/Elevators.hpp index 02b0b64e..1a096161 100644 --- a/src/Components/Modules/Elevators.hpp +++ b/src/Components/Modules/Elevators.hpp @@ -6,7 +6,6 @@ namespace Components { public: Elevators(); - ~Elevators(); private: enum ElevatorSettings { DISABLED, ENABLED, EASY }; diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index c5b09faf..3700587b 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -234,7 +234,7 @@ namespace Components Game::UI_UpdateArenas(); std::string command; - for (auto i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) + for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) { const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 2170e3c6..963b1777 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -495,7 +495,7 @@ namespace Components FastFiles::FastFiles() { - Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone."); + Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_ARCHIVE, "Display current loaded zone."); // Fix XSurface assets Utils::Hook(0x0048E8A5, FastFiles::Load_XSurfaceArray, HOOK_CALL).install()->quick(); @@ -594,7 +594,7 @@ namespace Components Command::Add("loadzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XZoneInfo info; info.name = params->get(1); @@ -622,9 +622,4 @@ namespace Components }, HOOK_CALL).install()/*->quick()*/; #endif } - - FastFiles::~FastFiles() - { - FastFiles::ZonePaths.clear(); - } } diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index 38c3e62c..a1b4c235 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -6,7 +6,6 @@ namespace Components { public: FastFiles(); - ~FastFiles(); static void AddZonePath(const std::string& path); static std::string Current(); diff --git a/src/Components/Modules/Flags.cpp b/src/Components/Modules/Flags.cpp index e3139910..87400340 100644 --- a/src/Components/Modules/Flags.cpp +++ b/src/Components/Modules/Flags.cpp @@ -6,13 +6,7 @@ namespace Components bool Flags::HasFlag(const std::string& flag) { - static auto parsed = false; - - if (!parsed) - { - Flags::ParseFlags(); - parsed = true; - } + Flags::ParseFlags(); for (const auto& entry : Flags::EnabledFlags) { @@ -27,11 +21,17 @@ namespace Components void Flags::ParseFlags() { + static auto flagsParsed = false; + if (flagsParsed) + { + return; + } + + // Only parse flags once + flagsParsed = true; int numArgs; auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs); - assert(Flags::EnabledFlags.empty()); - if (argv) { for (auto i = 0; i < numArgs; ++i) @@ -40,7 +40,7 @@ namespace Components if (wFlag[0] == L'-') { wFlag.erase(wFlag.begin()); - Flags::EnabledFlags.push_back(Utils::String::Convert(wFlag)); + Flags::EnabledFlags.emplace_back(Utils::String::Convert(wFlag)); } } @@ -50,11 +50,7 @@ namespace Components // Workaround for wine if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout")) { - Flags::EnabledFlags.push_back("stdout"); + Flags::EnabledFlags.emplace_back("stdout"); } } - - Flags::Flags() - { - } } diff --git a/src/Components/Modules/Flags.hpp b/src/Components/Modules/Flags.hpp index ec35f350..b8ee410d 100644 --- a/src/Components/Modules/Flags.hpp +++ b/src/Components/Modules/Flags.hpp @@ -5,7 +5,7 @@ namespace Components class Flags : public Component { public: - Flags(); + Flags() = default; static bool HasFlag(const std::string& flag); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index d8d483ac..b77a983a 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -578,12 +578,12 @@ namespace Components if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return; - Dvar::Register("cl_anonymous", false, Game::DVAR_FLAG_SAVED, "Enable invisible mode for Steam"); - Dvar::Register("cl_notifyFriendState", true, Game::DVAR_FLAG_SAVED, "Update friends about current game status"); + Dvar::Register("cl_anonymous", false, Game::DVAR_ARCHIVE, "Enable invisible mode for Steam"); + Dvar::Register("cl_notifyFriendState", true, Game::DVAR_ARCHIVE, "Update friends about current game status"); Command::Add("addFriend", [](Command::Params* params) { - if (params->length() < 2u) + if (params->size() < 2u) { Logger::Print("Usage: %s \n", params->get(0)); return; diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 445868aa..f6fc1aef 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1641,7 +1641,7 @@ namespace Components void Gamepad::Axis_Bind_f(Command::Params* params) { - if (params->length() < 4) + if (params->size() < 4) { Logger::Print("bindaxis \n"); return; @@ -1711,32 +1711,32 @@ namespace Components void Gamepad::InitDvars() { - gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_FLAG_SAVED, "Game pad enabled"); - gpad_debug = Dvar::Register("gpad_debug", false, Game::DVAR_FLAG_NONE, "Game pad debugging"); - gpad_present = Dvar::Register("gpad_present", false, Game::DVAR_FLAG_NONE, "Game pad present"); - gpad_in_use = Dvar::Register("gpad_in_use", false, Game::DVAR_FLAG_NONE, "A game pad is in use"); - gpad_style = Dvar::Register("gpad_style", false, Game::DVAR_FLAG_SAVED, "Switch between Xbox and PS HUD"); - gpad_sticksConfig = Dvar::Register("gpad_sticksConfig", "", Game::DVAR_FLAG_SAVED, "Game pad stick configuration"); - gpad_buttonConfig = Dvar::Register("gpad_buttonConfig", "", Game::DVAR_FLAG_SAVED, "Game pad button configuration"); - gpad_menu_scroll_delay_first = Dvar::Register("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_FLAG_SAVED, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); - gpad_menu_scroll_delay_rest = Dvar::Register("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_FLAG_SAVED, + gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_ARCHIVE, "Game pad enabled"); + gpad_debug = Dvar::Register("gpad_debug", false, Game::DVAR_NONE, "Game pad debugging"); + gpad_present = Dvar::Register("gpad_present", false, Game::DVAR_NONE, "Game pad present"); + gpad_in_use = Dvar::Register("gpad_in_use", false, Game::DVAR_NONE, "A game pad is in use"); + gpad_style = Dvar::Register("gpad_style", false, Game::DVAR_ARCHIVE, "Switch between Xbox and PS HUD"); + gpad_sticksConfig = Dvar::Register("gpad_sticksConfig", "", Game::DVAR_ARCHIVE, "Game pad stick configuration"); + gpad_buttonConfig = Dvar::Register("gpad_buttonConfig", "", Game::DVAR_ARCHIVE, "Game pad button configuration"); + gpad_menu_scroll_delay_first = Dvar::Register("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_ARCHIVE, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); + gpad_menu_scroll_delay_rest = Dvar::Register("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_ARCHIVE, "Menu scroll key-repeat delay, for repeats after the first, in milliseconds"); - gpad_rumble = Dvar::Register("gpad_rumble", true, Game::DVAR_FLAG_SAVED, "Enable game pad rumble"); - gpad_stick_pressed_hysteresis = Dvar::Register("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, + gpad_rumble = Dvar::Register("gpad_rumble", true, Game::DVAR_ARCHIVE, "Enable game pad rumble"); + gpad_stick_pressed_hysteresis = Dvar::Register("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad stick pressed no-change-zone around gpad_stick_pressed to prevent bouncing"); - gpad_stick_pressed = Dvar::Register("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_FLAG_NONE, "Game pad stick pressed threshhold"); - gpad_stick_deadzone_max = Dvar::Register("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum stick deadzone"); - gpad_stick_deadzone_min = Dvar::Register("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad minimum stick deadzone"); - gpad_button_deadzone = Dvar::Register("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad button deadzone threshhold"); - gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); - gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); - gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, std::numeric_limits::max(), Game::DVAR_FLAG_NONE, "Time to hold the 'use' button on gamepads to activate use"); - gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad lockon aim assist enabled"); - gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad slowdown aim assist enabled"); + gpad_stick_pressed = Dvar::Register("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_NONE, "Game pad stick pressed threshhold"); + gpad_stick_deadzone_max = Dvar::Register("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum stick deadzone"); + gpad_stick_deadzone_min = Dvar::Register("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad minimum stick deadzone"); + gpad_button_deadzone = Dvar::Register("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad button deadzone threshhold"); + gpad_button_lstick_deflect_max = Dvar::Register("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value"); + gpad_button_rstick_deflect_max = Dvar::Register("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value"); + gpad_use_hold_time = Dvar::Register("gpad_use_hold_time", 250, 0, std::numeric_limits::max(), Game::DVAR_NONE, "Time to hold the 'use' button on gamepads to activate use"); + gpad_lockon_enabled = Dvar::Register("gpad_lockon_enabled", true, Game::DVAR_ARCHIVE, "Game pad lockon aim assist enabled"); + gpad_slowdown_enabled = Dvar::Register("gpad_slowdown_enabled", true, Game::DVAR_ARCHIVE, "Game pad slowdown aim assist enabled"); - input_viewSensitivity = Dvar::Register("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity"); - input_invertPitch = Dvar::Register("input_invertPitch", false, Game::DVAR_FLAG_SAVED, "Invert gamepad pitch"); - sv_allowAimAssist = Dvar::Register("sv_allowAimAssist", true, Game::DVAR_FLAG_NONE, "Controls whether aim assist features on clients are enabled"); + input_viewSensitivity = Dvar::Register("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_ARCHIVE, "View Sensitivity"); + input_invertPitch = Dvar::Register("input_invertPitch", false, Game::DVAR_ARCHIVE, "Invert gamepad pitch"); + sv_allowAimAssist = Dvar::Register("sv_allowAimAssist", true, Game::DVAR_NONE, "Controls whether aim assist features on clients are enabled"); aim_turnrate_pitch = Dvar::Var("aim_turnrate_pitch"); aim_turnrate_pitch_ads = Dvar::Var("aim_turnrate_pitch_ads"); aim_turnrate_yaw = Dvar::Var("aim_turnrate_yaw"); diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 0bed7bac..3b385506 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -277,7 +277,7 @@ namespace Components // Overwrite SetString Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick(); - Localization::UseLocalization = Dvar::Register("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings"); + Localization::UseLocalization = Dvar::Register("ui_localize", true, Game::dvar_flag::DVAR_NONE, "Use localization strings"); // Generate localized entries for custom classes above 10 AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/) diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 75f2ec3b..f43724f3 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -242,7 +242,7 @@ namespace Components Logger::Logger() { - Dvar::Register("iw4x_onelog", false, Game::dvar_flag::DVAR_FLAG_LATCHED | Game::dvar_flag::DVAR_FLAG_SAVED, "Only write the game log to the 'userraw' OS folder"); + Dvar::Register("iw4x_onelog", false, Game::dvar_flag::DVAR_LATCH | Game::dvar_flag::DVAR_ARCHIVE, "Only write the game log to the 'userraw' OS folder"); Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick(); Logger::PipeOutput(nullptr); @@ -261,7 +261,7 @@ namespace Components { Command::AddSV("log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -273,7 +273,7 @@ namespace Components Command::AddSV("log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[0].size()) @@ -312,7 +312,7 @@ namespace Components Command::AddSV("g_log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -324,7 +324,7 @@ namespace Components Command::AddSV("g_log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[1].size()) diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index dc842f4d..f46fdd56 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -544,7 +544,7 @@ namespace Components } } - Dvar::Register(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); + Dvar::Register(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); Maps::DlcPacks.push_back(dlc); Maps::UpdateDlcStatus(); @@ -690,7 +690,7 @@ namespace Components Game::dvar_t* Maps::GetSpecularDvar() { Game::dvar_t*& r_specular = *reinterpret_cast(0x69F0D94); - static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_FLAG_SAVED, "Allows shaders to use phong specular lighting on custom maps"); + static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_ARCHIVE, "Allows shaders to use phong specular lighting on custom maps"); if (Maps::IsCustomMap()) { @@ -769,8 +769,8 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("isDlcInstalled_All", false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("r_listSModels", false, Game::DVAR_FLAG_NONE, "Display a list of visible SModels"); + Dvar::Register("isDlcInstalled_All", false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("r_listSModels", false, Game::DVAR_NONE, "Display a list of visible SModels"); Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} }); Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} }); diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 9f7faa12..f29b4499 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -845,7 +845,7 @@ namespace Components Command::Add("openmenu", [](Command::Params* params) { - if (params->length() != 2) + if (params->size() != 2) { Logger::Print("USAGE: openmenu \n"); return; @@ -913,7 +913,6 @@ namespace Components Menus::~Menus() { - Menus::CustomMenus.clear(); Menus::FreeEverything(); } } diff --git a/src/Components/Modules/ModList.cpp b/src/Components/Modules/ModList.cpp index 8935b586..955142a9 100644 --- a/src/Components/Modules/ModList.cpp +++ b/src/Components/Modules/ModList.cpp @@ -93,7 +93,7 @@ namespace Components if (Dedicated::IsEnabled()) return; ModList::CurrentMod = 0; - Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Perform a vid_restart when loading a mod."); + Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_ARCHIVE, "Perform a vid_restart when loading a mod."); UIScript::Add("LoadMods", ModList::UIScript_LoadMods); UIScript::Add("RunMod", ModList::UIScript_RunMod); @@ -101,9 +101,4 @@ namespace Components UIFeeder::Add(9.0f, ModList::GetItemCount, ModList::GetItemText, ModList::Select); } - - ModList::~ModList() - { - ModList::Mods.clear(); - } } diff --git a/src/Components/Modules/ModList.hpp b/src/Components/Modules/ModList.hpp index a871fb45..185aaed1 100644 --- a/src/Components/Modules/ModList.hpp +++ b/src/Components/Modules/ModList.hpp @@ -6,7 +6,6 @@ namespace Components { public: ModList(); - ~ModList(); static void RunMod(const std::string& mod); diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index a59a00a5..57bfc72f 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -260,20 +260,20 @@ namespace Components } } - Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float value, - float min, float max, int, const char* desc) + Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value, + float min, float max, unsigned __int16 /*flags*/, const char* description) { - Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register(name, value, - min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); + Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register(dvarName, value, + min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description); return Movement::PlayerLastStandCrawlSpeedScale.get(); } - Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* name, float value, - float min, float max, int, const char* desc) + Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, + float min, float max, unsigned __int16 /*flags*/, const char* description) { - Movement::PlayerSpectateSpeedScale = Dvar::Register(name, value, - min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); + Movement::PlayerSpectateSpeedScale = Dvar::Register(dvarName, value, + min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description); return Movement::PlayerSpectateSpeedScale.get(); } @@ -291,36 +291,36 @@ namespace Components }; Movement::PlayerDuckedSpeedScale = Dvar::Register("player_duckedSpeedScale", - 0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The scale applied to the player speed when ducking"); Movement::PlayerProneSpeedScale = Dvar::Register("player_proneSpeedScale", - 0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The scale applied to the player speed when crawling"); // 3arc naming convention Movement::CGUfoScaler = Dvar::Register("cg_ufo_scaler", - 6.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The speed at which ufo camera moves"); Movement::CGNoclipScaler = Dvar::Register("cg_noclip_scaler", - 3.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The speed at which noclip camera moves"); Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces", - bg_bouncesValues, Movement::DISABLED, Game::DVAR_FLAG_REPLICATED, "Bounce glitch settings"); + bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings"); Movement::BGBouncesAllAngles = Dvar::Register("bg_bouncesAllAngles", - false, Game::DVAR_FLAG_REPLICATED, "Force bounce from all angles"); + false, Game::DVAR_CODINFO, "Force bounce from all angles"); Movement::BGRocketJump = Dvar::Register("bg_rocketJump", - false, Game::DVAR_FLAG_REPLICATED, "Enable CoD4 rocket jumps"); + false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps"); Movement::BGPlayerEjection = Dvar::Register("bg_playerEjection", - true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); Movement::BGPlayerCollision = Dvar::Register("bg_playerCollision", - true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); }); // Hook PM_CmdScaleForStance in PM_CmdScale_Walk diff --git a/src/Components/Modules/Movement.hpp b/src/Components/Modules/Movement.hpp index 97243ee2..2b718258 100644 --- a/src/Components/Modules/Movement.hpp +++ b/src/Components/Modules/Movement.hpp @@ -40,7 +40,7 @@ namespace Components static int StuckInClient_Hk(Game::gentity_s* self); static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles); - static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); - static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); + static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); + static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); }; } diff --git a/src/Components/Modules/MusicalTalent.cpp b/src/Components/Modules/MusicalTalent.cpp index 7deef61c..9769fcb6 100644 --- a/src/Components/Modules/MusicalTalent.cpp +++ b/src/Components/Modules/MusicalTalent.cpp @@ -39,9 +39,4 @@ namespace Components MusicalTalent::Replace("music_mainmenu_mp", "hz_t_menumusic.mp3"); } - - MusicalTalent::~MusicalTalent() - { - MusicalTalent::SoundAliasList.clear(); - } } diff --git a/src/Components/Modules/MusicalTalent.hpp b/src/Components/Modules/MusicalTalent.hpp index e5bfc181..9d10d3d9 100644 --- a/src/Components/Modules/MusicalTalent.hpp +++ b/src/Components/Modules/MusicalTalent.hpp @@ -6,7 +6,6 @@ namespace Components { public: MusicalTalent(); - ~MusicalTalent(); static void Replace(const std::string& sound, const char* file); diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 18132d2b..cd573569 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -403,11 +403,4 @@ namespace Components Network::SendRaw(address, address.getString()); }); } - - Network::~Network() - { - Network::SelectedPacket.clear(); - Network::PacketHandlers.clear(); - Network::StartupSignal.clear(); - } } diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index f3248817..f3096350 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -52,7 +52,6 @@ namespace Components typedef void(CallbackRaw)(); Network(); - ~Network(); static unsigned short GetPort(); diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index ae852e51..a377084e 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -39,9 +39,9 @@ namespace Components { if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi? - Dvar::Register("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, ""); + Dvar::Register("g_firstLaunch", true, Game::DVAR_ARCHIVE, ""); - Dvar::Register("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_FLAG_WRITEPROTECTED, "Current version number."); + Dvar::Register("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_WRITEPROTECTED, "Current version number."); UIScript::Add("checkFirstLaunch", [](UIScript::Token) { diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 7aa1584b..50797f93 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -377,7 +377,7 @@ namespace Components Command::Add("addnode", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Node::Add({ params->get(1) }); }); } diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index afa418ad..564ec01b 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -79,7 +79,7 @@ namespace Components Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description) { - return Dvar::Register(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get(); + return Dvar::Register(name, 1, 1, max, Game::dvar_flag::DVAR_WRITEPROTECTED | flag, description).get(); } bool Party::PlaylistAwaiting() @@ -150,8 +150,8 @@ namespace Components Party::Party() { - static Game::dvar_t* partyEnable = Dvar::Register("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get(); - Dvar::Register("xblive_privatematch", true, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED, ""); + static Game::dvar_t* partyEnable = Dvar::Register("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_NONE, "Enable party system").get(); + Dvar::Register("xblive_privatematch", true, Game::dvar_flag::DVAR_WRITEPROTECTED, ""); // various changes to SV_DirectConnect-y stuff to allow non-party joinees Utils::Hook::Set(0x460D96, 0x90E9); @@ -249,19 +249,19 @@ namespace Components Utils::Hook::Set(0x5E3772, "sv_maxclients"); // Unlatch maxclient dvars - Utils::Hook::Xor(0x426187, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4D374E, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x5E376A, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4261A1, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x4D376D, Game::dvar_flag::DVAR_FLAG_LATCHED); - Utils::Hook::Xor(0x5E3789, Game::dvar_flag::DVAR_FLAG_LATCHED); + Utils::Hook::Xor(0x426187, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4D374E, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x5E376A, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4261A1, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x4D376D, Game::dvar_flag::DVAR_LATCH); + Utils::Hook::Xor(0x5E3789, Game::dvar_flag::DVAR_LATCH); // Patch Live_PlayerHasLoopbackAddr //Utils::Hook::Set(0x418F30, 0x90C3C033); Command::Add("connect", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { return; } @@ -513,9 +513,4 @@ namespace Components Friends::UpdateServer(address, info.get("hostname"), info.get("mapname")); }); } - - Party::~Party() - { - Party::LobbyMap.clear(); - } } diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index 974bdc2f..d8f70cf1 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -6,7 +6,6 @@ namespace Components { public: Party(); - ~Party(); static Network::Address Target(); static void Connect(Network::Address target); diff --git a/src/Components/Modules/PlayerName.cpp b/src/Components/Modules/PlayerName.cpp index 793bcc8a..d90cadf7 100644 --- a/src/Components/Modules/PlayerName.cpp +++ b/src/Components/Modules/PlayerName.cpp @@ -61,7 +61,7 @@ namespace Components PlayerName::PlayerName() { - sv_allowColoredNames = Dvar::Register("sv_allowColoredNames", true, Game::dvar_flag::DVAR_FLAG_NONE, "Allow colored names on the server"); + sv_allowColoredNames = Dvar::Register("sv_allowColoredNames", true, Game::dvar_flag::DVAR_NONE, "Allow colored names on the server"); // Disable SV_UpdateUserinfo_f, to block changing the name ingame Utils::Hook::Set(0x6258D0, 0xC3); diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index e413d534..059b80f1 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -21,7 +21,7 @@ namespace Components Dvar::Var("xblive_privateserver").set(false); - std::string playlistFilename = Dvar::Var("playlistFilename").get(); + auto playlistFilename = Dvar::Var("playlistFilename").get(); FileSystem::File playlist(playlistFilename); if (playlist.exists()) @@ -190,11 +190,4 @@ namespace Components Network::Handle("playlistResponse", PlaylistReponse); Network::Handle("playlistInvalidPassword", PlaylistInvalidPassword); } - - Playlist::~Playlist() - { - Playlist::MapRelocation.clear(); - Playlist::CurrentPlaylistBuffer.clear(); - Playlist::ReceivedPlaylistBuffer.clear(); - } } diff --git a/src/Components/Modules/Playlist.hpp b/src/Components/Modules/Playlist.hpp index c586815f..d8e7a8fb 100644 --- a/src/Components/Modules/Playlist.hpp +++ b/src/Components/Modules/Playlist.hpp @@ -8,7 +8,6 @@ namespace Components typedef void(*Callback)(); Playlist(); - ~Playlist(); static void LoadPlaylist(); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 64ab5efe..de055020 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -86,17 +86,15 @@ namespace Components void QuickPatch::SelectStringTableEntryInDvarStub() { - Command::ClientParams args; + Command::ClientParams params; - if (args.length() >= 4) + if (params.size() >= 4) { - std::string cmd = args[0]; - std::string table = args[1]; - std::string col = args[2]; - std::string dvarName = args[3]; - Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data()); + const auto* dvarName = params[3]; + const auto* dvar = Game::Dvar_FindVar(dvarName); - if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY)))) + if (Command::Find(dvarName) || + (dvar != nullptr && dvar->flags & (Game::DVAR_WRITEPROTECTED | Game::DVAR_CHEAT | Game::DVAR_READONLY))) { return; } @@ -238,7 +236,7 @@ namespace Components } } - Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* name, char**, int defaultVal, int flags, const char* description) + Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** /*valueList*/, int defaultIndex, unsigned __int16 flags, const char* description) { static const char* r_aspectRatioEnum[] = { @@ -256,7 +254,7 @@ namespace Components "Screen aspect ratio. Divide the width by the height in order to get the aspect ratio value. For example: 16 / 9 = 1,77"); // register enumeration dvar - return Game::Dvar_RegisterEnum(name, r_aspectRatioEnum, defaultVal, flags, description); + return Game::Dvar_RegisterEnum(dvarName, r_aspectRatioEnum, defaultIndex, flags, description); } void QuickPatch::SetAspectRatio() @@ -353,13 +351,13 @@ namespace Components Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName, float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description) { - return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_FLAG_READONLY, description); + return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_READONLY, description); } QuickPatch::QuickPatch() { - // quit_hard - Command::Add("quit_hard", [](Command::Params*) + // quitHard + Command::Add("quitHard", [](Command::Params*) { int data = false; const Utils::Library ntdll("ntdll.dll"); @@ -374,9 +372,9 @@ namespace Components Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick(); // Intermission time dvar - Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::DVAR_FLAG_REPLICATED | Game::DVAR_FLAG_DEDISAVED, "Time in seconds before match server loads the next map"); + Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_NONE, "Time in seconds before match server loads the next map"); - g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_FLAG_REPLICATED, "Perform antilag"); + g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag"); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick(); @@ -477,7 +475,7 @@ namespace Components // Numerical ping (cg_scoreboardPingText 1) Utils::Hook::Set(0x45888E, 1); - Utils::Hook::Set(0x45888C, Game::dvar_flag::DVAR_FLAG_CHEAT); + Utils::Hook::Set(0x45888C, Game::dvar_flag::DVAR_CHEAT); // increase font sizes for chat on higher resolutions static float float13 = 13.0f; @@ -633,7 +631,7 @@ namespace Components }); // Fix mouse pitch adjustments - Dvar::Register("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); + Dvar::Register("ui_mousePitch", false, Game::DVAR_ARCHIVE, ""); UIScript::Add("updateui_mousePitch", [](UIScript::Token) { if (Dvar::Var("ui_mousePitch").get()) @@ -671,7 +669,7 @@ namespace Components Command::Add("dumptechsets", [](Command::Params* param) { - if (param->length() != 2) + if (param->size() != 2) { Logger::Print("usage: dumptechsets | all\n"); return; @@ -843,6 +841,7 @@ namespace Components } }); +#ifdef DEBUG AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/) { if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD) @@ -857,9 +856,10 @@ namespace Components Utils::IO::WriteFile("userraw/logs/matlog.txt", buffer); } }); +#endif // Dvars - Dvar::Register("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI"); + Dvar::Register("ui_streamFriendly", false, Game::DVAR_ARCHIVE, "Stream friendly UI"); // Debug patches #ifdef DEBUG diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 32c3ed61..6eac85a2 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -28,7 +28,7 @@ namespace Components static void InvalidNameStub(); static Dvar::Var r_customAspectRatio; - static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* name, char** enumValues, int defaultVal, int flags, const char* description); + static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); static void SetAspectRatioStub(); static void SetAspectRatio(); diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..00606dcf 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -7,19 +7,22 @@ namespace Components std::string RCon::Password; + Dvar::Var RCon::RconPassword; + Dvar::Var RCon::RconLogRequests; + RCon::RCon() { Command::Add("rcon", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; - std::string operation = params->get(1); - if (operation == "login") + const auto* operation = params->get(1); + if (std::strcmp(operation, "login") == 0) { - if (params->length() < 3) return; + if (params->size() < 3) return; RCon::Password = params->get(2); } - else if (operation == "logout") + else if (std::strcmp(operation, "logout") == 0) { RCon::Password.clear(); } @@ -75,8 +78,8 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - Dvar::Register("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_NONE, "The password for rcon"); + RCon::RconLogRequests = Dvar::Register("rcon_log_requests", false, Game::dvar_flag::DVAR_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data) @@ -100,7 +103,7 @@ namespace Components password.erase(password.begin()); } - std::string svPassword = Dvar::Var("rcon_password").get(); + const std::string svPassword = RCon::RconPassword.get(); if (svPassword.empty()) { @@ -114,7 +117,7 @@ namespace Components outputBuffer.clear(); #ifndef DEBUG - if (Dvar::Var("log_rcon_requests").get()) + if (RCon::RconLogRequests.get()) #endif { Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); @@ -173,9 +176,4 @@ namespace Components } }); } - - RCon::~RCon() - { - RCon::Password.clear(); - } } diff --git a/src/Components/Modules/RCon.hpp b/src/Components/Modules/RCon.hpp index 1cc486e5..0c0282c6 100644 --- a/src/Components/Modules/RCon.hpp +++ b/src/Components/Modules/RCon.hpp @@ -6,7 +6,6 @@ namespace Components { public: RCon(); - ~RCon(); private: class Container @@ -25,5 +24,8 @@ namespace Components // For sr0's fucking rcon command // Son of a bitch! Annoying me day and night with that shit... static std::string Password; + + static Dvar::Var RconPassword; + static Dvar::Var RconLogRequests; }; } diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index 30489edf..108da3e0 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -24,7 +24,7 @@ namespace Components Command::Add("dumpraw", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Specify a filename!\n"); return; diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index e79472dc..efa91e94 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -546,12 +546,12 @@ namespace Components nullptr }; - Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_FLAG_CHEAT, "Draw scene model bounding boxes"); - Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_FLAG_CHEAT, "Draw scene model collisions"); - Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_FLAG_CHEAT, "Draw triggers"); - Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_FLAG_CHEAT, "Draw all model names"); - Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_FLAG_CHEAT, "Draw aabb trees"); - Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_FLAG_SAVED, "r_draw debug functions draw distance, relative to the player"); + Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_CHEAT, "Draw scene model bounding boxes"); + Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_CHEAT, "Draw scene model collisions"); + Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_CHEAT, "Draw triggers"); + Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_CHEAT, "Draw all model names"); + Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_CHEAT, "Draw aabb trees"); + Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_ARCHIVE, "r_draw debug functions draw distance, relative to the player"); }); } diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index 42b9037c..5dc331a3 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -705,14 +705,6 @@ namespace Components Script::~Script() { - Script::ScriptName.clear(); - Script::ScriptHandles.clear(); - Script::ScriptNameStack.clear(); - Script::ScriptFunctions.clear(); - Script::ReplacedFunctions.clear(); Script::VMShutdownSignal.clear(); - - Script::ScriptStorage.clear(); - Script::ScriptBaseProgramNum.clear(); } } diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 471b32a6..7e54f8a8 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -11,11 +11,11 @@ namespace Components bool ServerCommands::OnServerCommand() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - for (auto &serverCommandCB : ServerCommands::Commands) + for (const auto& serverCommandCB : ServerCommands::Commands) { - if (params.length() >= 1) + if (params.size() >= 1) { if (params.get(0)[0] == serverCommandCB.first) { @@ -65,9 +65,4 @@ namespace Components // Server command receive hook Utils::Hook(0x59449F, ServerCommands::OnServerCommandStub).install()->quick(); } - - ServerCommands::~ServerCommands() - { - ServerCommands::Commands.clear(); - } } diff --git a/src/Components/Modules/ServerCommands.hpp b/src/Components/Modules/ServerCommands.hpp index 8fc22459..61f823a6 100644 --- a/src/Components/Modules/ServerCommands.hpp +++ b/src/Components/Modules/ServerCommands.hpp @@ -6,7 +6,6 @@ namespace Components { public: ServerCommands(); - ~ServerCommands(); static void OnCommand(std::int32_t cmd, Utils::Slot cb); diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 94c3e473..a4e61251 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -734,16 +734,16 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist"); - Dvar::Register("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, "Map of the selected server"); + Dvar::Register("ui_serverSelected", false, Game::dvar_flag::DVAR_NONE, "Whether a server has been selected in the serverlist"); + Dvar::Register("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_NONE, "Map of the selected server"); - Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server queries per frame"); - Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server query frames per second"); + Dvar::Register("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame"); + Dvar::Register("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second"); }); // Fix ui_netsource dvar Utils::Hook::Nop(0x4CDEEC, 5); // Don't reset the netsource when gametypes aren't loaded - Dvar::Register("ui_netSource", 1, 0, 2, Game::DVAR_FLAG_SAVED, reinterpret_cast(0x6D9F08)); + Dvar::Register("ui_netSource", 1, 0, 2, Game::DVAR_ARCHIVE, reinterpret_cast(0x6D9F08)); //Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0"); Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0 (0)"); @@ -782,8 +782,8 @@ namespace Components // Set default masterServerName + port and save it #ifdef USE_LEGACY_SERVER_LIST Utils::Hook::Set(0x60AD92, "127.0.0.1"); - Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_FLAG_SAVED); // masterServerName - Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_FLAG_SAVED); // masterPort + Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName + Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort #endif // Add server list feeder @@ -880,15 +880,8 @@ namespace Components ServerList::~ServerList() { - ServerList::OnlineList.clear(); - ServerList::OfflineList.clear(); - ServerList::FavouriteList.clear(); - ServerList::VisibleList.clear(); - - { - std::lock_guard _(ServerList::RefreshContainer.mutex); - ServerList::RefreshContainer.awatingList = false; - ServerList::RefreshContainer.servers.clear(); - } + std::lock_guard _(ServerList::RefreshContainer.mutex); + ServerList::RefreshContainer.awatingList = false; + ServerList::RefreshContainer.servers.clear(); } } diff --git a/src/Components/Modules/Slowmotion.cpp b/src/Components/Modules/SlowMotion.cpp similarity index 99% rename from src/Components/Modules/Slowmotion.cpp rename to src/Components/Modules/SlowMotion.cpp index ff80ca1f..268a2a0a 100644 --- a/src/Components/Modules/Slowmotion.cpp +++ b/src/Components/Modules/SlowMotion.cpp @@ -91,4 +91,4 @@ namespace Components Utils::Hook(0x4A54ED, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4A54FB, SlowMotion::DrawConnectionInterruptedStub, HOOK_CALL).install()->quick(); } -} \ No newline at end of file +} diff --git a/src/Components/Modules/Slowmotion.hpp b/src/Components/Modules/SlowMotion.hpp similarity index 100% rename from src/Components/Modules/Slowmotion.hpp rename to src/Components/Modules/SlowMotion.hpp diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index 16cf8497..8b9fbe8e 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -9,9 +9,9 @@ namespace Components { Dvar::OnInit([]() { - Dvar::Register("ui_startupMessage", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("ui_startupMessageTitle", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); - Dvar::Register("ui_startupNextButtonText", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); + Dvar::Register("ui_startupMessage", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("ui_startupMessageTitle", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); + Dvar::Register("ui_startupNextButtonText", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, ""); }); UIScript::Add("nextStartupMessage", [](UIScript::Token) @@ -34,11 +34,6 @@ namespace Components }); } - StartupMessages::~StartupMessages() - { - StartupMessages::MessageList.clear(); - } - void StartupMessages::AddMessage(const std::string& message) { StartupMessages::MessageList.push_back(message); diff --git a/src/Components/Modules/StartupMessages.hpp b/src/Components/Modules/StartupMessages.hpp index 6ecf3cbe..7680c77a 100644 --- a/src/Components/Modules/StartupMessages.hpp +++ b/src/Components/Modules/StartupMessages.hpp @@ -6,7 +6,6 @@ namespace Components { public: StartupMessages(); - ~StartupMessages(); static void AddMessage(const std::string& message); diff --git a/src/Components/Modules/Stats.cpp b/src/Components/Modules/Stats.cpp index cdfab8c9..dc807c37 100644 --- a/src/Components/Modules/Stats.cpp +++ b/src/Components/Modules/Stats.cpp @@ -107,9 +107,4 @@ namespace Components // Write stats to mod folder if a mod is loaded Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick(); } - - Stats::~Stats() - { - - } } diff --git a/src/Components/Modules/Stats.hpp b/src/Components/Modules/Stats.hpp index 6fa5be2c..c4de9fd9 100644 --- a/src/Components/Modules/Stats.hpp +++ b/src/Components/Modules/Stats.hpp @@ -6,7 +6,6 @@ namespace Components { public: Stats(); - ~Stats(); static bool IsMaxLevel(); diff --git a/src/Components/Modules/StringTable.cpp b/src/Components/Modules/StringTable.cpp index 3fd00880..8f1d590d 100644 --- a/src/Components/Modules/StringTable.cpp +++ b/src/Components/Modules/StringTable.cpp @@ -76,9 +76,4 @@ namespace Components return header; }); } - - StringTable::~StringTable() - { - StringTable::StringTableMap.clear(); - } } diff --git a/src/Components/Modules/StringTable.hpp b/src/Components/Modules/StringTable.hpp index 21701b24..118cd076 100644 --- a/src/Components/Modules/StringTable.hpp +++ b/src/Components/Modules/StringTable.hpp @@ -6,7 +6,6 @@ namespace Components { public: StringTable(); - ~StringTable(); private: static std::unordered_map StringTableMap; diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index 64e3b375..983ee2e7 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -311,9 +311,4 @@ namespace Components } }); } - - StructuredData::~StructuredData() - { - StructuredData::MemAllocator.clear(); - } } diff --git a/src/Components/Modules/StructuredData.hpp b/src/Components/Modules/StructuredData.hpp index 8c7a6431..3a1b42f2 100644 --- a/src/Components/Modules/StructuredData.hpp +++ b/src/Components/Modules/StructuredData.hpp @@ -24,7 +24,6 @@ namespace Components }; StructuredData(); - ~StructuredData(); private: static bool UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *oldDef); diff --git a/src/Components/Modules/TextRenderer.cpp b/src/Components/Modules/TextRenderer.cpp index e5a26a91..2a11a676 100644 --- a/src/Components/Modules/TextRenderer.cpp +++ b/src/Components/Modules/TextRenderer.cpp @@ -1598,10 +1598,10 @@ namespace Components { currentColorTable = &colorTableDefault; - cg_newColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use Warfare 2 color code style."); - cg_fontIconAutocomplete = Dvar::Register("cg_fontIconAutocomplete", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Show autocomplete for fonticons when typing."); - cg_fontIconAutocompleteHint = Dvar::Register("cg_fontIconAutocompleteHint", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Show hint text in autocomplete for fonticons."); - sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_FLAG_REPLICATED, "Color for the extended color code."); + cg_newColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_ARCHIVE, "Use Warfare 2 color code style."); + cg_fontIconAutocomplete = Dvar::Register("cg_fontIconAutocomplete", true, Game::dvar_flag::DVAR_ARCHIVE, "Show autocomplete for fonticons when typing."); + cg_fontIconAutocompleteHint = Dvar::Register("cg_fontIconAutocompleteHint", true, Game::dvar_flag::DVAR_ARCHIVE, "Show hint text in autocomplete for fonticons."); + sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_CODINFO, "Color for the extended color code."); // Initialize font icons when initializing UI Utils::Hook(0x4B5422, UI_Init_Hk, HOOK_CALL).install()->quick(); @@ -1616,11 +1616,11 @@ namespace Components Utils::Hook(0x417770, ColorIndex, HOOK_JUMP).install()->quick(); // Add a colorblind mode for team colors - r_colorBlind = Dvar::Register("r_colorBlind", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors"); + r_colorBlind = Dvar::Register("r_colorBlind", false, Game::dvar_flag::DVAR_ARCHIVE, "Use color-blindness-friendly colors"); // A dark red - g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Enemy team color for colorblind mode"); + g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Enemy team color for colorblind mode"); // A bright yellow - g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Ally team color for colorblind mode"); + g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Ally team color for colorblind mode"); // Replace team colors with colorblind team colors when colorblind is enabled Utils::Hook(0x406530, GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/Theatre.cpp b/src/Components/Modules/Theatre.cpp index 2e3cdcaa..84a95284 100644 --- a/src/Components/Modules/Theatre.cpp +++ b/src/Components/Modules/Theatre.cpp @@ -342,8 +342,8 @@ namespace Components Theatre::Theatre() { - Dvar::Register("cl_autoRecord", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Automatically record games."); - Dvar::Register("cl_demosKeep", 30, 1, 999, Game::dvar_flag::DVAR_FLAG_SAVED, "How many demos to keep with autorecord."); + Dvar::Register("cl_autoRecord", true, Game::dvar_flag::DVAR_ARCHIVE, "Automatically record games."); + Dvar::Register("cl_demosKeep", 30, 1, 999, Game::dvar_flag::DVAR_ARCHIVE, "How many demos to keep with autorecord."); Utils::Hook(0x5A8370, Theatre::GamestateWriteStub, HOOK_CALL).install()->quick(); Utils::Hook(0x5A85D2, Theatre::RecordGamestateStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/UIFeeder.cpp b/src/Components/Modules/UIFeeder.cpp index ee3032ab..b0e554bf 100644 --- a/src/Components/Modules/UIFeeder.cpp +++ b/src/Components/Modules/UIFeeder.cpp @@ -383,9 +383,9 @@ namespace Components Dvar::OnInit([]() { - Dvar::Register("ui_map_long", "Afghan", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_map_name", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, ""); - Dvar::Register("ui_map_desc", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); + Dvar::Register("ui_map_long", "Afghan", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_map_name", "mp_afghan", Game::dvar_flag::DVAR_NONE, ""); + Dvar::Register("ui_map_desc", "", Game::dvar_flag::DVAR_NONE, ""); }); // Get feeder item count diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index d526c747..e1becfe7 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -37,7 +37,10 @@ namespace Components int Weapon::ParseWeaponConfigStrings() { Command::ClientParams params; - if (params.length() <= 1) return 0; + + if (params.size() <= 1) + return 0; + int index = atoi(params[1]); if (index >= 4139) diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index 2a7b07de..a5669656 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -144,8 +144,8 @@ namespace Components Window::Window() { // Borderless window - Window::NoBorder = Dvar::Register("r_noborder", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Do not use a border in windowed mode"); - Window::NativeCursor = Dvar::Register("ui_nativeCursor", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display native cursor"); + Window::NoBorder = Dvar::Register("r_noborder", true, Game::dvar_flag::DVAR_ARCHIVE, "Do not use a border in windowed mode"); + Window::NativeCursor = Dvar::Register("ui_nativeCursor", false, Game::dvar_flag::DVAR_ARCHIVE, "Display native cursor"); Utils::Hook(0x507643, Window::StyleHookStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index b548ed99..1715ebe7 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1110,7 +1110,7 @@ namespace Components Command::Add("verifyzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; /* Utils::Hook(0x4AE9C2, [] { Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; @@ -1165,7 +1165,7 @@ namespace Components Command::Add("buildzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string zoneName = params->get(1); Logger::Print("Building zone '%s'...\n", zoneName.data()); @@ -1455,7 +1455,7 @@ namespace Components Command::Add("listassets", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XAssetType type = Game::DB_GetXAssetNameType(params->get(1)); if (type != Game::XAssetType::ASSET_TYPE_INVALID) @@ -1470,7 +1470,7 @@ namespace Components Command::Add("loadtempzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; if (FastFiles::Exists(params->get(1))) { @@ -1502,7 +1502,7 @@ namespace Components Command::Add("iwiDump", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string path = Utils::String::VA("%s\\mods\\%s\\images", Dvar::Var("fs_basepath").get(), params->get(1)); std::vector images = FileSystem::GetSysFileList(path, "iwi", false); @@ -1525,7 +1525,7 @@ namespace Components Logger::Print("------------------- END IWI DUMP -------------------\n"); }); - ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register("zb_prefer_disk_assets", false, Game::DVAR_FLAG_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?"); + ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register("zb_prefer_disk_assets", false, Game::DVAR_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?"); } } diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index da24ffeb..24af1db6 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -3696,10 +3696,5 @@ namespace Components Utils::Hook::Set(0x6B9602,0xCCCC); #endif } - - Zones::~Zones() - { - - } } #pragma optimize( "", on ) \ No newline at end of file diff --git a/src/Components/Modules/Zones.hpp b/src/Components/Modules/Zones.hpp index dd1b5df6..615bc450 100644 --- a/src/Components/Modules/Zones.hpp +++ b/src/Components/Modules/Zones.hpp @@ -18,7 +18,6 @@ namespace Components }; Zones(); - ~Zones(); static void SetVersion(int version); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 7bf988a3..95a3c7e9 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -393,13 +393,8 @@ namespace Game XAssetHeader* DB_XAssetPool = reinterpret_cast(0x7998A8); unsigned int* g_poolSize = reinterpret_cast(0x7995E8); - DWORD* cmd_id = reinterpret_cast(0x1AAC5D0); - DWORD* cmd_argc = reinterpret_cast(0x1AAC614); - char*** cmd_argv = reinterpret_cast(0x1AAC634); - - DWORD* cmd_id_sv = reinterpret_cast(0x1ACF8A0); - DWORD* cmd_argc_sv = reinterpret_cast(0x1ACF8E4); - char*** cmd_argv_sv = reinterpret_cast(0x1ACF904); + CmdArgs* cmd_args = reinterpret_cast(0x1AAC5D0); + CmdArgs* sv_cmd_args = reinterpret_cast(0x1ACF8A0); cmd_function_t** cmd_functions = reinterpret_cast(0x1AAC658); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 7975d876..5ec72a9b 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -232,67 +232,67 @@ namespace Game typedef void(__cdecl * DB_XModelSurfsFixup_t)(XModel* model); extern DB_XModelSurfsFixup_t DB_XModelSurfsFixup; - typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool defaultVal, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterBool_t)(const char* dvarName, bool value, unsigned __int16 flags, const char* description); extern Dvar_RegisterBool_t Dvar_RegisterBool; - typedef dvar_t* (__cdecl * Dvar_RegisterFloat_t)(const char* name, float defaultVal, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterFloat_t)(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterFloat_t Dvar_RegisterFloat; - typedef dvar_t* (__cdecl * Dvar_RegisterVec2_t)(const char* name, float defx, float defy, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec2_t)(const char* dvarName, float x, float y, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec2_t Dvar_RegisterVec2; - typedef dvar_t* (__cdecl * Dvar_RegisterVec3_t)(const char* name, float defx, float defy, float defz, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec3_t)(const char* dvarName, float x, float y, float z, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec3_t Dvar_RegisterVec3; - typedef dvar_t* (__cdecl * Dvar_RegisterVec4_t)(const char* name, float defx, float defy, float defz, float defw, float min, float max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterVec4_t)(const char* dvarName, float x, float y, float z, float w, float min, float max, unsigned __int16 flags, const char* description); extern Dvar_RegisterVec4_t Dvar_RegisterVec4; - typedef dvar_t* (__cdecl * Dvar_RegisterInt_t)(const char* name, int defaultVal, int min, int max, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterInt_t)(const char* dvarName, int value, int min, int max, unsigned __int16 flags, const char* description); extern Dvar_RegisterInt_t Dvar_RegisterInt; - typedef dvar_t* (__cdecl * Dvar_RegisterEnum_t)(const char* name, const char** enumValues, int defaultVal, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterEnum_t)(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); extern Dvar_RegisterEnum_t Dvar_RegisterEnum; - typedef dvar_t* (__cdecl * Dvar_RegisterString_t)(const char* name, const char* defaultVal, int, const char*); + typedef dvar_t*(__cdecl * Dvar_RegisterString_t)(const char* dvarName, const char* value, unsigned __int16 flags, const char* description); extern Dvar_RegisterString_t Dvar_RegisterString; - typedef dvar_t* (__cdecl * Dvar_RegisterColor_t)(const char* name, float r, float g, float b, float a, int flags, const char* description); + typedef dvar_t*(__cdecl * Dvar_RegisterColor_t)(const char* dvarName, float r, float g, float b, float a, unsigned __int16 flags, const char* description); extern Dvar_RegisterColor_t Dvar_RegisterColor; typedef void(__cdecl * Dvar_SetFromStringByName_t)(const char* dvarName, const char* string); extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName; - typedef const dvar_t* (__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source); + typedef const dvar_t*(__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* dvarName, const char* string, DvarSetSource source); extern Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource; - typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value); + typedef void(__cdecl * Dvar_SetStringByName_t)(const char* dvarName, const char* value); extern Dvar_SetStringByName_t Dvar_SetStringByName; - typedef void (__cdecl * Dvar_SetString_t)(const dvar_t* cvar, const char* value); + typedef void(__cdecl * Dvar_SetString_t)(const dvar_t* dvar, const char* value); extern Dvar_SetString_t Dvar_SetString; - typedef void (__cdecl * Dvar_SetBool_t)(const dvar_t* cvar, bool enabled); + typedef void(__cdecl * Dvar_SetBool_t)(const dvar_t* dvar, bool enabled); extern Dvar_SetBool_t Dvar_SetBool; - typedef void (__cdecl * Dvar_SetFloat_t)(const dvar_t* cvar, float value); + typedef void(__cdecl * Dvar_SetFloat_t)(const dvar_t* dvar, float value); extern Dvar_SetFloat_t Dvar_SetFloat; - typedef void (__cdecl * Dvar_SetInt_t)(const dvar_t* cvar, int integer); + typedef void(__cdecl * Dvar_SetInt_t)(const dvar_t* dvar, int integer); extern Dvar_SetInt_t Dvar_SetInt; - typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color); + typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* dvarName, float* expandedColor); extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName; - typedef dvar_t* (__cdecl * Dvar_FindVar_t)(const char *dvarName); + typedef dvar_t*(__cdecl * Dvar_FindVar_t)(const char* dvarName); extern Dvar_FindVar_t Dvar_FindVar; - typedef char* (__cdecl * Dvar_InfoString_Big_t)(int bit); + typedef char*(__cdecl * Dvar_InfoString_Big_t)(int bit); extern Dvar_InfoString_Big_t Dvar_InfoString_Big; typedef void(__cdecl * Dvar_SetCommand_t)(const char* dvarName, const char* string); extern Dvar_SetCommand_t Dvar_SetCommand; - typedef const char* (__cdecl * Dvar_DisplayableValue_t)(const dvar_t* cvar); + typedef const char*(__cdecl * Dvar_DisplayableValue_t)(const dvar_t* dvar); extern Dvar_DisplayableValue_t Dvar_DisplayableValue; typedef bool(__cdecl * Encode_Init_t)(const char* ); @@ -930,13 +930,9 @@ namespace Game extern XAssetHeader* DB_XAssetPool; extern unsigned int* g_poolSize; - extern DWORD* cmd_id; - extern DWORD* cmd_argc; - extern char*** cmd_argv; - - extern DWORD* cmd_id_sv; - extern DWORD* cmd_argc_sv; - extern char*** cmd_argv_sv; + constexpr auto CMD_MAX_NESTING = 8; + extern CmdArgs* cmd_args; + extern CmdArgs* sv_cmd_args; extern cmd_function_t** cmd_functions; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index e32dfdca..fd4acc95 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -74,29 +74,27 @@ namespace Game ASSET_TYPE_INVALID = -1, }; - typedef enum : unsigned int + enum dvar_flag : unsigned __int16 { - DVAR_FLAG_NONE = 0x0, //no flags - DVAR_FLAG_SAVED = 0x1, //saves in config_mp.cfg for clients - DVAR_FLAG_LATCHED = 0x2, //no changing apart from initial value (although it might apply on a map reload, I think) - DVAR_FLAG_CHEAT = 0x4, //cheat - DVAR_FLAG_REPLICATED = 0x8, //on change, this is sent to all clients (if you are host) - DVAR_FLAG_UNKNOWN10 = 0x10, //unknown - DVAR_FLAG_UNKNOWN20 = 0x20, //unknown - DVAR_FLAG_UNKNOWN40 = 0x40, //unknown - DVAR_FLAG_UNKNOWN80 = 0x80, //unknown - DVAR_FLAG_USERCREATED = 0x100, //a 'set' type command created it - DVAR_FLAG_USERINFO = 0x200, //userinfo? - DVAR_FLAG_SERVERINFO = 0x400, //in the getstatus oob - DVAR_FLAG_WRITEPROTECTED = 0x800, //write protected - DVAR_FLAG_UNKNOWN1000 = 0x1000, //unknown - DVAR_FLAG_READONLY = 0x2000, //read only (same as 0x800?) - DVAR_FLAG_UNKNOWN4000 = 0x4000, //unknown - DVAR_FLAG_UNKNOWN8000 = 0x8000, //unknown - DVAR_FLAG_UNKNOWN10000 = 0x10000, //unknown - DVAR_FLAG_DEDISAVED = 0x1000000, //unknown - DVAR_FLAG_NONEXISTENT = 0xFFFFFFFF //no such dvar - } dvar_flag; + DVAR_NONE = 0x0, // No flags + DVAR_ARCHIVE = 0x1, // Set to cause it to be saved to config_mp.cfg of the client + DVAR_LATCH = 0x2, // Will only change when C code next does a Dvar_Get(), so it can't be changed + // without proper initialization. Modified will be set, even though the value hasn't changed yet + DVAR_CHEAT = 0x4, // Can not be changed if cheats are disabled + DVAR_CODINFO = 0x8, // On change, this is sent to all clients (if you are host) + DVAR_SCRIPTINFO = 0x10, + DVAR_UNKNOWN20 = 0x20, + DVAR_CHANGEABLE_RESET = 0x40, + DVAR_UNKNOWN80 = 0x80, + DVAR_EXTERNAL = 0x100, // Created by a set command + DVAR_USERINFO = 0x200, // Sent to server on connect or change + DVAR_SERVERINFO = 0x400, // Sent in response to front end requests + DVAR_WRITEPROTECTED = 0x800, + DVAR_SYSTEMINFO = 0x1000, // Will be duplicated on all clients + DVAR_READONLY = 0x2000, // Read only (same as DVAR_WRITEPROTECTED?) + DVAR_SAVED = 0x4000, + DVAR_AUTOEXEC = 0x8000, + }; enum ImageCategory : char { @@ -170,8 +168,8 @@ namespace Game typedef enum { CS_FREE = 0x0, - CS_UNKNOWN1 = 0x1, - CS_UNKNOWN2 = 0x2, + CS_ZOMBIE = 0x1, + CS_RECONNECTING = 0x2, CS_CONNECTED = 0x3, CS_CLIENTLOADING = 0x4, CS_ACTIVE = 0x5, @@ -244,6 +242,17 @@ namespace Game struct MenuEventHandlerSet; struct menuDef_t; + struct CmdArgs + { + int nesting; + int localClientNum[8]; + int controllerIndex[8]; + int argc[8]; + const char** argv[8]; + }; + + static_assert(sizeof(CmdArgs) == 132); + typedef struct cmd_function_s { cmd_function_s *next; @@ -3329,14 +3338,14 @@ namespace Game unsigned int unsignedInt; float value; float vector[4]; - const char *string; + const char* string; unsigned char color[4]; }; struct $BFBB53559BEAC4289F32B924847E59CB { int stringCount; - const char **strings; + const char** strings; }; struct $9CA192F9DB66A3CB7E01DE78A0DEA53D @@ -3361,8 +3370,8 @@ namespace Game struct dvar_t { - const char *name; - const char *description; + const char* name; + const char* description; unsigned int flags; dvar_type type; bool modified; @@ -3370,26 +3379,26 @@ namespace Game DvarValue latched; DvarValue reset; DvarLimits domain; - bool(__cdecl *domainFunc)(dvar_t *, DvarValue); + bool(__cdecl * domainFunc)(dvar_t*, DvarValue); dvar_t *hashNext; }; struct StaticDvar { - dvar_t *dvar; - char *dvarName; + dvar_t* dvar; + char* dvarName; }; struct StaticDvarList { int numStaticDvars; - StaticDvar **staticDvars; + StaticDvar** staticDvars; }; struct StringList { int totalStrings; - const char **strings; + const char** strings; }; struct ExpressionSupportingData diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 4ae48092..bdec22d1 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -54,14 +54,7 @@ #include #pragma comment (lib, "xinput.lib") -// Usefull for debugging -template class Sizer { }; -#define BindNum(x, y) Sizer y; -#define Size_Of(x, y) BindNum(sizeof(x), y) -#define Offset_Of(x, y, z) BindNum(offsetof(x, y), z) - -// Submodules -// Ignore the warnings, it's not our code! +// Ignore the warnings #pragma warning(push) #pragma warning(disable: 4005) #pragma warning(disable: 4091) @@ -79,6 +72,7 @@ template class Sizer { }; #pragma warning(disable: 6258) #pragma warning(disable: 6386) #pragma warning(disable: 6387) +#pragma warning(disable: 26812) #include diff --git a/src/Utils/Library.cpp b/src/Utils/Library.cpp index 0cf9ab67..1b10bf40 100644 --- a/src/Utils/Library.cpp +++ b/src/Utils/Library.cpp @@ -19,15 +19,9 @@ namespace Utils return Library(handle); } - Library::Library(const std::string& buffer, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy) + Library::Library(const std::string& name, bool _freeOnDestroy) : _module(nullptr), freeOnDestroy(_freeOnDestroy) { - this->_module = LoadLibraryExA(buffer.data(), nullptr, 0); - } - - Library::Library(const std::string& buffer) - { - this->_module = GetModuleHandleA(buffer.data()); - this->freeOnDestroy = true; + this->_module = LoadLibraryExA(name.data(), nullptr, 0); } Library::Library(const HMODULE handle) @@ -49,7 +43,7 @@ namespace Utils return this->_module != nullptr; } - HMODULE Library::getModule() + HMODULE Library::getModule() const { return this->_module; } diff --git a/src/Utils/Memory.hpp b/src/Utils/Memory.hpp index f5eb5e50..88bb7007 100644 --- a/src/Utils/Memory.hpp +++ b/src/Utils/Memory.hpp @@ -81,10 +81,12 @@ namespace Utils this->pool.push_back(data); return data; } + template inline T* allocate() { return this->allocateArray(1); } + template inline T* allocateArray(size_t count = 1) { return static_cast(this->allocate(count * sizeof(T))); diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index dd84caca..e17480bf 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -107,9 +107,9 @@ namespace Utils void SetEnvironment() { wchar_t exeName[512]; - GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2); + GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t)); - wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); + auto* exeBaseName = wcsrchr(exeName, L'\\'); exeBaseName[0] = L'\0'; SetCurrentDirectoryW(exeName); From fdc2e0c759ae6fc557de53f43b0904e8ff8d34e9 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 7 Apr 2022 11:47:53 +0200 Subject: [PATCH 51/52] Fix build --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19cd75f0..78b7c4c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,8 +52,8 @@ jobs: with: name: ${{matrix.configuration}} binaries path: | - build/bin/Win32/${{matrix.configuration}}/iw4x.dll - build/bin/Win32/${{matrix.configuration}}/iw4x.pdb + build/bin/${{matrix.configuration}}/iw4x.dll + build/bin/${{matrix.configuration}}/iw4x.pdb # - name: Upload ${{matrix.configuration}} data artifacts # uses: actions/upload-artifact@v2 From f7f74f2cb2c310ff8a0de1abd176fa64313b41fe Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 7 Apr 2022 11:54:28 +0200 Subject: [PATCH 52/52] Fix platform --- .github/workflows/build.yml | 4 ++-- premake5.lua | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78b7c4c3..19cd75f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,8 +52,8 @@ jobs: with: name: ${{matrix.configuration}} binaries path: | - build/bin/${{matrix.configuration}}/iw4x.dll - build/bin/${{matrix.configuration}}/iw4x.pdb + build/bin/Win32/${{matrix.configuration}}/iw4x.dll + build/bin/Win32/${{matrix.configuration}}/iw4x.pdb # - name: Upload ${{matrix.configuration}} data artifacts # uses: actions/upload-artifact@v2 diff --git a/premake5.lua b/premake5.lua index e5771089..93fa8ce9 100644 --- a/premake5.lua +++ b/premake5.lua @@ -216,8 +216,7 @@ workspace "iw4x" startproject "iw4x" location "./build" objdir "%{wks.location}/obj" - targetdir "%{wks.location}/bin/%{cfg.buildcfg}" - buildlog "%{wks.location}/obj/%{cfg.architecture}/%{cfg.buildcfg}/%{prj.name}/%{prj.name}.log" + targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}" configurations {"Debug", "Release"}