Navigation Menu

Skip to content

Commit

Permalink
- fixed: The static event manager never got a link to the primary level.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Feb 6, 2019
1 parent 37a7947 commit f38060d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/events.cpp
Expand Up @@ -217,14 +217,15 @@ void EventManager::InitHandler(PClass* type)
RegisterHandler(handler);
}

void EventManager::InitStaticHandlers(bool map)
void EventManager::InitStaticHandlers(FLevelLocals *l, bool map)
{
// don't initialize map handlers if restoring from savegame.
if (savegamerestore)
return;

// just make sure
Shutdown();
Level = l;

// initialize event handlers from gameinfo
for (const FString& typeName : gameinfo.EventHandlers)
Expand All @@ -241,7 +242,7 @@ void EventManager::InitStaticHandlers(bool map)
return;

// initialize event handlers from mapinfo
for (const FString& typeName : level.info->EventHandlers)
for (const FString& typeName : Level->info->EventHandlers)
{
PClass* type = GetHandlerClass(typeName);
if (IsStaticType(type))
Expand Down
2 changes: 1 addition & 1 deletion src/events.h
Expand Up @@ -249,7 +249,7 @@ struct EventManager
// check type
bool IsStaticType(PClass* type);
// init static handlers
void InitStaticHandlers(bool map);
void InitStaticHandlers(FLevelLocals *l, bool map);
// shutdown handlers
void Shutdown();

Expand Down
2 changes: 1 addition & 1 deletion src/gamedata/info.cpp
Expand Up @@ -395,7 +395,7 @@ void PClassActor::StaticInit()
InitBotStuff();

// reinit GLOBAL static stuff from gameinfo, once classes are loaded.
staticEventManager.InitStaticHandlers(false);
staticEventManager.InitStaticHandlers(primaryLevel, false);
}

//==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/p_setup.cpp
Expand Up @@ -423,7 +423,7 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)

// [ZZ] init per-map static handlers. we need to call this before everything is set up because otherwise scripts don't receive PlayerEntered event
// (which happens at god-knows-what stage in this function, but definitely not the last part, because otherwise it'd work to put E_InitStaticHandlers before the player spawning)
Level->localEventManager->InitStaticHandlers(true);
Level->localEventManager->InitStaticHandlers(Level, true);

// generate a checksum for the level, to be included and checked with savegames.
map->GetChecksum(Level->md5);
Expand Down

0 comments on commit f38060d

Please sign in to comment.