Open Freeeaky opened 9 years ago
I've been asked about this innumerable times. Can ye provide some insight into this issue, or where to start digging?
It feels like GTALua simply loses its tick/hook, which likely means the game mem has shifted and somehow GTALua did not pick up on this fact and re-register with scripthook?
What exactly happens when you load a save?
Repro steps:
void GTALua::UpdateLoop()
{
while (m_bActive)
{
Update();
}
}
However, comparing this to scripthookvdotnet, it appears what is lacking is 'What to do after m_bActive is no longer active'.
void ScriptMain()
{
// Set up fibers
sGameReloaded = true;
sMainFib = GetCurrentFiber();
if (sScriptFib == nullptr)
{
const auto callback = [](LPVOID)
{
while (ManagedInit())
{
sGameReloaded = false;
// Run main loop
while (!sGameReloaded && ManagedTick())
{
// Switch back to main script fiber used by Script Hook
SwitchToFiber(sMainFib);
}
}
};
// Create our own fiber for the common language runtime once
sScriptFib = CreateFiber(0, callback, nullptr);
}
while (true)
{
// Yield execution
scriptWait(0);
// Switch to our own fiber and wait for it to switch back
SwitchToFiber(sScriptFib);
}
}
BOOL WINAPI DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
scriptRegister(hModule, &ScriptMain);
keyboardHandlerRegister(&ScriptKeyboardMessage);
break;
case DLL_PROCESS_DETACH:
DeleteFiber(sScriptFib);
scriptUnregister(hModule);
keyboardHandlerUnregister(&ScriptKeyboardMessage);
break;
}
I agree, it's probably related to not using scriptUnregister properly. Try finding out when m_bActive is false.
void GTALua::UpdateLoop() { while (m_bActive) { Update(); } MessageBox(0, "m_bActive is false", 0, 0); }
for example
void GTALua::UpdateLoop()
{
while(m_bActive)
{
Update();
}
printf("m_bActive == false\n");
}
That's interesting, i'll try looking into it too.
Reported by Baaa, IRC