Skip to content

Commit

Permalink
libcommon: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 10, 2014
1 parent 41d0219 commit 94db4c5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
19 changes: 9 additions & 10 deletions doomsday/plugins/common/include/g_defs.h
Expand Up @@ -31,20 +31,19 @@
ded_t &Defs();

/**
* Translates a warp map number to unique map identifier. Always returns a valid
* map identifier.
* Translates a map warp number for the @em current episode to a unique map identifier.
*
* @note This should only be used where necessary for compatibility reasons as
* the "warp translation" mechanic is redundant in the context of Doomsday's
* altogether better handling of map resources and their references. Instead,
* use the map URI mechanism.
* @note This should only be used where necessary for compatibility reasons as the
* "warp translation" mechanic is redundant in the context of Doomsday's altogether
* better handling of map resources and their references. Instead, use the map URI
* mechanism.
*
* @param map The warp map number to translate.
* @param warpNumber Warp number to translate.
*
* @return The unique identifier of the map given a warp map number. If the map
* is not found a URI to the first available map is returned (i.e., Maps:MAP01)
* @return The unique identifier of the map. If no game session is in progress or the
* warp number is not found, the URI "Maps:" is returned.
*/
de::Uri P_TranslateMap(uint map);
de::Uri TranslateMapWarpNumber(uint warpNumber);

extern "C" {
#endif
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/d_net.cpp
Expand Up @@ -117,7 +117,7 @@ int D_NetServerStarted(int before)
#if __JHEXEN__
// Map numbers need to be translated.
/// @todo fixme: What about cfg.netEpisode?
de::Uri netMapUri = P_TranslateMap(::cfg.netMap);
de::Uri netMapUri = TranslateMapWarpNumber(::cfg.netMap);
#elif __JDOOM64__
de::Uri netMapUri = G_ComposeMapUri(0/*::cfg.netEpisode*/, ::cfg.netMap);
#else
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/common/src/d_netsv.cpp
Expand Up @@ -348,8 +348,7 @@ static de::Uri NetSv_ScanCycle(int index, maprule_t *rules = 0)

#if __JHEXEN__
// In Hexen map numbers must be translated (urgh...).
/// @todo fixme: What about the episode?
de::Uri mapUri = P_TranslateMap(map);
de::Uri mapUri = TranslateMapWarpNumber(map);
#else
de::Uri mapUri = G_ComposeMapUri(episode, map);
#endif
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/g_defs.cpp
Expand Up @@ -58,12 +58,12 @@ void GetDefState(char const *def, int *val)
if(*val < 0) *val = 0;
}

de::Uri P_TranslateMap(uint map)
de::Uri TranslateMapWarpNumber(uint warpNumber)
{
if(Record const *rec = COMMON_GAMESESSION->episodeDef())
{
defn::Episode episodeDef(*rec);
if(Record const *mgNodeRec = episodeDef.tryFindMapGraphNodeByWarpNumber(map))
if(Record const *mgNodeRec = episodeDef.tryFindMapGraphNodeByWarpNumber(warpNumber))
{
return de::Uri(mgNodeRec->gets("id"), RC_NULL);
}
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -3098,8 +3098,7 @@ D_CMD(WarpMap)

#if __JHEXEN__
// Hexen map numbers require translation.
/// @todo fixme: What about the episode?
newMapUri = P_TranslateMap(map);
newMapUri = TranslateMapWarpNumber(map);
#else
// Internally epsiode and map numbers are zero-based.
if(epsd != 0) epsd -= 1;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/hexen/src/h2_main.cpp
Expand Up @@ -415,13 +415,13 @@ void X_PostInit()
}
else
{
startMapUri = P_TranslateMap(mapNumber);
startMapUri = TranslateMapWarpNumber(mapNumber);
}
}

if(startMapUri.path().isEmpty())
{
startMapUri = P_TranslateMap(1);
startMapUri = TranslateMapWarpNumber(1);
}

// Are we autostarting?
Expand Down

0 comments on commit 94db4c5

Please sign in to comment.