summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-11 18:09:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-11 18:09:33 +0300
commit17dcb835103ac05012c5a7eafa8c7702cef53390 (patch)
tree422c28adfba13f2161fcfc36943a3903e531490b
parent84d53b7bb98bb44696ed1bc2c3f132e51394ac00 (diff)
downloadplus-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.gz
plus-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.bz2
plus-17dcb835103ac05012c5a7eafa8c7702cef53390.tar.xz
plus-17dcb835103ac05012c5a7eafa8c7702cef53390.zip
Add some fixes after automatic checks.
-rw-r--r--src/actorspritemanager.cpp4
-rw-r--r--src/actorspritemanager.h4
-rw-r--r--src/client.cpp19
-rw-r--r--src/client.h3
-rw-r--r--src/compoundsprite.cpp20
-rw-r--r--src/gui/socialwindow.cpp9
-rw-r--r--src/gui/statuspopup.cpp39
-rw-r--r--src/gui/statuspopup.h5
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/guitable.cpp2
-rw-r--r--src/gui/widgets/shopitems.cpp4
-rw-r--r--src/gui/widgets/shoplistbox.cpp4
-rw-r--r--src/gui/widgets/shoplistbox.h2
-rw-r--r--src/maplayer.cpp2
-rw-r--r--src/maplayer.h2
-rw-r--r--src/net/ea/inventoryhandler.cpp60
-rw-r--r--src/resources/mapreader.cpp4
-rw-r--r--src/utils/process.cpp4
-rw-r--r--src/utils/stringutils.cpp6
19 files changed, 63 insertions, 132 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index a9897872b..90a71aaee 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -842,7 +842,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
aroundBeing, int maxDist,
- const Being::Type type,
+ const Being::Type &type,
const int x, const int y,
const Being *const
excluded) const
@@ -1653,7 +1653,7 @@ bool ActorSpriteManager::checkForPickup(const FloorItem *const item) const
}
void ActorSpriteManager::updateEffects(const std::map<int, int> &addEffects,
- const std::set<int> removeEffects)
+ const std::set<int> &removeEffects)
{
for_actors
{
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 59cd53962..cdf85e471 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -300,7 +300,7 @@ class ActorSpriteManager final: public ConfigListener
bool checkForPickup(const FloorItem *const item) const A_WARN_UNUSED;
void updateEffects(const std::map<int, int> &addEffects,
- const std::set<int> removeEffects);
+ const std::set<int> &removeEffects);
protected:
bool validateBeing(const Being *const aroundBeing,
@@ -311,7 +311,7 @@ class ActorSpriteManager final: public ConfigListener
Being *findNearestLivingBeing(const Being *const aroundBeing,
const int maxdist,
- const Being::Type type,
+ const Being::Type &type,
const int x, const int y,
const Being *const
excluded = nullptr) const A_WARN_UNUSED;
diff --git a/src/client.cpp b/src/client.cpp
index 2d73b791f..467d49f3b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2193,25 +2193,6 @@ void Client::accountLogin(LoginData *const data) const
serverConfig.setValue("remember", remember);
}
-bool Client::copyFile(const std::string &configPath,
- const std::string &oldConfigPath) const
-{
- FILE *const configFile = fopen(oldConfigPath.c_str(), "r");
-
- if (configFile)
- {
- fclose(configFile);
-
- std::ifstream ifs(oldConfigPath.c_str(), std::ios::binary);
- std::ofstream ofs(configPath.c_str(), std::ios::binary);
- ofs << ifs.rdbuf();
- ifs.close();
- ofs.close();
- return true;
- }
- return false;
-}
-
void Client::storeSafeParameters() const
{
bool tmpHwaccel;
diff --git a/src/client.h b/src/client.h
index 456dee6a8..ee495d9a9 100644
--- a/src/client.h
+++ b/src/client.h
@@ -342,9 +342,6 @@ private:
void initServerConfig(std::string serverName);
- bool copyFile(const std::string &configPath,
- const std::string &oldConfigPath) const;
-
void accountLogin(LoginData *const data) const;
void storeSafeParameters() const;
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 7f7e554a9..45c047060 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -158,15 +158,11 @@ void CompoundSprite::drawSpritesSDL(Graphics *const graphics,
int CompoundSprite::getWidth() const
{
- const Sprite *base = nullptr;
-
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if ((base = *it))
- {
- if (base)
- return base->getWidth();
- }
+ const Sprite *const base = *it;
+ if (base)
+ return base->getWidth();
}
return 0;
@@ -174,15 +170,11 @@ int CompoundSprite::getWidth() const
int CompoundSprite::getHeight() const
{
- const Sprite *base = nullptr;
-
FOR_EACH (SpriteConstIterator, it, mSprites)
{
- if ((base = *it))
- {
- if (base)
- return base->getHeight();
- }
+ const Sprite *const base = nullptr;
+ if (base)
+ return base->getHeight();
}
return 0;
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 6c74f4397..653140e3f 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -766,16 +766,15 @@ public:
if (!map)
return;
- Avatar *ava = nullptr;
std::vector<Avatar*>::const_iterator i = avatars->begin();
const std::vector<Avatar*>::const_iterator i_end = avatars->end();
while (i != i_end)
{
- ava = (*i);
+ Avatar *const ava = *i;
if (!ava)
break;
- const MapItem *const item = map->findPortalXY(
+ const MapItem *const item = map->findPortalXY(
ava->getX(), ava->getY());
if (item)
{
@@ -802,14 +801,12 @@ public:
if (!map)
return 01;
- const Avatar *ava = nullptr;
std::vector<Avatar*>::const_iterator i = avatars->begin();
const std::vector<Avatar*>::const_iterator i_end = avatars->end();
unsigned num = 0;
while (i != i_end)
{
- ava = (*i);
-
+ const Avatar *const ava = *i;
if (!ava)
break;
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index e794cea66..f4b06991c 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -188,14 +188,7 @@ void StatusPopup::view(const int x, const int y)
requestMoveToTop();
}
-void StatusPopup::setLabelText(Label *const label, const char *const text,
- int const key) const
-{
- label->setCaption(strprintf("%s %s", text,
- inputManager.getKeyValueString(key).c_str()));
-}
-
-void StatusPopup::setLabelText2(Label *const label,
+void StatusPopup::setLabelText(Label *const label,
const std::string &text,
const Input::KeyAction key) const
{
@@ -209,34 +202,34 @@ void StatusPopup::updateLabels()
if (!player_node || !viewport)
return;
- setLabelText2(mMoveType, player_node->getInvertDirectionString(),
+ setLabelText(mMoveType, player_node->getInvertDirectionString(),
Input::KEY_INVERT_DIRECTION);
- setLabelText2(mCrazyMoveType, player_node->getCrazyMoveTypeString(),
+ setLabelText(mCrazyMoveType, player_node->getCrazyMoveTypeString(),
Input::KEY_CHANGE_CRAZY_MOVES_TYPE);
- setLabelText2(mMoveToTargetType, player_node->getMoveToTargetTypeString(),
+ setLabelText(mMoveToTargetType, player_node->getMoveToTargetTypeString(),
Input::KEY_CHANGE_MOVE_TO_TARGET);
- setLabelText2(mFollowMode, player_node->getFollowModeString(),
+ setLabelText(mFollowMode, player_node->getFollowModeString(),
Input::KEY_CHANGE_FOLLOW_MODE);
- setLabelText2(mAttackWeaponType, player_node->getAttackWeaponTypeString(),
+ setLabelText(mAttackWeaponType, player_node->getAttackWeaponTypeString(),
Input::KEY_CHANGE_ATTACK_WEAPON_TYPE);
- setLabelText2(mAttackType, player_node->getAttackTypeString(),
+ setLabelText(mAttackType, player_node->getAttackTypeString(),
Input::KEY_CHANGE_ATTACK_TYPE);
- setLabelText2(mDropCounter, player_node->getQuickDropCounterString(),
+ setLabelText(mDropCounter, player_node->getQuickDropCounterString(),
Input::KEY_SWITCH_QUICK_DROP);
- setLabelText2(mPickUpType, player_node->getPickUpTypeString(),
+ setLabelText(mPickUpType, player_node->getPickUpTypeString(),
Input::KEY_CHANGE_PICKUP_TYPE);
- setLabelText2(mMapType, player_node->getDebugPathString(),
+ setLabelText(mMapType, player_node->getDebugPathString(),
Input::KEY_PATHFIND);
- setLabelText2(mMagicAttackType, player_node->getMagicAttackString(),
+ setLabelText(mMagicAttackType, player_node->getMagicAttackString(),
Input::KEY_SWITCH_MAGIC_ATTACK);
- setLabelText2(mPvpAttackType, player_node->getPvpAttackString(),
+ setLabelText(mPvpAttackType, player_node->getPvpAttackString(),
Input::KEY_SWITCH_PVP_ATTACK);
- setLabelText2(mImitationMode, player_node->getImitationModeString(),
+ setLabelText(mImitationMode, player_node->getImitationModeString(),
Input::KEY_CHANGE_IMITATION_MODE);
- setLabelText2(mAwayMode, player_node->getAwayModeString(),
+ setLabelText(mAwayMode, player_node->getAwayModeString(),
Input::KEY_AWAY);
- setLabelText2(mCameraMode, player_node->getCameraModeString(),
+ setLabelText(mCameraMode, player_node->getCameraModeString(),
Input::KEY_CAMERA);
- setLabelText2(mDisableGameModifiers, player_node->getGameModifiersString(),
+ setLabelText(mDisableGameModifiers, player_node->getGameModifiersString(),
Input::KEY_DISABLE_GAME_MODIFIERS);
}
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index d57fe54ba..128345d51 100644
--- a/src/gui/statuspopup.h
+++ b/src/gui/statuspopup.h
@@ -63,10 +63,7 @@ class StatusPopup final : public Popup
private:
void updateLabels();
- void setLabelText(Label *const label, const char *const text,
- const int key) const;
-
- void setLabelText2(Label *const label, const std::string &text,
+ void setLabelText(Label *const label, const std::string &text,
const Input::KeyAction key) const;
Label *mMoveType;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index bbd31cee7..93c65e356 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -536,7 +536,7 @@ int BrowserBox::calcHeight()
{
const signed char c = row.at(start + 2);
- bool valid;
+ bool valid(false);
const gcn::Color col[2] =
{
getThemeCharColor(c, valid),
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 8b6722a59..e40248121 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -382,7 +382,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mTopWidget)
{
- const gcn::Rectangle bounds = mTopWidget->getDimension();
+ const gcn::Rectangle &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
mTopWidget->draw(graphics);
graphics->popClipArea();
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index f97767064..22049e944 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -116,13 +116,11 @@ void ShopItems::clear()
ShopItem *ShopItems::findItem(const int id, const unsigned char color) const
{
- ShopItem *item;
-
std::vector<ShopItem*>::const_iterator it = mShopItems.begin();
const std::vector<ShopItem*>::const_iterator e = mShopItems.end();
while (it != e)
{
- item = *(it);
+ ShopItem *const item = *it;
if (item->getId() == id && item->getColor() == color)
return item;
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index d2868f3d2..45891f202 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -73,10 +73,6 @@ ShopListBox::ShopListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(Theme::LISTBOX);
}
-void ShopListBox::init()
-{
-}
-
void ShopListBox::setPlayersMoney(const int money)
{
mPlayerMoney = money;
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 16f54e78a..ad58ea413 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -85,8 +85,6 @@ class ShopListBox final : public ListBox
void mouseExited(gcn::MouseEvent& mouseEvent) override;
private:
- void init();
-
int mPlayerMoney;
/**
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 449714927..315e9a342 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -620,7 +620,7 @@ void SpecialLayer::setTile(const int x, const int y, const int type)
}
}
-void SpecialLayer::addRoad(const Path road)
+void SpecialLayer::addRoad(const Path &road)
{
FOR_EACH (Path::const_iterator, i, road)
{
diff --git a/src/maplayer.h b/src/maplayer.h
index 2f9b6d347..b4a43529d 100644
--- a/src/maplayer.h
+++ b/src/maplayer.h
@@ -206,7 +206,7 @@ class SpecialLayer final
void setTile(const int x, const int y, const int type);
- void addRoad(const Path road);
+ void addRoad(const Path &road);
void clean() const;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 9e751f27c..1f589356e 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -160,14 +160,8 @@ int InventoryHandler::getSlot(int eAthenaSlot)
void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
bool playerInvintory)
{
- int index, amount, itemId, arrow;
- int cards[4], itemType;
- unsigned char identified;
- Inventory *inventory = nullptr;
-
- if (player_node)
- inventory = PlayerInfo::getInventory();
-
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
if (playerInvintory)
{
if (PlayerInfo::getEquipment())
@@ -190,17 +184,17 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16();
- itemId = msg.readInt16();
- itemType = msg.readInt8();
- identified = msg.readInt8();
- amount = msg.readInt16();
- arrow = msg.readInt16();
+ int cards[4];
+ const int index = msg.readInt16() - (playerInvintory
+ ? INVENTORY_OFFSET : STORAGE_OFFSET);
+ const int itemId = msg.readInt16();
+ const int itemType = msg.readInt8();
+ unsigned char identified = msg.readInt8();
+ const int amount = msg.readInt16();
+ const int arrow = msg.readInt16();
for (int i = 0; i < 4; i++)
cards[i] = msg.readInt16();
- index -= (playerInvintory ? INVENTORY_OFFSET : STORAGE_OFFSET);
-
if (mDebugInventory)
{
logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
@@ -233,24 +227,21 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
{
- int index, amount, itemId, refine;
- int cards[4], itemType;
- unsigned char identified;
-
msg.readInt16(); // length
const int number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16() - STORAGE_OFFSET;
- itemId = msg.readInt16();
- itemType = msg.readInt8();
- identified = msg.readInt8();
- amount = 1;
+ int cards[4];
+ const int index = msg.readInt16() - STORAGE_OFFSET;
+ const int itemId = msg.readInt16();
+ const int itemType = msg.readInt8();
+ unsigned char identified = msg.readInt8();
+ const int amount = 1;
msg.readInt16(); // Equip Point?
msg.readInt16(); // Another Equip Point?
msg.readInt8(); // Attribute (broken)
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
for (int i = 0; i < 4; i++)
cards[i] = msg.readInt16();
@@ -507,10 +498,6 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
{
- int index, itemId, equipType, refine;
- int number;
- unsigned char identified;
-
Inventory *inventory = nullptr;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -522,22 +509,21 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&mEquips);
}
- number = (msg.getLength() - 4) / 20;
+ const int number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
- index = msg.readInt16() - INVENTORY_OFFSET;
- itemId = msg.readInt16();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int itemId = msg.readInt16();
const int itemType = msg.readInt8(); // type
- identified = msg.readInt8(); // identify flag
+ unsigned char identified = msg.readInt8(); // identify flag
msg.readInt16(); // equip type
- equipType = msg.readInt16();
+ const int equipType = msg.readInt16();
msg.readInt8(); // attribute
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
msg.skip(8); // card
-
if (mDebugInventory)
{
logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 98de2cd49..6a149c6fd 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -635,13 +635,11 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map)
return;
std::string csv(data);
-
- size_t pos = 0;
size_t oldPos = 0;
while (oldPos != csv.npos)
{
- pos = csv.find_first_of(",", oldPos);
+ const size_t pos = csv.find_first_of(",", oldPos);
if (pos == csv.npos)
return;
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index b24949cfe..dbc314921 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -42,8 +42,8 @@ const int timeOut = 10;
int execFileWait(std::string pathName, std::string name A_UNUSED,
std::string arg1, std::string arg2, int waitTime)
{
- if (!waitTime)
- waitTime = timeOut;
+// if (!waitTime)
+// waitTime = timeOut;
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 3378ec132..1994cda98 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -207,12 +207,11 @@ size_t findI(std::string str, std::string subStr)
size_t findI(std::string text, StringVect &list)
{
std::string str = toLower(text);
- size_t idx;
FOR_EACH (StringVectCIter, i, list)
{
std::string subStr = *i;
subStr = toLower(subStr);
- idx = str.find(subStr);
+ const size_t idx = str.find(subStr);
if (idx != std::string::npos)
return idx;
}
@@ -375,11 +374,10 @@ bool getBoolFromString(const std::string &text)
void replaceSpecialChars(std::string &text)
{
- size_t idx = 0;
size_t pos1 = text.find("&");
while (pos1 != std::string::npos)
{
- idx = pos1 + 1;
+ const size_t idx = pos1 + 1;
if (idx >= text.size())
break;