From fa40711ee86e985650f08db06efa19fc8e7800e9 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 12 Sep 2021 15:46:47 +0200 Subject: [PATCH] Remove unused hud icon drawing patches from Material component --- src/Components/Modules/Materials.cpp | 70 ---------------------------- src/Components/Modules/Materials.hpp | 5 -- 2 files changed, 75 deletions(-) diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index d7959909..9fdd7f96 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -2,7 +2,6 @@ namespace Components { - int Materials::ImageNameLength; Utils::Hook Materials::ImageVersionCheckHook; std::vector Materials::ImageTable; @@ -151,66 +150,6 @@ namespace Components } } - Game::Material* Materials::ResolveMaterial(const char* stringPtr) - { - const char* imagePtr = stringPtr + 4; - unsigned int length = static_cast(stringPtr[3] & 0xFF); - - if (strlen(imagePtr) >= length) - { - Materials::ImageNameLength = 4 + length; - std::string image(imagePtr, length); - - auto* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material; - - if(material == nullptr || material->techniqueSet == nullptr || material->techniqueSet->name == nullptr || strcmp(material->techniqueSet->name, "2d") != 0) - return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material; - - return material; - } - - Materials::ImageNameLength = 4; - return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material; - } - - __declspec(naked) void Materials::PostDrawMaterialStub() - { - __asm - { - mov eax, Materials::ImageNameLength - add [esp + 30h], eax - - mov eax, 5358FFh - jmp eax - } - } - - __declspec(naked) void Materials::DrawMaterialStub() - { - __asm - { - push eax - pushad - - push ecx - call Materials::ResolveMaterial - add esp, 4h - - mov [esp + 20h], eax - - // Make all material text icons have white tint - mov eax,[esp + 0x50] - or eax,0x00FFFFFF - mov [esp + 0x50],eax - - popad - pop eax - - push 5310F0h - retn - } - } - int Materials::WriteDeathMessageIcon(char* string, int offset, Game::Material* material) { if (!material) @@ -293,18 +232,9 @@ namespace Components Materials::Materials() { - Materials::ImageNameLength = 7; - // Allow codo images Materials::ImageVersionCheckHook.initialize(0x53A456, Materials::ImageVersionCheck, HOOK_CALL)->install(); - // Fix material pointer exploit - // Also make all material text icons have white tint - Utils::Hook(0x534E0C, Materials::DrawMaterialStub, HOOK_CALL).install()->quick(); - - // Increment string pointer accordingly - Utils::Hook(0x5358FA, Materials::PostDrawMaterialStub, HOOK_JUMP).install()->quick(); - // Adapt death message to IW5 material format Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).install()->quick(); diff --git a/src/Components/Modules/Materials.hpp b/src/Components/Modules/Materials.hpp index 2a2d55dd..38388ae6 100644 --- a/src/Components/Modules/Materials.hpp +++ b/src/Components/Modules/Materials.hpp @@ -21,15 +21,10 @@ namespace Components private: static std::vector ImageTable; static std::vector MaterialTable; - static int ImageNameLength; static Utils::Hook ImageVersionCheckHook; static void ImageVersionCheck(); - static Game::Material* ResolveMaterial(const char* stringPtr); - static void DrawMaterialStub(); - static void PostDrawMaterialStub(); - static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material); static void DeathMessageStub();