Skip to content

Commit 2938be7

Browse files
committed
Optimize GetTechnoType
1 parent ae15a03 commit 2938be7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Ext/Techno/Hooks.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
#include <Utilities/AresHelper.h>
1818
#include <Utilities/AresFunctions.h>
1919

20+
#pragma region GetTechnoType
21+
22+
// Avoid secondary jump
23+
DEFINE_JUMP(VTABLE, 0x7E2328, 0x41C200) // AircraftClass_GetTechnoType -> AircraftClass_GetType
24+
DEFINE_JUMP(VTABLE, 0x7E3F40, 0x459EE0) // BuildingClass_GetTechnoType -> BuildingClass_GetType
25+
DEFINE_JUMP(VTABLE, 0x7EB0DC, 0x51FAF0) // InfantryClass_GetTechnoType -> InfantryClass_GetType
26+
DEFINE_JUMP(VTABLE, 0x7F5CF4, 0x741490) // UnitClass_GetTechnoType -> UnitClass_GetType
27+
28+
#pragma endregion
29+
2030
#pragma region Update
2131

2232
// Early, before ObjectClass_AI

src/Ext/TechnoType/Body.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ TechnoTypeClass* TechnoTypeExt::GetTechnoType(ObjectTypeClass* pType)
195195
UnitType = 0x7F6218,
196196
};
197197
auto const vtThis = static_cast<IUnknownVtbl>(VTable::Get(pType));
198-
if (vtThis == IUnknownVtbl::AircraftType ||
199-
vtThis == IUnknownVtbl::BuildingType ||
200-
vtThis == IUnknownVtbl::InfantryType ||
201-
vtThis == IUnknownVtbl::UnitType)
198+
if (vtThis == IUnknownVtbl::InfantryType
199+
|| vtThis == IUnknownVtbl::UnitType
200+
|| vtThis == IUnknownVtbl::AircraftType
201+
|| vtThis == IUnknownVtbl::BuildingType)
202202
{
203203
return static_cast<TechnoTypeClass*>(pType);
204204
}

0 commit comments

Comments
 (0)