From 90f10cad8ee6ce5ed38f2d85f926b35081374acb Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 10 Aug 2014 14:00:03 +0100 Subject: [PATCH] libcommon: Updated translation of map "warp numbers" to URIs --- doomsday/plugins/common/src/g_defs.cpp | 30 ++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/doomsday/plugins/common/src/g_defs.cpp b/doomsday/plugins/common/src/g_defs.cpp index 94d75ba498..4361419ea1 100644 --- a/doomsday/plugins/common/src/g_defs.cpp +++ b/doomsday/plugins/common/src/g_defs.cpp @@ -21,7 +21,9 @@ #include "common.h" #include "g_defs.h" #include +#include #include "g_common.h" +#include "gamesession.h" using namespace de; @@ -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().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. }