Skip to content

Commit

Permalink
libcommon: Use defn::Episode to test for hub changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 10, 2014
1 parent 0fdf099 commit 7b327f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
14 changes: 5 additions & 9 deletions doomsday/plugins/common/src/fi_lib.cpp
Expand Up @@ -21,6 +21,7 @@
#include "common.h"
#include "fi_lib.h"

#include <doomsday/defs/episode.h>
#include "p_sound.h"
#include "p_tick.h"
#include "hu_log.h"
Expand Down Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -64,6 +64,7 @@
#include <cstdlib>
#include <de/App>
#include <de/NativePath>
#include <doomsday/defs/episode.h>
#include <doomsday/uri.h>

using namespace de;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions doomsday/plugins/common/src/gamesession.cpp
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7b327f9

Please sign in to comment.