summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-12-10 16:46:55 +0300
committerAndrei Karas <akaras@inbox.ru>2016-12-10 16:46:55 +0300
commit608dfae22e1b5145210314ca6c7268420dd639c8 (patch)
tree5f7317be7e895a1f8aede182ea69ef56d456c54f /src
parent9eb389060d44672c311a36348036eab297859e7e (diff)
downloadmanaverse-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')
-rw-r--r--src/actions/chat.cpp2
-rw-r--r--src/actions/commands.cpp2
-rw-r--r--src/actormanager.cpp2
-rw-r--r--src/configmanager.cpp4
-rw-r--r--src/game.cpp7
-rw-r--r--src/graphicsmanager.cpp6
-rw-r--r--src/gui/models/modelistmodel.cpp8
-rw-r--r--src/gui/widgets/browserbox.cpp10
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp4
-rw-r--r--src/gui/widgets/textbox.cpp12
-rw-r--r--src/gui/windows/chatwindow.cpp10
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/registerdialog.cpp2
-rw-r--r--src/gui/windows/shopwindow.cpp2
-rw-r--r--src/gui/windows/whoisonline.cpp2
-rw-r--r--src/input/inputmanager.cpp2
-rw-r--r--src/net/download.cpp2
-rw-r--r--src/net/ea/gamehandler.cpp2
-rw-r--r--src/net/ea/playerrecv.cpp2
-rw-r--r--src/net/eathena/chathandler.cpp6
-rw-r--r--src/net/tmwa/chathandler.cpp6
-rw-r--r--src/resources/map/map.cpp8
-rw-r--r--src/resources/mapreader.cpp12
-rw-r--r--src/resources/sprite/animatedsprite.cpp8
-rw-r--r--src/resources/sprite/spritedef.cpp2
-rw-r--r--src/resources/wallpaper.cpp4
-rw-r--r--src/units.cpp2
-rw-r--r--src/utils/langs.cpp8
-rw-r--r--src/utils/paths.cpp4
-rw-r--r--src/utils/stringutils.cpp38
30 files changed, 89 insertions, 92 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index 150e1fa56..d3e869f5c 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -211,7 +211,7 @@ static bool splitWhisper(const std::string &args,
}
else
{
- const size_t pos = args.find(" ");
+ const size_t pos = args.find(' ');
if (pos != std::string::npos)
{
recvnick = args.substr(0, pos);
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index df86fefc2..74c7bfe52 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -702,7 +702,7 @@ impHandler(openUrl)
impHandler(execute)
{
- const size_t idx = event.args.find(" ");
+ const size_t idx = event.args.find(' ');
std::string name;
std::string params;
if (idx == std::string::npos)
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 808ccd7fa..8974c4ddd 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1782,7 +1782,7 @@ void ActorManager::parseLevels(std::string levels) const
std::string part = levels.substr(f, pos - f);
if (part.empty())
break;
- const size_t bktPos = part.rfind("(");
+ const size_t bktPos = part.rfind('(');
if (bktPos != std::string::npos)
{
Being *const being = findBeingByName(part.substr(0, bktPos),
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 9f67ad2c5..8358aa995 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -263,7 +263,7 @@ void ConfigManager::storeSafeParameters()
enableMumble = config.getBoolValue("enableMumble");
enableMapReduce = config.getBoolValue("enableMapReduce");
- if (!settings.options.safeMode && !tmpOpengl)
+ if (!settings.options.safeMode && tmpOpengl == RenderType::RENDER_SOFTWARE)
{
// if video mode configured reset most settings to safe
config.setValue("hwaccel", false);
@@ -306,7 +306,7 @@ void ConfigManager::storeSafeParameters()
}
config.setValue("safemode", false);
- if (!tmpOpengl)
+ if (tmpOpengl == RenderType::RENDER_SOFTWARE)
{
config.setValue("hwaccel", tmpHwaccel);
config.setValue("opengl", CAST_S32(tmpOpengl));
diff --git a/src/game.cpp b/src/game.cpp
index 56e86ba6d..69333841f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -401,8 +401,9 @@ Game::Game() :
top->add(viewport);
viewport->requestMoveToBottom();
- AnimatedSprite::setEnableCache(mainGraphics->getOpenGL()
- && config.getBoolValue("enableDelayedAnimations"));
+ AnimatedSprite::setEnableCache(
+ mainGraphics->getOpenGL() != RenderType::RENDER_SOFTWARE &&
+ config.getBoolValue("enableDelayedAnimations"));
CompoundSprite::setEnableDelay(
config.getBoolValue("enableCompoundSpriteDelay"));
@@ -656,7 +657,7 @@ void Game::slowLogic()
effectManager->logic();
}
- if (mainGraphics->getOpenGL())
+ if (mainGraphics->getOpenGL() != RenderType::RENDER_SOFTWARE)
DelayedManager::delayedLoad();
#ifdef TMWA_SUPPORT
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index b8383076d..3508f335b 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -526,9 +526,11 @@ void GraphicsManager::initGraphics()
SafeOpenGLImageHelper::setBlur(config.getBoolValue("blur"));
#endif // ANDROID
SurfaceImageHelper::SDLSetEnableAlphaCache(
- config.getBoolValue("alphaCache") && !openGLMode);
+ config.getBoolValue("alphaCache") &&
+ openGLMode == RenderType::RENDER_SOFTWARE);
ImageHelper::setEnableAlpha((config.getFloatValue("guialpha") != 1.0F ||
- openGLMode) && config.getBoolValue("enableGuiOpacity"));
+ openGLMode != RenderType::RENDER_SOFTWARE) &&
+ config.getBoolValue("enableGuiOpacity"));
#else // USE_OPENGL
SurfaceImageHelper::SDLSetEnableAlphaCache(
config.getBoolValue("alphaCache"));
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
index 5c63cf15e..673662a48 100644
--- a/src/gui/models/modelistmodel.cpp
+++ b/src/gui/models/modelistmodel.cpp
@@ -34,13 +34,13 @@
#ifndef ANDROID
static bool modeSorter(const std::string &mode1, const std::string &mode2)
{
- const int width1 = atoi(mode1.substr(0, mode1.find("x")).c_str());
- const int height1 = atoi(mode1.substr(mode1.find("x") + 1).c_str());
+ const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str());
+ const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str());
if (!width1 || !height1)
return false;
- const int width2 = atoi(mode2.substr(0, mode2.find("x")).c_str());
- const int height2 = atoi(mode2.substr(mode2.find("x") + 1).c_str());
+ const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str());
+ const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str());
if (!width2 || !height2)
return false;
if (width1 != width2)
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 20fc6c81c..0141eafbc 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -227,7 +227,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
idx1 = tmp.find("###");
while (idx1 != std::string::npos)
{
- const size_t idx2 = tmp.find(";", idx1);
+ const size_t idx2 = tmp.find(';', idx1);
if (idx2 == std::string::npos)
break;
@@ -242,7 +242,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
idx1 = tmp.find("@@");
while (idx1 != std::string::npos)
{
- const size_t idx2 = tmp.find("|", idx1);
+ const size_t idx2 = tmp.find('|', idx1);
const size_t idx3 = tmp.find("@@", idx2);
if (idx2 == std::string::npos || idx3 == std::string::npos)
@@ -290,7 +290,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
}
else
{ // item link
- size_t idx = bLink.link.find(",");
+ size_t idx = bLink.link.find(',');
if (idx != std::string::npos)
{
const int id = atoi(bLink.link.substr(0, idx).c_str());
@@ -359,7 +359,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
idx1 = newRow.find("\\t");
while (idx1 != std::string::npos)
{
- const size_t idx2 = newRow.find(";", idx1);
+ const size_t idx2 = newRow.find(';', idx1);
if (idx2 == std::string::npos)
break;
@@ -445,7 +445,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
if (nextChar < sz && tempRow.at(nextChar) == ' ')
{
int nextSpacePos = CAST_U32(
- tempRow.find(" ", (nextChar + 1)));
+ tempRow.find(' ', (nextChar + 1)));
if (nextSpacePos <= 0)
nextSpacePos = CAST_U32(sz) - 1U;
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 85927cd0e..3da3ea7bf 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -377,8 +377,8 @@ void Setup_Video::action(const ActionEvent &event)
return;
}
}
- const int width = atoi(mode.substr(0, mode.find("x")).c_str());
- const int height = atoi(mode.substr(mode.find("x") + 1).c_str());
+ const int width = atoi(mode.substr(0, mode.find('x')).c_str());
+ const int height = atoi(mode.substr(mode.find('x') + 1).c_str());
if (!width || !height)
return;
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 479349503..edf360b62 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -116,7 +116,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
mMinWidth = minDimension;
const size_t textSize = text.size();
- size_t spacePos = text.rfind(" ", textSize);
+ size_t spacePos = text.rfind(' ', textSize);
if (spacePos != std::string::npos)
{
@@ -136,7 +136,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
do
{
// Determine next piece of string to wrap
- newlinePos = text.find("\n", lastNewlinePos);
+ newlinePos = text.find('\n', lastNewlinePos);
if (newlinePos == std::string::npos)
newlinePos = textSize;
@@ -151,7 +151,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
do
{
- spacePos = line.find(" ", lastSpacePos);
+ spacePos = line.find(' ', lastSpacePos);
if (spacePos == std::string::npos)
spacePos = sz;
@@ -190,7 +190,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
wrappedStream.clear();
wrappedStream.str("");
lastNewlinePos = 0;
- newlinePos = text.find("\n", lastNewlinePos);
+ newlinePos = text.find('\n', lastNewlinePos);
if (newlinePos == std::string::npos)
newlinePos = textSize;
line = text.substr(lastNewlinePos, newlinePos -
@@ -208,7 +208,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension)
}
while (spacePos != sz);
- if (text.find("\n", lastNewlinePos) != std::string::npos)
+ if (text.find('\n', lastNewlinePos) != std::string::npos)
wrappedStream << "\n";
lastNewlinePos = newlinePos + 1;
@@ -240,7 +240,7 @@ void TextBox::setText(const std::string& text)
int length;
do
{
- pos = text.find("\n", lastPos);
+ pos = text.find('\n', lastPos);
if (pos != std::string::npos)
length = CAST_S32(pos - lastPos);
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index d7392acc6..726774cdf 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1107,7 +1107,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick,
if (tab->getRemoveNames())
{
std::string msg = mes;
- const size_t idx = mes.find(":");
+ const size_t idx = mes.find(':');
if (idx != std::string::npos && idx > 0)
{
std::string nick2 = msg.substr(0, idx);
@@ -1592,10 +1592,10 @@ bool ChatWindow::resortChatLog(std::string line,
if (idx2 != std::string::npos)
{
std::string tmpNick = line.substr(0, idx2);
- if (tmpNick.find("#") != std::string::npos ||
- tmpNick.find(":") != std::string::npos ||
- tmpNick.find("%") != std::string::npos ||
- tmpNick.find("@") != std::string::npos ||
+ if (tmpNick.find('#') != std::string::npos ||
+ tmpNick.find(':') != std::string::npos ||
+ tmpNick.find('%') != std::string::npos ||
+ tmpNick.find('@') != std::string::npos ||
tmpNick.size() < 5 ||
tmpNick[0] == '@' ||
tmpNick[0] == '/' ||
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 38dbb8b92..84193a5d7 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -708,7 +708,7 @@ void NpcDialog::parseListItems(const std::string &itemString)
{
if (tmp.empty())
continue;
- const size_t pos = tmp.find("|");
+ const size_t pos = tmp.find('|');
if (pos == std::string::npos)
{
mItems.push_back(tmp);
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index b3cecc424..091e2c20e 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -224,7 +224,7 @@ void RegisterDialog::action(const ActionEvent &event)
error = 2;
}
else if (mEmailField &&
- mEmailField->getText().find("@") == std::string::npos)
+ mEmailField->getText().find('@') == std::string::npos)
{
// TRANSLATORS: error message
errorMsg = _("Incorrect email.");
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 83d54730f..4dc8174cb 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -906,7 +906,7 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
if (!inv)
return;
- const size_t idx = data.find(" ");
+ const size_t idx = data.find(' ');
if (idx == std::string::npos)
return;
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index d970cf8b9..eb4fff376 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -430,7 +430,7 @@ void WhoIsOnline::loadWebList()
}
trim(lineStr);
- pos = lineStr.find("/", 0);
+ pos = lineStr.find('/', 0);
if (pos != std::string::npos)
lineStr = lineStr.substr(0, pos);
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index a916776c0..f54855316 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -957,8 +957,6 @@ void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
FOR_EACH (KeyToActionMapIter, it, actionMap)
{
KeysVector *const keys = &it->second;
- if (!keys)
- continue;
if (keys->size() > 1)
std::sort(keys->begin(), keys->end(), inputActionDataSorter);
}
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 3844cc01f..570007cea 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -92,7 +92,7 @@ Download::Download(void *const ptr,
const std::string serverName = settings.serverName;
if (!serverName.empty())
{
- if (mUrl.find("?") == std::string::npos)
+ if (mUrl.find('?') == std::string::npos)
mUrl.append("?host=");
else
mUrl.append("&host=");
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 397e10a29..5e5fe01d3 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -44,7 +44,7 @@ void GameHandler::who() const
void GameHandler::setMap(const std::string &map)
{
- GameRecv::mMap = map.substr(0, map.rfind("."));
+ GameRecv::mMap = map.substr(0, map.rfind('.'));
}
void GameHandler::clear() const
diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp
index 92b151b21..6503b9f3c 100644
--- a/src/net/ea/playerrecv.cpp
+++ b/src/net/ea/playerrecv.cpp
@@ -85,7 +85,7 @@ void PlayerRecv::processPlayerWarp(Net::MessageIn &msg)
const bool sameMap = (currentMapName == mapPath);
// Switch the actual map, deleting the previous one if necessary
- mapPath = mapPath.substr(0, mapPath.rfind("."));
+ mapPath = mapPath.substr(0, mapPath.rfind('.'));
game->changeMap(mapPath);
int scrollOffsetX = 0;
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index bbfc1af3e..349777136 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -120,7 +120,7 @@ void ChatHandler::sendRaw(const std::string &args) const
if (line.empty())
return;
- size_t pos = line.find(" ");
+ size_t pos = line.find(' ');
if (pos != std::string::npos)
{
str = line.substr(0, pos);
@@ -129,7 +129,7 @@ void ChatHandler::sendRaw(const std::string &args) const
outMsg = new MessageOut(id);
outMsg->writeInt16(id, "packet id");
line = line.substr(pos + 1);
- pos = line.find(" ");
+ pos = line.find(' ');
}
else
{
@@ -145,7 +145,7 @@ void ChatHandler::sendRaw(const std::string &args) const
str = line.substr(0, pos);
processRaw(*outMsg, str);
line = line.substr(pos + 1);
- pos = line.find(" ");
+ pos = line.find(' ');
}
if (!line.empty())
processRaw(*outMsg, line);
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index c372e4305..766e32108 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -118,7 +118,7 @@ void ChatHandler::sendRaw(const std::string &args) const
if (line.empty())
return;
- size_t pos = line.find(" ");
+ size_t pos = line.find(' ');
if (pos != std::string::npos)
{
str = line.substr(0, pos);
@@ -126,7 +126,7 @@ void ChatHandler::sendRaw(const std::string &args) const
outMsg = new MessageOut(id);
outMsg->writeInt16(id, "packet id");
line = line.substr(pos + 1);
- pos = line.find(" ");
+ pos = line.find(' ');
}
else
{
@@ -142,7 +142,7 @@ void ChatHandler::sendRaw(const std::string &args) const
str = line.substr(0, pos);
processRaw(*outMsg, str);
line = line.substr(pos + 1);
- pos = line.find(" ");
+ pos = line.find(' ');
}
if (!line.empty())
processRaw(*outMsg, line);
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.
diff --git a/src/units.cpp b/src/units.cpp
index 237b414f0..08f410c9d 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -284,7 +284,7 @@ std::string Units::formatWeight(const int value)
static std::string splitNumber(std::string str, const std::string &separator)
{
std::string lastPart;
- const size_t point = str.find(".");
+ const size_t point = str.find('.');
if (point != std::string::npos)
{
lastPart = str.substr(point);
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index c8101930c..275c3449e 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -48,11 +48,11 @@ LangVect getLang()
return langs;
}
- size_t dot = lang.find(".");
+ size_t dot = lang.find('.');
if (dot != std::string::npos)
lang = lang.substr(0, dot);
langs.push_back(lang);
- dot = lang.find("_");
+ dot = lang.find('_');
if (dot != std::string::npos)
langs.push_back(lang.substr(0, dot));
return langs;
@@ -90,10 +90,10 @@ std::string getLangShort()
return "";
}
- size_t dot = lang.find(".");
+ size_t dot = lang.find('.');
if (dot != std::string::npos)
lang = lang.substr(0, dot);
- dot = lang.find("_");
+ dot = lang.find('_');
if (dot != std::string::npos)
return lang.substr(0, dot);
return lang;
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index 9023c4909..1a7f50b69 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -108,8 +108,8 @@ std::string &fixDirSeparators(std::string &str)
std::string removeLast(const std::string &str)
{
- size_t pos2 = str.rfind("/");
- const size_t pos3 = str.rfind("\\");
+ size_t pos2 = str.rfind('/');
+ const size_t pos3 = str.rfind('\\');
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index d1d9b7200..7292a4f62 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -265,11 +265,11 @@ unsigned int decodeStr(const std::string &str)
std::string extractNameFromSprite(std::string str)
{
- const size_t pos1 = str.rfind(".");
+ const size_t pos1 = str.rfind('.');
if (pos1 != std::string::npos)
{
- size_t pos2 = str.rfind("/");
- const size_t pos3 = str.rfind("\\");
+ size_t pos2 = str.rfind('/');
+ const size_t pos3 = str.rfind('\\');
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -287,12 +287,12 @@ std::string extractNameFromSprite(std::string str)
std::string removeSpriteIndex(std::string str)
{
- const size_t pos1 = str.rfind("[");
+ const size_t pos1 = str.rfind('[');
if (pos1 != std::string::npos)
{
- size_t pos2 = str.rfind("/");
- const size_t pos3 = str.rfind("\\");
+ size_t pos2 = str.rfind('/');
+ const size_t pos3 = str.rfind('\\');
if (pos3 != std::string::npos)
{
if (pos2 == std::string::npos || pos3 > pos2)
@@ -341,8 +341,8 @@ void getSafeUtf8String(std::string text, char *const buf)
std::string getFileName(const std::string &path)
{
- size_t pos1 = path.rfind("/");
- const size_t pos2 = path.rfind("\\");
+ size_t pos1 = path.rfind('/');
+ const size_t pos2 = path.rfind('\\');
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -355,8 +355,8 @@ std::string getFileName(const std::string &path)
std::string getFileDir(const std::string &path)
{
- size_t pos1 = path.rfind("/");
- const size_t pos2 = path.rfind("\\");
+ size_t pos1 = path.rfind('/');
+ const size_t pos2 = path.rfind('\\');
if (pos1 == std::string::npos)
pos1 = pos2;
else if (pos2 != std::string::npos && pos2 > pos1)
@@ -398,7 +398,7 @@ bool getBoolFromString(const std::string &text)
void replaceSpecialChars(std::string &text)
{
- size_t pos1 = text.find("&");
+ size_t pos1 = text.find('&');
while (pos1 != std::string::npos)
{
const size_t idx = pos1 + 1;
@@ -425,7 +425,7 @@ void replaceSpecialChars(std::string &text)
pos1 = f + 1;
}
- pos1 = text.find("&", pos1);
+ pos1 = text.find('&', pos1);
}
}
@@ -512,7 +512,7 @@ std::string combineDye(std::string file, const std::string &dye)
{
if (dye.empty())
return file;
- const size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of('|');
if (pos != std::string::npos)
return file.substr(0, pos).append("|").append(dye);
return file.append("|").append(dye);
@@ -523,7 +523,7 @@ std::string combineDye2(std::string file, const std::string &dye)
if (dye.empty())
return file;
- const size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of('|');
if (pos != std::string::npos)
{
const std::string dye1 = file.substr(pos + 1);
@@ -550,7 +550,7 @@ std::string combineDye3(std::string file, const std::string &dye)
if (dye.empty())
return file;
- const size_t pos = file.find_last_of("|");
+ const size_t pos = file.find_last_of('|');
if (pos != std::string::npos)
{
const std::string dye1 = file.substr(pos + 1);
@@ -866,9 +866,9 @@ void secureChatCommand(std::string &str)
bool parse2Int(const std::string &args, int &x, int &y)
{
bool isValid = false;
- size_t pos = args.find(" ");
+ size_t pos = args.find(' ');
if (pos == std::string::npos)
- pos = args.find(",");
+ pos = args.find(',');
if (pos != std::string::npos)
{
if (pos + 1 < args.length())
@@ -884,9 +884,9 @@ bool parse2Int(const std::string &args, int &x, int &y)
bool parse2Str(const std::string &args, std::string &str1, std::string &str2)
{
bool isValid = false;
- size_t pos = args.find(" ");
+ size_t pos = args.find(' ');
if (pos == std::string::npos)
- pos = args.find(",");
+ pos = args.find(',');
if (pos != std::string::npos)
{
if (pos + 1 < args.length())