Skip to content

Commit e8b6966

Browse files
committed
Fix SA crash at 0x000CEA92 (0x4CEA92, CAnimBlendAssociation::SetCurrentTime)
1 parent 3466e0f commit e8b6966

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Client/multiplayer_sa/CMultiplayerSA_CrashFixHacks.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,40 @@ static void __declspec(naked) HOOK_CrashFix_Misc30()
10131013
}
10141014
}
10151015

1016+
////////////////////////////////////////////////////////////////////////
1017+
// CAnimBlendAssociation::SetCurrentTime
1018+
//
1019+
// "this" is invalid
1020+
////////////////////////////////////////////////////////////////////////
1021+
#define HOOKPOS_CrashFix_Misc32 0x4CEA80
1022+
#define HOOKSIZE_CrashFix_Misc32 8
1023+
DWORD RETURN_CrashFix_Misc32 = 0x4CEA88;
1024+
1025+
void _declspec(naked) HOOK_CrashFix_Misc32()
1026+
{
1027+
_asm
1028+
{
1029+
test ecx, ecx
1030+
jz cont
1031+
1032+
// Check hierarchy pointer (offset 0x14)
1033+
// We can use eax as scratch because it gets overwritten by the first replaced instruction anyway
1034+
mov eax, [ecx+14h]
1035+
test eax, eax
1036+
jz cont
1037+
1038+
// Execute replaced code
1039+
mov eax, [esp+4]
1040+
fld dword ptr [esp+4]
1041+
jmp RETURN_CrashFix_Misc32
1042+
1043+
cont:
1044+
push 32
1045+
call CrashAverted
1046+
retn 4
1047+
}
1048+
}
1049+
10161050
////////////////////////////////////////////////////////////////////////
10171051
// CClumpModelInfo::GetFrameFromId
10181052
//
@@ -2225,6 +2259,7 @@ void CMultiplayerSA::InitHooks_CrashFixHacks()
22252259
EZHookInstall(CrashFix_Misc28);
22262260
EZHookInstall(CrashFix_Misc29);
22272261
EZHookInstallChecked(CrashFix_Misc30);
2262+
EZHookInstall(CrashFix_Misc32);
22282263
EZHookInstall(CClumpModelInfo_GetFrameFromId);
22292264
EZHookInstallChecked(CEntity_GetBoundRect);
22302265
EZHookInstallChecked(CVehicle_AddUpgrade);

0 commit comments

Comments
 (0)