summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp3
-rw-r--r--src/actorsprite.h3
-rw-r--r--src/actorspritemanager.cpp4
-rw-r--r--src/actorspritemanager.h2
-rw-r--r--src/animatedsprite.cpp2
-rw-r--r--src/animatedsprite.h2
-rw-r--r--src/being.cpp3
-rw-r--r--src/being.h3
-rw-r--r--src/client.cpp25
-rw-r--r--src/client.h2
-rw-r--r--src/compoundsprite.cpp2
-rw-r--r--src/compoundsprite.h2
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/shopwindow.cpp2
-rw-r--r--src/gui/shopwindow.h2
-rw-r--r--src/gui/socialwindow.cpp8
-rw-r--r--src/gui/widgets/avatarlistbox.cpp6
-rw-r--r--src/gui/widgets/avatarlistbox.h2
-rw-r--r--src/gui/widgets/button.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/layout.cpp2
-rw-r--r--src/gui/widgets/layout.h2
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/popup.h2
-rw-r--r--src/gui/widgets/scrollarea.cpp2
-rw-r--r--src/gui/widgets/setupitem.cpp5
-rw-r--r--src/gui/widgets/setupitem.h4
-rw-r--r--src/gui/widgets/slider.cpp2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/tab.cpp2
-rw-r--r--src/gui/windowmenu.cpp2
-rw-r--r--src/guichan/cliprectangle.cpp5
-rw-r--r--src/guichan/color.cpp6
-rw-r--r--src/guichan/event.cpp4
-rw-r--r--src/guichan/exception.cpp2
-rw-r--r--src/guichan/include/guichan/cliprectangle.hpp12
-rw-r--r--src/guichan/include/guichan/color.hpp6
-rw-r--r--src/guichan/include/guichan/event.hpp2
-rw-r--r--src/guichan/include/guichan/exception.hpp2
-rw-r--r--src/guichan/include/guichan/inputevent.hpp10
-rw-r--r--src/guichan/include/guichan/key.hpp2
-rw-r--r--src/guichan/include/guichan/keyevent.hpp14
-rw-r--r--src/guichan/include/guichan/mouseevent.hpp20
-rw-r--r--src/guichan/include/guichan/mouseinput.hpp10
-rw-r--r--src/guichan/include/guichan/rectangle.hpp2
-rw-r--r--src/guichan/include/guichan/sdl/sdlimage.hpp2
-rw-r--r--src/guichan/include/guichan/selectionevent.hpp2
-rw-r--r--src/guichan/include/guichan/widgets/dropdown.hpp6
-rw-r--r--src/guichan/include/guichan/widgets/icon.hpp2
-rw-r--r--src/guichan/include/guichan/widgets/scrollarea.hpp2
-rw-r--r--src/guichan/include/guichan/widgets/slider.hpp4
-rw-r--r--src/guichan/inputevent.cpp10
-rw-r--r--src/guichan/key.cpp2
-rw-r--r--src/guichan/keyevent.cpp32
-rw-r--r--src/guichan/mouseevent.cpp41
-rw-r--r--src/guichan/mouseinput.cpp20
-rw-r--r--src/guichan/rectangle.cpp5
-rw-r--r--src/guichan/sdl/sdlimage.cpp2
-rw-r--r--src/guichan/selectionevent.cpp4
-rw-r--r--src/guichan/widgets/dropdown.cpp6
-rw-r--r--src/guichan/widgets/icon.cpp2
-rw-r--r--src/guichan/widgets/scrollarea.cpp2
-rw-r--r--src/guichan/widgets/slider.cpp4
-rw-r--r--src/imagesprite.h2
-rw-r--r--src/inputmanager.cpp4
-rw-r--r--src/inputmanager.h2
-rw-r--r--src/localplayer.cpp18
-rw-r--r--src/localplayer.h17
-rw-r--r--src/logger.cpp8
-rw-r--r--src/logger.h10
-rw-r--r--src/main.cpp8
-rw-r--r--src/map.cpp181
-rw-r--r--src/map.h110
-rw-r--r--src/sprite.h2
75 files changed, 360 insertions, 355 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 9be6b3bca..93bb21b85 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -101,7 +101,8 @@ bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
return drawSpriteAt(graphics, px, py);
}
-bool ActorSprite::drawSpriteAt(Graphics *graphics, int x, int y) const
+bool ActorSprite::drawSpriteAt(Graphics *const graphics,
+ const int x, const int y) const
{
return CompoundSprite::draw(graphics, x, y);
}
diff --git a/src/actorsprite.h b/src/actorsprite.h
index 14e2558fd..2424983b2 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -84,7 +84,8 @@ public:
virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const;
- virtual bool drawSpriteAt(Graphics *graphics, int x, int y) const;
+ virtual bool drawSpriteAt(Graphics *const graphics,
+ const int x, const int y) const;
virtual void logic();
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 3f8215eda..10d8a941e 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -763,7 +763,7 @@ void ActorSpriteManager::logic()
if ((*it) && (*it)->getType() == Being::PLAYER)
{
- Being *const being = static_cast<Being*>(*it);
+ const Being *const being = static_cast<Being*>(*it);
being->addToCache();
if (beingEquipmentWindow)
beingEquipmentWindow->resetBeing(being);
@@ -1438,7 +1438,7 @@ void ActorSpriteManager::updatePlayerGuild() const
}
}
-void ActorSpriteManager::parseLevels(std::string levels)
+void ActorSpriteManager::parseLevels(std::string levels) const
{
levels += ", ";
size_t f = 0;
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index a3f5b3941..a5ae7e6d8 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -222,7 +222,7 @@ class ActorSpriteManager: public ConfigListener
void updatePlayerGuild() const;
- void parseLevels(std::string levels);
+ void parseLevels(std::string levels) const;
bool pickUpAll(const int x1, const int y1, const int x2, const int y2,
const bool serverBuggy = false);
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 341212b27..2446e19dc 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -277,7 +277,7 @@ bool AnimatedSprite::draw(Graphics *graphics, int posX, int posY) const
posY + mFrame->offsetY);
}
-bool AnimatedSprite::setSpriteDirection(SpriteDirection direction)
+bool AnimatedSprite::setSpriteDirection(const SpriteDirection direction)
{
if (mDirection != direction)
{
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index cc7fc122d..394329d18 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -73,7 +73,7 @@ class AnimatedSprite : public Sprite
const Image* getImage() const;
- bool setSpriteDirection(SpriteDirection direction);
+ bool setSpriteDirection(const SpriteDirection direction);
int getNumberOfLayers() const
{ return 1; }
diff --git a/src/being.cpp b/src/being.cpp
index baf9ae651..6eecb9989 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1992,7 +1992,8 @@ void Being::drawSpritesSDL(Graphics* graphics, int posX, int posY) const
}
}
-bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const
+bool Being::drawSpriteAt(Graphics *const graphics,
+ const int x, const int y) const
{
bool res = true;
diff --git a/src/being.h b/src/being.h
index 019c9eec8..4e78f7eb9 100644
--- a/src/being.h
+++ b/src/being.h
@@ -668,7 +668,8 @@ class Being : public ActorSprite, public ConfigListener
bool draw(Graphics *graphics, int offsetX, int offsetY) const;
- bool drawSpriteAt(Graphics *graphics, int x, int y) const;
+ bool drawSpriteAt(Graphics *const graphics,
+ const int x, const int y) const;
void setMoveTime()
{ mMoveTime = cur_time; }
diff --git a/src/client.cpp b/src/client.cpp
index c16d26aa6..468f06f10 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -568,7 +568,7 @@ void Client::gameInit()
sound.setSfxVolume(config.getIntValue("sfxVolume"));
sound.setMusicVolume(config.getIntValue("musicVolume"));
}
- catch (const char *err)
+ catch (const char *const err)
{
mState = STATE_ERROR;
errorMessage = err;
@@ -2013,25 +2013,6 @@ bool Client::copyFile(const std::string &configPath,
return false;
}
-bool Client::createConfig(std::string &configPath)
-{
- std::string oldHomeDir;
-#ifdef __APPLE__
- // Use Application Directory instead of .mana
- oldHomeDir = std::string(PHYSFS_getUserDir()) +
- "/Library/Application Support/" +
- branding.getValue("appName", "ManaPlus");
-#else
- oldHomeDir = std::string(PHYSFS_getUserDir()) +
- "/." + branding.getValue("appShort", "mana");
-#endif
-
- oldHomeDir += "/config.xml";
-
- logger->log("Restore config from: " + configPath);
- return copyFile(configPath, oldHomeDir);
-}
-
void Client::storeSafeParameters() const
{
bool tmpHwaccel;
@@ -2342,7 +2323,7 @@ bool Client::checkPackets(const int type)
return true;
PacketLimit &limit = instance()->mPacketLimits[type];
- int timeLimit = limit.timeLimit;
+ const int timeLimit = limit.timeLimit;
if (!timeLimit)
return true;
@@ -2384,7 +2365,7 @@ bool Client::limitPackets(const int type)
if (!serverConfig.getValueBool("enableBuggyServers", true))
return true;
- int timeLimit = instance()->mPacketLimits[type].timeLimit;
+ const int timeLimit = instance()->mPacketLimits[type].timeLimit;
if (!timeLimit)
return true;
diff --git a/src/client.h b/src/client.h
index e311cdecb..3153ee821 100644
--- a/src/client.h
+++ b/src/client.h
@@ -332,8 +332,6 @@ private:
bool copyFile(const std::string &configPath,
const std::string &oldConfigPath) const;
- bool createConfig(std::string &configPath);
-
void accountLogin(LoginData *const data) const;
void storeSafeParameters() const;
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index ecb7d8c6e..f22e927f0 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -207,7 +207,7 @@ const Image *CompoundSprite::getImage() const
return mImage;
}
-bool CompoundSprite::setSpriteDirection(SpriteDirection direction)
+bool CompoundSprite::setSpriteDirection(const SpriteDirection direction)
{
bool ret = false;
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 893dfcbd8..928a2a08b 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -74,7 +74,7 @@ public:
virtual const Image *getImage() const;
- virtual bool setSpriteDirection(SpriteDirection direction);
+ virtual bool setSpriteDirection(const SpriteDirection direction);
int getNumberOfLayers() const;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index a22ff6a28..829d45d14 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -69,7 +69,7 @@ static const int SLOTS_PER_ROW = 5;
class CharDeleteConfirm : public ConfirmDialog
{
public:
- CharDeleteConfirm(CharSelectDialog *m, int index):
+ CharDeleteConfirm(CharSelectDialog *const m, const int index) :
ConfirmDialog(_("Confirm Character Delete"),
_("Are you sure you want to delete this character?"),
false, false, m),
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index e05cee111..a75b8d810 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -850,7 +850,7 @@ int ShopWindow::sumAmount(const Item *const shopItem)
return sum;
}
-bool ShopWindow::isShopEmpty()
+bool ShopWindow::isShopEmpty() const
{
if (!mBuyShopItems || !mSellShopItems)
return true;
diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h
index 58725afcf..874353873 100644
--- a/src/gui/shopwindow.h
+++ b/src/gui/shopwindow.h
@@ -136,7 +136,7 @@ class ShopWindow : public Window, public gcn::ActionListener,
bool checkFloodCounter(int &counterTime) const;
- bool isShopEmpty();
+ bool isShopEmpty() const;
private:
void startTrade();
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index eb0dc5549..2db0efb85 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -581,7 +581,7 @@ private:
class SocialNavigationTab : public SocialTab
{
public:
- SocialNavigationTab(bool showBackground) :
+ SocialNavigationTab(const bool showBackground) :
mBeings(new BeingsListModal())
{
mList = new AvatarListBox(mBeings);
@@ -916,7 +916,7 @@ protected:
class SocialAttackTab : public SocialTab
{
public:
- SocialAttackTab(bool showBackground) :
+ SocialAttackTab(const bool showBackground) :
mBeings(new BeingsListModal())
{
mList = new AvatarListBox(mBeings);
@@ -971,7 +971,7 @@ private:
class SocialPickupTab : public SocialTab
{
public:
- SocialPickupTab(bool showBackground) :
+ SocialPickupTab(const bool showBackground) :
mBeings(new BeingsListModal())
{
mList = new AvatarListBox(mBeings);
@@ -1068,7 +1068,7 @@ public:
if (!actorSpriteManager)
return;
- std::vector<Avatar*> *avatars = mBeings->getMembers();
+ std::vector<Avatar*> *const avatars = mBeings->getMembers();
if (!avatars)
return;
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index b33233d73..b54b3d945 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -45,7 +45,7 @@ int AvatarListBox::instances = 0;
Image *AvatarListBox::onlineIcon = nullptr;
Image *AvatarListBox::offlineIcon = nullptr;
-AvatarListBox::AvatarListBox(AvatarListModel *model):
+AvatarListBox::AvatarListBox(AvatarListModel *const model) :
ListBox(model),
mShowGender(config.getBoolValue("showgender")),
mShowLevel(config.getBoolValue("showlevel")),
@@ -344,8 +344,8 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
const Avatar *const avatar = model->getAvatarAt(selected);
if (avatar)
{
- Being *const being = actorSpriteManager->findBeingByName(
- avatar->getName(), Being::PLAYER);
+ const Being *const being = actorSpriteManager
+ ->findBeingByName(avatar->getName(), Being::PLAYER);
if (being)
viewport->showPopup(being);
else
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
index b2b135a9c..0148a24d0 100644
--- a/src/gui/widgets/avatarlistbox.h
+++ b/src/gui/widgets/avatarlistbox.h
@@ -46,7 +46,7 @@ public:
class AvatarListBox : public ListBox, public ConfigListener
{
public:
- AvatarListBox(AvatarListModel *model);
+ AvatarListBox(AvatarListModel *const model);
~AvatarListBox();
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 2f475db88..3f253932b 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -196,7 +196,7 @@ Button::~Button()
if (mInstances == 0 && Theme::instance())
{
- Theme *const theme = Theme::instance();
+ const Theme *const theme = Theme::instance();
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unloadRect(button[mode]);
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index bb18ff2dd..0aab1f165 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -139,7 +139,7 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
- float alpha = std::max(Client::getGuiAlpha(),
+ const float alpha = std::max(Client::getGuiAlpha(),
Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index d530a1594..04c6de606 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -391,7 +391,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
else if (itemId < SKILL_MIN_ID && spellManager)
{
mItemPopup->setVisible(false);
- TextCommand *const spell = spellManager->getSpellByItem(itemId);
+ const TextCommand *const spell = spellManager->getSpellByItem(itemId);
if (spell && viewport)
{
mSpellPopup->setItem(spell);
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 1597cdc33..bfb190e41 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -226,7 +226,7 @@ LayoutCell &LayoutArray::place(gcn::Widget *const widget, const int x,
void LayoutArray::align(int &pos, int &size, const int dim,
LayoutCell const &cell, const int *const sizes,
- int sizeCount) const
+ const int sizeCount) const
{
int size_max = sizes[0];
int cnt = cell.mExtent[dim];
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index a30cff1e1..71de85320 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -130,7 +130,7 @@ class LayoutArray
* Gets the position and size of a widget along a given axis
*/
void align(int &pos, int &size, const int dim, LayoutCell const &cell,
- const int *const sizes, int sizeCount) const;
+ const int *const sizes, const int sizeCount) const;
/**
* Ensures the private vectors are large enough.
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 2a4065ac2..8c0e938ba 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -138,7 +138,7 @@ void Popup::setContentSize(int width, int height)
mRedraw = true;
}
-void Popup::setLocationRelativeTo(gcn::Widget *const widget)
+void Popup::setLocationRelativeTo(const gcn::Widget *const widget)
{
if (!widget)
return;
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 61aac98c1..2442aa220 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -83,7 +83,7 @@ class Popup : public Container, public gcn::MouseListener,
/**
* Sets the location relative to the given widget.
*/
- void setLocationRelativeTo(gcn::Widget *const widget);
+ void setLocationRelativeTo(const gcn::Widget *const widget);
void mouseMoved(gcn::MouseEvent &event);
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index b752eb245..28532927b 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -91,7 +91,7 @@ ScrollArea::~ScrollArea()
delete getContent();
instances--;
- Theme *const theme = Theme::instance();
+ const Theme *const theme = Theme::instance();
if (theme)
{
theme->unloadRect(background);
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index a835bf51a..f569fddb5 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -125,7 +125,7 @@ void SetupItem::load()
}
}
-void SetupItem::save()
+void SetupItem::save() const
{
Configuration *const cfg = getConfig();
cfg->setValue(mKeyName, mValue);
@@ -629,7 +629,8 @@ SetupItemSlider::SetupItemSlider(std::string text, std::string description,
}
SetupItemSlider::SetupItemSlider(std::string text, std::string description,
- std::string keyName, SetupTabScroll *parent,
+ std::string keyName,
+ SetupTabScroll *const parent,
std::string eventName,
const double min, const double max,
std::string def, const int width,
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 32304ac22..f1ec4d23b 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -72,7 +72,7 @@ class SetupItem : public gcn::ActionListener
void load();
- void save();
+ void save() const;
virtual void fromWidget() = 0;
@@ -288,7 +288,7 @@ class SetupItemSlider : public SetupItem
const bool mainConfig = true);
SetupItemSlider(std::string text, std::string description,
- std::string keyName, SetupTabScroll *parent,
+ std::string keyName, SetupTabScroll *const parent,
std::string eventName,
const double min, const double max,
std::string def, const int width = 150,
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c5eac9769..da6cb31f6 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -62,7 +62,7 @@ Slider::~Slider()
mInstances--;
if (mInstances == 0 && Theme::instance())
{
- Theme *const theme = Theme::instance();
+ const Theme *const theme = Theme::instance();
for (int mode = 0; mode < 2; mode ++)
theme->unloadRect(buttons[mode]);
}
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index ec79ccb93..2a3799ca8 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -279,7 +279,7 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event)
(mNumber * SPELL_SHORTCUT_ITEMS) + index);
mSpellPopup->setVisible(false);
- TextCommand *const spell = spellManager->getSpell(itemId);
+ const TextCommand *const spell = spellManager->getSpell(itemId);
if (spell && !spell->isEmpty())
{
mSpellPopup->setItem(spell);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index bf37a643e..eb470cc02 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -78,7 +78,7 @@ Tab::~Tab()
mInstances--;
if (mInstances == 0 && Theme::instance())
{
- Theme *const theme = Theme::instance();
+ const Theme *const theme = Theme::instance();
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unloadRect(tabImg[mode]);
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 0e25c1f18..5a81f73be 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -228,7 +228,7 @@ void WindowMenu::addButton(const char *const text,
const std::string &description,
int &x, int &h, const int key, const bool visible)
{
- Button *btn = new Button(gettext(text), text, this);
+ Button *const btn = new Button(gettext(text), text, this);
btn->setPosition(x, 0);
btn->setDescription(description);
btn->setTag(key);
diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp
index e05736870..285cbbe81 100644
--- a/src/guichan/cliprectangle.cpp
+++ b/src/guichan/cliprectangle.cpp
@@ -62,8 +62,9 @@ namespace gcn
height = 0;
}
- ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0,
- int xOffset0, int yOffset0) :
+ ClipRectangle::ClipRectangle(const int x0, const int y0,
+ const int width0, const int height0,
+ const int xOffset0, const int yOffset0) :
xOffset(xOffset0),
yOffset(yOffset0)
{
diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp
index f58e7b58e..7cc3b887a 100644
--- a/src/guichan/color.cpp
+++ b/src/guichan/color.cpp
@@ -60,7 +60,7 @@ namespace gcn
{
}
- Color::Color(int color) :
+ Color::Color(const int color) :
r((color >> 16) & 0xFF),
g((color >> 8) & 0xFF),
b(color & 0xFF),
@@ -68,7 +68,7 @@ namespace gcn
{
}
- Color::Color(int ar, int ag, int ab, int aa) :
+ Color::Color(const int ar, const int ag, const int ab, const int aa) :
r(ar),
g(ag),
b(ab),
@@ -104,7 +104,7 @@ namespace gcn
return result;
}
- Color Color::operator*(float value) const
+ Color Color::operator*(const float value) const
{
Color result(static_cast<int>(r * value),
static_cast<int>(g * value),
diff --git a/src/guichan/event.cpp b/src/guichan/event.cpp
index 5983af7e7..24c913880 100644
--- a/src/guichan/event.cpp
+++ b/src/guichan/event.cpp
@@ -52,8 +52,8 @@
namespace gcn
{
- Event::Event(Widget* source)
- :mSource(source)
+ Event::Event(Widget *const source) :
+ mSource(source)
{
}
diff --git a/src/guichan/exception.cpp b/src/guichan/exception.cpp
index 4ea86896e..75eaac2e9 100644
--- a/src/guichan/exception.cpp
+++ b/src/guichan/exception.cpp
@@ -73,7 +73,7 @@ namespace gcn
Exception::Exception(const std::string& message,
const std::string& function,
const std::string& filename,
- unsigned int line)
+ const unsigned int line)
: mFunction(function),
mMessage(message),
mFilename(filename),
diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp
index ea44ac680..886153549 100644
--- a/src/guichan/include/guichan/cliprectangle.hpp
+++ b/src/guichan/include/guichan/cliprectangle.hpp
@@ -79,12 +79,12 @@ namespace gcn
* calculating the actual screen coordinate from
* the relative screen coordinate.
*/
- ClipRectangle(int x0,
- int y0,
- int width0,
- int height0,
- int xOffset0,
- int yOffset0);
+ ClipRectangle(const int x0,
+ const int y0,
+ const int width0,
+ const int height0,
+ const int xOffset0,
+ const int yOffset0);
/**
* Copy constructor. Copies x, y, width and height
diff --git a/src/guichan/include/guichan/color.hpp b/src/guichan/include/guichan/color.hpp
index 6f0cfc1ff..795cdc12d 100644
--- a/src/guichan/include/guichan/color.hpp
+++ b/src/guichan/include/guichan/color.hpp
@@ -75,7 +75,7 @@ namespace gcn
*
* @param color The color to initialise the object with.
*/
- Color(int color);
+ Color(const int color);
/**
* Constructor. The default alpha value is 255.
@@ -86,7 +86,7 @@ namespace gcn
* @param a Alpha, used for transparency. A value of 0 means
* totaly transparent, 255 is totaly opaque.
*/
- Color(int r, int g, int b, int a = 255);
+ Color(const int r, const int g, const int b, const int a = 255);
/**
* Adds the RGB values of two colors together. The values will be
@@ -121,7 +121,7 @@ namespace gcn
* the add and subtract operations, be multiplied as
* well.
*/
- Color operator*(float value) const;
+ Color operator*(const float value) const;
/**
* Compares two colors.
diff --git a/src/guichan/include/guichan/event.hpp b/src/guichan/include/guichan/event.hpp
index 3a4ad26e2..1b52df8ed 100644
--- a/src/guichan/include/guichan/event.hpp
+++ b/src/guichan/include/guichan/event.hpp
@@ -67,7 +67,7 @@ namespace gcn
*
* @param source The source widget of the event.
*/
- Event(Widget* source);
+ Event(Widget *const source);
/**
* Destructor.
diff --git a/src/guichan/include/guichan/exception.hpp b/src/guichan/include/guichan/exception.hpp
index 1b591f2d6..e2dd958be 100644
--- a/src/guichan/include/guichan/exception.hpp
+++ b/src/guichan/include/guichan/exception.hpp
@@ -115,7 +115,7 @@ namespace gcn
Exception(const std::string& message,
const std::string& function,
const std::string& filename,
- unsigned int line);
+ const unsigned int line);
/**
* Gets the function name where the exception occured.
diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp
index 1de9d1832..296f14cd2 100644
--- a/src/guichan/include/guichan/inputevent.hpp
+++ b/src/guichan/include/guichan/inputevent.hpp
@@ -69,11 +69,11 @@ namespace gcn
* @param isAltPressed True if alt is pressed, false otherwise.
* @param isMetaPressed True if meta is pressed, false otherwise.
*/
- InputEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed);
+ InputEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed);
/**
* Checks if shift is pressed.
diff --git a/src/guichan/include/guichan/key.hpp b/src/guichan/include/guichan/key.hpp
index b852638b3..9b31d7c6b 100644
--- a/src/guichan/include/guichan/key.hpp
+++ b/src/guichan/include/guichan/key.hpp
@@ -68,7 +68,7 @@ namespace gcn
*
* @param value The ascii or enum value for the key.
*/
- Key(int value = 0);
+ Key(const int value = 0);
/**
* Checks if a key is a character.
diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp
index e841f4a62..5cf1d26c7 100644
--- a/src/guichan/include/guichan/keyevent.hpp
+++ b/src/guichan/include/guichan/keyevent.hpp
@@ -81,13 +81,13 @@ namespace gcn
* false otherwise.
* @param key The key of the event.
*/
- KeyEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed,
- unsigned int type,
- bool numericPad,
+ KeyEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed,
+ const unsigned int type,
+ const bool numericPad,
const Key& key);
/**
diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp
index 5b012dc20..ba2200d8d 100644
--- a/src/guichan/include/guichan/mouseevent.hpp
+++ b/src/guichan/include/guichan/mouseevent.hpp
@@ -78,16 +78,16 @@ namespace gcn
* @param clickCount The number of clicks generated with the same button.
* It's set to zero if another button is used.
*/
- MouseEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed,
- unsigned int type,
- unsigned int button,
- int x,
- int y,
- int clickCount);
+ MouseEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed,
+ const unsigned int type,
+ const unsigned int button,
+ const int x,
+ const int y,
+ const int clickCount);
/**
* Gets the button of the mouse event.
diff --git a/src/guichan/include/guichan/mouseinput.hpp b/src/guichan/include/guichan/mouseinput.hpp
index 35952fde5..99ed1fad8 100644
--- a/src/guichan/include/guichan/mouseinput.hpp
+++ b/src/guichan/include/guichan/mouseinput.hpp
@@ -84,11 +84,11 @@ namespace gcn
* @param timeStamp The timestamp of the mouse input. Used to
* check for double clicks.
*/
- MouseInput(unsigned int button,
- unsigned int type,
- int x,
- int y,
- int timeStamp);
+ MouseInput(const unsigned int button,
+ const unsigned int type,
+ const int x,
+ const int y,
+ const int timeStamp);
/**
* Sets the type of the mouse input.
diff --git a/src/guichan/include/guichan/rectangle.hpp b/src/guichan/include/guichan/rectangle.hpp
index 013fe9b69..a4de652a4 100644
--- a/src/guichan/include/guichan/rectangle.hpp
+++ b/src/guichan/include/guichan/rectangle.hpp
@@ -75,7 +75,7 @@ namespace gcn
* @param height The height of the rectangle.
* @since 0.1.0
*/
- Rectangle(int x, int y, int width, int height);
+ Rectangle(const int x, const int y, const int width, const int height);
/**
* Sets the dimension of a rectangle.
diff --git a/src/guichan/include/guichan/sdl/sdlimage.hpp b/src/guichan/include/guichan/sdl/sdlimage.hpp
index cd4285346..52fb9976b 100644
--- a/src/guichan/include/guichan/sdl/sdlimage.hpp
+++ b/src/guichan/include/guichan/sdl/sdlimage.hpp
@@ -70,7 +70,7 @@ namespace gcn
* @param surface the surface from which to load.
* @param autoFree true if the surface should automatically be deleted.
*/
- SDLImage(SDL_Surface* surface, bool autoFree);
+ SDLImage(SDL_Surface *const surface, const bool autoFree);
/**
* Destructor.
diff --git a/src/guichan/include/guichan/selectionevent.hpp b/src/guichan/include/guichan/selectionevent.hpp
index 331ebe92d..53efc93f5 100644
--- a/src/guichan/include/guichan/selectionevent.hpp
+++ b/src/guichan/include/guichan/selectionevent.hpp
@@ -67,7 +67,7 @@ namespace gcn
*
* @param source source The widget of the selection event.
*/
- SelectionEvent(Widget* source);
+ SelectionEvent(Widget *const source);
/**
* Destructor.
diff --git a/src/guichan/include/guichan/widgets/dropdown.hpp b/src/guichan/include/guichan/widgets/dropdown.hpp
index 7663a265f..6c6ffb4c5 100644
--- a/src/guichan/include/guichan/widgets/dropdown.hpp
+++ b/src/guichan/include/guichan/widgets/dropdown.hpp
@@ -95,9 +95,9 @@ namespace gcn
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
- DropDown(ListModel *listModel = nullptr,
- ScrollArea *scrollArea = nullptr,
- ListBox *listBox = nullptr);
+ DropDown(ListModel *const listModel = nullptr,
+ ScrollArea *const scrollArea = nullptr,
+ ListBox *const listBox = nullptr);
/**
* Destructor.
diff --git a/src/guichan/include/guichan/widgets/icon.hpp b/src/guichan/include/guichan/widgets/icon.hpp
index e25a7a770..ed010c31a 100644
--- a/src/guichan/include/guichan/widgets/icon.hpp
+++ b/src/guichan/include/guichan/widgets/icon.hpp
@@ -74,7 +74,7 @@ namespace gcn
*
* @param image The image to display.
*/
- Icon(const Image* image);
+ Icon(const Image *const image);
/**
* Descructor.
diff --git a/src/guichan/include/guichan/widgets/scrollarea.hpp b/src/guichan/include/guichan/widgets/scrollarea.hpp
index 4937bcbea..84649d530 100644
--- a/src/guichan/include/guichan/widgets/scrollarea.hpp
+++ b/src/guichan/include/guichan/widgets/scrollarea.hpp
@@ -90,7 +90,7 @@ namespace gcn
*
* @param content The content of the scroll area.
*/
- ScrollArea(Widget *content);
+ ScrollArea(Widget *const content);
/**
* Constructor.
diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp
index a22c36844..bf2ce5937 100644
--- a/src/guichan/include/guichan/widgets/slider.hpp
+++ b/src/guichan/include/guichan/widgets/slider.hpp
@@ -81,7 +81,7 @@ namespace gcn
*
* @param scaleEnd The end value of the slider scale.
*/
- Slider(double scaleEnd = 1.0);
+ Slider(const double scaleEnd = 1.0);
/**
* Constructor.
@@ -89,7 +89,7 @@ namespace gcn
* @param scaleStart The start value of the slider scale.
* @param scaleEnd The end value of the slider scale.
*/
- Slider(double scaleStart, double scaleEnd);
+ Slider(const double scaleStart, const double scaleEnd);
/**
* Destructor.
diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp
index 53ae91442..4b0bec69d 100644
--- a/src/guichan/inputevent.cpp
+++ b/src/guichan/inputevent.cpp
@@ -52,11 +52,11 @@
namespace gcn
{
- InputEvent::InputEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed)
+ InputEvent::InputEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed)
:Event(source),
mShiftPressed(shiftPressed),
mControlPressed(controlPressed),
diff --git a/src/guichan/key.cpp b/src/guichan/key.cpp
index d2913837e..4c6bfde80 100644
--- a/src/guichan/key.cpp
+++ b/src/guichan/key.cpp
@@ -52,7 +52,7 @@
namespace gcn
{
- Key::Key(int value) :
+ Key::Key(const int value) :
mValue(value)
{
}
diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp
index 2b7064dc7..003b288dc 100644
--- a/src/guichan/keyevent.cpp
+++ b/src/guichan/keyevent.cpp
@@ -52,22 +52,22 @@
namespace gcn
{
- KeyEvent::KeyEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed,
- unsigned int type,
- bool numericPad,
- const Key& key)
- :InputEvent(source,
- shiftPressed,
- controlPressed,
- altPressed,
- metaPressed),
- mType(type),
- mIsNumericPad(numericPad),
- mKey(key)
+ KeyEvent::KeyEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed,
+ const unsigned int type,
+ const bool numericPad,
+ const Key& key) :
+ InputEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mType(type),
+ mIsNumericPad(numericPad),
+ mKey(key)
{
}
diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp
index 2e5c757c5..7f386b0a6 100644
--- a/src/guichan/mouseevent.cpp
+++ b/src/guichan/mouseevent.cpp
@@ -52,28 +52,27 @@
namespace gcn
{
- MouseEvent::MouseEvent(Widget* source,
- bool shiftPressed,
- bool controlPressed,
- bool altPressed,
- bool metaPressed,
- unsigned int type,
- unsigned int button,
- int x,
- int y,
- int clickCount)
- :InputEvent(source,
- shiftPressed,
- controlPressed,
- altPressed,
- metaPressed),
- mType(type),
- mButton(button),
- mX(x),
- mY(y),
- mClickCount(clickCount)
+ MouseEvent::MouseEvent(Widget *const source,
+ const bool shiftPressed,
+ const bool controlPressed,
+ const bool altPressed,
+ const bool metaPressed,
+ const unsigned int type,
+ const unsigned int button,
+ const int x,
+ const int y,
+ const int clickCount) :
+ InputEvent(source,
+ shiftPressed,
+ controlPressed,
+ altPressed,
+ metaPressed),
+ mType(type),
+ mButton(button),
+ mX(x),
+ mY(y),
+ mClickCount(clickCount)
{
-
}
unsigned int MouseEvent::getButton() const
diff --git a/src/guichan/mouseinput.cpp b/src/guichan/mouseinput.cpp
index 791c8d7e9..f3b0fe511 100644
--- a/src/guichan/mouseinput.cpp
+++ b/src/guichan/mouseinput.cpp
@@ -52,16 +52,16 @@
namespace gcn
{
- MouseInput::MouseInput(unsigned int button,
- unsigned int type,
- int x,
- int y,
- int timeStamp)
- : mType(type),
- mButton(button),
- mTimeStamp(timeStamp),
- mX(x),
- mY(y)
+ MouseInput::MouseInput(const unsigned int button,
+ const unsigned int type,
+ const int x,
+ const int y,
+ const int timeStamp) :
+ mType(type),
+ mButton(button),
+ mTimeStamp(timeStamp),
+ mX(x),
+ mY(y)
{
}
diff --git a/src/guichan/rectangle.cpp b/src/guichan/rectangle.cpp
index 0a6ed2908..eb87bff50 100644
--- a/src/guichan/rectangle.cpp
+++ b/src/guichan/rectangle.cpp
@@ -60,8 +60,9 @@ namespace gcn
{
}
- Rectangle::Rectangle(int x_, int y_, int width_, int height_)
- : x(x_),
+ Rectangle::Rectangle(const int x_, const int y_,
+ const int width_, const int height_) :
+ x(x_),
y(y_),
width(width_),
height(height_)
diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp
index 5bb7041ff..3c0325280 100644
--- a/src/guichan/sdl/sdlimage.cpp
+++ b/src/guichan/sdl/sdlimage.cpp
@@ -55,7 +55,7 @@
namespace gcn
{
- SDLImage::SDLImage(SDL_Surface* surface, bool autoFree) :
+ SDLImage::SDLImage(SDL_Surface *const surface, const bool autoFree) :
mSurface(surface),
mAutoFree(autoFree)
{
diff --git a/src/guichan/selectionevent.cpp b/src/guichan/selectionevent.cpp
index 8c8a3f28f..59ba9e641 100644
--- a/src/guichan/selectionevent.cpp
+++ b/src/guichan/selectionevent.cpp
@@ -52,8 +52,8 @@
namespace gcn
{
- SelectionEvent::SelectionEvent(Widget* source)
- :Event(source)
+ SelectionEvent::SelectionEvent(Widget *const source) :
+ Event(source)
{
}
diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp
index 0cd979adc..c446b869d 100644
--- a/src/guichan/widgets/dropdown.cpp
+++ b/src/guichan/widgets/dropdown.cpp
@@ -57,9 +57,9 @@
namespace gcn
{
- DropDown::DropDown(ListModel *listModel,
- ScrollArea *scrollArea,
- ListBox *listBox)
+ DropDown::DropDown(ListModel *const listModel,
+ ScrollArea *const scrollArea,
+ ListBox *const listBox)
{
setWidth(100);
setFocusable(true);
diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp
index 26139716d..b0d277fbd 100644
--- a/src/guichan/widgets/icon.cpp
+++ b/src/guichan/widgets/icon.cpp
@@ -71,7 +71,7 @@ namespace gcn
mImage->getHeight());
}
- Icon::Icon(const Image* image) :
+ Icon::Icon(const Image *const image) :
mImage(image),
mInternalImage(false)
{
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp
index 1251bc665..f8bd11334 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/guichan/widgets/scrollarea.cpp
@@ -80,7 +80,7 @@ namespace gcn
addMouseListener(this);
}
- ScrollArea::ScrollArea(Widget *content) :
+ ScrollArea::ScrollArea(Widget *const content) :
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp
index ed14f525a..a9e9bed31 100644
--- a/src/guichan/widgets/slider.cpp
+++ b/src/guichan/widgets/slider.cpp
@@ -56,7 +56,7 @@
namespace gcn
{
- Slider::Slider(double scaleEnd) :
+ Slider::Slider(const double scaleEnd) :
mDragged(false),
mScaleStart(0),
mScaleEnd(scaleEnd)
@@ -72,7 +72,7 @@ namespace gcn
addKeyListener(this);
}
- Slider::Slider(double scaleStart, double scaleEnd) :
+ Slider::Slider(const double scaleStart, const double scaleEnd) :
mDragged(false),
mScaleStart(scaleStart),
mScaleEnd(scaleEnd)
diff --git a/src/imagesprite.h b/src/imagesprite.h
index debee945e..f7229eed4 100644
--- a/src/imagesprite.h
+++ b/src/imagesprite.h
@@ -55,7 +55,7 @@ public:
const Image* getImage() const
{ return mImage; }
- virtual bool setSpriteDirection(SpriteDirection direction A_UNUSED)
+ virtual bool setSpriteDirection(const SpriteDirection direction A_UNUSED)
{ return false; }
int getNumberOfLayers() const
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 7f62862be..969867a83 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -503,7 +503,7 @@ bool InputManager::handleEvent(const SDL_Event &event)
}
if (gui)
{
- bool res = gui->handleInput();
+ const bool res = gui->handleInput();
if (res && event.type == SDL_KEYDOWN)
return true;
}
@@ -689,7 +689,7 @@ int InputManager::getKeyIndex(const int value, const int grp,
return Input::KEY_NO_VALUE;
}
-int InputManager::getActionByKey(const SDL_Event &event)
+int InputManager::getActionByKey(const SDL_Event &event) const
{
// for now support only keyboard events
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
diff --git a/src/inputmanager.h b/src/inputmanager.h
index 394819816..213781bed 100644
--- a/src/inputmanager.h
+++ b/src/inputmanager.h
@@ -162,7 +162,7 @@ class InputManager
void updateConditionMask();
- int getActionByKey(const SDL_Event &event);
+ int getActionByKey(const SDL_Event &event) const;
protected:
Setup_Input *mSetupInput; /**< Reference to setup window */
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 3a001ca31..5a5c87221 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -390,7 +390,7 @@ void LocalPlayer::setGMLevel(const int level)
}
-Position LocalPlayer::getNextWalkPosition(unsigned char dir) const
+Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
{
// Compute where the next tile will be set.
int dx = 0, dy = 0;
@@ -1503,7 +1503,7 @@ int LocalPlayer::getAttackRange() const
bool LocalPlayer::withinAttackRange(const Being *const target,
const bool fixDistance,
- const int addRange)
+ const int addRange) const
{
if (!target)
return false;
@@ -2112,7 +2112,7 @@ static const char *debugPathStrings[] =
N_("(b) black & white map view")
};
-std::string LocalPlayer::getDebugPathString()
+std::string LocalPlayer::getDebugPathString() const
{
return gettext(getVarItem(&debugPathStrings[0],
viewport->getDebugPath(), debugPathSize));
@@ -2245,7 +2245,7 @@ static const char *cameraModeStrings[] =
N_("(?) away")
};
-std::string LocalPlayer::getCameraModeString()
+std::string LocalPlayer::getCameraModeString() const
{
return gettext(getVarItem(&cameraModeStrings[0],
viewport->getCameraMode(), cameraModeSize));
@@ -3171,7 +3171,7 @@ void LocalPlayer::moveByDirection(const unsigned char dir)
move(dx, dy);
}
-void LocalPlayer::specialMove(unsigned char direction)
+void LocalPlayer::specialMove(const unsigned char direction)
{
if (direction && (mNavigateX || mNavigateY))
navigateClean();
@@ -3216,7 +3216,7 @@ void LocalPlayer::debugMsg(std::string str) const
debugChatTab->chatLog(str);
}
-void LocalPlayer::magicAttack()
+void LocalPlayer::magicAttack() const
{
if (!chatWindow || !isAlive()
|| !Net::getPlayerHandler()->canUseMagic())
@@ -3744,7 +3744,7 @@ int LocalPlayer::getPathLength(const Being *const being)
}
}
-int LocalPlayer::getAttackRange2()
+int LocalPlayer::getAttackRange2() const
{
int range = getAttackRange();
if (range == 1)
@@ -3823,7 +3823,7 @@ void LocalPlayer::cancelFollow()
}
void LocalPlayer::imitateEmote(const Being *const being,
- const unsigned char action)
+ const unsigned char action) const
{
if (!being)
return;
@@ -3900,7 +3900,7 @@ void LocalPlayer::imitateOutfit(Being *const player, const int sprite) const
if (equipmentSprite)
{
// logger->log("have equipmentSprite");
- Inventory *const inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
diff --git a/src/localplayer.h b/src/localplayer.h
index da8dd02cd..bfa74d660 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -90,7 +90,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
* Compute the next pathnode location when walking using keyboard.
* used by nextTile().
*/
- Position getNextWalkPosition(unsigned char dir) const;
+ Position getNextWalkPosition(const unsigned char dir) const;
/**
* Adds a new tile to the path when walking.
@@ -129,7 +129,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
*/
int getAttackRange() const;
- int getAttackRange2();
+ int getAttackRange2() const;
void attack(Being *const target = nullptr, const bool keep = false,
const bool dontChangeEquipment = false);
@@ -183,7 +183,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
*/
bool withinAttackRange(const Being *const target,
const bool fixDistance = false,
- const int addRange = 0);
+ const int addRange = 0) const;
/**
* Stops the player dead in his tracks
@@ -294,9 +294,9 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void switchGameModifiers();
- void magicAttack();
+ void magicAttack() const;
- void specialMove(unsigned char direction);
+ void specialMove(const unsigned char direction);
void moveByDirection(const unsigned char dir);
@@ -356,7 +356,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void navigateClean();
- void imitateEmote(const Being *const being, const unsigned char emote);
+ void imitateEmote(const Being *const being,
+ const unsigned char emote) const;
void imitateAction(const Being *const being,
const Being::Action action);
@@ -503,7 +504,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
std::string getPickUpTypeString();
- std::string getDebugPathString();
+ std::string getDebugPathString() const;
std::string getMagicAttackString();
@@ -513,7 +514,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
std::string getAwayModeString();
- std::string getCameraModeString();
+ std::string getCameraModeString() const;
std::string getGameModifiersString();
diff --git a/src/logger.cpp b/src/logger.cpp
index df938c5f3..2ccd8398f 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -108,7 +108,7 @@ void Logger::dlog(std::string str)
debugChatTab->chatLog(str, BY_LOGGER);
}
-void Logger::log1(const char *buf)
+void Logger::log1(const char *const buf)
{
// Get the current system time
timeval tv;
@@ -140,7 +140,7 @@ void Logger::log1(const char *buf)
debugChatTab->chatLog(buf, BY_LOGGER);
}
-void Logger::log(const char *log_text, ...)
+void Logger::log(const char *const log_text, ...)
{
unsigned size = 1024;
char* buf = nullptr;
@@ -207,7 +207,7 @@ void Logger::safeError(const std::string &error_text)
// (ConstStr255Param) msg, nullptr, nullptr);
#elif defined(__linux__) || defined(__linux)
std::cerr << "Error: " << error_text << std::endl;
- std::string msg = "xmessage \"" + error_text + "\"";
+ const std::string msg = "xmessage \"" + error_text + "\"";
if (system(msg.c_str()) == -1)
std::cerr << "Error: " << error_text << std::endl;
#else
@@ -234,7 +234,7 @@ void Logger::error(const std::string &error_text)
// (ConstStr255Param) msg, nullptr, nullptr);
#elif defined(__linux__) || defined(_linux)
std::cerr << "Error: " << error_text << std::endl;
- std::string msg = "xmessage \"Error happend. "
+ const std::string msg = "xmessage \"Error happend. "
"Please see log file for more information.\"";
if (system(msg.c_str()) == -1)
std::cerr << "Error: " << error_text << std::endl;
diff --git a/src/logger.h b/src/logger.h
index e05d1c2d6..32b7d32c8 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -58,19 +58,19 @@ class Logger
/**
* Sets whether the log should be written to standard output.
*/
- void setLogToStandardOut(bool value)
+ void setLogToStandardOut(const bool value)
{ mLogToStandardOut = value; }
/**
* Enables logging to chat window
*/
- void setChatWindow(ChatWindow *window)
+ void setChatWindow(ChatWindow *const window)
{ mChatWindow = window; }
/**
* Enters a message in the log. The message will be timestamped.
*/
- void log(const char *log_text, ...)
+ void log(const char *const log_text, ...)
#ifdef __GNUC__
__attribute__((__format__(gnu_printf, 2, 3)))
#endif
@@ -79,7 +79,7 @@ class Logger
/**
* Enters a message in the log. The message will be timestamped.
*/
- void log1(const char *log_text);
+ void log1(const char *const log_text);
/**
* Enters a message in the log. The message will be timestamped.
@@ -91,7 +91,7 @@ class Logger
*/
void dlog(std::string str);
- void setDebugLog(bool n)
+ void setDebugLog(const bool n)
{ mDebugLog = n; }
/**
diff --git a/src/main.cpp b/src/main.cpp
index d3683be1e..9c10fad04 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -90,9 +90,10 @@ static void printVersion()
std::cout << strprintf("ManaPlus client %s", FULL_VERSION) << std::endl;
}
-static void parseOptions(int argc, char *argv[], Client::Options &options)
+static void parseOptions(const int argc, char *const argv[],
+ Client::Options &options)
{
- const char *optstring = "hvud:U:P:Dc:p:l:L:C:s:t:T";
+ const char *const optstring = "hvud:U:P:Dc:p:l:L:C:s:t:T";
const struct option long_options[] =
{
@@ -122,7 +123,8 @@ static void parseOptions(int argc, char *argv[], Client::Options &options)
while (optind < argc)
{
- int result = getopt_long(argc, argv, optstring, long_options, nullptr);
+ const int result = getopt_long(argc, argv,
+ optstring, long_options, nullptr);
if (result == -1)
break;
diff --git a/src/map.cpp b/src/map.cpp
index c1905e3bb..88396b4aa 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -58,7 +58,7 @@ struct Location
/**
* Constructor.
*/
- Location(int px, int py, MetaTile *ptile):
+ Location(const int px, const int py, MetaTile *const ptile):
x(px), y(py), tile(ptile)
{}
@@ -77,7 +77,7 @@ struct Location
class ActorFunctuator
{
public:
- bool operator()(const Actor *a, const Actor *b) const
+ bool operator()(const Actor *const a, const Actor *const b) const
{
if (!a || !b)
return false;
@@ -85,7 +85,7 @@ class ActorFunctuator
}
} actorCompare;
-TileAnimation::TileAnimation(Animation *ani):
+TileAnimation::TileAnimation(Animation *const ani):
mAnimation(new SimpleAnimation(ani)),
mLastImage(nullptr)
{
@@ -97,7 +97,7 @@ TileAnimation::~TileAnimation()
mAnimation = nullptr;
}
-bool TileAnimation::update(int ticks)
+bool TileAnimation::update(const int ticks)
{
if (!mAnimation)
return false;
@@ -107,7 +107,7 @@ bool TileAnimation::update(int ticks)
return false;
// exchange images
- Image *img = mAnimation->getCurrentImage();
+ Image *const img = mAnimation->getCurrentImage();
if (img != mLastImage)
{
for (TilePairVectorCIter i = mAffected.begin(),
@@ -121,7 +121,8 @@ bool TileAnimation::update(int ticks)
return true;
}
-Map::Map(int width, int height, int tileWidth, int tileHeight):
+Map::Map(const int width, const int height,
+ const int tileWidth, const int tileHeight) :
mWidth(width), mHeight(height),
mTileWidth(tileWidth), mTileHeight(tileHeight),
mMaxTileHeight(height),
@@ -226,7 +227,7 @@ void Map::optionChanged(const std::string &value)
void Map::initializeAmbientLayers()
{
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
// search for "foreground*" or "overlay*" (old term) in map properties
for (int i = 0; /* terminated by a break */; i++)
@@ -239,7 +240,7 @@ void Map::initializeAmbientLayers()
else
break; // the FOR loop
- Image *img = resman->getImage(getProperty(name + "image"));
+ Image *const img = resman->getImage(getProperty(name + "image"));
const float speedX = getFloatProperty(name + "scrollX");
const float speedY = getFloatProperty(name + "scrollY");
const float parallax = getFloatProperty(name + "parallax");
@@ -263,7 +264,7 @@ void Map::initializeAmbientLayers()
{
const std::string name = "background" + toString(i);
- Image *img = resman->getImage(getProperty(name + "image"));
+ Image *const img = resman->getImage(getProperty(name + "image"));
const float speedX = getFloatProperty(name + "scrollX");
const float speedY = getFloatProperty(name + "scrollY");
const float parallax = getFloatProperty(name + "parallax");
@@ -280,7 +281,7 @@ void Map::initializeAmbientLayers()
}
}
-void Map::addLayer(MapLayer *layer)
+void Map::addLayer(MapLayer *const layer)
{
if (layer)
{
@@ -290,7 +291,7 @@ void Map::addLayer(MapLayer *layer)
}
}
-void Map::addTileset(Tileset *tileset)
+void Map::addTileset(Tileset *const tileset)
{
if (!tileset)
return;
@@ -301,7 +302,7 @@ void Map::addTileset(Tileset *tileset)
mMaxTileHeight = tileset->getHeight();
}
-void Map::update(int ticks)
+void Map::update(const int ticks)
{
// Update animated tiles
for (TileAnimationMapCIter iAni = mTileAnimations.begin(),
@@ -439,10 +440,10 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
// Draws beings with a lower opacity to make them visible
// even when covered by a wall or some other elements...
ActorsCIter ai = mActors.begin();
- ActorsCIter ai_end = mActors.end();
+ const ActorsCIter ai_end = mActors.end();
while (ai != ai_end)
{
- if (Actor *actor = *ai)
+ if (Actor *const actor = *ai)
{
if (!mOpenGL && (actor->getTileX() < startX
|| actor->getTileX() > endX || actor->getTileY() < startY
@@ -489,10 +490,11 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
}\
}\
-void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
- int debugFlags)
+void Map::drawCollision(Graphics *const graphics,
+ const int scrollX, const int scrollY,
+ const int debugFlags) const
{
- int endPixelY = graphics->mHeight + scrollY + mTileHeight - 1;
+ const int endPixelY = graphics->mHeight + scrollY + mTileHeight - 1;
int startX = scrollX / mTileWidth;
int startY = scrollY / mTileHeight;
int endX = (graphics->mWidth + scrollX + mTileWidth - 1) / mTileWidth;
@@ -522,7 +524,7 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
for (int x = startX; x < endX; x++, tilePtr++)
{
int width = 0;
- int x0 = x;
+ const int x0 = x;
fillCollision(BLOCKMASK_WALL, COLLISION_HIGHLIGHT);
fillCollision(BLOCKMASK_AIR, AIR_COLLISION_HIGHLIGHT);
@@ -532,7 +534,7 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
}
}
-void Map::updateAmbientLayers(float scrollX, float scrollY)
+void Map::updateAmbientLayers(const float scrollX, const float scrollY)
{
static int lastTick = tick_time; // static = only initialized at first call
@@ -544,9 +546,9 @@ void Map::updateAmbientLayers(float scrollX, float scrollY)
}
// Update Overlays
- float dx = scrollX - mLastAScrollX;
- float dy = scrollY - mLastAScrollY;
- int timePassed = get_elapsed_time(lastTick);
+ const float dx = scrollX - mLastAScrollX;
+ const float dy = scrollY - mLastAScrollY;
+ const int timePassed = get_elapsed_time(lastTick);
for (AmbientLayerVectorCIter i = mBackgrounds.begin(),
i_end = mBackgrounds.end(); i != i_end; ++i)
@@ -565,8 +567,8 @@ void Map::updateAmbientLayers(float scrollX, float scrollY)
lastTick = tick_time;
}
-void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
- int detail)
+void Map::drawAmbientLayers(Graphics *const graphics, const LayerType type,
+ const int detail)
{
// Detail 0 = no ambient effects except background image
if (detail <= 0 && type != BACKGROUND_LAYERS)
@@ -599,7 +601,7 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
}
}
-Tileset *Map::getTilesetWithGid(int gid) const
+Tileset *Map::getTilesetWithGid(const int gid) const
{
if (gid >= 0 && gid < mIndexedTilesetsSize)
return mIndexedTilesets[gid];
@@ -607,7 +609,7 @@ Tileset *Map::getTilesetWithGid(int gid) const
return nullptr;
}
-void Map::blockTile(int x, int y, BlockType type)
+void Map::blockTile(const int x, const int y, const BlockType type)
{
if (type == BLOCKTYPE_NONE || !contains(x, y))
return;
@@ -649,7 +651,7 @@ void Map::blockTile(int x, int y, BlockType type)
}
}
-bool Map::getWalk(int x, int y, unsigned char walkmask) const
+bool Map::getWalk(const int x, const int y, const unsigned char walkmask) const
{
// You can't walk outside of the map
if (x < 0 || y < 0 || x >= mWidth || y >= mHeight)
@@ -659,18 +661,18 @@ bool Map::getWalk(int x, int y, unsigned char walkmask) const
return !(mMetaTiles[x + y * mWidth].blockmask & walkmask);
}
-void Map::setWalk(int x, int y, bool walkable A_UNUSED)
+void Map::setWalk(const int x, const int y, const bool walkable A_UNUSED)
{
blockTile(x, y, Map::BLOCKTYPE_GROUNDTOP);
}
-bool Map::occupied(int x, int y) const
+bool Map::occupied(const int x, const int y) const
{
const ActorSprites &actors = actorSpriteManager->getAll();
for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
it != it_end; ++it)
{
- const ActorSprite *actor = *it;
+ const ActorSprite *const actor = *it;
//+++ if (actor->getTileX() == x && actor->getTileY() == y
// && being->getSubType() != 45)
@@ -684,17 +686,17 @@ bool Map::occupied(int x, int y) const
return false;
}
-bool Map::contains(int x, int y) const
+bool Map::contains(const int x, const int y) const
{
return x >= 0 && y >= 0 && x < mWidth && y < mHeight;
}
-MetaTile *Map::getMetaTile(int x, int y) const
+MetaTile *Map::getMetaTile(const int x, const int y) const
{
return &mMetaTiles[x + y * mWidth];
}
-Actors::iterator Map::addActor(Actor *actor)
+Actors::iterator Map::addActor(Actor *const actor)
{
mActors.push_front(actor);
// mSpritesUpdated = true;
@@ -729,7 +731,7 @@ const std::string Map::getFilename() const
return fileName.substr(lastSlash, lastDot - lastSlash);
}
-Position Map::checkNodeOffsets(int radius, unsigned char walkMask,
+Position Map::checkNodeOffsets(int radius, const unsigned char walkMask,
const Position &position) const
{
// Pre-computing character's position in tiles
@@ -793,9 +795,10 @@ Position Map::checkNodeOffsets(int radius, unsigned char walkMask,
return Position(tx * 32 + fx, ty * 32 + fy);
}
-Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX,
- int endPixelY,
- int radius, unsigned char walkMask, int maxCost)
+Path Map::findPixelPath(const int startPixelX, const int startPixelY,
+ const int endPixelX, const int endPixelY,
+ const int radius, const unsigned char walkMask,
+ const int maxCost)
{
Path myPath = findPath(startPixelX / 32, startPixelY / 32,
endPixelX / 32, endPixelY / 32, walkMask, maxCost);
@@ -805,24 +808,24 @@ Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX,
return myPath;
// Find the starting offset
- float startOffsetX = static_cast<float>(startPixelX % 32);
- float startOffsetY = static_cast<float>(startPixelY % 32);
+ const float startOffsetX = static_cast<float>(startPixelX % 32);
+ const float startOffsetY = static_cast<float>(startPixelY % 32);
// Find the ending offset
- float endOffsetX = static_cast<float>(endPixelX % 32);
- float endOffsetY = static_cast<float>(endPixelY % 32);
+ const float endOffsetX = static_cast<float>(endPixelX % 32);
+ const float endOffsetY = static_cast<float>(endPixelY % 32);
- int sz = static_cast<int>(myPath.size());
+ const int sz = static_cast<int>(myPath.size());
// Find the distance, and divide it by the number of steps
- int changeX = static_cast<int>((endOffsetX - startOffsetX)
- / static_cast<float>(sz));
- int changeY = static_cast<int>((endOffsetY - startOffsetY)
- / static_cast<float>(sz));
+ const int changeX = static_cast<int>((endOffsetX - startOffsetX)
+ / static_cast<float>(sz));
+ const int changeY = static_cast<int>((endOffsetY - startOffsetY)
+ / static_cast<float>(sz));
// Convert the map path to pixels over tiles
// And add interpolation between the starting and ending offsets
Path::iterator it = myPath.begin();
- Path::iterator it_end = myPath.end();
+ const Path::iterator it_end = myPath.end();
int i = 0;
while (it != it_end)
{
@@ -838,7 +841,7 @@ Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX,
// Remove the last path node, as it's more clever to go to the destination.
// It also permit to avoid zigzag at the end of the path,
// especially with mouse.
- Position destination = checkNodeOffsets(radius, walkMask,
+ const Position destination = checkNodeOffsets(radius, walkMask,
endPixelX, endPixelY);
myPath.pop_back();
myPath.push_back(destination);
@@ -846,8 +849,9 @@ Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX,
return myPath;
}
-Path Map::findPath(int startX, int startY, int destX, int destY,
- unsigned char walkmask, int maxCost)
+Path Map::findPath(const int startX, const int startY,
+ const int destX, const int destY,
+ const unsigned char walkmask, const int maxCost)
{
// The basic walking cost of a tile.
static int const basicCost = 100;
@@ -863,7 +867,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
return path;
// Reset starting tile's G cost to 0
- MetaTile *startTile = &mMetaTiles[startX + startY * mWidth];
+ MetaTile *const startTile = &mMetaTiles[startX + startY * mWidth];
if (!startTile)
return path;
@@ -881,7 +885,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
while (!openList.empty() && !foundPath)
{
// Take the location with the lowest F cost from the open list.
- Location curr = openList.top();
+ const Location curr = openList.top();
openList.pop();
// If the tile is already on the closed list, this means it has already
@@ -911,7 +915,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
if ((dx == 0 && dy == 0) || !contains(x, y))
continue;
- MetaTile *newTile = &mMetaTiles[x + yWidth];
+ MetaTile *const newTile = &mMetaTiles[x + yWidth];
// Skip if the tile is on the closed list or is not walkable
// unless its the destination tile
@@ -928,9 +932,10 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
// corner.
if (dx != 0 && dy != 0)
{
- MetaTile *t1 = &mMetaTiles[curr.x +
+ const MetaTile *const t1 = &mMetaTiles[curr.x +
(curr.y + dy) * mWidth];
- MetaTile *t2 = &mMetaTiles[curr.x + dx + curWidth];
+ const MetaTile *const t2 = &mMetaTiles[curr.x +
+ dx + curWidth];
//+++ here need check block must depend on player abilities.
if (((t1->blockmask | t2->blockmask) & BLOCKMASK_WALL))
@@ -975,7 +980,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
work reliably if the heuristic cost is higher than the
real cost. In particular, using Manhattan distance is
forbidden here. */
- int dx1 = std::abs(x - destX);
+ const int dx1 = std::abs(x - destX);
newTile->Hcost = std::abs(dx1 - dy1) * basicCost +
std::min(dx1, dy1) * (basicCost * 362 / 256);
@@ -1050,7 +1055,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
path.push_front(Position(pathX, pathY));
// Find out the next parent
- MetaTile *tile = &mMetaTiles[pathX + pathY * mWidth];
+ const MetaTile *const tile = &mMetaTiles[pathX + pathY * mWidth];
pathX = tile->parentX;
pathY = tile->parentY;
}
@@ -1060,7 +1065,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
}
void Map::addParticleEffect(const std::string &effectFile,
- int x, int y, int w, int h)
+ const int x, const int y, const int w, const int h)
{
ParticleEffectData newEffect;
newEffect.file = effectFile;
@@ -1071,7 +1076,7 @@ void Map::addParticleEffect(const std::string &effectFile,
particleEffects.push_back(newEffect);
}
-void Map::initializeParticleEffects(Particle *engine)
+void Map::initializeParticleEffects(Particle *const engine)
{
if (!engine)
return;
@@ -1130,7 +1135,7 @@ void Map::addExtraLayer()
while (ss >> buf)
comment += " " + buf;
- int type = atoi(type1.c_str());
+ const int type = atoi(type1.c_str());
if (comment.empty())
{
@@ -1161,7 +1166,7 @@ void Map::addExtraLayer()
}
}
-void Map::saveExtraLayer()
+void Map::saveExtraLayer() const
{
if (!mSpecialLayer)
{
@@ -1186,14 +1191,14 @@ void Map::saveExtraLayer()
return;
}
- int width = mSpecialLayer->mWidth;
- int height = mSpecialLayer->mHeight;
+ const int width = mSpecialLayer->mWidth;
+ const int height = mSpecialLayer->mHeight;
for (int x = 0; x < width; x ++)
{
for (int y = 0; y < height; y ++)
{
- MapItem *item = mSpecialLayer->getTile(x, y);
+ const MapItem *const item = mSpecialLayer->getTile(x, y);
if (item && item->mType != MapItem::EMPTY
&& item->mType != MapItem::HOME)
{
@@ -1212,8 +1217,8 @@ std::string Map::getUserMapDirectory() const
+ getProperty("_realfilename");
}
-void Map::addRange(const std::string &name, int type,
- int x, int y, int dx, int dy)
+void Map::addRange(const std::string &name, const int type,
+ const int x, const int y, const int dx, const int dy)
{
if (!mObjects)
return;
@@ -1221,13 +1226,14 @@ void Map::addRange(const std::string &name, int type,
mObjects->addObject(name, type, x / 32, y / 32, dx / 32, dy / 32);
}
-void Map::addPortal(const std::string &name, int type,
- int x, int y, int dx, int dy)
+void Map::addPortal(const std::string &name, const int type,
+ const int x, const int y, const int dx, const int dy)
{
addPortalTile(name, type, (x / 32) + (dx / 64), (y / 32) + (dy / 64));
}
-void Map::addPortalTile(const std::string &name, int type, int x, int y)
+void Map::addPortalTile(const std::string &name, const int type,
+ const int x, const int y)
{
MapItem *item = new MapItem(type, name, x, y);
if (mSpecialLayer)
@@ -1237,8 +1243,8 @@ void Map::addPortalTile(const std::string &name, int type, int x, int y)
mMapPortals.push_back(item);
}
-void Map::updatePortalTile(const std::string &name, int type,
- int x, int y, bool addNew)
+void Map::updatePortalTile(const std::string &name, const int type,
+ const int x, const int y, const bool addNew)
{
MapItem *item = findPortalXY(x, y);
if (item)
@@ -1259,7 +1265,7 @@ void Map::updatePortalTile(const std::string &name, int type,
}
}
-MapItem *Map::findPortalXY(int x, int y) const
+MapItem *Map::findPortalXY(const int x, const int y) const
{
for (std::vector<MapItem*>::const_iterator it = mMapPortals.begin(),
it_end = mMapPortals.end(); it != it_end; ++it)
@@ -1267,14 +1273,14 @@ MapItem *Map::findPortalXY(int x, int y) const
if (!*it)
continue;
- MapItem *item = *it;
+ MapItem *const item = *it;
if (item->mX == x && item->mY == y)
return item;
}
return nullptr;
}
-TileAnimation *Map::getAnimationForGid(int gid) const
+TileAnimation *Map::getAnimationForGid(const int gid) const
{
if (mTileAnimations.empty())
return nullptr;
@@ -1283,9 +1289,9 @@ TileAnimation *Map::getAnimationForGid(int gid) const
return (i == mTileAnimations.end()) ? nullptr : i->second;
}
-void Map::setPvpMode(int mode)
+void Map::setPvpMode(const int mode)
{
- int oldMode = mPvp;
+ const int oldMode = mPvp;
if (!mode)
mPvp = 0;
@@ -1315,21 +1321,23 @@ void Map::setPvpMode(int mode)
}
}
-std::string Map::getObjectData(unsigned x, unsigned y, int type)
+std::string Map::getObjectData(const unsigned x, const unsigned y,
+ const int type)
{
if (!mObjects)
return "";
- MapObjectList *list = mObjects->getAt(x, y);
+ MapObjectList *const list = mObjects->getAt(x, y);
if (!list)
return "";
std::vector<MapObject>::const_iterator it = list->objects.begin();
- std::vector<MapObject>::const_iterator it_end = list->objects.end();
+ const std::vector<MapObject>::const_iterator it_end = list->objects.end();
while (it != it_end)
{
if ((*it).type == type)
return (*it).data;
+ ++ it;
}
return "";
@@ -1414,11 +1422,11 @@ void Map::reduce()
layeri_end = mLayers.end();
layeri != layeri_end; ++ layeri)
{
- MapLayer *layer = *layeri;
+ const MapLayer *const layer = *layeri;
if (x >= layer->mWidth || y >= layer->mHeight)
continue;
- Image *img = layer->mTiles[x + y * layer->mWidth];
+ Image *const img = layer->mTiles[x + y * layer->mWidth];
if (img)
{
if (img->hasAlphaChannel() && img->isAlphaCalculated())
@@ -1442,14 +1450,15 @@ void Map::reduce()
}
else if (img->hasAlphaChannel())
{
- uint8_t *arr = img->SDLgetAlphaChannel();
+ const uint8_t *const arr = img->SDLgetAlphaChannel();
if (!arr)
continue;
bool bad(false);
bool stop(false);
int width;
- SubImage *subImg = dynamic_cast<SubImage*>(img);
+ const SubImage *const subImg
+ = dynamic_cast<SubImage*>(img);
if (subImg)
width = subImg->mInternalBounds.w;
else
@@ -1461,7 +1470,7 @@ void Map::reduce()
for (int d = img->mBounds.y;
d < img->mBounds.y + img->mBounds.h; d ++)
{
- uint8_t chan = arr[f + d * width];
+ const uint8_t chan = arr[f + d * width];
if (chan != 255)
{
bad = true;
@@ -1491,14 +1500,14 @@ void Map::reduce()
Layers::reverse_iterator ri = mLayers.rbegin();
while (ri != mLayers.rend())
{
- MapLayer *layer = *ri;
+ const MapLayer *const layer = *ri;
if (x >= layer->mWidth || y >= layer->mHeight)
{
++ ri;
continue;
}
- Image *img = layer->mTiles[x + y * layer->mWidth];
+ const Image *img = layer->mTiles[x + y * layer->mWidth];
if (img && !img->isAlphaVisible())
{ // removing all down tiles
++ ri;
diff --git a/src/map.h b/src/map.h
index 1a81e8ccb..5cd1cf8ed 100644
--- a/src/map.h
+++ b/src/map.h
@@ -81,13 +81,13 @@ struct MetaTile
class TileAnimation
{
public:
- TileAnimation(Animation *ani);
+ TileAnimation(Animation *const ani);
~TileAnimation();
- bool update(int ticks = 1);
+ bool update(const int ticks = 1);
- void addAffectedTile(MapLayer *layer, int index)
+ void addAffectedTile(MapLayer *const layer, const int index)
{ mAffected.push_back(std::make_pair(layer, index)); }
private:
@@ -152,7 +152,8 @@ class Map : public Properties, public ConfigListener
/**
* Constructor, taking map and tile size as parameters.
*/
- Map(int width, int height, int tileWidth, int tileHeight);
+ Map(const int width, const int height,
+ const int tileWidth, const int tileHeight);
/**
* Destructor.
@@ -168,7 +169,7 @@ class Map : public Properties, public ConfigListener
/**
* Updates animations. Called as needed.
*/
- void update(int ticks = 1);
+ void update(const int ticks = 1);
/**
* Draws the map to the given graphics output. This method draws all
@@ -183,48 +184,49 @@ class Map : public Properties, public ConfigListener
/**
* Visualizes collision layer for debugging
*/
- void drawCollision(Graphics *graphics, int scrollX, int scrollY,
- int debugFlags);
+ void drawCollision(Graphics *const graphics,
+ const int scrollX, const int scrollY,
+ const int debugFlags) const;
/**
* Adds a layer to this map. The map takes ownership of the layer.
*/
- void addLayer(MapLayer *layer);
+ void addLayer(MapLayer *const layer);
/**
* Adds a tileset to this map. The map takes ownership of the tileset.
*/
- void addTileset(Tileset *tileset);
+ void addTileset(Tileset *const tileset);
/**
* Finds the tile set that a tile with the given global id is part of.
*/
- Tileset *getTilesetWithGid(int gid) const;
+ Tileset *getTilesetWithGid(const int gid) const;
/**
* Get tile reference.
*/
- MetaTile *getMetaTile(int x, int y) const;
+ MetaTile *getMetaTile(const int x, const int y) const;
/**
* Marks a tile as occupied.
*/
- void blockTile(int x, int y, BlockType type);
+ void blockTile(const int x, const int y, const BlockType type);
/**
* Gets walkability for a tile with a blocking bitmask. When called
* without walkmask, only blocks against colliding tiles.
*/
- bool getWalk(int x, int y,
- unsigned char walkmask = BLOCKMASK_WALL | BLOCKMASK_AIR
- | BLOCKMASK_WATER) const;
+ bool getWalk(const int x, const int y,
+ const unsigned char walkmask = BLOCKMASK_WALL
+ | BLOCKMASK_AIR | BLOCKMASK_WATER) const;
- void setWalk(int x, int y, bool walkable);
+ void setWalk(const int x, const int y, const bool walkable);
/**
* Tells whether a tile is occupied by a being.
*/
- bool occupied(int x, int y) const;
+ bool occupied(const int x, const int y) const;
/**
* Returns the width of this map in tiles.
@@ -263,45 +265,48 @@ class Map : public Properties, public ConfigListener
* Check the current position against surrounding blocking tiles, and
* correct the position offset within tile when needed.
*/
- Position checkNodeOffsets(int radius, unsigned char walkMask,
+ Position checkNodeOffsets(int radius, const unsigned char walkMask,
const Position &position) const;
- Position checkNodeOffsets(int radius, unsigned char walkMask,
- int x, int y) const
+ Position checkNodeOffsets(const int radius,
+ const unsigned char walkMask,
+ const int x, const int y) const
{ return checkNodeOffsets(radius, walkMask, Position(x, y)); }
/**
* Find a pixel path from one location to the next.
*/
- Path findPixelPath(int startPixelX, int startPixelY,
- int destPixelX, int destPixelY,
- int radius, unsigned char walkmask,
- int maxCost = 20);
+ Path findPixelPath(const int startPixelX, const int startPixelY,
+ const int destPixelX, const int destPixelY,
+ const int radius, const unsigned char walkmask,
+ const int maxCost = 20);
/**
* Find a path from one location to the next.
*/
- Path findPath(int startX, int startY, int destX, int destY,
- unsigned char walkmask, int maxCost = 20);
+ Path findPath(const int startX, const int startY,
+ const int destX, const int destY,
+ const unsigned char walkmask, const int maxCost = 20);
/**
* Adds a particle effect
*/
void addParticleEffect(const std::string &effectFile,
- int x, int y, int w = 0, int h = 0);
+ const int x, const int y,
+ const int w = 0, const int h = 0);
/**
* Initializes all added particle effects
*/
- void initializeParticleEffects(Particle* particleEngine);
+ void initializeParticleEffects(Particle *const particleEngine);
/**
* Adds a tile animation to the map
*/
- void addAnimation(int gid, TileAnimation *animation)
+ void addAnimation(const int gid, TileAnimation *const animation)
{ mTileAnimations[gid] = animation; }
- void setDebugFlags(int n)
+ void setDebugFlags(const int n)
{ mDebugFlags = n; }
int getDebugFlags() const
@@ -309,7 +314,7 @@ class Map : public Properties, public ConfigListener
void addExtraLayer();
- void saveExtraLayer();
+ void saveExtraLayer() const;
SpecialLayer *getTempLayer() const
{ return mTempLayer; }
@@ -317,7 +322,7 @@ class Map : public Properties, public ConfigListener
SpecialLayer *getSpecialLayer() const
{ return mSpecialLayer; }
- void setHasWarps(bool n)
+ void setHasWarps(const bool n)
{ mHasWarps = n; }
bool getHasWarps() const
@@ -325,16 +330,18 @@ class Map : public Properties, public ConfigListener
std::string getUserMapDirectory() const;
- void addPortal(const std::string &name, int type,
- int x, int y, int dx, int dy);
+ void addPortal(const std::string &name, const int type,
+ const int x, const int y, const int dx, const int dy);
- void addRange(const std::string &name, int type,
- int x, int y, int dx, int dy);
+ void addRange(const std::string &name, const int type,
+ const int x, const int y, const int dx, const int dy);
- void addPortalTile(const std::string &name, int type, int x, int y);
+ void addPortalTile(const std::string &name, const int type,
+ const int x, const int y);
- void updatePortalTile(const std::string &name, int type,
- int x, int y, bool addNew = true);
+ void updatePortalTile(const std::string &name, const int type,
+ const int x, const int y,
+ const bool addNew = true);
std::vector<MapItem*> &getPortals()
{ return mMapPortals; }
@@ -342,33 +349,34 @@ class Map : public Properties, public ConfigListener
/**
* Gets the tile animation for a specific gid
*/
- TileAnimation *getAnimationForGid(int gid) const;
+ TileAnimation *getAnimationForGid(const int gid) const;
void optionChanged(const std::string &value);
- MapItem *findPortalXY(int x, int y) const;
+ MapItem *findPortalXY(const int x, const int y) const;
int getActorsCount() const
{ return static_cast<int>(mActors.size()); }
- void setPvpMode(int mode);
+ void setPvpMode(const int mode);
ObjectsLayer* getObjectsLayer() const
{ return mObjects; }
- std::string getObjectData(unsigned x, unsigned y, int type);
+ std::string getObjectData(const unsigned x, const unsigned y,
+ const int type);
void indexTilesets();
void clearIndexedTilesets();
- void setActorsFix(int x, int y)
+ void setActorsFix(const int x, const int y)
{ mActorFixX = x; mActorFixY = y; }
int getVersion() const
{ return mVersion; }
- void setVersion(int n)
+ void setVersion(const int n)
{ mVersion = n; }
void reduce();
@@ -378,10 +386,10 @@ class Map : public Properties, public ConfigListener
bool empty() const
{ return mLayers.empty(); }
- void setCustom(bool b)
+ void setCustom(const bool b)
{ mCustom = b; }
- bool isCustom()
+ bool isCustom() const
{ return mCustom; }
protected:
@@ -409,18 +417,18 @@ class Map : public Properties, public ConfigListener
/**
* Updates scrolling of ambient layers. Has to be called each game tick.
*/
- void updateAmbientLayers(float scrollX, float scrollY);
+ void updateAmbientLayers(const float scrollX, const float scrollY);
/**
* Draws the foreground or background layers to the given graphics output.
*/
- void drawAmbientLayers(Graphics *graphics, LayerType type,
- int detail);
+ void drawAmbientLayers(Graphics *const graphics, const LayerType type,
+ const int detail);
/**
* Tells whether the given coordinates fall within the map boundaries.
*/
- bool contains(int x, int y) const;
+ bool contains(const int x, const int y) const;
/**
* Blockmasks for different entities
diff --git a/src/sprite.h b/src/sprite.h
index 60dc288f1..2d7b7c0a6 100644
--- a/src/sprite.h
+++ b/src/sprite.h
@@ -83,7 +83,7 @@ class Sprite
*
* @returns true if the sprite changed, false otherwise
*/
- virtual bool setSpriteDirection(SpriteDirection direction) = 0;
+ virtual bool setSpriteDirection(const SpriteDirection direction) = 0;
/**
* Sets the alpha value of the animated sprite