diff --git a/doomsday/plugins/common/src/fi_lib.cpp b/doomsday/plugins/common/src/fi_lib.cpp index ed706cf4c7..795345808e 100644 --- a/doomsday/plugins/common/src/fi_lib.cpp +++ b/doomsday/plugins/common/src/fi_lib.cpp @@ -21,6 +21,7 @@ #include "common.h" #include "fi_lib.h" +#include #include "p_sound.h" #include "p_tick.h" #include "hu_log.h" @@ -88,16 +89,11 @@ static void initStateConditions(fi_state_t *s) #if __JHEXEN__ // Leaving the current hub? - if(Record const *curMapInfo = COMMON_GAMESESSION->mapInfo()) + if(Record const *episodeDef = COMMON_GAMESESSION->episodeDef()) { - s->conditions.leave_hub = true; - if(!nextMapUri.path().isEmpty()) - { - if(curMapInfo->geti("hub") == Defs().mapInfos.find("id", nextMapUri.compose()).geti("hub")) - { - s->conditions.leave_hub = false; - } - } + defn::Episode epsd(*episodeDef); + Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + s->conditions.leave_hub = (currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())); } App_Log(DE2_DEV_SCR_VERBOSE, "Infine state condition: leave_hub=%i", s->conditions.leave_hub); #endif diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index d432af4da4..d4b2100d91 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -64,6 +64,7 @@ #include #include #include +#include #include using namespace de; @@ -1797,10 +1798,13 @@ void G_PlayerLeaveMap(int player) if(!p->plr->inGame) return; #if __JHEXEN__ - dd_bool newHub = true; - if(!nextMapUri.path().isEmpty()) + // Leaving the current hub? + bool newHub = true; + if(Record const *episodeDef = COMMON_GAMESESSION->episodeDef()) { - newHub = (COMMON_GAMESESSION->mapInfo()->geti("hub") != Defs().mapInfos.find("id", ::nextMapUri.compose()).geti("hub")); + defn::Episode epsd(*episodeDef); + Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + newHub = (currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())); } #endif @@ -2548,9 +2552,11 @@ char const *G_InFineDebriefing(de::Uri const *mapUri) if(briefDisabled) return 0; #if __JHEXEN__ - if(cfg.overrideHubMsg && G_GameState() == GS_MAP && !::nextMapUri.path().isEmpty()) + if(cfg.overrideHubMsg && G_GameState() == GS_MAP) { - if(Defs().mapInfos.find("id", mapUri->compose()).geti("hub") != Defs().mapInfos.find("id", ::nextMapUri.compose()).geti("hub")) + defn::Episode epsd(*COMMON_GAMESESSION->episodeDef()); + Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + if(currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())) { return 0; } diff --git a/doomsday/plugins/common/src/gamesession.cpp b/doomsday/plugins/common/src/gamesession.cpp index 0fb9ba5d4c..405ee0a840 100644 --- a/doomsday/plugins/common/src/gamesession.cpp +++ b/doomsday/plugins/common/src/gamesession.cpp @@ -1059,10 +1059,12 @@ void GameSession::leaveMap() // Are we entering a new hub? #if __JHEXEN__ - if(mapInfo()->geti("hub") != Defs().mapInfos.find("id", ::nextMapUri.compose()).geti("hub")) + defn::Episode epsd(*episodeDef()); + Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + if(currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())) #endif { - // Clear all saved map states in the old hub. + // Clear all saved map states in the current hub. Folder::Contents contents = mapsFolder.contents(); DENG2_FOR_EACH_CONST(Folder::Contents, i, contents) {