- restored calling OnRegister for event handlers after loading a savegame

It should be said in no uncertain terms that OnRegister operates on an uninitialized level so it should only be used for setting up the registering process of the event handler itself and nothing else - not even the event handler's data!!!
This commit is contained in:
Christoph Oelckers 2019-03-26 17:02:40 +01:00
parent ddc67fb1bc
commit 0422f40d80
3 changed files with 10 additions and 0 deletions

View file

@ -46,6 +46,13 @@
EventManager staticEventManager;
EventManager eventManager;
void EventManager::CallOnRegister()
{
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
{
handler->OnRegister();
}
}
bool EventManager::RegisterHandler(DStaticEventHandler* handler)
{

View file

@ -240,6 +240,8 @@ struct EventManager
~EventManager() { Shutdown(); }
bool ShouldCallStatic(bool forplay);
// for use after loading a savegame. The old handler explicitly reinstalled all handlers instead of doing a list deserialization which resulted in OnRegister being called even when a save was loaded.
void CallOnRegister();
// register
bool RegisterHandler(DStaticEventHandler* handler);
// unregister

View file

@ -994,6 +994,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
// [ZZ] serialize events
arc("firstevent", localEventManager->FirstEventHandler)
("lastevent", localEventManager->LastEventHandler);
localEventManager->CallOnRegister();
Thinkers.SerializeThinkers(arc, hubload);
arc("polyobjs", Polyobjects);
SerializeSubsectors(arc, "subsectors");