File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1010
1111#include " StdInc.h"
1212#include " CColStoreSA.h"
13+ #include " CGameSA.h"
14+
15+ extern CGameSA* pGame;
1316
1417void CColStoreSA::Initialise ()
1518{
@@ -55,6 +58,22 @@ void CColStoreSA::AddCollisionNeededAtPosition(const CVector& position)
5558
5659void 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);
You can’t perform that action at this time.
0 commit comments