Skip to content

Commit d2ef262

Browse files
committed
Fix SA crash @ 0x001619EF
1 parent 3308359 commit d2ef262

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Client/game_sa/CColStoreSA.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
#include "StdInc.h"
1212
#include "CColStoreSA.h"
13+
#include "CGameSA.h"
14+
15+
extern CGameSA* pGame;
1316

1417
void CColStoreSA::Initialise()
1518
{
@@ -55,6 +58,22 @@ void CColStoreSA::AddCollisionNeededAtPosition(const CVector& position)
5558

5659
void CColStoreSA::EnsureCollisionIsInMemory(const CVector& position)
5760
{
61+
// Wait for GTA to complete initialization before calling collision functions
62+
// Race condition: MTA can trigger streaming/collision operations before GTA completes initialization.
63+
// GTA calls CTimer::Initialise at 0x53BDE6 during startup, which sets _timerFunction at 0x56189E.
64+
// If called before GTA reaches GS_INIT_PLAYING_GAME, the timer isn't initialized > crash at 0x5619E9 (CTimer::Suspend)
65+
66+
if (!pGame || pGame->GetSystemState() < SystemState::GS_INIT_PLAYING_GAME)
67+
return; // GTA not ready yet - skip (will retry on next streaming update)
68+
69+
// Just in case
70+
constexpr auto ADDR_timerFunction = 0xB7CB28;
71+
const auto timerFunction = *reinterpret_cast<void* const*>(ADDR_timerFunction);
72+
if (!timerFunction)
73+
return; // Timer not initialized yet - skip
74+
75+
// SA function signature: void __cdecl CColStore::EnsureCollisionIsInMemory(const CVector2D&)
76+
// CVector implicitly converts to CVector2D (uses x, y components only)
5877
using Signature = void(__cdecl*)(const CVector&);
5978
const auto function = reinterpret_cast<Signature>(0x410AD0);
6079
function(position);

0 commit comments

Comments
 (0)