Skip to content

Commit

Permalink
- restored calling OnRegister for event handlers after loading a save…
Browse files Browse the repository at this point in the history
…game

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!!!
  • Loading branch information
coelckers committed Mar 26, 2019
1 parent ddc67fb commit 0422f40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/events.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/events.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/p_saveg.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit 0422f40

Please sign in to comment.