diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index f7c8f5ca..bd284e8c 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -386,7 +386,7 @@ namespace Components { if (Components::Weapon::GModelIndexHasBeenReallocated) { - model = Components::Weapon::G_ModelIndexReallocated[ent->model]; + model = Components::Weapon::cached_models_reallocated[ent->model]; } else { diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index cde7379a..e8a7ded9 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -298,20 +298,6 @@ namespace Components return Game::Dvar_RegisterBool(dvarName, value_, flags, description); } - void DObjCalcAnim(Game::DObj *a1, int *partBits, Game::XAnimCalcAnimInfo *a3) - { - printf(""); - - if (a1->models[0]->name == "body_urban_civ_female_a"s) - { - printf(""); - } - - Utils::Hook::Call(0x49E230)(a1, partBits, a3); - - printf(""); - } - QuickPatch::QuickPatch() { // Filtering any mapents that is intended for Spec:Ops gamemode (CODO) and prevent them from spawning diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 8df1b33f..191b82f5 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -713,32 +713,6 @@ namespace Components return result; } - void DebugTest() - { - //auto clientNum = Game::CG_GetClientNum(); - //auto* clientEntity = &Game::g_entities[clientNum]; - - //// Ingame only & player only - //if (!Game::CL_IsCgameInitialized() || clientEntity->client == nullptr) - //{ - // return; - //} - - - //static std::string str = ""; - - //str += std::format("\n{} => {} {} {} {} {} {}", "s.partBits", clientEntity->s.partBits[0], clientEntity->s.partBits[1], clientEntity->s.partBits[2], clientEntity->s.partBits[3], clientEntity->s.partBits[4], clientEntity->s.partBits[5]); - // - - //const auto clientNumber = clientEntity->r.ownerNum.number; - //Game::scene->sceneDObj[clientNumber].obj->hidePartBits; - - //str += std::format("\n{} => {} {} {} {} {} {}", "DOBJ hidePartBits", clientEntity->s.partBits[0], clientEntity->s.partBits[1], clientEntity->s.partBits[2], clientEntity->s.partBits[3], clientEntity->s.partBits[4], clientEntity->s.partBits[5]); - - //Game::R_AddCmdDrawText(); - - } - Renderer::Renderer() { if (Dedicated::IsEnabled()) return; @@ -757,7 +731,6 @@ namespace Components ListSamplers(); DrawPrimaryLights(); DebugDrawClipmap(); - DebugTest(); } }, Scheduler::Pipeline::RENDERER); diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index 5f3fd9f0..0413fd9d 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -6,9 +6,18 @@ namespace Components { const Game::dvar_t* Weapon::BGWeaponOffHandFix; - Game::XModel* Weapon::G_ModelIndexReallocated[G_MODELINDEX_LIMIT]; + Game::XModel* Weapon::cached_models_reallocated[G_MODELINDEX_LIMIT]; bool Weapon::GModelIndexHasBeenReallocated; + // Config strings mapping + // 0-1067 unknown + // 1125-1580 cached models (512 long range) + // 1581-1637 also reserved for models? + // 1637-4082 unknown + // 4082-above = bad index? + // 4137 : timescale + // 4138-above = reserved for weapons? + Game::WeaponCompleteDef* Weapon::LoadWeaponCompleteDef(const char* name) { if (auto* rawWeaponFile = Game::BG_LoadWeaponCompleteDefInternal("mp", name)) @@ -22,7 +31,7 @@ namespace Components const char* Weapon::GetWeaponConfigString(int index) { - if (index >= (1200 + 2804)) index += (2939 - 2804); + if (index >= (BASEGAME_WEAPON_LIMIT + 2804)) index += (2939 - 2804); return Game::CL_GetConfigString(index); } @@ -34,7 +43,7 @@ namespace Components { for (unsigned int i = 1; i < Game::BG_GetNumWeapons(); ++i) { - Game::SV_SetConfigstring(i + (i >= 1200 ? 2939 : 2804), Game::BG_GetWeaponName(i)); + Game::SV_SetConfigstring(i + (i >= BASEGAME_WEAPON_LIMIT ? 2939 : 2804), Game::BG_GetWeaponName(i)); } } } @@ -57,12 +66,14 @@ namespace Components return 0; } - if (index >= 4139) + if (index >= BASEGAME_MAX_CONFIGSTRINGS) { + // if above 4139, remap to 1200<>? index -= 2939; } - else if (index > 2804 && index <= 2804 + 1200) + else if (index > 2804 && index <= 2804 + BASEGAME_WEAPON_LIMIT) { + // from 2804 to 4004, remap to 0<>1200 index -= 2804; } else @@ -283,8 +294,8 @@ namespace Components // And http://reverseengineering.stackexchange.com/questions/1397/how-can-i-reverse-optimized-integer-division-modulo-by-constant-operations // The game's magic number is computed using this formula: (1 / 1200) * (2 ^ (32 + 7) // I'm too lazy to generate the new magic number, so we can make use of the fact that using powers of 2 as scales allows to change the compensating shift - static_assert(((WEAPON_LIMIT / 1200) * 1200) == WEAPON_LIMIT && (WEAPON_LIMIT / 1200) != 0 && !((WEAPON_LIMIT / 1200) & ((WEAPON_LIMIT / 1200) - 1)), "WEAPON_LIMIT / 1200 is not a power of 2!"); - const unsigned char compensation = 7 + static_cast(log2(WEAPON_LIMIT / 1200)); // 7 is the compensation the game uses + static_assert(((WEAPON_LIMIT / BASEGAME_WEAPON_LIMIT) * BASEGAME_WEAPON_LIMIT) == WEAPON_LIMIT && (WEAPON_LIMIT / BASEGAME_WEAPON_LIMIT) != 0 && !((WEAPON_LIMIT / BASEGAME_WEAPON_LIMIT) & ((WEAPON_LIMIT / BASEGAME_WEAPON_LIMIT) - 1)), "WEAPON_LIMIT / 1200 is not a power of 2!"); + const unsigned char compensation = 7 + static_cast(log2(WEAPON_LIMIT / BASEGAME_WEAPON_LIMIT)); // 7 is the compensation the game uses Utils::Hook::Set(0x49263D, compensation); Utils::Hook::Set(0x5E250C, compensation); Utils::Hook::Set(0x5E2B43, compensation); @@ -407,46 +418,46 @@ namespace Components // Patch bg_weaponDefs on the stack Utils::Hook::Set(0x40C31D, sizeof(bg_weaponDefs)); Utils::Hook::Set(0x40C32F, sizeof(bg_weaponDefs)); - Utils::Hook::Set(0x40C311, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C45F, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C478, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C434, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C434, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); + Utils::Hook::Set(0x40C311, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C45F, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C478, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C434, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C434, 0x258C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); // Move second buffer pointers - Utils::Hook::Set(0x40C336, 0x12E4 + ((sizeof(bg_weaponDefs)) - (1200 * 4))); - Utils::Hook::Set(0x40C3C6, 0x12DC + ((sizeof(bg_weaponDefs)) - (1200 * 4))); - Utils::Hook::Set(0x40C3CE, 0x12DC + ((sizeof(bg_weaponDefs)) - (1200 * 4))); + Utils::Hook::Set(0x40C336, 0x12E4 + ((sizeof(bg_weaponDefs)) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x40C3C6, 0x12DC + ((sizeof(bg_weaponDefs)) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x40C3CE, 0x12DC + ((sizeof(bg_weaponDefs)) - (BASEGAME_WEAPON_LIMIT * 4))); // Move arg0 pointers - Utils::Hook::Set(0x40C365, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C44E, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); - Utils::Hook::Set(0x40C467, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); + Utils::Hook::Set(0x40C365, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C44E, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); + Utils::Hook::Set(0x40C467, 0x259C + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); // Move arg4 pointers - Utils::Hook::Set(0x40C344, 0x25B4 + ((sizeof(bg_weaponDefs) * 2) - (1200 * 4 * 2))); + Utils::Hook::Set(0x40C344, 0x25B4 + ((sizeof(bg_weaponDefs) * 2) - (BASEGAME_WEAPON_LIMIT * 4 * 2))); // Patch bg_sharedAmmoCaps on the stack Utils::Hook::Set(0x4F76E6, sizeof(bg_sharedAmmoCaps)); - Utils::Hook::Set(0x4F7621, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); - Utils::Hook::Set(0x4F76AF, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); - Utils::Hook::Set(0x4F76DA, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); - Utils::Hook::Set(0x4F77C5, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); + Utils::Hook::Set(0x4F7621, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x4F76AF, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x4F76DA, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x4F77C5, 0x12C8 + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); // Move arg0 pointers - Utils::Hook::Set(0x4F766D, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); - Utils::Hook::Set(0x4F76B7, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); - Utils::Hook::Set(0x4F76FB, 0x12EC + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); + Utils::Hook::Set(0x4F766D, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x4F76B7, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); + Utils::Hook::Set(0x4F76FB, 0x12EC + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); // Move arg4 pointers - Utils::Hook::Set(0x4F7630, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (1200 * 4))); + Utils::Hook::Set(0x4F7630, 0x12DC + (sizeof(bg_sharedAmmoCaps) - (BASEGAME_WEAPON_LIMIT * 4))); // Reallocate G_ModelIndex - Utils::Hook::Set(0x420654 + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x43BCE4 + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x44F27B + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x479087 + 1, G_ModelIndexReallocated); - Utils::Hook::Set(0x48069D + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x48F088 + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x4F457C + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x5FC762 + 3, G_ModelIndexReallocated); - Utils::Hook::Set(0x5FC7BE + 3, G_ModelIndexReallocated); + Utils::Hook::Set(0x420654 + 3, cached_models_reallocated); + Utils::Hook::Set(0x43BCE4 + 3, cached_models_reallocated); + Utils::Hook::Set(0x44F27B + 3, cached_models_reallocated); + Utils::Hook::Set(0x479087 + 1, cached_models_reallocated); + Utils::Hook::Set(0x48069D + 3, cached_models_reallocated); + Utils::Hook::Set(0x48F088 + 3, cached_models_reallocated); + Utils::Hook::Set(0x4F457C + 3, cached_models_reallocated); + Utils::Hook::Set(0x5FC762 + 3, cached_models_reallocated); + Utils::Hook::Set(0x5FC7BE + 3, cached_models_reallocated); Utils::Hook::Set(0x44F256 + 2, G_MODELINDEX_LIMIT); GModelIndexHasBeenReallocated = true; diff --git a/src/Components/Modules/Weapon.hpp b/src/Components/Modules/Weapon.hpp index 60c17c60..3065a1e0 100644 --- a/src/Components/Modules/Weapon.hpp +++ b/src/Components/Modules/Weapon.hpp @@ -1,14 +1,16 @@ #pragma once +#define BASEGAME_WEAPON_LIMIT 1200 +#define BASEGAME_MAX_CONFIGSTRINGS 4139 + // Increase the weapon limit -// Was 1200 before #define WEAPON_LIMIT 2400 -#define MAX_CONFIGSTRINGS (4139 - 1200 + WEAPON_LIMIT) +#define MAX_CONFIGSTRINGS (BASEGAME_MAX_CONFIGSTRINGS - BASEGAME_WEAPON_LIMIT + WEAPON_LIMIT) // Double the limit to allow loading of some heavy-duty MW3 maps #define ADDITIONAL_GMODELS 512 -#define G_MODELINDEX_LIMIT (512 + WEAPON_LIMIT - 1200 + ADDITIONAL_GMODELS) +#define G_MODELINDEX_LIMIT (512 + WEAPON_LIMIT - BASEGAME_WEAPON_LIMIT + ADDITIONAL_GMODELS) namespace Components { @@ -16,7 +18,7 @@ namespace Components { public: Weapon(); - static Game::XModel* G_ModelIndexReallocated[G_MODELINDEX_LIMIT]; + static Game::XModel* cached_models_reallocated[G_MODELINDEX_LIMIT]; static bool GModelIndexHasBeenReallocated; diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index 248723ff..c4710b4a 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -276,8 +276,6 @@ namespace Steam void Proxy::RunFrame() { - return; - std::lock_guard _(Proxy::CallMutex); if (Proxy::SteamUtils)