Remove unused hud icon drawing patches from Material component

This commit is contained in:
Jan 2021-09-12 15:46:47 +02:00
parent 539b70d38b
commit fa40711ee8
2 changed files with 0 additions and 75 deletions

View File

@ -2,7 +2,6 @@
namespace Components
{
int Materials::ImageNameLength;
Utils::Hook Materials::ImageVersionCheckHook;
std::vector<Game::GfxImage*> 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<unsigned int>(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();

View File

@ -21,15 +21,10 @@ namespace Components
private:
static std::vector<Game::GfxImage*> ImageTable;
static std::vector<Game::Material*> 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();