summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-16 00:34:53 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-16 00:34:53 +0300
commitcf79b26f999ddd795a54b553af3fdb553ec04536 (patch)
tree8ebc6649f316d5b3021ad80f72b79e9f209366ad
parent665e33246a82838dc8893e6b84a576de803a3195 (diff)
downloadmv-cf79b26f999ddd795a54b553af3fdb553ec04536.tar.gz
mv-cf79b26f999ddd795a54b553af3fdb553ec04536.tar.bz2
mv-cf79b26f999ddd795a54b553af3fdb553ec04536.tar.xz
mv-cf79b26f999ddd795a54b553af3fdb553ec04536.zip
improve mapdb file.
-rw-r--r--src/resources/mapdb.cpp14
-rw-r--r--src/resources/mapdb.h7
2 files changed, 11 insertions, 10 deletions
diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp
index 0efc07bf6..621387175 100644
--- a/src/resources/mapdb.cpp
+++ b/src/resources/mapdb.cpp
@@ -53,7 +53,7 @@ void MapDB::load()
void MapDB::loadRemap()
{
- XML::Document *doc = new XML::Document(
+ XML::Document *const doc = new XML::Document(
paths.getStringValue("maps").append("remap.xml"));
const XmlNodePtr root = doc->rootNode();
@@ -67,11 +67,11 @@ void MapDB::loadRemap()
{
if (xmlNameEqual(node, "map"))
{
- std::string name = XML::getProperty(node, "name", "");
+ const std::string name = XML::getProperty(node, "name", "");
if (name.empty())
continue;
- std::string value = XML::getProperty(node, "value", "");
+ const std::string value = XML::getProperty(node, "value", "");
if (value.empty())
continue;
@@ -145,7 +145,7 @@ void MapDB::unload()
mLoaded = false;
}
-std::string MapDB::getMapName(const std::string &name)
+const std::string MapDB::getMapName(const std::string &name)
{
const MapIterator it = mMaps.find(name);
@@ -154,13 +154,13 @@ std::string MapDB::getMapName(const std::string &name)
return name;
}
-MapDB::MapInfo *MapDB::getMapAtlas(const std::string &name)
+const MapDB::MapInfo *MapDB::getMapAtlas(const std::string &name)
{
- MapInfoIter it = mInfos.find(name);
+ const MapInfoIter it = mInfos.find(name);
if (it == mInfos.end())
return nullptr;
MapInfo *const info = &(*it).second;
- AtlasIter it2 = mAtlases.find(info->atlas);
+ const AtlasCIter it2 = mAtlases.find(info->atlas);
if (it2 == mAtlases.end())
return nullptr;
info->files = &((*it2).second);
diff --git a/src/resources/mapdb.h b/src/resources/mapdb.h
index 574c99780..1f54a17f0 100644
--- a/src/resources/mapdb.h
+++ b/src/resources/mapdb.h
@@ -36,7 +36,7 @@ namespace MapDB
struct MapInfo
{
std::string atlas;
- StringVect *files;
+ const StringVect *files;
};
/**
@@ -53,9 +53,9 @@ namespace MapDB
*/
void unload();
- std::string getMapName(const std::string &name) A_WARN_UNUSED;
+ const std::string getMapName(const std::string &name) A_WARN_UNUSED;
- MapInfo *getMapAtlas(const std::string &name) A_WARN_UNUSED;
+ const MapInfo *getMapAtlas(const std::string &name) A_WARN_UNUSED;
// Maps DB
typedef std::map<std::string, std::string> Maps;
@@ -66,6 +66,7 @@ namespace MapDB
// atlas to files map
typedef std::map<std::string, StringVect> Atlases;
typedef Atlases::iterator AtlasIter;
+ typedef Atlases::const_iterator AtlasCIter;
} // namespace MapDB
#endif