Remove unused hud icon drawing patches from Material component
This commit is contained in:
parent
539b70d38b
commit
fa40711ee8
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
int Materials::ImageNameLength;
|
|
||||||
Utils::Hook Materials::ImageVersionCheckHook;
|
Utils::Hook Materials::ImageVersionCheckHook;
|
||||||
|
|
||||||
std::vector<Game::GfxImage*> Materials::ImageTable;
|
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)
|
int Materials::WriteDeathMessageIcon(char* string, int offset, Game::Material* material)
|
||||||
{
|
{
|
||||||
if (!material)
|
if (!material)
|
||||||
@ -293,18 +232,9 @@ namespace Components
|
|||||||
|
|
||||||
Materials::Materials()
|
Materials::Materials()
|
||||||
{
|
{
|
||||||
Materials::ImageNameLength = 7;
|
|
||||||
|
|
||||||
// Allow codo images
|
// Allow codo images
|
||||||
Materials::ImageVersionCheckHook.initialize(0x53A456, Materials::ImageVersionCheck, HOOK_CALL)->install();
|
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
|
// Adapt death message to IW5 material format
|
||||||
Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
|
@ -21,15 +21,10 @@ namespace Components
|
|||||||
private:
|
private:
|
||||||
static std::vector<Game::GfxImage*> ImageTable;
|
static std::vector<Game::GfxImage*> ImageTable;
|
||||||
static std::vector<Game::Material*> MaterialTable;
|
static std::vector<Game::Material*> MaterialTable;
|
||||||
static int ImageNameLength;
|
|
||||||
|
|
||||||
static Utils::Hook ImageVersionCheckHook;
|
static Utils::Hook ImageVersionCheckHook;
|
||||||
static void ImageVersionCheck();
|
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 int WriteDeathMessageIcon(char* string, int offset, Game::Material* material);
|
||||||
static void DeathMessageStub();
|
static void DeathMessageStub();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user