Skip to content

Commit f0c0f4b

Browse files
committed
Optimize the use of GetTechnoType() in 85669c3
1 parent 85669c3 commit f0c0f4b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/Ext/Techno/Hooks.Misc.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,32 +767,34 @@ DEFINE_HOOK(0x70FB73, FootClass_IsBunkerableNow_Dehardcode, 0x6)
767767

768768
DEFINE_HOOK(0x730D1F, DeployCommandClass_Execute_VoiceDeploy, 0x5)
769769
{
770-
GET_STACK(int, unitsToDeploy, STACK_OFFSET(0x18, -0x4));
770+
GET_STACK(const int, unitsToDeploy, STACK_OFFSET(0x18, -0x4));
771771

772772
if (unitsToDeploy != 1)
773773
return 0;
774774

775775
GET(TechnoClass* const, pThis, ESI);
776-
auto const whatAmI = pThis->WhatAmI();
776+
777+
const auto whatAmI = pThis->WhatAmI();
777778

778779
if (whatAmI == AbstractType::Infantry)
779780
{
780-
auto pInfantry = static_cast<InfantryClass*>(pThis);
781+
const auto pInfantry = static_cast<InfantryClass*>(pThis);
781782

782783
if (!pInfantry->IsDeploying)
783784
{
784785
if (pInfantry->IsDeployed())
785-
pThis->QueueVoice(pThis->GetTechnoType()->VoiceUndeploy);
786+
pThis->QueueVoice(pInfantry->Type->VoiceUndeploy);
786787
else
787-
pThis->QueueVoice(pThis->GetTechnoType()->VoiceDeploy);
788+
pThis->QueueVoice(pInfantry->Type->VoiceDeploy);
788789
}
789790
}
790791
else if (whatAmI == AbstractType::Unit)
791792
{
792-
auto pUnit = static_cast<UnitClass*>(pThis);
793+
const auto pUnit = static_cast<UnitClass*>(pThis);
794+
const auto pType = pUnit->Type;
793795

794-
if (pUnit->TryToDeploy() || pUnit->Type->IsSimpleDeployer)
795-
pThis->QueueVoice(pThis->GetTechnoType()->VoiceDeploy);
796+
if (pUnit->TryToDeploy() || pType->IsSimpleDeployer)
797+
pThis->QueueVoice(pType->VoiceDeploy);
796798
}
797799

798800
return 0;

src/Ext/Unit/Hooks.Crushing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <Utilities/Macro.h>
77
#include <Utilities/TemplateDef.h>
88

9-
DEFINE_HOOK(0x073B05B, UnitClass_PerCellProcess_TiltWhenCrushes, 0x6)
9+
DEFINE_HOOK(0x73B05B, UnitClass_PerCellProcess_TiltWhenCrushes, 0x6)
1010
{
1111
enum { SkipGameCode = 0x73B074 };
1212

@@ -22,7 +22,7 @@ DEFINE_HOOK(0x073B05B, UnitClass_PerCellProcess_TiltWhenCrushes, 0x6)
2222
return SkipGameCode;
2323
}
2424

25-
DEFINE_HOOK(0x0741941, UnitClass_OverrunSquare_TiltWhenCrushes, 0x6)
25+
DEFINE_HOOK(0x741941, UnitClass_OverrunSquare_TiltWhenCrushes, 0x6)
2626
{
2727
enum { SkipGameCode = 0x74195E };
2828

@@ -91,7 +91,7 @@ DEFINE_HOOK(0x6A108D, ShipLocomotionClass_WhileMoving_CrushTilt, 0xD)
9191
{
9292
enum { SkipGameCode = 0x6A109A };
9393

94-
GET(DriveLocomotionClass*, pThis, EBP);
94+
GET(ShipLocomotionClass*, pThis, EBP);
9595

9696
auto const pLinkedTo = pThis->LinkedTo;
9797
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pLinkedTo->GetTechnoType());

0 commit comments

Comments
 (0)