From e579e996a84dc04f201d45144a16f20db2fa2920 Mon Sep 17 00:00:00 2001 From: danij Date: Mon, 30 Jun 2014 20:22:15 +0100 Subject: [PATCH] ResourceSystem|MapDef: Store map id and source file in MapDef MapDef will be used with all maps regardless of their origin, meaning they may or may not have an associated Id1MapRecognizer from which to obtain these properties. --- .../client/include/resource/resourcesystem.h | 37 +++++++++++++------ .../client/src/resource/resourcesystem.cpp | 7 +++- doomsday/client/src/world/map.cpp | 2 +- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/doomsday/client/include/resource/resourcesystem.h b/doomsday/client/include/resource/resourcesystem.h index d21b3178cc..053d23cc62 100644 --- a/doomsday/client/include/resource/resourcesystem.h +++ b/doomsday/client/include/resource/resourcesystem.h @@ -56,25 +56,19 @@ class MapDef : public de::PathTree::Node : Node(args) {} - MapDef &setRecognizer(de::Id1MapRecognizer *newRecognizer) { - _recognized.reset(newRecognizer); + MapDef &setId(de::String const &newId) { + _id = newId; return *this; } - de::Id1MapRecognizer const &recognizer() const { - DENG2_ASSERT(!_recognized.isNull()); - return *_recognized; + de::String const &id() const { + return _id; } - inline de::String const &id() const { return recognizer().id(); } - inline de::File1 *sourceFile() const { return recognizer().sourceFile(); } - /** * Returns the URI this resource will be known by. */ - de::Uri composeUri() const { - return de::Uri("Maps", id()); - } + inline de::Uri composeUri() const { return de::Uri("Maps", _id); } /** * Returns the id used to uniquely reference the map in some (old) definitions. @@ -88,9 +82,30 @@ class MapDef : public de::PathTree::Node .toLower(); } + MapDef &setSourceFile(de::File1 *newSourceFile) { + _sourceFile = newSourceFile; + return *this; + } + + de::File1 *sourceFile() const { + return _sourceFile; + } + + MapDef &setRecognizer(de::Id1MapRecognizer *newRecognizer) { + _recognized.reset(newRecognizer); + return *this; + } + + de::Id1MapRecognizer const &recognizer() const { + DENG2_ASSERT(!_recognized.isNull()); + return *_recognized; + } + private: //String cachePath; //bool lastLoadAttemptFailed; + de::String _id; + de::File1 *_sourceFile; QScopedPointer _recognized; }; diff --git a/doomsday/client/src/resource/resourcesystem.cpp b/doomsday/client/src/resource/resourcesystem.cpp index 37b86b296a..031f5b9b18 100644 --- a/doomsday/client/src/resource/resourcesystem.cpp +++ b/doomsday/client/src/resource/resourcesystem.cpp @@ -3466,7 +3466,12 @@ void ResourceSystem::initMapDefs() lastLump = recognizer->lastLump(); if(recognizer->format() != Id1MapRecognizer::UnknownFormat) { - d->mapDefs.insert(recognizer->id()).setRecognizer(recognizer.take()); + File1 *sourceFile = recognizer->sourceFile(); + String const mapId = recognizer->id(); + MapDef &mapDef = d->mapDefs.insert(mapId); + mapDef.setId(mapId) + .setSourceFile(sourceFile) + .setRecognizer(recognizer.take()); } } } diff --git a/doomsday/client/src/world/map.cpp b/doomsday/client/src/world/map.cpp index 0b66a96eaf..07612c3cdf 100644 --- a/doomsday/client/src/world/map.cpp +++ b/doomsday/client/src/world/map.cpp @@ -3597,7 +3597,7 @@ D_CMD(InspectMap) LOG_SCR_MSG( _E(l) "Uri: " _E(.) _E(i) "%s" _E(.) /*" " _E(l) " OldUid: " _E(.) _E(i) "%s" _E(.)*/ _E(l) " Music: " _E(.) _E(i) "%i") - << (map.def()? map.def()->composeUri().asText() : "(unknown map") + << (map.def()? map.def()->composeUri().asText() : "(unknown map)") /*<< map.oldUniqueId()*/ << Con_GetInteger("map-music");