Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor|libcommon: Obtain the current map URI via common::GameSession
  • Loading branch information
danij-deng committed Aug 19, 2014
1 parent 9121c1e commit 39534cb
Show file tree
Hide file tree
Showing 21 changed files with 149 additions and 147 deletions.
23 changes: 9 additions & 14 deletions doomsday/plugins/common/include/g_common.h
Expand Up @@ -105,29 +105,24 @@ bool G_SetGameActionLoadSession(de::String slotId);
void G_SetGameActionMapCompleted(de::Uri const &nextMapUri, uint nextMapEntryPoint, dd_bool secretExit);

/**
* @param episodeId Identifier of the episode to lookup the title of. Can be @c 0 in
* which case the title for the @em current episode will be returned
* (if set).
* @param episodeId Identifier of the episode to lookup the title of.
*/
de::String G_EpisodeTitle(de::String const *episodeId = 0);
de::String G_EpisodeTitle(de::String episodeId);

/**
* @param mapUri Identifier of the map to lookup the author of. Can be @c 0 in which
* case the author for the @em current map will be returned (if set).
* @param mapUri Identifier of the map to lookup the author of.
*/
de::String G_MapAuthor(de::Uri const *mapUri = 0, bool supressGameAuthor = false);
de::String G_MapAuthor(de::Uri const &mapUri, bool supressGameAuthor = false);

/**
* @param mapUri Identifier of the map to lookup the title of. Can be @c 0 in which
* case the title for the @em current map will be returned (if set).
* @param mapUri Identifier of the map to lookup the title of.
*/
de::String G_MapTitle(de::Uri const *mapUri = 0);
de::String G_MapTitle(de::Uri const &mapUri);

/**
* @param mapUri Identifier of the map to lookup the title of. Can be @c 0 in which
* case the title for the @em current map will be returned (if set).
* @param mapUri Identifier of the map to lookup the title of.
*/
patchid_t G_MapTitlePatch(de::Uri const *mapUri = 0);
patchid_t G_MapTitlePatch(de::Uri const &mapUri);

extern "C" {
#endif
Expand Down Expand Up @@ -201,7 +196,7 @@ de::Uri G_ComposeMapUri(uint episode, uint map);
extern "C" {
#endif

struct uri_s const *G_CurrentMapUri(void);
AutoStr *G_CurrentMapUriPath(void);

int G_Ruleset_Skill();
#if !__JHEXEN__
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/d_netcl.cpp
Expand Up @@ -122,7 +122,7 @@ void NetCl_UpdateGameState(reader_s *msg)
/// @todo Breaks session management logic; rules cannot change once the session has
/// begun and setting the current map and/or entrance is illogical at this point.
DENG2_ASSERT(!Str_Compare(gsEpisodeId, COMMON_GAMESESSION->episodeId().toLatin1().constData()));
DENG2_ASSERT(*reinterpret_cast<de::Uri *>(gsMapUri) == ::gameMapUri);
DENG2_ASSERT(*reinterpret_cast<de::Uri *>(gsMapUri) == COMMON_GAMESESSION->mapUri());

COMMON_GAMESESSION->applyNewRules(gsRules);
//COMMON_GAMESESSION->setMap(*gsMapUri);
Expand Down
5 changes: 3 additions & 2 deletions doomsday/plugins/common/src/d_netsv.cpp
Expand Up @@ -662,12 +662,13 @@ void NetSv_SendGameState(int flags, int to)

AutoStr *gameId = AutoStr_FromTextStd(COMMON_GAMESESSION->gameId().toLatin1().constData());
AutoStr *episodeId = AutoStr_FromTextStd(COMMON_GAMESESSION->episodeId().toLatin1().constData());
de::Uri mapUri = COMMON_GAMESESSION->mapUri();

// Print a short message that describes the game state.
LOG_NET_NOTE("Sending game setup: %s %s %s %s")
<< gameId
<< episodeId
<< ::gameMapUri.resolved()
<< mapUri.resolved()
<< gameConfigString;

// Send an update to all the players in the game.
Expand All @@ -683,7 +684,7 @@ void NetSv_SendGameState(int flags, int to)
Str_Write(gameId, writer);

// Current map.
Uri_Write(reinterpret_cast<uri_s *>(&::gameMapUri), writer);
Uri_Write(reinterpret_cast<uri_s *>(&mapUri), writer);

// Current episode.
Str_Write(episodeId, writer);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/fi_lib.cpp
Expand Up @@ -92,7 +92,7 @@ static void initStateConditions(fi_state_t *s)
if(Record const *episodeDef = COMMON_GAMESESSION->episodeDef())
{
defn::Episode epsd(*episodeDef);
Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose());
Record const *currentHub = epsd.tryFindHubByMapId(COMMON_GAMESESSION->mapUri().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);
Expand Down

0 comments on commit 39534cb

Please sign in to comment.