diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-12-10 16:46:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-12-10 16:46:55 +0300 |
commit | 608dfae22e1b5145210314ca6c7268420dd639c8 (patch) | |
tree | 5f7317be7e895a1f8aede182ea69ef56d456c54f /src/resources | |
parent | 9eb389060d44672c311a36348036eab297859e7e (diff) | |
download | manaverse-608dfae22e1b5145210314ca6c7268420dd639c8.tar.gz manaverse-608dfae22e1b5145210314ca6c7268420dd639c8.tar.bz2 manaverse-608dfae22e1b5145210314ca6c7268420dd639c8.tar.xz manaverse-608dfae22e1b5145210314ca6c7268420dd639c8.zip |
Fix some issues found by automatic checks.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/map/map.cpp | 8 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 12 | ||||
-rw-r--r-- | src/resources/sprite/animatedsprite.cpp | 8 | ||||
-rw-r--r-- | src/resources/sprite/spritedef.cpp | 2 | ||||
-rw-r--r-- | src/resources/wallpaper.cpp | 4 |
5 files changed, 15 insertions, 19 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index f662bedac..97e6def6a 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -835,16 +835,16 @@ const std::string Map::getName() const restrict2 const std::string Map::getFilename() const restrict2 { const std::string fileName = getProperty("_filename"); - const size_t lastSlash = fileName.rfind("/") + 1; - return fileName.substr(lastSlash, fileName.rfind(".") - lastSlash); + 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 size_t lastSlash = fileName.rfind("/") + 1; + const size_t lastSlash = fileName.rfind('/') + 1; return fileName.substr(lastSlash, - fileName.rfind(".") - lastSlash).append(".gat"); + fileName.rfind('.') - lastSlash).append(".gat"); } Path Map::findPath(const int startX, const int startY, diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index f0f43d225..215d5c13e 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -327,7 +327,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) BLOCK_START("MapReader::readMap xml") // Take the filename off the path - const std::string pathDir = path.substr(0, path.rfind("/") + 1); + const std::string pathDir = path.substr(0, path.rfind('/') + 1); const int w = XML::getProperty(node, "width", 0); const int h = XML::getProperty(node, "height", 0); @@ -354,7 +354,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) w, h, tilew, tileh); - const std::string fileName = path.substr(path.rfind("/") + 1); + const std::string fileName = path.substr(path.rfind('/') + 1); map->setProperty("shortName", fileName); #ifdef USE_OPENGL @@ -800,7 +800,7 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode, { while (oldPos != csv.npos) { - const size_t pos = csv.find_first_of(",", oldPos); + const size_t pos = csv.find_first_of(',', oldPos); if (pos == csv.npos) return false; @@ -830,7 +830,7 @@ bool MapReader::readCsvLayer(const XmlNodePtrConst childNode, { while (oldPos != csv.npos) { - const size_t pos = csv.find_first_of(",", oldPos); + const size_t pos = csv.find_first_of(',', oldPos); if (pos == csv.npos) return false; @@ -1078,7 +1078,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node, } // Reset path to be realtive to the tsx file - pathDir = filename.substr(0, filename.rfind("/") + 1); + pathDir = filename.substr(0, filename.rfind('/') + 1); } const int tw = XML::getProperty(node, "tilewidth", map->getTileWidth()); @@ -1272,7 +1272,7 @@ Map *MapReader::createEmptyMap(const std::string &restrict filename, void MapReader::updateMusic(Map *const map) { std::string name = map->getProperty("shortName"); - const size_t p = name.rfind("."); + const size_t p = name.rfind('.'); if (p != std::string::npos) name = name.substr(0, p); name.append(".ogg"); diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp index 546c3a415..25c6d0e74 100644 --- a/src/resources/sprite/animatedsprite.cpp +++ b/src/resources/sprite/animatedsprite.cpp @@ -235,12 +235,8 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2 mFrameIndex = 0; mFrame = &mAnimation->mFrames[mFrameIndex]; - if (!mFrame) - { - fail = true; - } - else if ((mFrame->type == FrameType::LABEL - && !mFrame->nextAction.empty())) + if ((mFrame->type == FrameType::LABEL && + !mFrame->nextAction.empty())) { fail = false; } diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp index 2f6fcaf65..bcc37421a 100644 --- a/src/resources/sprite/spritedef.cpp +++ b/src/resources/sprite/spritedef.cpp @@ -418,7 +418,7 @@ void SpriteDef::loadAnimation(const XmlNodePtr animationNode, FOR_EACH (StringVectCIter, it, vals) { const std::string str = *it; - const size_t idx = str.find("-"); + const size_t idx = str.find('-'); if (str == "p") { animation->addPause(delay, rand); diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 93d6699b5..ea426ea0b 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -97,11 +97,11 @@ void Wallpaper::loadWallpapers() // First, get the base filename of the image: std::string filename = *i; - size_t separator = filename.rfind("_"); + size_t separator = filename.rfind('_'); filename = filename.substr(0, separator); // Check that the base filename doesn't have any '%' markers. - separator = filename.find("%"); + separator = filename.find('%'); if (separator == std::string::npos) { // Then, append the width and height search mask. |