summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-25 01:52:08 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-25 02:16:11 +0300
commitda457cf152d5aff51d859c18d3668682348dbf7a (patch)
tree6ec10caec1fc472f2ef3c7664a1c536434df1c0f /src
parentb474de4a54c9b1d4d863971e40b807588d554436 (diff)
downloadmv-da457cf152d5aff51d859c18d3668682348dbf7a.tar.gz
mv-da457cf152d5aff51d859c18d3668682348dbf7a.tar.bz2
mv-da457cf152d5aff51d859c18d3668682348dbf7a.tar.xz
mv-da457cf152d5aff51d859c18d3668682348dbf7a.zip
change vars or methods to const.
Diffstat (limited to 'src')
-rw-r--r--src/actionmanager.cpp32
-rw-r--r--src/actionmanager.h2
-rw-r--r--src/actor.cpp2
-rw-r--r--src/actor.h2
-rw-r--r--src/actorsprite.cpp82
-rw-r--r--src/actorsprite.h40
-rw-r--r--src/actorspritemanager.cpp232
-rw-r--r--src/actorspritemanager.h102
-rw-r--r--src/keydata.h2
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/localplayer.h4
11 files changed, 268 insertions, 236 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 7a635f852..13b9bb956 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -67,8 +67,8 @@
#include "debug.h"
-#define impHandler(name) bool name(InputEvent &event)
-#define impHandler0(name) bool name(InputEvent &event A_UNUSED)
+#define impHandler(name) bool name(const InputEvent &event)
+#define impHandler0(name) bool name(const InputEvent &event A_UNUSED)
extern ShortcutWindow *spellShortcutWindow;
extern QuitDialog *quitDialog;
@@ -78,7 +78,7 @@ namespace ActionManager
impHandler0(moveUp)
{
- if (NpcDialog *dialog = NpcDialog::getActive())
+ if (NpcDialog *const dialog = NpcDialog::getActive())
{
dialog->refocus();
return false;
@@ -90,7 +90,7 @@ impHandler0(moveUp)
impHandler0(moveDown)
{
- if (NpcDialog *dialog = NpcDialog::getActive())
+ if (NpcDialog *const dialog = NpcDialog::getActive())
{
dialog->refocus();
return false;
@@ -130,7 +130,7 @@ impHandler0(moveRight)
impHandler(emote)
{
- int emotion = 1 + event.action - Input::KEY_EMOTE_1;
+ const int emotion = 1 + event.action - Input::KEY_EMOTE_1;
if (emotion > 0)
{
if (emoteShortcut)
@@ -145,7 +145,7 @@ impHandler(emote)
impHandler(moveToPoint)
{
- int num = event.action - Input::KEY_MOVE_TO_POINT_1;
+ const int num = event.action - Input::KEY_MOVE_TO_POINT_1;
if (socialWindow && num >= 0)
{
socialWindow->selectPortal(num);
@@ -159,7 +159,7 @@ impHandler(outfit)
{
if (inputManager.isActionActive(Input::KEY_WEAR_OUTFIT))
{
- int num = event.action - Input::KEY_OUTFIT_1;
+ const int num = event.action - Input::KEY_OUTFIT_1;
if (outfitWindow && num >= 0)
{
outfitWindow->wearOutfit(num);
@@ -170,7 +170,7 @@ impHandler(outfit)
}
else if (inputManager.isActionActive(Input::KEY_COPY_OUTFIT))
{
- int num = event.action - Input::KEY_OUTFIT_1;
+ const int num = event.action - Input::KEY_OUTFIT_1;
if (outfitWindow && num >= 0)
{
outfitWindow->copyOutfit(num);
@@ -212,7 +212,7 @@ impHandler0(ok)
setupWindow->action(gcn::ActionEvent(nullptr, "cancel"));
return true;
}
- else if (NpcDialog *dialog = NpcDialog::getActive())
+ else if (NpcDialog *const dialog = NpcDialog::getActive())
{
dialog->action(gcn::ActionEvent(nullptr, "ok"));
return true;
@@ -224,7 +224,7 @@ impHandler(shortcut)
{
if (itemShortcutWindow)
{
- int num = itemShortcutWindow->getTabIndex();
+ const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS))
{
itemShortcut[num]->useItem(event.action
@@ -679,7 +679,7 @@ impHandler0(helpWindowShow)
return false;
}
-static void showHideWindow(Window *window)
+static void showHideWindow(Window *const window)
{
if (window)
{
@@ -815,7 +815,7 @@ impHandler0(changeMapMode)
miniStatusWindow->updateStatus();
if (Game::instance())
{
- if (Map *map = Game::instance()->getCurrentMap())
+ if (Map *const map = Game::instance()->getCurrentMap())
map->redrawMap();
}
return true;
@@ -930,7 +930,7 @@ impHandler0(talk)
{
if (player_node)
{
- Being *target = player_node->getTarget();
+ Being *const target = player_node->getTarget();
if (target)
{
if (target->canTalk())
@@ -983,7 +983,7 @@ impHandler0(targetAttack)
if (player_node && actorSpriteManager)
{
- bool newTarget = !inputManager.isActionActive(
+ const bool newTarget = !inputManager.isActionActive(
Input::KEY_STOP_ATTACK);
// A set target has highest priority
if (!player_node->getTarget())
@@ -1003,11 +1003,11 @@ impHandler0(targetAttack)
return false;
}
-static bool setTarget(ActorSprite::Type type)
+static bool setTarget(const ActorSprite::Type type)
{
if (actorSpriteManager && player_node)
{
- Being *target = actorSpriteManager->findNearestLivingBeing(
+ Being *const target = actorSpriteManager->findNearestLivingBeing(
player_node, 20, type);
if (target && target != player_node->getTarget())
diff --git a/src/actionmanager.h b/src/actionmanager.h
index ebbfc65ad..b415e1a5b 100644
--- a/src/actionmanager.h
+++ b/src/actionmanager.h
@@ -24,7 +24,7 @@
#include <string>
#include <map>
-#define decHandler(name) bool name(InputEvent &event)
+#define decHandler(name) bool name(const InputEvent &event)
struct InputEvent;
class Window;
diff --git a/src/actor.cpp b/src/actor.cpp
index 5af1f47d3..2e14a68b1 100644
--- a/src/actor.cpp
+++ b/src/actor.cpp
@@ -39,7 +39,7 @@ Actor::~Actor()
setMap(nullptr);
}
-void Actor::setMap(Map *map)
+void Actor::setMap(Map *const map)
{
// Remove Actor from potential previous map
if (mMap)
diff --git a/src/actor.h b/src/actor.h
index 4c566ea5e..c2529ac7d 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -120,7 +120,7 @@ public:
*/
virtual void setAlpha(float alpha) = 0;
- void setMap(Map *map);
+ void setMap(Map *const map);
Map* getMap() const
{ return mMap; }
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 5e53febcd..9be6b3bca 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -48,7 +48,7 @@ ImageSet *ActorSprite::targetCursorImages[2][NUM_TC];
SimpleAnimation *ActorSprite::targetCursor[2][NUM_TC];
bool ActorSprite::loaded = false;
-ActorSprite::ActorSprite(int id):
+ActorSprite::ActorSprite(const int id):
mId(id),
mStunMode(0),
mStatusParticleEffects(&mStunParticleEffects, false),
@@ -118,7 +118,7 @@ void ActorSprite::logic()
for (std::set<int>::const_iterator it = mStatusEffects.begin(),
it_end = mStatusEffects.end(); it != it_end; ++it)
{
- const StatusEffect *effect
+ const StatusEffect *const effect
= StatusEffect::getStatusEffect(*it, true);
if (effect && effect->particleEffectIsPersistent())
updateStatusEffect(*it, true);
@@ -133,7 +133,7 @@ void ActorSprite::actorLogic()
{
}
-void ActorSprite::setMap(Map* map)
+void ActorSprite::setMap(Map *const map)
{
Actor::setMap(map);
@@ -142,12 +142,12 @@ void ActorSprite::setMap(Map* map)
mMustResetParticles = true; // Reset status particles on next redraw
}
-void ActorSprite::controlParticle(Particle *particle)
+void ActorSprite::controlParticle(Particle *const particle)
{
mChildParticleEffects.addLocally(particle);
}
-void ActorSprite::setTargetType(TargetCursorType type)
+void ActorSprite::setTargetType(const TargetCursorType type)
{
if (type == TCT_NONE)
untarget();
@@ -165,12 +165,13 @@ static EffectDescription *default_effect = nullptr;
static std::map<int, EffectDescription *> effects;
static bool effects_initialized = false;
-static EffectDescription *getEffectDescription(XmlNodePtr node, int *id)
+static EffectDescription *getEffectDescription(XmlNodePtr const node,
+ int *const id)
{
if (!id)
return nullptr;
- EffectDescription *ed = new EffectDescription;
+ EffectDescription *const ed = new EffectDescription;
*id = atoi(XML::getProperty(node, "id", "-1").c_str());
ed->mSFXEffect = XML::getProperty(node, "audio", "");
@@ -179,12 +180,12 @@ static EffectDescription *getEffectDescription(XmlNodePtr node, int *id)
return ed;
}
-static EffectDescription *getEffectDescription(int effectId)
+static EffectDescription *getEffectDescription(const int effectId)
{
if (!effects_initialized)
{
XML::Document doc(EFFECTS_FILE);
- XmlNodePtr root = doc.rootNode();
+ const XmlNodePtr root = doc.rootNode();
if (!root || !xmlNameEqual(root, "being-effects"))
{
@@ -198,13 +199,13 @@ static EffectDescription *getEffectDescription(int effectId)
if (xmlNameEqual(node, "effect"))
{
- EffectDescription *EffectDescription =
+ EffectDescription *const effectDescription =
getEffectDescription(node, &id);
- effects[id] = EffectDescription;
+ effects[id] = effectDescription;
}
else if (xmlNameEqual(node, "default"))
{
- EffectDescription *effectDescription =
+ EffectDescription *const effectDescription =
getEffectDescription(node, &id);
delete default_effect;
@@ -216,12 +217,12 @@ static EffectDescription *getEffectDescription(int effectId)
effects_initialized = true;
} // done initializing
- EffectDescription *ed = effects[effectId];
+ EffectDescription *const ed = effects[effectId];
return ed ? ed : default_effect;
}
-void ActorSprite::setStatusEffect(int index, bool active)
+void ActorSprite::setStatusEffect(const int index, const bool active)
{
const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end();
@@ -235,18 +236,21 @@ void ActorSprite::setStatusEffect(int index, bool active)
}
}
-void ActorSprite::setStatusEffectBlock(int offset, uint16_t newEffects)
+void ActorSprite::setStatusEffectBlock(const int offset,
+ const uint16_t newEffects)
{
for (unsigned i = 0; i < STATUS_EFFECTS; i++)
{
- int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i);
+ const int index = StatusEffect::blockEffectIndexToEffectIndex(
+ offset + i);
if (index != -1)
setStatusEffect(index, (newEffects & (1 << i)) > 0);
}
}
-void ActorSprite::internalTriggerEffect(int effectId, bool sfx, bool gfx)
+void ActorSprite::internalTriggerEffect(const int effectId, const bool sfx,
+ const bool gfx)
{
if (reportTrue(!particleEngine))
return;
@@ -257,7 +261,7 @@ void ActorSprite::internalTriggerEffect(int effectId, bool sfx, bool gfx)
getId() == player_node->getId() ? "self" : "other");
}
- EffectDescription *ed = getEffectDescription(effectId);
+ const EffectDescription *const ed = getEffectDescription(effectId);
if (reportTrue(!ed))
{
@@ -277,18 +281,19 @@ void ActorSprite::internalTriggerEffect(int effectId, bool sfx, bool gfx)
sound.playSfx(ed->mSFXEffect);
}
-void ActorSprite::updateStunMode(int oldMode, int newMode)
+void ActorSprite::updateStunMode(const int oldMode, const int newMode)
{
handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1);
handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1);
}
-void ActorSprite::updateStatusEffect(int index, bool newStatus)
+void ActorSprite::updateStatusEffect(const int index, const bool newStatus)
{
handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index);
}
-void ActorSprite::handleStatusEffect(StatusEffect *effect, int effectId)
+void ActorSprite::handleStatusEffect(StatusEffect *const effect,
+ const int effectId)
{
if (!effect)
return;
@@ -299,7 +304,7 @@ void ActorSprite::handleStatusEffect(StatusEffect *effect, int effectId)
//if (action != ACTION_INVALID)
// setAction(action);
- Particle *particle = effect->getParticle();
+ Particle *const particle = effect->getParticle();
if (effectId >= 0)
{
@@ -314,7 +319,8 @@ void ActorSprite::handleStatusEffect(StatusEffect *effect, int effectId)
}
void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
- bool forceDisplay, int imageType,
+ const bool forceDisplay,
+ const int imageType,
std::string color)
{
clear();
@@ -328,7 +334,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
std::string file = paths.getStringValue("sprites")
+ combineDye2((*it)->sprite, color);
- int variant = (*it)->variant;
+ const int variant = (*it)->variant;
addSprite(AnimatedSprite::delayedLoad(file, variant));
}
@@ -343,7 +349,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
}
else
{
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
std::string imagePath;
switch (imageType)
{
@@ -379,7 +385,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
itr_end = display.particles.end();
itr != itr_end; ++itr)
{
- Particle *p = particleEngine->addEffect(*itr, 0, 0);
+ Particle *const p = particleEngine->addEffect(*itr, 0, 0);
controlParticle(p);
}
}
@@ -406,17 +412,18 @@ void ActorSprite::unload()
loaded = false;
}
-void ActorSprite::addActorSpriteListener(ActorSpriteListener *listener)
+void ActorSprite::addActorSpriteListener(ActorSpriteListener *const listener)
{
mActorSpriteListeners.push_front(listener);
}
-void ActorSprite::removeActorSpriteListener(ActorSpriteListener *listener)
+void ActorSprite::removeActorSpriteListener(ActorSpriteListener *const
+ listener)
{
mActorSpriteListeners.remove(listener);
}
-static const char *cursorType(int type)
+static const char *cursorType(const int type)
{
switch (type)
{
@@ -428,7 +435,7 @@ static const char *cursorType(int type)
}
}
-static const char *cursorSize(int size)
+static const char *cursorSize(const int size)
{
switch (size)
{
@@ -444,9 +451,9 @@ static const char *cursorSize(int size)
void ActorSprite::initTargetCursor()
{
- static std::string targetCursorFile = "target-cursor-%s-%s.png";
- static int targetWidths[NUM_TC] = {44, 62, 82};
- static int targetHeights[NUM_TC] = {35, 44, 60};
+ static const std::string targetCursorFile = "target-cursor-%s-%s.png";
+ static const int targetWidths[NUM_TC] = {44, 62, 82};
+ static const int targetHeights[NUM_TC] = {35, 44, 60};
// Load target cursors
for (int size = TC_SMALL; size < NUM_TC; size++)
@@ -481,12 +488,13 @@ void ActorSprite::cleanupTargetCursors()
}
void ActorSprite::loadTargetCursor(const std::string &filename,
- int width, int height, int type, int size)
+ const int width, const int height,
+ const int type, const int size)
{
if (reportTrue(size < TC_SMALL || size >= NUM_TC))
return;
- ImageSet *currentImageSet = Theme::getImageSetFromTheme(
+ ImageSet *const currentImageSet = Theme::getImageSetFromTheme(
filename, width, height);
if (!currentImageSet)
@@ -495,7 +503,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
return;
}
- Animation *anim = new Animation;
+ Animation *const anim = new Animation;
for (size_t i = 0; i < currentImageSet->size(); ++i)
{
@@ -505,7 +513,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
100);
}
- SimpleAnimation *currentCursor = new SimpleAnimation(anim);
+ SimpleAnimation *const currentCursor = new SimpleAnimation(anim);
if (targetCursor[type][size])
{
diff --git a/src/actorsprite.h b/src/actorsprite.h
index 21ed0ae12..14e2558fd 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -66,14 +66,14 @@ public:
NUM_TCT
};
- ActorSprite(int id);
+ ActorSprite(const int id);
~ActorSprite();
int getId() const
{ return mId; }
- void setId(int id)
+ void setId(const int id)
{ mId = id; }
/**
@@ -90,7 +90,7 @@ public:
static void actorLogic();
- void setMap(Map* map);
+ void setMap(Map *const map);
/**
* Gets the way the object blocks pathfinding for other objects
@@ -101,7 +101,7 @@ public:
/**
* Take control of a particle.
*/
- void controlParticle(Particle *particle);
+ void controlParticle(Particle *const particle);
/**
* Returns the required size of a target cursor for this being.
@@ -118,7 +118,7 @@ public:
/**
* Sets the target animation for this actor.
*/
- void setTargetType(TargetCursorType type);
+ void setTargetType(const TargetCursorType type);
/**
* Untargets the actor.
@@ -132,21 +132,21 @@ public:
*
* \param effectId ID of the effect to trigger
*/
- virtual void triggerEffect(int effectId)
+ virtual void triggerEffect(const int effectId)
{ internalTriggerEffect(effectId, false, true); }
/**
* Sets the actor's stun mode. If zero, the being is `normal', otherwise it
* is `stunned' in some fashion.
*/
- void setStunMode(uint16_t stunMode)
+ void setStunMode(const uint16_t stunMode)
{
if (mStunMode != stunMode)
updateStunMode(mStunMode, stunMode);
mStunMode = stunMode;
}
- void setStatusEffect(int index, bool active);
+ void setStatusEffect(const int index, const bool active);
/**
* A status effect block is a 16 bit mask of status effects. We assign each
@@ -154,9 +154,9 @@ public:
*
* These are NOT the same as the status effect indices.
*/
- void setStatusEffectBlock(int offset, uint16_t flags);
+ void setStatusEffectBlock(const int offset, const uint16_t flags);
- virtual void setAlpha(float alpha)
+ virtual void setAlpha(const float alpha)
{ CompoundSprite::setAlpha(alpha); }
virtual float getAlpha() const
@@ -175,12 +175,12 @@ public:
/**
* Add an ActorSprite listener.
*/
- void addActorSpriteListener(ActorSpriteListener *listener);
+ void addActorSpriteListener(ActorSpriteListener *const listener);
/**
* Remove an ActorSprite listener.
*/
- void removeActorSpriteListener(ActorSpriteListener *listener);
+ void removeActorSpriteListener(ActorSpriteListener *const listener);
protected:
/**
@@ -190,19 +190,20 @@ protected:
* \param sfx Whether to trigger sound effects
* \param gfx Whether to trigger graphical effects
*/
- void internalTriggerEffect(int effectId, bool sfx, bool gfx);
+ void internalTriggerEffect(const int effectId, const bool sfx,
+ const bool gfx);
/**
* Notify self that the stun mode has been updated. Invoked by
* setStunMode if something changed.
*/
- virtual void updateStunMode(int oldMode, int newMode);
+ virtual void updateStunMode(const int oldMode, const int newMode);
/**
* Notify self that a status effect has flipped.
* The new flag is passed.
*/
- virtual void updateStatusEffect(int index, bool newStatus);
+ virtual void updateStatusEffect(const int index, const bool newStatus);
/**
* Handle an update to a status or stun effect
@@ -210,10 +211,12 @@ protected:
* \param The StatusEffect to effect
* \param effectId -1 for stun, otherwise the effect index
*/
- virtual void handleStatusEffect(StatusEffect *effect, int effectId);
+ virtual void handleStatusEffect(StatusEffect *const effect,
+ const int effectId);
void setupSpriteDisplay(const SpriteDisplay &display,
- bool forceDisplay = true, int imageType = 0,
+ const bool forceDisplay = true,
+ const int imageType = 0,
std::string color = "");
int mId;
@@ -238,7 +241,8 @@ private:
* Helper function for loading target cursors
*/
static void loadTargetCursor(const std::string &filename,
- int width, int height, int type, int size);
+ const int width, const int height,
+ const int type, const int size);
/** Images of the target cursor. */
static ImageSet *targetCursorImages[NUM_TCT][NUM_TC];
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 012cdd3e0..33f602acc 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -54,16 +54,16 @@
class FindBeingFunctor
{
public:
- bool operator() (ActorSprite *actor)
+ bool operator() (const ActorSprite *const actor) const
{
if (!actor || actor->getType() == ActorSprite::FLOOR_ITEM
|| actor->getType() == ActorSprite::PORTAL)
{
return false;
}
- Being* b = static_cast<Being*>(actor);
+ const Being *const b = static_cast<const Being* const>(actor);
- unsigned other_y = y + ((b->getType()
+ const unsigned other_y = y + ((b->getType()
== ActorSprite::NPC) ? 1 : 0);
const Vector &pos = b->getPosition();
return (static_cast<unsigned>(pos.x) / 32 == x &&
@@ -80,7 +80,7 @@ class FindBeingFunctor
class FindBeingEqualFunctor
{
public:
- bool operator() (Being *being)
+ bool operator() (const Being *const being) const
{
if (!being || !findBeing)
return false;
@@ -93,7 +93,8 @@ class FindBeingEqualFunctor
class SortBeingFunctor
{
public:
- bool operator() (Being* being1, Being* being2)
+ bool operator() (const Being *const being1,
+ const Being *const being2) const
{
if (!being1 || !being2)
return false;
@@ -102,9 +103,9 @@ class SortBeingFunctor
{
int w1 = defaultPriorityIndex;
int w2 = defaultPriorityIndex;
- std::map<std::string, int>::const_iterator it1
+ const std::map<std::string, int>::const_iterator it1
= priorityBeings->find(being1->getName());
- std::map<std::string, int>::const_iterator it2
+ const std::map<std::string, int>::const_iterator it2
= priorityBeings->find(being2->getName());
if (it1 != priorityBeings->end())
w1 = (*it1).second;
@@ -155,9 +156,9 @@ class SortBeingFunctor
{
int w1 = defaultAttackIndex;
int w2 = defaultAttackIndex;
- std::map<std::string, int>::const_iterator it1
+ const std::map<std::string, int>::const_iterator it1
= attackBeings->find(being1->getName());
- std::map<std::string, int>::const_iterator it2
+ const std::map<std::string, int>::const_iterator it2
= attackBeings->find(being2->getName());
if (it1 != attackBeings->end())
w1 = (*it1).second;
@@ -207,7 +208,7 @@ ActorSpriteManager::~ActorSpriteManager()
clear();
}
-void ActorSpriteManager::setMap(Map *map)
+void ActorSpriteManager::setMap(Map *const map)
{
mMap = map;
@@ -215,7 +216,7 @@ void ActorSpriteManager::setMap(Map *map)
player_node->setMap(map);
}
-void ActorSpriteManager::setPlayer(LocalPlayer *player)
+void ActorSpriteManager::setPlayer(LocalPlayer *const player)
{
player_node = player;
mActors.insert(player);
@@ -225,20 +226,23 @@ void ActorSpriteManager::setPlayer(LocalPlayer *player)
socialWindow->updatePickupFilter();
}
-Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type,
- uint16_t subtype)
+Being *ActorSpriteManager::createBeing(const int id,
+ const ActorSprite::Type type,
+ const uint16_t subtype)
{
- Being *being = new Being(id, type, subtype, mMap);
+ Being *const being = new Being(id, type, subtype, mMap);
mActors.insert(being);
return being;
}
-FloorItem *ActorSpriteManager::createItem(int id, int itemId, int x, int y,
- int amount, unsigned char color,
- int subX, int subY)
+FloorItem *ActorSpriteManager::createItem(const int id, const int itemId,
+ const int x, const int y,
+ const int amount,
+ const unsigned char color,
+ const int subX, const int subY)
{
- FloorItem *floorItem = new FloorItem(id, itemId, x, y,
+ FloorItem *const floorItem = new FloorItem(id, itemId, x, y,
mMap, amount, color, subX, subY);
if (!checkForPickup(floorItem))
@@ -247,7 +251,7 @@ FloorItem *ActorSpriteManager::createItem(int id, int itemId, int x, int y,
return floorItem;
}
-void ActorSpriteManager::destroy(ActorSprite *actor)
+void ActorSpriteManager::destroy(ActorSprite *const actor)
{
if (!actor || actor == player_node)
return;
@@ -255,7 +259,7 @@ void ActorSpriteManager::destroy(ActorSprite *actor)
mDeleteActors.insert(actor);
}
-void ActorSpriteManager::erase(ActorSprite *actor)
+void ActorSpriteManager::erase(ActorSprite *const actor)
{
if (!actor || actor == player_node)
return;
@@ -263,7 +267,7 @@ void ActorSpriteManager::erase(ActorSprite *actor)
mActors.erase(actor);
}
-void ActorSpriteManager::undelete(ActorSprite *actor)
+void ActorSpriteManager::undelete(const ActorSprite *const actor)
{
if (!actor || actor == player_node)
return;
@@ -281,11 +285,11 @@ void ActorSpriteManager::undelete(ActorSprite *actor)
}
}
-Being *ActorSpriteManager::findBeing(int id) const
+Being *ActorSpriteManager::findBeing(const int id) const
{
for_actors
{
- ActorSprite *actor = *it;
+ ActorSprite *const actor = *it;
if (actor->getId() == id &&
actor->getType() != ActorSprite::FLOOR_ITEM)
{
@@ -296,26 +300,26 @@ Being *ActorSpriteManager::findBeing(int id) const
return nullptr;
}
-Being *ActorSpriteManager::findBeing(int x, int y,
- ActorSprite::Type type) const
+Being *ActorSpriteManager::findBeing(const int x, const int y,
+ const ActorSprite::Type type) const
{
beingFinder.x = static_cast<uint16_t>(x);
beingFinder.y = static_cast<uint16_t>(y);
beingFinder.type = type;
- ActorSpritesConstIterator it = find_if(mActors.begin(), mActors.end(),
- beingFinder);
+ const ActorSpritesConstIterator it = find_if(
+ mActors.begin(), mActors.end(), beingFinder);
return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it);
}
-Being *ActorSpriteManager::findBeingByPixel(int x, int y,
- bool allPlayers) const
+Being *ActorSpriteManager::findBeingByPixel(const int x, const int y,
+ const bool allPlayers) const
{
if (!mMap)
return nullptr;
- bool targetDead = mTargetDeadPlayers;
+ const bool targetDead = mTargetDeadPlayers;
if (mExtMouseTargeting)
{
@@ -334,7 +338,8 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
{
if (!noBeing)
{
- FloorItem *floor = static_cast<FloorItem*>(*it);
+ const FloorItem *const floor
+ = static_cast<FloorItem*>(*it);
if ((floor->getPixelX() - 32 <= x) &&
(floor->getPixelX() + 32 > x) &&
(floor->getPixelY() - 64 <= y) &&
@@ -346,7 +351,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getInfo() && !being->getInfo()->isTargetSelection())
continue;
@@ -393,7 +398,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getInfo() && !being->getInfo()->isTargetSelection())
continue;
@@ -411,7 +416,8 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
}
void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
- int x, int y, bool allPlayers) const
+ const int x, const int y,
+ const bool allPlayers) const
{
if (!mMap)
return;
@@ -427,7 +433,7 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
if ((*it)->getType() == ActorSprite::PORTAL)
continue;
- Being *being = dynamic_cast<Being*>(*it);
+ const Being *const being = dynamic_cast<Being*>(*it);
if (being && being->getInfo()
&& !being->getInfo()->isTargetSelection())
@@ -435,7 +441,7 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
continue;
}
- ActorSprite *actor = *it;
+ ActorSprite *const actor = *it;
if ((being && (being->isAlive()
|| (mTargetDeadPlayers && being->getType() == Being::PLAYER))
@@ -454,7 +460,7 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
}
}
-Being *ActorSpriteManager::findPortalByTile(int x, int y) const
+Being *ActorSpriteManager::findPortalByTile(const int x, const int y) const
{
if (!mMap)
return nullptr;
@@ -467,7 +473,7 @@ Being *ActorSpriteManager::findPortalByTile(int x, int y) const
if ((*it)->getType() != ActorSprite::PORTAL)
continue;
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getTileX() == x && being->getTileY() == y)
return being;
@@ -476,7 +482,7 @@ Being *ActorSpriteManager::findPortalByTile(int x, int y) const
return nullptr;
}
-FloorItem *ActorSpriteManager::findItem(int id) const
+FloorItem *ActorSpriteManager::findItem(const int id) const
{
for_actors
{
@@ -493,7 +499,7 @@ FloorItem *ActorSpriteManager::findItem(int id) const
return nullptr;
}
-FloorItem *ActorSpriteManager::findItem(int x, int y) const
+FloorItem *ActorSpriteManager::findItem(const int x, const int y) const
{
for_actors
{
@@ -510,14 +516,15 @@ FloorItem *ActorSpriteManager::findItem(int x, int y) const
return nullptr;
}
-bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
- bool serverBuggy)
+bool ActorSpriteManager::pickUpAll(const int x1, const int y1,
+ const int x2, const int y2,
+ const bool serverBuggy)
{
if (!player_node)
return false;
bool finded(false);
- bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
+ const bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
if (!serverBuggy)
{
for_actors
@@ -529,7 +536,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
&& ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
&& ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
{
- FloorItem *item = static_cast<FloorItem*>(*it);
+ FloorItem *const item = static_cast<FloorItem*>(*it);
if (allowAll)
{
if (mIgnorePickupItemsSet.find(item->getName())
@@ -564,7 +571,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
&& ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
&& ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
{
- FloorItem *tempItem = static_cast<FloorItem*>(*it);
+ FloorItem *const tempItem = static_cast<FloorItem*>(*it);
if (tempItem->getPickupCount() < cnt)
{
if (allowAll)
@@ -606,7 +613,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
return finded;
}
-bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
+bool ActorSpriteManager::pickUpNearest(const int x, const int y, int maxdist)
{
if (!player_node)
return false;
@@ -614,7 +621,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
maxdist = maxdist * maxdist;
FloorItem *closestItem = nullptr;
int dist = 0;
- bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
+ const bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
for_actors
{
@@ -623,10 +630,10 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
{
- FloorItem *item = static_cast<FloorItem*>(*it);
+ FloorItem *const item = static_cast<FloorItem*>(*it);
- int d = (item->getTileX() - x) * (item->getTileX() - x)
- + (item->getTileY() - y) * (item->getTileY() - y);
+ const int d = (item->getTileX() - x) * (item->getTileX() - x)
+ + (item->getTileY() - y) * (item->getTileY() - y);
if ((d < dist || !closestItem) && (!mTargetOnlyReachable
|| player_node->isReachable(item->getTileX(),
@@ -660,7 +667,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
}
Being *ActorSpriteManager::findBeingByName(const std::string &name,
- ActorSprite::Type type) const
+ const ActorSprite::Type type) const
{
for_actors
{
@@ -673,7 +680,7 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name,
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getName() == name &&
(type == ActorSprite::UNKNOWN || type == being->getType()))
{
@@ -684,7 +691,7 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name,
}
Being *ActorSpriteManager::findNearestByName(const std::string &name,
- Being::Type type) const
+ const Being::Type type) const
{
if (!player_node)
return nullptr;
@@ -707,7 +714,7 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name,
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being && being->getName() == name &&
(type == Being::UNKNOWN || type == being->getType()))
@@ -716,8 +723,8 @@ Being *ActorSpriteManager::findNearestByName(const std::string &name,
return being;
else
{
- int d = (being->getTileX() - x) * (being->getTileX() - x)
- + (being->getTileY() - y) * (being->getTileY() - y);
+ const int d = (being->getTileX() - x) * (being->getTileX() - x)
+ + (being->getTileY() - y) * (being->getTileY() - y);
if (validateBeing(nullptr, being, type, nullptr, 50)
&& (d < dist || closestBeing == nullptr))
@@ -756,7 +763,7 @@ void ActorSpriteManager::logic()
if ((*it) && (*it)->getType() == Being::PLAYER)
{
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
being->addToCache();
if (beingEquipmentWindow)
beingEquipmentWindow->resetBeing(being);
@@ -806,35 +813,32 @@ void ActorSpriteManager::clear()
mActors.insert(player_node);
}
-Being *ActorSpriteManager::findNearestLivingBeing(int x, int y,
- int maxTileDist,
- ActorSprite::Type type,
- Being *excluded) const
+Being *ActorSpriteManager::findNearestLivingBeing(const int x, const int y,
+ const int maxTileDist,
+ const ActorSprite::Type type,
+ Being *const excluded) const
{
const int maxDist = maxTileDist * 32;
return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded);
}
-Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
- int maxDist,
- Being::Type type) const
+Being *ActorSpriteManager::findNearestLivingBeing(Being *const aroundBeing,
+ const int maxDist,
+ const Being::Type type) const
{
if (!aroundBeing)
return nullptr;
- int x = aroundBeing->getTileX();
- int y = aroundBeing->getTileY();
-
return findNearestLivingBeing(aroundBeing, maxDist, type,
- x, y, aroundBeing);
+ aroundBeing->getTileX(), aroundBeing->getTileY(), aroundBeing);
}
-Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
+Being *ActorSpriteManager::findNearestLivingBeing(Being *const aroundBeing,
int maxDist,
- Being::Type type,
- int x, int y,
- Being *excluded) const
+ const Being::Type type,
+ const int x, const int y,
+ Being *const excluded) const
{
if (!aroundBeing || !player_node)
return nullptr;
@@ -858,11 +862,11 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
maxDist = maxDist * maxDist;
- bool cycleSelect = (mCyclePlayers && type == Being::PLAYER)
+ const bool cycleSelect = (mCyclePlayers && type == Being::PLAYER)
|| (mCycleMonsters && type == Being::MONSTER)
|| (mCycleNPC && type == Being::NPC);
- bool filtered = config.getBoolValue("enableAttackFilter")
+ const bool filtered = config.getBoolValue("enableAttackFilter")
&& type == Being::MONSTER;
bool ignoreDefault = false;
@@ -905,7 +909,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
continue;
}
- Being *being = static_cast<Being*>(*i);
+ Being *const being = static_cast<Being*>(*i);
if (filtered)
{
@@ -959,7 +963,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
if (player_node->getTarget() == nullptr)
{
- Being *target = sortedBeings.at(0);
+ Being *const target = sortedBeings.at(0);
if (specialDistance && target->getType() == Being::MONSTER
&& target->getDistance() <= 2)
@@ -1000,7 +1004,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
{
continue;
}
- Being *being = static_cast<Being*>(*i);
+ Being *const being = static_cast<Being*>(*i);
if (filtered)
{
@@ -1022,7 +1026,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
// Being *being = (*i);
- bool valid = validateBeing(aroundBeing, being, type, excluded, 50);
+ const bool valid = validateBeing(aroundBeing, being, type, excluded, 50);
int d = being->getDistance();
// logger->log("dist: %d", dist);
// logger->log("name: %s, %d, %d", being->getName().c_str(), (int)valid, d);
@@ -1056,7 +1060,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
int w2 = defaultPriorityIndex;
if (closestBeing)
{
- std::map<std::string, int>::const_iterator it2
+ const std::map<std::string, int>::const_iterator it2
= priorityMobsMap.find(being->getName());
if (it2 != priorityMobsMap.end())
w2 = (*it2).second;
@@ -1081,7 +1085,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
{
dist = d;
closestBeing = being;
- std::map<std::string, int>::const_iterator it1
+ const std::map<std::string, int>::const_iterator it1
= priorityMobsMap.find(being->getName());
if (it1 != priorityMobsMap.end())
index = (*it1).second;
@@ -1094,9 +1098,11 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
}
}
-bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being,
- Being::Type type, Being* excluded,
- int maxCost) const
+bool ActorSpriteManager::validateBeing(const Being *const aroundBeing,
+ Being *const being,
+ const Being::Type type,
+ const Being* const excluded,
+ const int maxCost) const
{
return being && ((being->getType() == type
|| type == Being::UNKNOWN) && (being->isAlive()
@@ -1106,7 +1112,7 @@ bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being,
|| player_node->isReachable(being, maxCost));
}
-void ActorSpriteManager::healTarget()
+void ActorSpriteManager::healTarget() const
{
if (!player_node)
return;
@@ -1114,7 +1120,7 @@ void ActorSpriteManager::healTarget()
heal(player_node->getTarget());
}
-void ActorSpriteManager::heal(Being* target)
+void ActorSpriteManager::heal(const Being *const target) const
{
if (!player_node || !chatWindow || !player_node->isAlive()
|| !Net::getPlayerHandler()->canUseMagic())
@@ -1195,7 +1201,7 @@ void ActorSpriteManager::heal(Being* target)
}
}
-void ActorSpriteManager::itenplz()
+void ActorSpriteManager::itenplz() const
{
if (!player_node || !chatWindow || !player_node->isAlive()
|| !Net::getPlayerHandler()->canUseMagic())
@@ -1209,7 +1215,7 @@ void ActorSpriteManager::itenplz()
chatWindow->localChatInput(mSpellItenplz);
}
-bool ActorSpriteManager::hasActorSprite(ActorSprite *actor) const
+bool ActorSpriteManager::hasActorSprite(const ActorSprite *const actor) const
{
for_actors
{
@@ -1220,7 +1226,7 @@ bool ActorSpriteManager::hasActorSprite(ActorSprite *actor) const
return false;
}
-void ActorSpriteManager::addBlock(uint32_t id)
+void ActorSpriteManager::addBlock(const uint32_t id)
{
bool alreadyBlocked(false);
for (int i = 0; i < static_cast<int>(blockedBeings.size()); ++i)
@@ -1235,10 +1241,10 @@ void ActorSpriteManager::addBlock(uint32_t id)
blockedBeings.push_back(id);
}
-void ActorSpriteManager::deleteBlock(uint32_t id)
+void ActorSpriteManager::deleteBlock(const uint32_t id)
{
std::vector<uint32_t>::iterator iter = blockedBeings.begin();
- std::vector<uint32_t>::iterator iter_end = blockedBeings.end();
+ const std::vector<uint32_t>::iterator iter_end = blockedBeings.end();
while (iter != iter_end)
{
if (*iter == id)
@@ -1246,10 +1252,11 @@ void ActorSpriteManager::deleteBlock(uint32_t id)
blockedBeings.erase(iter);
break;
}
+ ++ iter;
}
}
-bool ActorSpriteManager::isBlocked(uint32_t id)
+bool ActorSpriteManager::isBlocked(const uint32_t id) const
{
bool blocked(false);
for (int i = 0; i < static_cast<int>(blockedBeings.size()); ++i)
@@ -1277,7 +1284,7 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings,
debugChatTab->chatLog("---------------------------------------");
debugChatTab->chatLog(header);
std::set<ActorSprite*>::const_iterator it;
- std::set<ActorSprite*>::const_iterator it_end = beings.end();
+ const std::set<ActorSprite*>::const_iterator it_end = beings.end();
for (it = beings.begin(); it != it_end; ++it)
{
if (!*it)
@@ -1286,7 +1293,7 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings,
if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
continue;
- const Being *being = static_cast<Being*>(*it);
+ const Being *const being = static_cast<Being*>(*it);
debugChatTab->chatLog(being->getName()
+ " (" + toString(being->getTileX()) + ","
@@ -1306,13 +1313,13 @@ void ActorSpriteManager::printBeingsToChat(std::vector<Being*> beings,
debugChatTab->chatLog(header);
std::vector<Being*>::const_iterator i;
- std::vector<Being*>::const_iterator i_end = beings.end();
+ const std::vector<Being*>::const_iterator i_end = beings.end();
for (i = beings.begin(); i != i_end; ++i)
{
if (!*i)
continue;
- const Being *being = *i;
+ const Being *const being = *i;
debugChatTab->chatLog(being->getName()
+ " (" + toString(being->getTileX()) + ","
@@ -1322,7 +1329,8 @@ void ActorSpriteManager::printBeingsToChat(std::vector<Being*> beings,
debugChatTab->chatLog("---------------------------------------");
}
-void ActorSpriteManager::getPlayerNames(StringVect &names, bool npcNames)
+void ActorSpriteManager::getPlayerNames(StringVect &names,
+ const bool npcNames) const
{
names.clear();
@@ -1337,7 +1345,7 @@ void ActorSpriteManager::getPlayerNames(StringVect &names, bool npcNames)
continue;
}
- Being *being = static_cast<Being*>(*it);
+ const Being *const being = static_cast<Being*>(*it);
if ((being->getType() == ActorSprite::PLAYER
|| (being->getType() == ActorSprite::NPC && npcNames))
&& being->getName() != "")
@@ -1347,7 +1355,7 @@ void ActorSpriteManager::getPlayerNames(StringVect &names, bool npcNames)
}
}
-void ActorSpriteManager::getMobNames(StringVect &names)
+void ActorSpriteManager::getMobNames(StringVect &names) const
{
names.clear();
@@ -1362,13 +1370,13 @@ void ActorSpriteManager::getMobNames(StringVect &names)
continue;
}
- Being *being = static_cast<Being*>(*it);
+ const Being *const being = static_cast<Being*>(*it);
if (being->getType() == ActorSprite::MONSTER && being->getName() != "")
names.push_back(being->getName());
}
}
-void ActorSpriteManager::updatePlayerNames()
+void ActorSpriteManager::updatePlayerNames() const
{
for_actors
{
@@ -1381,14 +1389,14 @@ void ActorSpriteManager::updatePlayerNames()
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
being->setGoodStatus(-1);
if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
being->updateName();
}
}
-void ActorSpriteManager::updatePlayerColors()
+void ActorSpriteManager::updatePlayerColors() const
{
for_actors
{
@@ -1401,13 +1409,13 @@ void ActorSpriteManager::updatePlayerColors()
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
being->updateColors();
}
}
-void ActorSpriteManager::updatePlayerGuild()
+void ActorSpriteManager::updatePlayerGuild() const
{
for_actors
{
@@ -1420,7 +1428,7 @@ void ActorSpriteManager::updatePlayerGuild()
continue;
}
- Being *being = static_cast<Being*>(*it);
+ Being *const being = static_cast<Being*>(*it);
if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
being->updateGuild();
}
@@ -1442,8 +1450,8 @@ void ActorSpriteManager::parseLevels(std::string levels)
size_t bktPos = part.rfind("(");
if (bktPos != std::string::npos)
{
- Being *being = findBeingByName(part.substr(0, bktPos),
- Being::PLAYER);
+ Being *const being = findBeingByName(part.substr(0, bktPos),
+ Being::PLAYER);
if (being)
{
being->setLevel(atoi(part.substr(bktPos + 1).c_str()));
@@ -1495,10 +1503,10 @@ void ActorSpriteManager::removePickupItem(const std::string &name)
#define addMobToList(name, mob) \
{\
- int size = get##mob##sSize();\
+ const int size = get##mob##sSize();\
if (size > 0)\
{\
- int idx = get##mob##Index("");\
+ const int idx = get##mob##Index("");\
if (idx + 1 == size)\
{\
std::list<std::string>::iterator itr = m##mob##s.end();\
@@ -1579,9 +1587,9 @@ void ActorSpriteManager::rebuildPickupItems()
}
int ActorSpriteManager::getIndexByName(std::string name,
- std::map<std::string, int> &map)
+ std::map<std::string, int> &map) const
{
- std::map<std::string, int>::const_iterator
+ const std::map<std::string, int>::const_iterator
i = map.find(name);
if (i == map.end())
return -1;
@@ -1659,7 +1667,7 @@ void ActorSpriteManager::storeAttackList()
serverConfig.setValue("ignorePickupItems", packList(mIgnorePickupItems));
}
-bool ActorSpriteManager::checkForPickup(const FloorItem *item)
+bool ActorSpriteManager::checkForPickup(const FloorItem *const item) const
{
if (mPickupItemsSet.find("") != mPickupItemsSet.end())
{
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 67ea8a32f..b011b0c6f 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -43,71 +43,75 @@ class ActorSpriteManager: public ConfigListener
/**
* Sets the map on which ActorSprites are created.
*/
- void setMap(Map *map);
+ void setMap(Map *const map);
/**
* Sets the current player.
*/
- void setPlayer(LocalPlayer *player);
+ void setPlayer(LocalPlayer *const player);
/**
* Create a Being and add it to the list of ActorSprites.
*/
- Being *createBeing(int id, ActorSprite::Type type, uint16_t subtype);
+ Being *createBeing(const int id, const ActorSprite::Type type,
+ const uint16_t subtype);
/**
* Create a FloorItem and add it to the list of ActorSprites.
*/
- FloorItem *createItem(int id, int itemId, int x, int y,
- int amount, unsigned char color,
- int subX, int subY);
+ FloorItem *createItem(const int id, const int itemId,
+ const int x, const int y,
+ const int amount, const unsigned char color,
+ const int subX, const int subY);
/**
* Destroys the given ActorSprite at the end of
* ActorSpriteManager::logic.
*/
- void destroy(ActorSprite *actor);
+ void destroy(ActorSprite *const actor);
- void erase(ActorSprite *actor);
+ void erase(ActorSprite *const actor);
- void undelete(ActorSprite *actor);
+ void undelete(const ActorSprite *const actor);
/**
* Returns a specific Being, by id;
*/
- Being *findBeing(int id) const;
+ Being *findBeing(const int id) const;
/**
* Returns a being at specific coordinates.
*/
- Being *findBeing(int x, int y,
- ActorSprite::Type type = ActorSprite::UNKNOWN) const;
+ Being *findBeing(const int x, const int y, const ActorSprite::Type
+ type = ActorSprite::UNKNOWN) const;
/**
* Returns a being at the specific pixel.
*/
- Being *findBeingByPixel(int x, int y, bool allPlayers = false) const;
+ Being *findBeingByPixel(const int x, const int y,
+ const bool allPlayers = false) const;
/**
* Returns a beings at the specific pixel.
*/
- void findBeingsByPixel(std::vector<ActorSprite*> &beings, int x, int y,
- bool allPlayers) const;
+ void findBeingsByPixel(std::vector<ActorSprite*> &beings,
+ const int x, const int y,
+ const bool allPlayers) const;
/**
* Returns a portal at the specific tile.
*/
- Being *findPortalByTile(int x, int y) const;
+ Being *findPortalByTile(const int x, const int y) const;
/**
* Returns a specific FloorItem, by id.
*/
- FloorItem *findItem(int id) const;
+ FloorItem *findItem(const int id) const;
/**
* Returns a FloorItem at specific coordinates.
*/
- FloorItem *findItem(int x, int y) const;
+ FloorItem *findItem(const int x, const int y) const;
/**
* Returns a being nearest to specific coordinates.
@@ -118,9 +122,11 @@ class ActorSpriteManager: public ConfigListener
* larger, no being is returned.
* @param type The type of being to look for.
*/
- Being *findNearestLivingBeing(int x, int y, int maxTileDist,
- ActorSprite::Type type = Being::UNKNOWN,
- Being *excluded = nullptr) const;
+ Being *findNearestLivingBeing(const int x, const int y,
+ int maxTileDist,
+ const ActorSprite::Type
+ type = Being::UNKNOWN,
+ Being *const excluded = nullptr) const;
/**
* Returns a being nearest to another being.
@@ -130,21 +136,24 @@ class ActorSpriteManager: public ConfigListener
* larger, no being is returned.
* @param type The type of being to look for.
*/
- Being *findNearestLivingBeing(Being *aroundBeing, int maxTileDist,
- ActorSprite::Type type = Being::UNKNOWN
+ Being *findNearestLivingBeing(Being *const aroundBeing,
+ const int maxTileDist,
+ const ActorSprite::Type
+ type = Being::UNKNOWN
) const;
/**
* Finds a being by name and (optionally) by type.
*/
Being *findBeingByName(const std::string &name,
- ActorSprite::Type type = Being::UNKNOWN) const;
+ const ActorSprite::Type
+ type = Being::UNKNOWN) const;
/**
* Finds a nearest being by name and (optionally) by type.
*/
Being *findNearestByName(const std::string &name,
- Being::Type type = Being::UNKNOWN) const;
+ const Being::Type type = Being::UNKNOWN) const;
/**
* Heal all players in distance.
@@ -155,11 +164,11 @@ class ActorSpriteManager: public ConfigListener
// void HealAllTargets(Being *aroundBeing, int maxdist,
// Being::Type type) const;
- void healTarget();
+ void healTarget() const;
- void heal(Being* target);
+ void heal(const Being *const target) const;
- void itenplz();
+ void itenplz() const;
/**
* Returns the whole list of beings.
@@ -172,7 +181,7 @@ class ActorSpriteManager: public ConfigListener
*
* \param actor the ActorSprite to search for
*/
- bool hasActorSprite(ActorSprite *actor) const;
+ bool hasActorSprite(const ActorSprite *const actor) const;
/**
* Performs ActorSprite logic and deletes ActorSprite scheduled to be
@@ -187,11 +196,11 @@ class ActorSpriteManager: public ConfigListener
std::vector<uint32_t> blockedBeings;
- void addBlock(uint32_t id);
+ void addBlock(const uint32_t id);
- void deleteBlock(uint32_t id);
+ void deleteBlock(const uint32_t id);
- bool isBlocked(uint32_t id);
+ bool isBlocked(const uint32_t id) const;
void printAllToChat() const;
@@ -201,22 +210,22 @@ class ActorSpriteManager: public ConfigListener
std::string header) const;
void getPlayerNames(StringVect &names,
- bool npcNames);
+ const bool npcNames) const;
- void getMobNames(StringVect &names);
+ void getMobNames(StringVect &names) const;
- void updatePlayerNames();
+ void updatePlayerNames() const;
- void updatePlayerColors();
+ void updatePlayerColors() const;
- void updatePlayerGuild();
+ void updatePlayerGuild() const;
void parseLevels(std::string levels);
- bool pickUpAll(int x1, int y1, int x2, int y2,
- bool serverBuggy = false);
+ bool pickUpAll(const int x1, const int y1, const int x2, const int y2,
+ const bool serverBuggy = false);
- bool pickUpNearest(int x, int y, int maxdist);
+ bool pickUpNearest(const int x, const int y, int maxdist);
void optionChanged(const std::string &name);
@@ -276,14 +285,17 @@ class ActorSpriteManager: public ConfigListener
int getPickupItemIndex(std::string name);
- int getIndexByName(std::string name, std::map<std::string, int> &map);
+ int getIndexByName(std::string name, std::map<std::string,
+ int> &map) const;
- bool checkForPickup(const FloorItem *item);
+ bool checkForPickup(const FloorItem *const item) const;
protected:
- bool validateBeing(Being *aroundBeing, Being* being,
- Being::Type type, Being* excluded = nullptr,
- int maxCost = 20) const;
+ bool validateBeing(const Being *const aroundBeing,
+ Being *const being,
+ const Being::Type type,
+ const Being *const excluded = nullptr,
+ const int maxCost = 20) const;
Being *findNearestLivingBeing(Being *aroundBeing, int maxdist,
Being::Type type, int x, int y,
diff --git a/src/keydata.h b/src/keydata.h
index dc5a136a6..88ff7f4ca 100644
--- a/src/keydata.h
+++ b/src/keydata.h
@@ -27,7 +27,7 @@
#include <string>
-typedef bool (*ActionFuncPtr) (InputEvent &event);
+typedef bool (*ActionFuncPtr) (const InputEvent &event);
struct KeyData
{
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 0c7c8a326..dec72bcf7 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -2977,7 +2977,7 @@ void LocalPlayer::crazyMoveA()
mCrazyMoveState = 0;
}
-bool LocalPlayer::isReachable(int x, int y, int maxCost)
+bool LocalPlayer::isReachable(int x, int y, int maxCost) const
{
if (!mMap)
return false;
@@ -2998,7 +2998,7 @@ bool LocalPlayer::isReachable(int x, int y, int maxCost)
return !debugPath.empty();
}
-bool LocalPlayer::isReachable(Being *being, int maxCost)
+bool LocalPlayer::isReachable(Being *being, int maxCost) const
{
if (!being || !mMap)
return false;
diff --git a/src/localplayer.h b/src/localplayer.h
index aeae31faf..a12aacc91 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -315,9 +315,9 @@ class LocalPlayer : public Being, public ActorSpriteListener,
// int getSkillLv(int id);
- bool isReachable(int x, int y, int maxCost = 0);
+ bool isReachable(int x, int y, int maxCost = 0) const;
- bool isReachable(Being *being, int maxCost = 0);
+ bool isReachable(Being *being, int maxCost = 0) const;
void setHome();