summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-07 14:57:08 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-07 21:38:21 +0300
commitae550d179c25e149f7e8a8d70011b364fb0d85d6 (patch)
treec4dabe3e38afc8b343e3946202eb6fa5f30a18a9
parent2566e68d2502d39c9f7c9d83ce4b281e2834fe29 (diff)
downloadmanaverse-ae550d179c25e149f7e8a8d70011b364fb0d85d6.tar.gz
manaverse-ae550d179c25e149f7e8a8d70011b364fb0d85d6.tar.bz2
manaverse-ae550d179c25e149f7e8a8d70011b364fb0d85d6.tar.xz
manaverse-ae550d179c25e149f7e8a8d70011b364fb0d85d6.zip
some fixes after auto check.
-rw-r--r--src/compoundsprite.cpp3
-rw-r--r--src/gui/chatwindow.cpp2
-rw-r--r--src/gui/killstats.cpp17
-rw-r--r--src/gui/serverdialog.cpp19
-rw-r--r--src/gui/skilldialog.cpp9
-rw-r--r--src/gui/statuswindow.cpp5
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/browserbox.h8
-rw-r--r--src/keyboardconfig.cpp3
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/localplayer.h2
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h2
-rw-r--r--src/net/eathena/beinghandler.cpp9
-rw-r--r--src/particleemitter.cpp11
-rw-r--r--src/playerrelations.cpp5
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/npcdb.cpp2
-rw-r--r--src/rotationalparticle.cpp6
-rw-r--r--src/touchmanager.h2
-rw-r--r--src/utils/mkdir.cpp4
-rw-r--r--src/utils/translation/translationmanager.cpp6
22 files changed, 56 insertions, 69 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 195a7ce2e..24fc7bbdb 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -237,8 +237,7 @@ void CompoundSprite::setSprite(const int layer, Sprite *const sprite)
if (mSprites.at(layer) == sprite)
return;
- if (mSprites.at(layer))
- delete mSprites.at(layer);
+ delete mSprites.at(layer);
mSprites[layer] = sprite;
mNeedsRedraw = true;
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 0bc3b9edc..88c9936fe 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -883,7 +883,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
ChatTab *const tab = getFocused();
if (tab && tab->hasRows())
{
- const size_t tabSize = tab->getRows().size();
+ const size_t &tabSize = tab->getRows().size();
if (mChatHistoryIndex + 1 < tabSize)
{
mChatHistoryIndex ++;
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index c1d8fa8b1..61d8acfcb 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -185,7 +185,8 @@ void KillStats::resetTimes()
void KillStats::gainXp(int xp)
{
- if (xp == PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED))
+ const int expNeed = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED);
+ if (xp == expNeed)
xp = 0;
else if (!xp)
return;
@@ -199,7 +200,7 @@ void KillStats::gainXp(int xp)
mKillCounter = 1;
const float AvgExp = static_cast<float>(mExpCounter / mKillCounter);
- int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED));
+ int xpNextLevel(expNeed);
if (mKillTimer == 0)
mKillTimer = cur_time;
@@ -212,14 +213,13 @@ void KillStats::gainXp(int xp)
if (timeDiff <= 0.001)
timeDiff = 1;
+ const int exp = PlayerInfo::getAttribute(PlayerInfo::EXP);
mLine1->setCaption(strprintf(_("Level: %d at %f%%"),
- player_node->getLevel(), static_cast<double>(
- PlayerInfo::getAttribute(PlayerInfo::EXP)) / static_cast<double>(
+ player_node->getLevel(), static_cast<double>(exp) / static_cast<double>(
xpNextLevel) * 100.0));
- mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"),
- PlayerInfo::getAttribute(PlayerInfo::EXP), xpNextLevel,
- xpNextLevel - PlayerInfo::getAttribute(PlayerInfo::EXP)));
+ mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), exp,
+ xpNextLevel, xpNextLevel - exp));
if (AvgExp >= 0.001f && AvgExp <= 0.001f)
{
@@ -242,8 +242,7 @@ void KillStats::gainXp(int xp)
toString(AvgExp).c_str()));
mLine6->setCaption(strprintf(_("No. of avg mob to next level: %s"),
- toString(static_cast<float>(xpNextLevel
- - PlayerInfo::getAttribute(PlayerInfo::EXP)) / AvgExp).c_str()));
+ toString(static_cast<float>(xpNextLevel - exp) / AvgExp).c_str()));
}
mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"),
toString(mKillCounter).c_str(), toString(mExpCounter).c_str()));
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 6bb09d8e9..4a9960beb 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -288,16 +288,15 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
mServersList->addSelectionListener(this);
usedScroll->setVerticalScrollAmount(0);
- const int n = 0;
- place(0, 0 + n, usedScroll, 7, 5).setPadding(3);
- place(0, 5 + n, mDescription, 7);
- place(0, 6 + n, mPersistentIPCheckBox, 7);
- place(0, 7 + n, mAddEntryButton);
- place(1, 7 + n, mEditEntryButton);
- place(2, 7 + n, mLoadButton);
- place(3, 7 + n, mDeleteButton);
- place(5, 7 + n, mQuitButton);
- place(6, 7 + n, mConnectButton);
+ place(0, 0, usedScroll, 7, 5).setPadding(3);
+ place(0, 5, mDescription, 7);
+ place(0, 6, mPersistentIPCheckBox, 7);
+ place(0, 7, mAddEntryButton);
+ place(1, 7, mEditEntryButton);
+ place(2, 7, mLoadButton);
+ place(3, 7, mDeleteButton);
+ place(5, 7, mQuitButton);
+ place(6, 7, mConnectButton);
// Make sure the list has enough height
getLayout().setRowHeight(0, 80);
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index c89bf5697..2a673a277 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -579,10 +579,11 @@ void SkillDialog::addSkill(const int id, const int level, const int range,
{
SkillInfo *const skill = new SkillInfo;
skill->id = static_cast<unsigned int>(id);
- skill->data->name = "Unknown skill Id: " + toString(id);
- skill->data->dispName = "Unknown skill Id: " + toString(id);
- skill->data->description.clear();
- skill->data->setIcon("");
+ SkillData *const data = skill->data;
+ data->name = "Unknown skill Id: " + toString(id);
+ data->dispName = "Unknown skill Id: " + toString(id);
+ data->description.clear();
+ data->setIcon("");
skill->modifiable = modifiable;
skill->visible = false;
skill->model = mDefaultModel;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index ddd16fa12..ef91582f8 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -415,10 +415,7 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
updateMPBar(mMpBar, true);
const Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end() && it->second)
- {
- if (it->second)
- it->second->update();
- }
+ it->second->update();
}
}
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index f2907aaf3..372218fe6 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -399,7 +399,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
const WhisperTab *const tab = chatWindow->addWhisperTab(
model->getAvatarAt(selected)->getName(), true);
- if (chatWindow && tab)
+ if (tab)
chatWindow->saveState();
}
}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 0b8c99c8a..045e0d5d5 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -48,8 +48,8 @@ struct BROWSER_LINK final
class LinePart final
{
public:
- LinePart(const int x, const int y, const gcn::Color color,
- const gcn::Color color2, const std::string &text,
+ LinePart(const int x, const int y, const gcn::Color &color,
+ const gcn::Color &color2, const std::string &text,
const bool bold) :
mX(x),
mY(y),
@@ -62,8 +62,8 @@ class LinePart final
{
}
- LinePart(const int x, const int y, const gcn::Color color,
- const gcn::Color color2, Image *const image) :
+ LinePart(const int x, const int y, const gcn::Color &color,
+ const gcn::Color &color2, Image *const image) :
mX(x),
mY(y),
mColor(color),
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index deef46e4b..132158eb1 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -45,8 +45,7 @@ KeyboardConfig::KeyboardConfig() :
void KeyboardConfig::init()
{
mEnabled = true;
- if (mActiveKeys2)
- delete mActiveKeys2;
+ delete mActiveKeys2;
mActiveKeys2 = new uint8_t[500];
mRepeatTime = config.getIntValue("repeateInterval2") / 10;
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index c1d3b9c5f..c38d66c18 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -2979,7 +2979,7 @@ bool LocalPlayer::isReachable(Being *const being,
}
bool LocalPlayer::isReachable(const int x, const int y,
- const int allowCollision) const
+ const bool allowCollision) const
{
const WalkLayer *const walk = mMap->getWalkLayer();
if (!walk)
diff --git a/src/localplayer.h b/src/localplayer.h
index 7dfa6025f..9ce72e5e3 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -304,7 +304,7 @@ class LocalPlayer final : public Being,
const int maxCost = 0) A_WARN_UNUSED;
bool isReachable(const int x, const int y,
- const int allowCollision) const A_WARN_UNUSED;
+ const bool allowCollision) const A_WARN_UNUSED;
void setHome();
diff --git a/src/map.cpp b/src/map.cpp
index 8ce96bdc5..ceb863359 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -712,7 +712,7 @@ Actors::iterator Map::addActor(Actor *const actor)
return mActors.begin();
}
-void Map::removeActor(const Actors::iterator iterator)
+void Map::removeActor(const Actors::iterator &iterator)
{
mActors.erase(iterator);
// mSpritesUpdated = true;
diff --git a/src/map.h b/src/map.h
index a449bbc6b..44dd6f2c1 100644
--- a/src/map.h
+++ b/src/map.h
@@ -426,7 +426,7 @@ class Map final : public Properties, public ConfigListener
/**
* Removes an actor from the map.
*/
- void removeActor(const Actors::iterator iterator);
+ void removeActor(const Actors::iterator &iterator);
private:
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index b026b5e71..f62d4d9db 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -596,13 +596,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
//need set stay state?
logger->log("QQQ2 SMSG_PLAYER_UPDATE_1:"
+ toString(id) + " " + toString(type));
- if (dstBeing)
- {
- logger->log("dstBeing id:"
- + toString(dstBeing->getId()));
- logger->log("dstBeing name:"
- + dstBeing->getName());
- }
+ logger->log("dstBeing id:" + toString(dstBeing->getId()));
+ logger->log("dstBeing name:" + dstBeing->getName());
break;
}
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 71eff9c3f..7666fb063 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -549,12 +549,15 @@ std::list<Particle *> ParticleEmitter::createParticles(const int tick)
newParticle->moveTo(position);
const float angleH = mParticleAngleHorizontal.value(tick);
+ const float cosAngleH = cos(angleH);
+ const float sinAngleH = sin(angleH);
const float angleV = mParticleAngleVertical.value(tick);
+ const float cosAngleV = cos(angleV);
+ const float sinAngleV = sin(angleV);
const float power = mParticlePower.value(tick);
- newParticle->setVelocity(
- static_cast<float>(cos(angleH) * cos(angleV)) * power,
- static_cast<float>(sin(angleH) * cos(angleV)) * power,
- static_cast<float>(sin(angleV)) * power);
+ newParticle->setVelocity(cosAngleH * cosAngleV * power,
+ sinAngleH * cosAngleV * power,
+ sinAngleV * power);
newParticle->setRandomness(mParticleRandomness.value(tick));
newParticle->setGravity(mParticleGravity.value(tick));
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 218b1e50a..184ef8adf 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -377,11 +377,8 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
void PlayerRelationsManager::removePlayer(const std::string &name)
{
- if (mRelations[name])
- delete mRelations[name];
-
+ delete mRelations[name];
mRelations.erase(name);
-
signalUpdate(name);
}
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 905d28921..9e2f9a395 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -122,9 +122,7 @@ void BeingInfo::addAttack(const int id, std::string action, const int effectId,
const int missEffectId,
const std::string &missileParticle)
{
- if (mAttacks[id])
- delete mAttacks[id];
-
+ delete mAttacks[id];
mAttacks[id] = new Attack(action, effectId, hitEffectId,
criticalHitEffectId, missEffectId, missileParticle);
}
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 6e94bb3c3..9fc8ea73c 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -71,7 +71,7 @@ void NPCDB::load()
BeingInfo *const currentInfo = new BeingInfo;
- currentInfo->setTargetSelection(XML::getProperty(npcNode,
+ currentInfo->setTargetSelection(XML::getBoolProperty(npcNode,
"targetSelection", true));
currentInfo->setTargetCursorSize(XML::getProperty(npcNode,
diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp
index d3b296587..a5473044f 100644
--- a/src/rotationalparticle.cpp
+++ b/src/rotationalparticle.cpp
@@ -25,10 +25,12 @@
#include "graphics.h"
#include "simpleanimation.h"
+#include <math.h>
+
#include "debug.h"
-static const double PI = 3.14159265;
-static const float PI2 = 2 * 3.14159265;
+static const double PI = M_PI;
+static const float PI2 = 2 * M_PI;
RotationalParticle::RotationalParticle(Map *const map,
Animation *const animation) :
diff --git a/src/touchmanager.h b/src/touchmanager.h
index 3dc1eda29..2f5deaba3 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -47,7 +47,7 @@ const int buttonsCount = 4;
struct TouchItem final
{
- TouchItem(const gcn::Rectangle rect0, const int type0,
+ TouchItem(const gcn::Rectangle &rect0, const int type0,
const std::string &eventPressed0,
const std::string &eventReleased0,
ImageRect *const images0, Image *const icon0,
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index bc089d3d8..4d7312285 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -113,7 +113,7 @@ int mkdir_r(const char *const pathname)
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
{
- const size_t len = static_cast<int>(strlen(pathname));
+ const size_t len = static_cast<size_t>(strlen(pathname));
char *tmp = new char[len + 2];
char *p;
@@ -132,7 +132,7 @@ int mkdir_r(const char *const pathname)
{
*p = '\0';
// ignore a slash at the beginning of a path
- if (strlen(tmp) == 0)
+ if (tmp[0] == 0)
{
*p = '/';
continue;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index e15ff0c0a..0a9a40c09 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -37,15 +37,13 @@
void TranslationManager::init()
{
- if (translator)
- delete translator;
+ delete translator;
translator = PoParser::getEmptyDict();
}
void TranslationManager::loadCurrentLang()
{
- if (translator)
- delete translator;
+ delete translator;
translator = loadLang(getLang(), "");
translator = loadLang(getLang(), "help/", translator);
}