Prevent clearing the event command list if the event system is not initialized

This fixes the issue where the game could crash (especially in optimized release) due to a memory corruption, because the event command list was deconstructed earlier
This commit is contained in:
smallmodel 2024-10-15 20:52:53 +02:00 committed by GitHub
parent ddbdcc91dd
commit 581585a47c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -533,6 +533,13 @@ void ScriptMaster::InitConstStrings(void)
AddString(ConstStrings[i]); AddString(ConstStrings[i]);
} }
if (!Listener::EventSystemStarted) {
// Added in OPM
// This usually means the game module is getting destroyed
// most often, the event command list has been destroyed earlier
return;
}
Event::normalCommandList.clear(); Event::normalCommandList.clear();
Event::returnCommandList.clear(); Event::returnCommandList.clear();
Event::getterCommandList.clear(); Event::getterCommandList.clear();

View file

@ -612,6 +612,12 @@ void L_ShutdownEvents(void)
Event::commandList.clear(); Event::commandList.clear();
Event::eventDefList.clear(); Event::eventDefList.clear();
#ifdef WITH_SCRIPT_ENGINE
Event::normalCommandList.clear();
Event::returnCommandList.clear();
Event::getterCommandList.clear();
Event::setterCommandList.clear();
#endif
Listener::EventSystemStarted = false; Listener::EventSystemStarted = false;
} }