diff options
-rw-r--r-- | src/being/localplayer.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/debugwindowtabs.cpp | 8 | ||||
-rw-r--r-- | src/gui/windows/minimap.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/questswindow.cpp | 3 | ||||
-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 |
7 files changed, 42 insertions, 39 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 135dce434..9cfdc4d82 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1406,7 +1406,7 @@ void LocalPlayer::moveToHome() else if (mMap != nullptr) { const std::map<std::string, Vector>::const_iterator iter = - mHomes.find(mMap->getProperty("_realfilename")); + mHomes.find(mMap->getProperty("_realfilename", std::string())); if (iter != mHomes.end()) { @@ -1816,7 +1816,7 @@ void LocalPlayer::setHome() if (specialLayer == nullptr) return; - const std::string key = mMap->getProperty("_realfilename"); + const std::string key = mMap->getProperty("_realfilename", std::string()); Vector pos = mHomes[key]; if (mAction == BeingAction::SIT) @@ -2676,7 +2676,7 @@ void LocalPlayer::updateNavigateList() if (mMap != nullptr) { const std::map<std::string, Vector>::const_iterator iter = - mHomes.find(mMap->getProperty("_realfilename")); + mHomes.find(mMap->getProperty("_realfilename", std::string())); if (iter != mHomes.end()) { @@ -2753,7 +2753,7 @@ void LocalPlayer::removeHome() if (mMap == nullptr) return; - const std::string key = mMap->getProperty("_realfilename"); + const std::string key = mMap->getProperty("_realfilename", std::string()); const std::map<std::string, Vector>::iterator iter = mHomes.find(key); if (iter != mHomes.end()) diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp index 321c3bcad..6199fccca 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.cpp +++ b/src/gui/widgets/tabs/debugwindowtabs.cpp @@ -199,16 +199,16 @@ void MapDebugTab::logic() // TRANSLATORS: debug window label mMusicFileLabel->setCaption(strprintf("%s %s", _("Music:"), - map->getProperty("music").c_str())); + map->getProperty("music", std::string()).c_str())); // TRANSLATORS: debug window label mMinimapLabel->setCaption(strprintf("%s %s", _("Minimap:"), - map->getProperty("minimap").c_str())); + map->getProperty("minimap", std::string()).c_str())); // TRANSLATORS: debug window label mMapLabel->setCaption(strprintf("%s %s", _("Map:"), - map->getProperty("_realfilename").c_str())); + map->getProperty("_realfilename", std::string()).c_str())); // TRANSLATORS: debug window label mMapNameLabel->setCaption(strprintf("%s %s", _("Map name:"), - map->getProperty("name").c_str())); + map->getProperty("name", std::string()).c_str())); if (mUpdateTime != cur_time) { diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 7f48f4a10..cf46bb6c6 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -181,7 +181,8 @@ void Minimap::setMap(const Map *const map) std::string tempname = pathJoin(paths.getStringValue("minimaps"), map->getFilename()).append(".png"); - std::string minimapName = map->getProperty("minimap"); + std::string minimapName = map->getProperty("minimap", + std::string()); if (minimapName.empty() && VirtFs::exists(tempname)) minimapName = tempname; diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 269f2aab9..80d853778 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -378,7 +378,8 @@ void QuestsWindow::setMap(const Map *const map) if (mMap == nullptr) return; - const std::string name = mMap->getProperty("shortName"); + const std::string name = mMap->getProperty("shortName", + std::string()); FOR_EACHP (STD_VECTOR<QuestEffect*>::const_iterator, it, mAllEffects) { const QuestEffect *const effect = *it; 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); |