Skip to content

Commit

Permalink
ResourceSystem|MapDef: Store map id and source file in MapDef
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danij-deng committed Jun 30, 2014
1 parent 1d28e3a commit e579e99
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
37 changes: 26 additions & 11 deletions doomsday/client/include/resource/resourcesystem.h
Expand Up @@ -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.
Expand All @@ -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<de::Id1MapRecognizer> _recognized;
};

Expand Down
7 changes: 6 additions & 1 deletion doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -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());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/world/map.cpp
Expand Up @@ -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");

Expand Down

0 comments on commit e579e99

Please sign in to comment.