summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-01 21:35:49 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-01 22:40:36 +0300
commitfc854786ed73fe768d6a3ca22c02f7013560a930 (patch)
tree3a12f555d194679957559760567ff8eb701b494b
parent09d74d9273cca445b7019edacaff53452a1eee3c (diff)
downloadplus-fc854786ed73fe768d6a3ca22c02f7013560a930.tar.gz
plus-fc854786ed73fe768d6a3ca22c02f7013560a930.tar.bz2
plus-fc854786ed73fe768d6a3ca22c02f7013560a930.tar.xz
plus-fc854786ed73fe768d6a3ca22c02f7013560a930.zip
Fix code style.
-rw-r--r--src/actorsprite.cpp2
-rw-r--r--src/actorspritemanager.cpp4
-rw-r--r--src/animatedsprite.cpp2
-rw-r--r--src/being.cpp2
-rw-r--r--src/being.h2
-rw-r--r--src/client.cpp2
-rw-r--r--src/configuration.cpp48
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/charselectdialog.cpp19
-rw-r--r--src/gui/chatwindow.cpp5
-rw-r--r--src/gui/socialwindow.h2
-rw-r--r--src/gui/theme.h2
-rw-r--r--src/gui/viewport.cpp45
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
-rw-r--r--src/guichan/focushandler.cpp14
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/map.cpp7
-rw-r--r--src/net/download.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp2
-rw-r--r--src/net/eathena/beinghandler.cpp2
-rw-r--r--src/net/eathena/charserverhandler.cpp7
-rw-r--r--src/net/tmwa/charserverhandler.cpp7
-rw-r--r--src/playerinfo.cpp7
-rw-r--r--src/resources/emotedb.cpp18
-rw-r--r--src/resources/imagehelper.cpp11
-rw-r--r--src/resources/resourcemanager.cpp9
-rw-r--r--src/utils/mkdir.cpp3
-rw-r--r--src/utils/process.cpp7
-rw-r--r--src/utils/sha256.cpp2
-rw-r--r--src/variabledata.h2
30 files changed, 125 insertions, 116 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index e5d0cd288..584156392 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -500,7 +500,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
Animation *anim = new Animation;
- for (unsigned int i = 0; i < currentImageSet->size(); ++i)
+ for (size_t i = 0; i < currentImageSet->size(); ++i)
{
anim->addFrame(currentImageSet->get(i), 75,
(16 - (currentImageSet->getWidth() / 2)),
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 9d933ad72..61ca20a79 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -655,7 +655,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
}
}
}
- if (closestItem && player_node && dist <= maxdist)
+ if (closestItem && dist <= maxdist)
return player_node->pickUp(closestItem);
return false;
@@ -1430,7 +1430,7 @@ void ActorSpriteManager::updatePlayerGuild()
void ActorSpriteManager::parseLevels(std::string levels)
{
levels += ", ";
- unsigned int f = 0;
+ size_t f = 0;
size_t pos = 0;
const std::string brkEnd = "), ";
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 4368643c5..69aaceaaa 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -206,7 +206,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
{
if (mFrame->rand == 100 || rand() % 100 <= mFrame->rand)
{
- for (unsigned i = 0; i < mAnimation->getLength(); i ++)
+ for (size_t i = 0; i < mAnimation->getLength(); i ++)
{
Frame *frame = &mAnimation->mFrames[i];
if (frame->type == Frame::LABEL
diff --git a/src/being.cpp b/src/being.cpp
index 094f01c66..e230d5a5a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2419,7 +2419,7 @@ void Being::searchSlotValueItr(std::vector<int>::iterator &it, int &idx,
// logger->log("found at %d", idx);
return;
}
- it ++;
+ ++ it;
idx ++;
}
// logger->log("not found");
diff --git a/src/being.h b/src/being.h
index d09e97225..5ece2bc41 100644
--- a/src/being.h
+++ b/src/being.h
@@ -527,7 +527,7 @@ class Being : public ActorSprite, public ConfigListener
* Returns the direction the being is facing.
*/
SpriteDirection getSpriteDirection() const
- { return SpriteDirection(mSpriteDirection); }
+ { return static_cast<SpriteDirection>(mSpriteDirection); }
void setPosition(const Vector &pos);
diff --git a/src/client.cpp b/src/client.cpp
index e264235d5..b91150626 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -495,7 +495,7 @@ void Client::gameInit()
icon = LoadIcon(GetModuleHandle(nullptr), "A");
if (icon)
- SetClassLong(pInfo.window, GCL_HICON, (LONG)(icon));
+ SetClassLong(pInfo.window, GCL_HICON, reinterpret_cast<LONG>(icon));
#else
mIcon = IMG_Load(iconFile.c_str());
if (mIcon)
diff --git a/src/configuration.cpp b/src/configuration.cpp
index defa38812..d61e24a3b 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -364,19 +364,19 @@ int Configuration::getIntValue(const std::string &key) const
if (itdef != mDefaultsData->end() && itdef->second)
{
- if (itdef->second->getType() == VariableData::DATA_INT)
+ VariableData::DataType type = static_cast<
+ VariableData::DataType>(itdef->second->getType());
+ if (type == VariableData::DATA_INT)
{
defaultValue = (static_cast<IntData*>(
itdef->second))->getData();
}
- else if (itdef->second->getType()
- == VariableData::DATA_STRING)
+ else if (type == VariableData::DATA_STRING)
{
defaultValue = atoi((static_cast<StringData*>(
itdef->second))->getData().c_str());
}
- else if (itdef->second->getType()
- == VariableData::DATA_BOOL)
+ else if (type == VariableData::DATA_BOOL)
{
if ((static_cast<BoolData*>(
itdef->second))->getData())
@@ -388,7 +388,7 @@ int Configuration::getIntValue(const std::string &key) const
defaultValue = 0;
}
}
- else if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ else if (type == VariableData::DATA_FLOAT)
{
defaultValue = static_cast<int>(
(static_cast<FloatData*>(itdef->second))->getData());
@@ -445,14 +445,14 @@ std::string Configuration::getStringValue(const std::string &key) const
if (itdef != mDefaultsData->end() && itdef->second)
{
- if (itdef->second->getType()
- == VariableData::DATA_STRING)
+ VariableData::DataType type = static_cast<
+ VariableData::DataType>(itdef->second->getType());
+ if (type == VariableData::DATA_STRING)
{
defaultValue = (static_cast<StringData*>(
itdef->second))->getData();
}
- else if (itdef->second->getType()
- == VariableData::DATA_BOOL)
+ else if (type == VariableData::DATA_BOOL)
{
if ((static_cast<BoolData*>(
itdef->second))->getData())
@@ -464,8 +464,7 @@ std::string Configuration::getStringValue(const std::string &key) const
defaultValue = "0";
}
}
- else if (itdef->second->getType()
- == VariableData::DATA_INT)
+ else if (type == VariableData::DATA_INT)
{
defaultValue = toString((static_cast<IntData*>(
itdef->second))->getData());
@@ -499,20 +498,20 @@ float Configuration::getFloatValue(const std::string &key) const
if (itdef != mDefaultsData->end() && itdef->second)
{
- if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ VariableData::DataType type = static_cast<
+ VariableData::DataType>(itdef->second->getType());
+ if (type == VariableData::DATA_FLOAT)
{
defaultValue = static_cast<float>(
(static_cast<FloatData*>(itdef->second))->getData());
}
- else if (itdef->second->getType()
- == VariableData::DATA_STRING)
+ else if (type == VariableData::DATA_STRING)
{
defaultValue = static_cast<float>(atof((
static_cast<StringData*>(
itdef->second))->getData().c_str()));
}
- else if (itdef->second->getType()
- == VariableData::DATA_BOOL)
+ else if (type == VariableData::DATA_BOOL)
{
if ((static_cast<BoolData*>(
itdef->second))->getData())
@@ -524,8 +523,7 @@ float Configuration::getFloatValue(const std::string &key) const
defaultValue = 0;
}
}
- else if (itdef->second->getType()
- == VariableData::DATA_INT)
+ else if (type == VariableData::DATA_INT)
{
defaultValue = static_cast<float>((static_cast<IntData*>(
itdef->second))->getData());
@@ -558,13 +556,14 @@ bool Configuration::getBoolValue(const std::string &key) const
if (itdef != mDefaultsData->end() && itdef->second)
{
- if (itdef->second->getType() == VariableData::DATA_BOOL)
+ VariableData::DataType type = static_cast<
+ VariableData::DataType>(itdef->second->getType());
+ if (type == VariableData::DATA_BOOL)
{
defaultValue = (static_cast<BoolData*>(
itdef->second))->getData();
}
- else if (itdef->second->getType()
- == VariableData::DATA_INT)
+ else if (type == VariableData::DATA_INT)
{
if ((static_cast<IntData*>(
itdef->second))->getData() != 0)
@@ -576,8 +575,7 @@ bool Configuration::getBoolValue(const std::string &key) const
defaultValue = false;
}
}
- else if (itdef->second->getType()
- == VariableData::DATA_STRING)
+ else if (type == VariableData::DATA_STRING)
{
if ((static_cast<StringData*>(
itdef->second))->getData() != "0")
@@ -589,7 +587,7 @@ bool Configuration::getBoolValue(const std::string &key) const
defaultValue = false;
}
}
- if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ if (type == VariableData::DATA_FLOAT)
{
if (static_cast<int>((static_cast<FloatData*>(
itdef->second))->getData()) != 0)
diff --git a/src/game.cpp b/src/game.cpp
index 58a559ec7..2314940d8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -643,7 +643,7 @@ void Game::adjustPerfomance()
{
mNextAdjustTime = cur_time + adjustDelay;
}
- else if (mNextAdjustTime < (unsigned)cur_time)
+ else if (mNextAdjustTime < static_cast<unsigned>(cur_time))
{
mNextAdjustTime = cur_time + adjustDelay;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index a212d08c4..95f76d228 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -530,16 +530,19 @@ bool CharSelectDialog::selectByName(const std::string &name,
for (int i = 0; i < static_cast<int>(mCharacterEntries.size()); ++i)
{
- Net::Character *character = mCharacterEntries[i]->getCharacter();
- if (mCharacterEntries[i] && character)
+ if (mCharacterEntries[i])
{
- if (character->dummy && character->dummy->getName() == name)
+ Net::Character *character = mCharacterEntries[i]->getCharacter();
+ if (character)
{
- if (mCharacterEntries[i])
- mCharacterEntries[i]->requestFocus();
- if (selAction == Choose)
- attemptCharacterSelect(i);
- return true;
+ if (character->dummy && character->dummy->getName() == name)
+ {
+ if (mCharacterEntries[i])
+ mCharacterEntries[i]->requestFocus();
+ if (selAction == Choose)
+ attemptCharacterSelect(i);
+ return true;
+ }
}
}
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 75ec6d09c..0229f9da5 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -845,11 +845,12 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
ChatTab *tab = getFocused();
if (tab && tab->hasRows())
{
- if (mChatHistoryIndex + 1 < tab->getRows().size())
+ const size_t tabSize = tab->getRows().size();
+ if (mChatHistoryIndex + 1 < tabSize)
{
mChatHistoryIndex ++;
}
- else if (mChatHistoryIndex < tab->getRows().size())
+ else if (mChatHistoryIndex < tabSize)
{
mChatHistoryIndex ++;
mChatInput->setText("");
diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h
index e4eac29ae..478b62bfe 100644
--- a/src/gui/socialwindow.h
+++ b/src/gui/socialwindow.h
@@ -110,7 +110,7 @@ public:
bool getProcessedPortals() const
{ return mProcessedPortals; }
- void setProcessedPortals(int n)
+ void setProcessedPortals(bool n)
{ mProcessedPortals = n; }
void selectPortal(unsigned num);
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 69a08bff0..216b19802 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -34,6 +34,8 @@
#include <map>
+#include "localconsts.h"
+
class DyePalette;
class Image;
class ImageSet;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 2a8d36a60..194ad7310 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -139,7 +139,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
// Calculate viewpoint
int midTileX = (graphics->mWidth + mScrollCenterOffsetX) / 2;
- int midTileY = (graphics->mHeight + mScrollCenterOffsetX) / 2;
+ int midTileY = (graphics->mHeight + mScrollCenterOffsetY) / 2;
const Vector &playerPos = player_node->getPosition();
const int player_x = static_cast<int>(playerPos.x)
@@ -219,27 +219,25 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
mMap->getWidth() * mMap->getTileWidth() - graphics->mWidth;
const int viewYmax =
mMap->getHeight() * mMap->getTileHeight() - graphics->mHeight;
- if (mMap)
+
+ if (mPixelViewX < 0)
+ mPixelViewX = 0;
+ if (mPixelViewY < 0)
+ mPixelViewY = 0;
+ if (mPixelViewX > viewXmax)
+ mPixelViewX = viewXmax;
+ if (mPixelViewY > viewYmax)
+ mPixelViewY = viewYmax;
+
+ // Draw tiles and sprites
+ mMap->draw(graphics, mPixelViewX, mPixelViewY);
+
+ if (mShowDebugPath)
{
- if (mPixelViewX < 0)
- mPixelViewX = 0;
- if (mPixelViewY < 0)
- mPixelViewY = 0;
- if (mPixelViewX > viewXmax)
- mPixelViewX = viewXmax;
- if (mPixelViewY > viewYmax)
- mPixelViewY = viewYmax;
-
- // Draw tiles and sprites
- mMap->draw(graphics, mPixelViewX, mPixelViewY);
-
- if (mShowDebugPath)
- {
- mMap->drawCollision(graphics, mPixelViewX,
- mPixelViewY, mShowDebugPath);
- if (mShowDebugPath == Map::MAP_DEBUG)
- _drawDebugPath(graphics);
- }
+ mMap->drawCollision(graphics, mPixelViewX,
+ mPixelViewY, mShowDebugPath);
+ if (mShowDebugPath == Map::MAP_DEBUG)
+ _drawDebugPath(graphics);
}
if (player_node->getCheckNameSetting())
@@ -780,10 +778,9 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
{
if (!mHoverSign->getComment().empty())
{
- if (mBeingPopup)
- mBeingPopup->setVisible(false);
+ mBeingPopup->setVisible(false);
mTextPopup->show(getMouseX(), getMouseY(),
- mHoverSign->getComment());
+ mHoverSign->getComment());
}
else
{
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 3031460c4..6171e9f03 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -118,7 +118,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
temp = mWarningColor;
temp.r = (temp.r + mHighlightColor.r) / 2;
temp.g = (temp.g + mHighlightColor.g) / 2;
- temp.b = (temp.g + mHighlightColor.b) / 2;
+ temp.b = (temp.b + mHighlightColor.b) / 2;
temp.a = alpha;
backgroundColor = &temp;
}
diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp
index 393c08880..494a2a899 100644
--- a/src/guichan/focushandler.cpp
+++ b/src/guichan/focushandler.cpp
@@ -369,10 +369,9 @@ namespace gcn
if (focusedWidget == focused)
return;
- if (mWidgets.at(focusedWidget)->isFocusable() &&
- mWidgets.at(focusedWidget)->isTabInEnabled() &&
- (!mModalFocusedWidget ||
- mWidgets.at(focusedWidget)->isModalFocused()))
+ const Widget *widget = mWidgets.at(focusedWidget);
+ if (widget->isFocusable() && widget->isTabInEnabled() &&
+ (!mModalFocusedWidget || widget->isModalFocused()))
{
done = true;
}
@@ -438,10 +437,9 @@ namespace gcn
if (focusedWidget == focused)
return;
- if (mWidgets.at(focusedWidget)->isFocusable() &&
- mWidgets.at(focusedWidget)->isTabInEnabled() &&
- (!mModalFocusedWidget ||
- mWidgets.at(focusedWidget)->isModalFocused()))
+ const Widget *widget = mWidgets.at(focusedWidget);
+ if (widget->isFocusable() && widget->isTabInEnabled() &&
+ (!mModalFocusedWidget || widget->isModalFocused()))
{
done = true;
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index dc5c697db..66b5c11c1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -4067,7 +4067,7 @@ void LocalPlayer::setRealPos(int x, int y)
mCrossX = x;
mCrossY = y;
}
- if (mMap && mMap->isCustom())
+ if (mMap->isCustom())
mMap->setWalk(x, y, true);
}
void LocalPlayer::fixAttackTarget()
diff --git a/src/map.cpp b/src/map.cpp
index 242162429..7fdb9a1bd 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -914,7 +914,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
// Skip if the tile is on the closed list or is not walkable
// unless its the destination tile
//+++ here need check block must depend on player abilities.
- if (!newTile || newTile->whichList == mOnClosedList ||
+ if (newTile->whichList == mOnClosedList ||
((newTile->blockmask & walkmask)
&& !(x == destX && y == destY))
|| (newTile->blockmask & BLOCKMASK_WALL))
@@ -931,11 +931,8 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
MetaTile *t2 = &mMetaTiles[curr.x + dx + curWidth];
//+++ here need check block must depend on player abilities.
- if (!t1 || !t2 || ((t1->blockmask | t2->blockmask)
- & BLOCKMASK_WALL))
- {
+ if (((t1->blockmask | t2->blockmask) & BLOCKMASK_WALL))
continue;
- }
}
// Calculate G cost for this route, ~sqrt(2) for moving diagonal
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 77ca69fa2..a0d7dbe25 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -129,7 +129,7 @@ void Download::setFile(const std::string &filename, int64_t adler32)
}
else
{
- mOptions.checkAdler = 0;
+ mOptions.checkAdler = 0;
}
}
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 0e4fefa21..765cbc651 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -273,7 +273,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
setSprite(dstBeing, EA_SPRITE_HAT, headTop);
setSprite(dstBeing, EA_SPRITE_SHOE, shoes);
setSprite(dstBeing, EA_SPRITE_GLOVES, gloves);
- setSprite(dstBeing, EA_SPRITE_WEAPON, weapon, "", true);
+ setSprite(dstBeing, EA_SPRITE_WEAPON, weapon, "", 1, true);
if (!config.getBoolValue("hideShield"))
setSprite(dstBeing, EA_SPRITE_SHIELD, shield);
}
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 799282d59..9cd7fdeaf 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -782,7 +782,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
setSprite(dstBeing, SPRITE_HAT, headTop);
setSprite(dstBeing, SPRITE_SHOE, shoes);
setSprite(dstBeing, SPRITE_GLOVES, gloves);
- setSprite(dstBeing, SPRITE_WEAPON, weapon, "", true);
+ setSprite(dstBeing, SPRITE_WEAPON, weapon, "", 1, true);
if (!config.getBoolValue("hideShield"))
setSprite(dstBeing, SPRITE_SHIELD, shield);
}
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 2348e0a67..085767a46 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -178,11 +178,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
PlayerInfoBackend &data = character->data;
data.mAttributes[PlayerInfo::EXP] = msg.readInt32();
data.mAttributes[PlayerInfo::MONEY] = msg.readInt32();
- data.mStats[JOB].exp = msg.readInt32();
+ Stat &jobStat = data.mStats[JOB];
+ jobStat.exp = msg.readInt32();
int temp = msg.readInt32();
- data.mStats[JOB].base = temp;
- data.mStats[JOB].mod = temp;
+ jobStat.base = temp;
+ jobStat.mod = temp;
int shoes = msg.readInt16();
int gloves = msg.readInt16();
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index b851a5093..0a660a79d 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -179,11 +179,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
PlayerInfoBackend &data = character->data;
data.mAttributes[PlayerInfo::EXP] = msg.readInt32();
data.mAttributes[PlayerInfo::MONEY] = msg.readInt32();
- data.mStats[JOB].exp = msg.readInt32();
+ Stat &jobStat = data.mStats[JOB];
+ jobStat.exp = msg.readInt32();
int temp = msg.readInt32();
- data.mStats[JOB].base = temp;
- data.mStats[JOB].mod = temp;
+ jobStat.base = temp;
+ jobStat.mod = temp;
int shoes = msg.readInt16();
int gloves = msg.readInt16();
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 61d72df3b..c22352436 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -267,9 +267,10 @@ void logic()
for (SpecialsMap::iterator it = mSpecials.begin(),
it_end = mSpecials.end(); it != it_end; ++it)
{
- it->second.currentMana += it->second.recharge;
- if (it->second.currentMana > it->second.neededMana)
- it->second.currentMana = it->second.neededMana;
+ Special &special = it->second;
+ special.currentMana += special.recharge;
+ if (special.currentMana > special.neededMana)
+ special.currentMana = special.neededMana;
}
}
mSpecialRechargeUpdateNeeded++;
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index b3628cdeb..a8e8b434f 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -181,11 +181,12 @@ void EmoteDB::unload()
{
if (i->second)
{
- while (!i->second->sprites.empty())
+ std::list<EmoteSprite*> &sprites = i->second->sprites;
+ while (!sprites.empty())
{
- delete i->second->sprites.front()->sprite;
- delete i->second->sprites.front();
- i->second->sprites.pop_front();
+ delete sprites.front()->sprite;
+ delete sprites.front();
+ sprites.pop_front();
}
delete i->second;
}
@@ -193,11 +194,12 @@ void EmoteDB::unload()
mEmoteInfos.clear();
- while (!mUnknown.sprites.empty())
+ std::list<EmoteSprite*> &sprites = mUnknown.sprites;
+ while (!sprites.empty())
{
- delete mUnknown.sprites.front()->sprite;
- delete mUnknown.sprites.front();
- mUnknown.sprites.pop_front();
+ delete sprites.front()->sprite;
+ delete sprites.front();
+ sprites.pop_front();
}
mLoaded = false;
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index a70889acd..4762d42e0 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -105,10 +105,13 @@ void ImageHelper::dumpSurfaceFormat(SDL_Surface *image)
const SDL_PixelFormat * const format = image->format;
logger->log("Bytes per pixel: %d", format->BytesPerPixel);
logger->log("Alpha: %d", format->alpha);
- logger->log("Loss: %02x, %02x, %02x, %02x", (int)format->Rloss,
- (int)format->Gloss, (int)format->Bloss, (int)format->Aloss);
- logger->log("Shift: %02x, %02x, %02x, %02x", (int)format->Rshift,
- (int)format->Gshift, (int)format->Bshift, (int)format->Ashift);
+ logger->log("Loss: %02x, %02x, %02x, %02x",
+ static_cast<int>(format->Rloss), static_cast<int>(format->Gloss),
+ static_cast<int>(format->Bloss), static_cast<int>(format->Aloss));
+ logger->log("Shift: %02x, %02x, %02x, %02x",
+ static_cast<int>(format->Rshift), static_cast<int>(format->Gshift),
+ static_cast<int>(format->Bshift),
+ static_cast<int>(format->Ashift));
logger->log("Mask: %08x, %08x, %08x, %08x", format->Rmask,
format->Gmask, format->Bmask, format->Amask);
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 8b9c4e3c0..5b4feb08f 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -688,12 +688,13 @@ void ResourceManager::deleteInstance()
while (iter != instance->mResources.end())
{
- if (iter->second)
+ Resource *res = iter->second;
+ if (res)
{
- if (iter->second->getRefCount())
+ if (res->getRefCount())
{
- logger->log("ResourceLeak: " + iter->second->getIdPath()
- + " (" + toString(iter->second->getRefCount()) + ")");
+ logger->log("ResourceLeak: " + res->getIdPath()
+ + " (" + toString(res->getRefCount()) + ")");
}
}
++iter;
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 4632bec84..f73af6db5 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -54,6 +54,9 @@ int mkdir_r(const char *pathname)
int len = static_cast<int>(strlen(tmp));
+ if (len < 1)
+ return -1;
+
// terminate the pathname with '/'
if (tmp[len - 1] != '/')
{
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index b02874b0d..3a742b313 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -86,9 +86,10 @@ bool execFile(std::string pathName, std::string name A_UNUSED,
if (!arg2.empty())
args += " " + arg2;
- bool res = CreateProcess(pathName.c_str(), (char*)args.c_str(), nullptr,
- nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr,
- &siStartupInfo, &piProcessInfo);
+ bool res = CreateProcess(pathName.c_str(), const_cast<char*>(
+ args.c_str()), nullptr, nullptr, false,
+ CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo,
+ &piProcessInfo);
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index 21ded486b..a56f6ec9a 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -279,7 +279,7 @@ std::string SHA256Hash(const char *src, int len)
unsigned char bytehash[SHA256_DIGEST_SIZE];
SHA256Context ctx;
SHA256Init(&ctx);
- SHA256Update(&ctx, (unsigned char *)(src),
+ SHA256Update(&ctx, static_cast<unsigned char *>(src),
static_cast<unsigned int>(len));
SHA256Final(&ctx, bytehash);
// Convert it to hex
diff --git a/src/variabledata.h b/src/variabledata.h
index c06c16e58..71c0e8afb 100644
--- a/src/variabledata.h
+++ b/src/variabledata.h
@@ -27,7 +27,7 @@
class VariableData
{
public:
- enum
+ enum DataType
{
DATA_NONE = 0,
DATA_INT,