Skip to content

Commit

Permalink
libcommon: Updated translation of map "warp numbers" to URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 10, 2014
1 parent 37e9963 commit 90f10ca
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions doomsday/plugins/common/src/g_defs.cpp
Expand Up @@ -21,7 +21,9 @@
#include "common.h"
#include "g_defs.h"
#include <de/RecordValue>
#include <doomsday/defs/episode.h>
#include "g_common.h"
#include "gamesession.h"

using namespace de;

Expand Down Expand Up @@ -56,33 +58,15 @@ void GetDefState(char const *def, int *val)
if(*val < 0) *val = 0;
}

/// @todo fixme: What about the episode?
de::Uri P_TranslateMap(uint map)
{
de::Uri matchedWithoutHub("Maps:", RC_NULL);

DictionaryValue::Elements const &mapInfosById = Defs().mapInfos.lookup("id").elements();
DENG2_FOR_EACH_CONST(DictionaryValue::Elements, i, mapInfosById)
if(Record const *rec = COMMON_GAMESESSION->episodeDef())
{
Record const &info = *i->second->as<RecordValue>().record();

if((unsigned)info.geti("warpTrans") == map)
defn::Episode episodeDef(*rec);
if(Record const *mgNodeRec = episodeDef.tryFindMapGraphNodeByWarpNumber(map))
{
if(info.geti("hub"))
{
LOGDEV_MAP_VERBOSE("Warp %u translated to map %s, hub %i")
<< map << info.gets("map") << info.geti("hub");
return de::Uri(info.gets("map"), RC_NULL);
}

LOGDEV_MAP_VERBOSE("Warp %u matches map %s, but it has no hub")
<< map << info.gets("map");
matchedWithoutHub = de::Uri(info.gets("map"), RC_NULL);
return de::Uri(mgNodeRec->gets("id"), RC_NULL);
}
}

LOGDEV_MAP_NOTE("Could not find warp %i, translating to map %s (without hub)")
<< map << matchedWithoutHub;

return matchedWithoutHub;
return de::Uri("Maps:", RC_NULL); // Not found.
}

0 comments on commit 90f10ca

Please sign in to comment.