Skip to content

Commit 0483fbe

Browse files
committed
Update Hooks.BugFixes.cpp
1 parent da7d1b9 commit 0483fbe

File tree

1 file changed

+49
-12
lines changed

1 file changed

+49
-12
lines changed

src/Misc/Hooks.BugFixes.cpp

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,30 +1968,67 @@ DEFINE_HOOK(0x64D5C5, Game_PreProcessMegaMissionList_CheckForTargetCrdRecal3, 0x
19681968
return pTechno->GetTechnoType()->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix ? SkipTargetCrdRecal : 0;
19691969
}
19701970

1971-
DEFINE_HOOK(0x51BFA2, InfantryClass_IsCellOccupied_Start, 0x6)
1971+
bool __fastcall ShouldSkipCellCheck(FootClass* pThis)
19721972
{
1973-
enum { MoveOK = 0x51C02D };
1974-
GET(InfantryClass*, pThis, EBP);
1975-
return pThis->Type->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix && pThis->IsInAir() ? MoveOK : 0;
1973+
return pThis->GetTechnoType()->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix && pThis->IsInAir();
19761974
}
19771975

1978-
DEFINE_HOOK(0x73F0A7, UnitClass_IsCellOccupied_Start, 0x9)
1976+
DEFINE_NAKED_HOOK(0x51BFA2, InfantryClass_IsCellOccupied_Start)
19791977
{
1980-
enum { MoveOK = 0x73F23F };
1981-
GET(UnitClass*, pThis, ECX);
1982-
return pThis->Type->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix && pThis->IsInAir() ? MoveOK : 0;
1978+
InfantryClass* pThis;
1979+
_asm { mov pThis, ebp }
1980+
_asm { mov esi, ecx }
1981+
if (ShouldSkipCellCheck(pThis))
1982+
{
1983+
_asm { mov eax, 0x51C02D }
1984+
}
1985+
else
1986+
{
1987+
_asm { mov ecx, esi }
1988+
_asm { test [ecx+140h], ebx }
1989+
_asm { mov eax, 0x51BFA8 }
1990+
}
1991+
_asm { jmp eax }
1992+
}
1993+
1994+
DEFINE_NAKED_HOOK(0x73F0A7, UnitClass_IsCellOccupied_Start)
1995+
{
1996+
UnitClass* pThis;
1997+
_asm { mov pThis, ecx }
1998+
if (ShouldSkipCellCheck(pThis))
1999+
{
2000+
_asm { mov eax, 0x73F23F }
2001+
}
2002+
else
2003+
{
2004+
_asm { mov ebx, ecx }
2005+
_asm { mov ecx, [esp+88h] }
2006+
_asm { mov eax, 0x73F0B0 }
2007+
}
2008+
_asm { jmp eax }
19832009
}
19842010

19852011
namespace ApproachTargetContext
19862012
{
19872013
bool IsBalloonHover = false;
19882014
}
19892015

1990-
DEFINE_HOOK(0x4D5690, FootClass_ApproachTarget_SetContext, 0x6)
2016+
bool __fastcall ShouldSetContext(FootClass* pThis)
19912017
{
1992-
GET(FootClass*, pThis, ECX);
1993-
ApproachTargetContext::IsBalloonHover = pThis->GetTechnoType()->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix;
1994-
return 0;
2018+
return pThis->GetTechnoType()->BalloonHover && RulesExt::Global()->BalloonHoverPathingFix;
2019+
}
2020+
2021+
DEFINE_NAKED_HOOK(0x4D5690, FootClass_ApproachTarget_SetContext)
2022+
{
2023+
FootClass* pThis;
2024+
_asm { mov pThis, ecx }
2025+
ShouldSetContext(pThis);
2026+
_asm { mov ApproachTargetContext::IsBalloonHover, al }
2027+
_asm { push ebp }
2028+
_asm { mov ebp, esp }
2029+
_asm { and esp, 0FFFFFFF8h }
2030+
_asm { mov eax, 0x4D5696 }
2031+
_asm { jmp eax }
19952032
}
19962033

19972034
DEFINE_HOOK_AGAIN(0x4D5A42, FootClass_ApproachTarget_ResetContext, 0x5);

0 commit comments

Comments
 (0)