summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:34 +0300
commitc9f43996f3147100627ee2c6f9da993ceb160113 (patch)
tree7577f02f4658b19e05d586f66b67a9a4f5fedb7e /src/resources
parent8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf (diff)
downloadmv-c9f43996f3147100627ee2c6f9da993ceb160113.tar.gz
mv-c9f43996f3147100627ee2c6f9da993ceb160113.tar.bz2
mv-c9f43996f3147100627ee2c6f9da993ceb160113.tar.xz
mv-c9f43996f3147100627ee2c6f9da993ceb160113.zip
Improve iterators part 2.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp5
-rw-r--r--src/resources/animation.cpp5
-rw-r--r--src/resources/emotedb.cpp5
-rw-r--r--src/resources/itemdb.cpp4
-rw-r--r--src/resources/iteminfo.h1
-rw-r--r--src/resources/spritedef.cpp27
-rw-r--r--src/resources/wallpaper.cpp5
7 files changed, 24 insertions, 28 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index 6c799cdfa..2c1c5d080 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -72,9 +72,8 @@ void Action::setAnimation(int direction, Animation *animation)
void Action::setLastFrameDelay(int delay)
{
- AnimationIter it = mAnimations.begin();
- AnimationIter it_end = mAnimations.end();
- for (; it != it_end; ++ it)
+ for (AnimationIter it = mAnimations.begin(),
+ it_end = mAnimations.end(); it != it_end; ++ it)
{
Animation *animation = (*it).second;
if (!animation)
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 853b79d64..63e73df55 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -78,9 +78,8 @@ void Animation::addPause(int delay, int rand)
void Animation::setLastFrameDelay(int delay)
{
- FramesRevIter it = mFrames.rbegin();
- FramesRevIter it_end = mFrames.rend();
- for (; it != it_end; ++ it)
+ for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend();
+ it != it_end; ++ it)
{
if ((*it).type == Frame::ANIMATION && (*it).image)
{
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index e6f04536e..045900415 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -170,9 +170,8 @@ void EmoteDB::load()
void EmoteDB::unload()
{
- for (EmoteInfos::const_iterator i = mEmoteInfos.begin();
- i != mEmoteInfos.end();
- ++i)
+ for (EmoteInfos::const_iterator i = mEmoteInfos.begin(),
+ i_end = mEmoteInfos.end(); i != i_end; ++ i)
{
if (i->second)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 72d1aa9eb..8d4cf8002 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -307,8 +307,8 @@ void ItemDB::load()
effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
- for (std::vector<Stat>::const_iterator it = extraStats.begin();
- it != extraStats.end(); ++it)
+ for (std::vector<Stat>::const_iterator it = extraStats.begin(),
+ it_end = extraStats.end(); it != it_end; ++it)
{
int value = XML::getProperty(node, it->tag.c_str(), 0);
if (!value)
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 56a442832..9d1f94954 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -92,6 +92,7 @@ enum ItemType
// sprite, <itemfrom, itemto>
typedef std::map<int, std::map<int, int> > SpriteToItemMap;
+typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter;
/**
* Defines a class for storing item infos. This includes information used when
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 3411b70c4..4aa0eada4 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -61,9 +61,8 @@ Action *SpriteDef::getAction(std::string action, unsigned num) const
unsigned SpriteDef::findNumber(unsigned num) const
{
unsigned min = 101;
- Actions::const_iterator it = mActions.begin();
- Actions::const_iterator it_end = mActions.end();
- for (; it != it_end; ++ it)
+ for (Actions::const_iterator it = mActions.begin(),
+ it_end = mActions.end(); it != it_end; ++ it)
{
unsigned n = (*it).first;
if (n >= num && n < min)
@@ -107,9 +106,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
void SpriteDef::fixDeadAction()
{
- ActionsIter it = mActions.begin();
- ActionsIter it_end = mActions.end();
- for (; it != it_end; ++ it)
+ for (ActionsIter it = mActions.begin(), it_end = mActions.end();
+ it != it_end; ++ it)
{
ActionMap *d = (*it).second;
if (!d)
@@ -122,9 +120,8 @@ void SpriteDef::fixDeadAction()
void SpriteDef::substituteAction(std::string complete, std::string with)
{
- ActionsConstIter it = mActions.begin();
- ActionsConstIter it_end = mActions.end();
- for (; it != it_end; ++ it)
+ for (ActionsConstIter it = mActions.begin(), it_end = mActions.end();
+ it != it_end; ++ it)
{
ActionMap *d = (*it).second;
if (!d)
@@ -326,9 +323,8 @@ void SpriteDef::loadAnimation(XmlNodePtr animationNode,
{
StringVect vals;
splitToStringVector(vals, value, ',');
- StringVectCIter it = vals.begin();
- StringVectCIter it_end = vals.end();
- for (; it != it_end; ++ it)
+ for (StringVectCIter it = vals.begin(), it_end = vals.end();
+ it != it_end; ++ it)
{
std::string str = *it;
size_t idx = str.find("-");
@@ -419,10 +415,11 @@ SpriteDef::~SpriteDef()
for (Actions::iterator i = mActions.begin(),
i_end = mActions.end(); i != i_end; ++i)
{
- ActionMap::iterator it = (*i).second->begin();
- ActionMap::iterator it_end = (*i).second->end();
- for (; it != it_end; ++ it)
+ for (ActionMap::iterator it = (*i).second->begin(),
+ it_end = (*i).second->end(); it != it_end; ++ it)
+ {
actions.insert(it->second);
+ }
delete (*i).second;
}
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 7b89bed6e..2f5fd9dca 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -136,13 +136,14 @@ void Wallpaper::loadWallpapers()
std::string Wallpaper::getWallpaper(int width, int height)
{
- std::vector<WallpaperData>::const_iterator iter;
WallpaperData wp;
// Wallpaper filename container
StringVect wallPaperVector;
- for (iter = wallpaperData.begin(); iter != wallpaperData.end(); ++iter)
+ for (std::vector<WallpaperData>::const_iterator
+ iter = wallpaperData.begin(), iter_end = wallpaperData.end();
+ iter != iter_end; ++iter)
{
wp = *iter;
if (wp.width <= width && wp.height <= height)