Skip to content

Commit 3304f26

Browse files
committed
Try to fix non-functional crashfix (0x000CFCD6)
1 parent ca66c9b commit 3304f26

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

Client/multiplayer_sa/CMultiplayerSA_CrashFixHacks.cpp

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,22 +1572,37 @@ static void __declspec(naked) HOOK_RwMatrixMultiply()
15721572
////////////////////////////////////////////////////////////////////////
15731573
void OnMY_CAnimBlendNode_GetCurrentTranslation(CAnimBlendNodeSAInterface* pInterface)
15741574
{
1575-
// Crash will occur at offset 0xCFCD6
1575+
if (!pInterface)
1576+
return;
1577+
1578+
// Crash will occur at offset 0x000CFCD6
15761579
OnCrashAverted(32);
15771580
CAnimBlendAssociationSAInterface* pAnimAssoc = pInterface->pAnimBlendAssociation;
1578-
CAnimBlendSequenceSAInterface* pAnimSequence = pInterface->pAnimSequence;
1579-
CAnimBlendHierarchySAInterface* pAnimHierarchy = pAnimAssoc->pAnimHierarchy;
1581+
if (!pAnimAssoc)
1582+
return;
1583+
1584+
CAnimBlendSequenceSAInterface* pAnimSequence = pInterface->pAnimSequence;
1585+
if (!pAnimSequence)
1586+
return;
15801587

1581-
bool bSequenceExistsInHierarchy = false;
1582-
CAnimBlendSequenceSAInterface* pAnimHierSequence = pAnimHierarchy->pSequences;
1583-
for (int i = 0; i < pAnimHierarchy->usNumSequences; i++)
1588+
CAnimBlendHierarchySAInterface* pAnimHierarchy = pAnimAssoc->pAnimHierarchy;
1589+
if (!pAnimHierarchy)
1590+
return;
1591+
1592+
bool bSequenceExistsInHierarchy = false;
1593+
1594+
if (pAnimHierarchy->pSequences && pAnimHierarchy->usNumSequences > 0 && pAnimHierarchy->usNumSequences < 1000)
15841595
{
1585-
if (pAnimHierSequence == pAnimSequence)
1596+
CAnimBlendSequenceSAInterface* pAnimHierSequence = pAnimHierarchy->pSequences;
1597+
for (int i = 0; i < pAnimHierarchy->usNumSequences; i++)
15861598
{
1587-
bSequenceExistsInHierarchy = true;
1588-
break;
1599+
if (pAnimHierSequence == pAnimSequence)
1600+
{
1601+
bSequenceExistsInHierarchy = true;
1602+
break;
1603+
}
1604+
pAnimHierSequence++;
15891605
}
1590-
pAnimHierSequence++;
15911606
}
15921607

15931608
LogEvent(588, "GetCurrentTranslation", "Incorrect endKeyFrameIndex",
@@ -1608,30 +1623,30 @@ static void __declspec(naked) HOOK_CAnimBlendNode_GetCurrentTranslation()
16081623
MTA_VERIFY_HOOK_LOCAL_SIZE;
16091624

16101625
__asm
1611-
{
1612-
// if end key frame index is greater than 10,000 then return
1626+
{
1627+
// if end key frame index is greater than 10,000 then return
16131628
cmp eax, 0x2710
16141629
jg altcode
16151630

1631+
// Normal path - execute original code
16161632
push ebx
16171633
mov bl, [edx + 4]
16181634
shr bl, 1
16191635
jmp RETURN_CAnimBlendNode_GetCurrentTranslation
16201636

1621-
// do alternate code
1622-
altcode :
1637+
// Crash prevention path
1638+
altcode:
1639+
// Save registers before logging
16231640
pushad
1624-
push ebp // this
1641+
push ebp // Pass 'this' pointer
16251642
call OnMY_CAnimBlendNode_GetCurrentTranslation
1626-
add esp, 4 * 1
1643+
add esp, 4
16271644
popad
16281645

1629-
pop edi
1630-
pop esi
1631-
pop ebp
1632-
add esp, 18h
1646+
// Return safely without executing original buggy code
1647+
// The function expects 8 bytes of parameters
16331648
retn 8
1634-
}
1649+
}
16351650
}
16361651

16371652
////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)