summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-20 21:21:10 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-20 21:21:10 +0300
commit7d606d7dd9708c9c382d1f8eba5fed9becdfd3d5 (patch)
tree8b74b950fd50627b9477d97053a4ade9fd9aa7fd /src
parent21069ec1635bd24ab33805e033d28f2c0b2de482 (diff)
downloadmv-7d606d7dd9708c9c382d1f8eba5fed9becdfd3d5.tar.gz
mv-7d606d7dd9708c9c382d1f8eba5fed9becdfd3d5.tar.bz2
mv-7d606d7dd9708c9c382d1f8eba5fed9becdfd3d5.tar.xz
mv-7d606d7dd9708c9c382d1f8eba5fed9becdfd3d5.zip
Add missing const in other left files.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp8
-rw-r--r--src/actormanager.cpp31
-rw-r--r--src/actormanager.h14
-rw-r--r--src/configuration.cpp4
-rw-r--r--src/dyetool/gui/viewport.cpp4
-rw-r--r--src/dyetool/gui/viewport.h4
-rw-r--r--src/listeners/renamelistener.cpp4
-rw-r--r--src/particle/particle.cpp2
-rw-r--r--src/position.cpp3
-rw-r--r--src/textmanager.cpp4
10 files changed, 45 insertions, 33 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 668b1aeb9..335a5439c 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -126,14 +126,14 @@ namespace Actions
{
static int uploadUpdate(void *ptr,
- DownloadStatusT status,
+ const DownloadStatusT status,
size_t total A_UNUSED,
- size_t remaining A_UNUSED) A_NONNULL(1);
+ const size_t remaining A_UNUSED) A_NONNULL(1);
static int uploadUpdate(void *ptr,
- DownloadStatusT status,
+ const DownloadStatusT status,
size_t total A_UNUSED,
- size_t remaining A_UNUSED)
+ const size_t remaining A_UNUSED)
{
if (status == DownloadStatus::Idle || status == DownloadStatus::Starting)
return 0;
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 1b454406a..c9fb63ac8 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -357,7 +357,7 @@ void ActorManager::erase(ActorSprite *const actor)
return;
mActors.erase(actor);
- ActorSpritesMapIterator it = mActorsIdMap.find(actor->getId());
+ const ActorSpritesMapIterator it = mActorsIdMap.find(actor->getId());
if (it != mActorsIdMap.end() && (*it).second == actor)
mActorsIdMap.erase(it);
}
@@ -379,7 +379,7 @@ void ActorManager::undelete(const ActorSprite *const actor)
Being *ActorManager::findBeing(const BeingId id) const
{
- ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
+ const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
if (it != mActorsIdMap.end())
{
ActorSprite *const actor = (*it).second;
@@ -595,7 +595,7 @@ Being *ActorManager::findPortalByTile(const int x, const int y) const
FloorItem *ActorManager::findItem(const BeingId id) const
{
- ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
+ const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
if (it != mActorsIdMap.end())
{
ActorSprite *const actor = (*it).second;
@@ -628,7 +628,7 @@ FloorItem *ActorManager::findItem(const int x, const int y) const
bool ActorManager::pickUpAll(const int x1, const int y1,
const int x2, const int y2,
- const bool serverBuggy)
+ const bool serverBuggy) const
{
if (!localPlayer)
return false;
@@ -901,7 +901,8 @@ void ActorManager::logic()
if (actor)
{
- ActorSpritesMapIterator itr = mActorsIdMap.find(actor->getId());
+ const ActorSpritesMapIterator itr = mActorsIdMap.find(
+ actor->getId());
if (itr != mActorsIdMap.end() && (*itr).second == actor)
mActorsIdMap.erase(itr);
@@ -1486,7 +1487,7 @@ void ActorManager::printAllToChat()
printBeingsToChat(_("Visible on map"));
}
-void ActorManager::printBeingsToChat(const std::string &header)
+void ActorManager::printBeingsToChat(const std::string &header) const
{
if (!debugChatTab)
return;
@@ -1517,7 +1518,7 @@ void ActorManager::printBeingsToChat(const std::string &header)
ChatMsgType::BY_SERVER);
FOR_EACH (ActorSpritesMapConstIterator, itr, mActorsIdMap)
{
- ActorSprite *actor = (*itr).second;
+ const ActorSprite *const actor = (*itr).second;
if (!actor)
continue;
if (actor->getId() != (*itr).first)
@@ -1995,7 +1996,7 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
return dstBeing;
}
-void ActorManager::updateBadges()
+void ActorManager::updateBadges() const
{
const uint8_t showBadges = CAST_U8(
config.getIntValue("showBadges"));
@@ -2064,13 +2065,17 @@ void ActorManager::updateSeenPlayers(const std::set<std::string>
}
}
-std::string ActorManager::getSeenPlayerById(const BeingId id)
+std::string ActorManager::getSeenPlayerById(const BeingId id) const
{
if (!mEnableIdCollecting)
return std::string();
- if (mIdName.find(id) != mIdName.end() && !mIdName[id].empty())
- return *(mIdName[id].begin());
+ const IdNameMappingCIter it = mIdName.find(id);
+ if (it != mIdName.end())
+ {
+ if (!it->second.empty())
+ return *(it->second.begin());
+ }
return std::string();
}
@@ -2102,7 +2107,7 @@ void ActorManager::updateRoom(const ChatObject *const newChat)
ActorSprite *const actor = *it;
if (actor->getType() == ActorType::Npc)
{
- Being *const being = static_cast<Being*>(actor);
+ const Being *const being = static_cast<Being*>(actor);
ChatObject *const chat = being->getChat();
if (chat && chat->chatId == newChat->chatId)
{
@@ -2117,7 +2122,7 @@ void ActorManager::updateRoom(const ChatObject *const newChat)
std::string ActorManager::findCharById(const int32_t id)
{
- std::map<int32_t, std::string>::const_iterator it = mChars.find(id);
+ const std::map<int32_t, std::string>::const_iterator it = mChars.find(id);
if (it == mChars.end())
return std::string();
return (*it).second;
diff --git a/src/actormanager.h b/src/actormanager.h
index 78f53a6d5..eac773fe8 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -60,6 +60,7 @@ typedef ActorSpritesMap::iterator ActorSpritesMapIterator;
typedef ActorSpritesMap::const_iterator ActorSpritesMapConstIterator;
typedef std::map<BeingId, std::set<std::string> > IdNameMapping;
+typedef IdNameMapping::const_iterator IdNameMappingCIter;
class ActorManager final: public ConfigListener
{
@@ -261,7 +262,7 @@ class ActorManager final: public ConfigListener
void printAllToChat();
- void printBeingsToChat(const std::string &header);
+ void printBeingsToChat(const std::string &header) const;
static void printBeingsToChat(const std::vector<Being*> &beings,
const std::string &header);
@@ -281,8 +282,11 @@ class ActorManager final: public ConfigListener
void parseLevels(std::string levels) const;
#endif
- bool pickUpAll(const int x1, const int y1, const int x2, const int y2,
- const bool serverBuggy = false);
+ bool pickUpAll(const int x1,
+ const int y1,
+ const int x2,
+ const int y2,
+ const bool serverBuggy = false) const;
bool pickUpNearest(const int x, const int y, int maxdist) const;
@@ -356,14 +360,14 @@ class ActorManager final: public ConfigListener
void updateEffects(const std::map<BeingTypeId, int> &addEffects,
const std::set<BeingTypeId> &removeEffects) const;
- void updateBadges();
+ void updateBadges() const;
void updateNameId(const std::string &name,
const BeingId beingId);
void updateSeenPlayers(const std::set<std::string> &onlinePlayers);
- std::string getSeenPlayerById(const BeingId id);
+ std::string getSeenPlayerById(const BeingId id) const;
size_t size() const
{ return mActors.size(); }
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 29d26f495..e035ae80f 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -804,8 +804,8 @@ void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
}
for (std::map<std::string, ConfigurationList>::const_iterator
- it = mContainerOptions.begin(), it_end = mContainerOptions.end();
- it != it_end; ++ it)
+ it = mContainerOptions.begin(), it_fend = mContainerOptions.end();
+ it != it_fend; ++ it)
{
const char *const name = it->first.c_str();
diff --git a/src/dyetool/gui/viewport.cpp b/src/dyetool/gui/viewport.cpp
index b01d27833..786b7a4f1 100644
--- a/src/dyetool/gui/viewport.cpp
+++ b/src/dyetool/gui/viewport.cpp
@@ -86,7 +86,7 @@ void Viewport::setMap(Map *const map A_UNUSED)
{
}
-void Viewport::draw(Graphics *graphics)
+void Viewport::draw(Graphics *const graphics)
{
BLOCK_START("Viewport::draw 1")
static int lastTick = tick_time;
@@ -104,7 +104,7 @@ void Viewport::draw(Graphics *graphics)
BLOCK_END("Viewport::draw 1")
}
-void Viewport::safeDraw(Graphics *graphics)
+void Viewport::safeDraw(Graphics *const graphics)
{
Viewport::draw(graphics);
}
diff --git a/src/dyetool/gui/viewport.h b/src/dyetool/gui/viewport.h
index 53b825066..763371338 100644
--- a/src/dyetool/gui/viewport.h
+++ b/src/dyetool/gui/viewport.h
@@ -69,9 +69,9 @@ class Viewport final : public WindowContainer,
/**
* Draws the viewport.
*/
- void draw(Graphics *graphics) override final A_NONNULL(2);
+ void draw(Graphics *const graphics) override final A_NONNULL(2);
- void safeDraw(Graphics *graphics) override final A_NONNULL(2);
+ void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
/**
* Implements player to keep following mouse.
diff --git a/src/listeners/renamelistener.cpp b/src/listeners/renamelistener.cpp
index 1166868cf..0f5cc9413 100644
--- a/src/listeners/renamelistener.cpp
+++ b/src/listeners/renamelistener.cpp
@@ -57,11 +57,11 @@ void RenameListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && viewport && mDialog)
{
- Map *const map = viewport->getMap();
+ const Map *const map = viewport->getMap();
if (!map)
return;
- SpecialLayer *const sl = map->getSpecialLayer();
+ const SpecialLayer *const sl = map->getSpecialLayer();
MapItem *item = nullptr;
if (sl)
{
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index 73cbb4b0d..97c2c42d6 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -239,7 +239,7 @@ bool Particle::update() restrict2
// Update child particles
for (ParticleIterator p = mChildParticles.begin(),
- p2 = mChildParticles.end(); p != p2; )
+ fp2 = mChildParticles.end(); p != fp2; )
{
Particle *restrict const particle = *p;
// move particle with its parent if desired
diff --git a/src/position.cpp b/src/position.cpp
index 6a7973105..61f2f011f 100644
--- a/src/position.cpp
+++ b/src/position.cpp
@@ -32,7 +32,8 @@ std::ostream& operator <<(std::ostream &os, const Position &p)
std::ostream& operator <<(std::ostream &os, const Path &path)
{
- Path::const_iterator i = path.begin(), i_end = path.end();
+ Path::const_iterator i = path.begin();
+ const Path::const_iterator i_end = path.end();
os << "(";
while (i != i_end)
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 77902674d..bdff28810 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -97,7 +97,9 @@ void TextManager::place(const Text *const textObj,
int cnt = 0;
for (TextList::const_iterator ptr = mTextList.begin(),
- pEnd = mTextList.end(); ptr != pEnd && cnt < nBeings; ++ptr, cnt ++)
+ pfEnd = mTextList.end();
+ ptr != pfEnd && cnt < nBeings;
+ ++ptr, cnt ++)
{
const Text *const text = *ptr;