diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-12-22 02:03:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-12-22 02:03:59 +0300 |
commit | 5133814218de74d57c7febadf61b3ab05216dc25 (patch) | |
tree | 60b88270c9a50ef333fefed38c805baab00429a1 /src/resources | |
parent | cc7a39f467a49b2e91717739cb6e7c3c4b34a245 (diff) | |
download | mv-5133814218de74d57c7febadf61b3ab05216dc25.tar.gz mv-5133814218de74d57c7febadf61b3ab05216dc25.tar.bz2 mv-5133814218de74d57c7febadf61b3ab05216dc25.tar.xz mv-5133814218de74d57c7febadf61b3ab05216dc25.zip |
Remove default parameters from properties.h
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/map/map.cpp | 44 | ||||
-rw-r--r-- | src/resources/map/properties.h | 6 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 9 |
3 files changed, 30 insertions, 29 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index 39365643d..56483486f 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -244,23 +244,23 @@ void Map::initializeAmbientLayers() restrict2 } Image *restrict const img = Loader::getImage( - getProperty(name + "image")); + getProperty(name + "image", std::string())); if (img != nullptr) { - int mask = atoi(getProperty(name + "mask").c_str()); + int mask = atoi(getProperty(name + "mask", std::string()).c_str()); if (mask == 0) mask = 1; - const float parallax = getFloatProperty(name + "parallax"); + const float parallax = getFloatProperty(name + "parallax", 0.0F); mForegrounds.push_back(new AmbientLayer( name, img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), - getFloatProperty(name + "posX"), - getFloatProperty(name + "posY"), - getFloatProperty(name + "scrollX"), - getFloatProperty(name + "scrollY"), - getBoolProperty(name + "keepratio"), + getFloatProperty(name + "posX", 0.0F), + getFloatProperty(name + "posY", 0.0F), + getFloatProperty(name + "scrollX", 0.0F), + getFloatProperty(name + "scrollY", 0.0F), + getBoolProperty(name + "keepratio", false), mask)); // The AmbientLayer takes control over the image. @@ -274,25 +274,25 @@ void Map::initializeAmbientLayers() restrict2 { const std::string name("background" + toString(i)); Image *restrict const img = Loader::getImage( - getProperty(name + "image")); + getProperty(name + "image", std::string())); if (img != nullptr) { - int mask = atoi(getProperty(name + "mask").c_str()); + int mask = atoi(getProperty(name + "mask", std::string()).c_str()); if (mask == 0) mask = 1; - const float parallax = getFloatProperty(name + "parallax"); + const float parallax = getFloatProperty(name + "parallax", 0.0F); mBackgrounds.push_back(new AmbientLayer( name, img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), - getFloatProperty(name + "posX"), - getFloatProperty(name + "posY"), - getFloatProperty(name + "scrollX"), - getFloatProperty(name + "scrollY"), - getBoolProperty(name + "keepratio"), + getFloatProperty(name + "posX", 0.0F), + getFloatProperty(name + "posY", 0.0F), + getFloatProperty(name + "scrollX", 0.0F), + getFloatProperty(name + "scrollY", 0.0F), + getBoolProperty(name + "keepratio", false), mask)); // The AmbientLayer takes control over the image. @@ -822,27 +822,27 @@ void Map::removeActor(const Actors::iterator &restrict iterator) restrict2 const std::string Map::getMusicFile() const restrict2 { - return getProperty("music"); + return getProperty("music", std::string()); } const std::string Map::getName() const restrict2 { if (hasProperty("name")) - return getProperty("name"); + return getProperty("name", std::string()); - return getProperty("mapname"); + return getProperty("mapname", std::string()); } const std::string Map::getFilename() const restrict2 { - const std::string fileName = getProperty("_filename"); + const std::string fileName = getProperty("_filename", std::string()); const size_t lastSlash = fileName.rfind('/') + 1; return fileName.substr(lastSlash, fileName.rfind('.') - lastSlash); } const std::string Map::getGatName() const restrict2 { - const std::string fileName = getProperty("_filename"); + const std::string fileName = getProperty("_filename", std::string()); const size_t lastSlash = fileName.rfind('/') + 1; return fileName.substr(lastSlash, fileName.rfind('.') - lastSlash).append(".gat"); @@ -1258,7 +1258,7 @@ void Map::saveExtraLayer() const restrict2 std::string Map::getUserMapDirectory() const restrict2 { return pathJoin(settings.serverConfigDir, - getProperty("_realfilename")); + getProperty("_realfilename", std::string())); } void Map::addRange(const std::string &restrict name, diff --git a/src/resources/map/properties.h b/src/resources/map/properties.h index 31d8cfe77..cf05da560 100644 --- a/src/resources/map/properties.h +++ b/src/resources/map/properties.h @@ -56,7 +56,7 @@ class Properties notfinal * doesn't exist. */ const std::string getProperty(const std::string &name, - const std::string &def = "") + const std::string &def) const A_WARN_UNUSED { const PropertyMap::const_iterator i = mProperties.find(name); @@ -72,7 +72,7 @@ class Properties notfinal * doesn't exist. */ float getFloatProperty(const std::string &name, - const float def = 0.0F) const A_WARN_UNUSED + const float def) const A_WARN_UNUSED { const PropertyMap::const_iterator i = mProperties.find(name); float ret = def; @@ -94,7 +94,7 @@ class Properties notfinal * doesn't exist. */ bool getBoolProperty(const std::string &name, - const bool def = false) const A_WARN_UNUSED + const bool def) const A_WARN_UNUSED { const PropertyMap::const_iterator i = mProperties.find(name); bool ret = def; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 4d0b89b3a..352830a7b 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -292,7 +292,7 @@ Map *MapReader::readMap(const std::string &restrict filename, map->setProperty("_filename", realFilename); map->setProperty("_realfilename", filename); - if (map->getProperty("music").empty()) + if (map->getProperty("music", std::string()).empty()) updateMusic(map); map->updateConditionLayers(); @@ -410,7 +410,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) { readProperties(childNode, map); map->setVersion(atoi(map->getProperty( - "manaplus version").c_str())); + "manaplus version", std::string()).c_str())); } else if (xmlNameEqual(childNode, "objectgroup")) { @@ -506,7 +506,8 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) map->initializeAmbientLayers(); map->clearIndexedTilesets(); - map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str())); + map->setActorsFix(0, + atoi(map->getProperty("actorsfix", std::string()).c_str())); map->reduce(); map->setWalkLayer(Loader::getWalkLayer(fileName, map)); unloadTempLayers(); @@ -1290,7 +1291,7 @@ Map *MapReader::createEmptyMap(const std::string &restrict filename, void MapReader::updateMusic(Map *const map) { - std::string name = map->getProperty("shortName"); + std::string name = map->getProperty("shortName", std::string()); const size_t p = name.rfind('.'); if (p != std::string::npos) name = name.substr(0, p); |