summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-20 20:43:54 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-20 23:48:07 +0300
commit2744e4fa8f39cd06bfe557a5a3881830bd11501c (patch)
tree2ec96c6ee820cfe0e5e76480fe828501bf555a4b /src/resources
parent531433248fbad49e2b8e9d90de9855f3ea9b2257 (diff)
downloadmanaplus-2744e4fa8f39cd06bfe557a5a3881830bd11501c.tar.gz
manaplus-2744e4fa8f39cd06bfe557a5a3881830bd11501c.tar.bz2
manaplus-2744e4fa8f39cd06bfe557a5a3881830bd11501c.tar.xz
manaplus-2744e4fa8f39cd06bfe557a5a3881830bd11501c.zip
Last part with FOR_EACH changes.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp3
-rw-r--r--src/resources/atlasmanager.cpp35
-rw-r--r--src/resources/emotedb.cpp3
-rw-r--r--src/resources/itemdb.cpp3
-rw-r--r--src/resources/resourcemanager.cpp8
-rw-r--r--src/resources/spritedef.cpp29
-rw-r--r--src/resources/wallpaper.cpp4
7 files changed, 25 insertions, 60 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index 752446e5e..362fa0370 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -72,8 +72,7 @@ void Action::setAnimation(const int direction, Animation *const animation)
void Action::setLastFrameDelay(const int delay)
{
- for (AnimationIter it = mAnimations.begin(),
- it_end = mAnimations.end(); it != it_end; ++ it)
+ FOR_EACH (AnimationIter, it, mAnimations)
{
Animation *const animation = (*it).second;
if (!animation)
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 555a3da31..ef36eedac 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -60,8 +60,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name,
simpleSort(name, atlases, images, maxSize);
// int k = 0;
- for (std::vector<TextureAtlas*>::iterator it = atlases.begin(),
- it_end = atlases.end(); it != it_end; ++ it)
+ FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
{
TextureAtlas *atlas = *it;
if (!atlas)
@@ -95,8 +94,7 @@ void AtlasManager::loadImages(const StringVect &files,
{
ResourceManager *const resman = ResourceManager::getInstance();
- for (StringVectCIter it = files.begin(), it_end = files.end();
- it != it_end; ++ it)
+ FOR_EACH (StringVectCIter, it, files)
{
const std::string str = *it;
// check is image with same name already in cache
@@ -237,9 +235,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *atlas)
graphics->_beginDraw();
// drawing SDL images to surface
- for (std::vector<AtlasItem*>::iterator it = atlas->items.begin(),
- it_end = atlas->items.end();
- it != it_end; ++ it)
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
{
AtlasItem *item = *it;
Image *image = item->image;
@@ -267,9 +263,7 @@ void AtlasManager::convertAtlas(TextureAtlas *atlas)
image->incRef();
}
- for (std::vector<AtlasItem*>::iterator it = atlas->items.begin(),
- it_end = atlas->items.end();
- it != it_end; ++ it)
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
{
AtlasItem *const item = *it;
// delete SDL Image
@@ -289,8 +283,7 @@ void AtlasManager::convertAtlas(TextureAtlas *atlas)
void AtlasManager::injectToResources(AtlasResource *resource)
{
ResourceManager *const resman = ResourceManager::getInstance();
- for (std::vector<TextureAtlas*>::iterator it = resource->atlases.begin(),
- it_end = resource->atlases.end(); it != it_end; ++ it)
+ FOR_EACH (std::vector<TextureAtlas*>::iterator, it, resource->atlases)
{
// add each atlas image to resources
TextureAtlas *const atlas = *it;
@@ -299,9 +292,7 @@ void AtlasManager::injectToResources(AtlasResource *resource)
Image *const image = atlas->atlasImage;
if (image)
resman->addResource(atlas->name, image);
- for (std::vector<AtlasItem*>::iterator it2 = atlas->items.begin(),
- it2_end = atlas->items.end();
- it2 != it2_end; ++ it2)
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
if (!item)
@@ -316,8 +307,7 @@ void AtlasManager::injectToResources(AtlasResource *resource)
void AtlasManager::moveToDeleted(AtlasResource *resource)
{
ResourceManager *const resman = ResourceManager::getInstance();
- for (std::vector<TextureAtlas*>::iterator it = resource->atlases.begin(),
- it_end = resource->atlases.end(); it != it_end; ++ it)
+ FOR_EACH (std::vector<TextureAtlas*>::iterator, it, resource->atlases)
{
// move each atlas image to deleted
TextureAtlas *const atlas = *it;
@@ -329,9 +319,7 @@ void AtlasManager::moveToDeleted(AtlasResource *resource)
// move each atlas image to deleted
resman->moveToDeleted(image);
}
- for (std::vector<AtlasItem*>::iterator it2 = atlas->items.begin(),
- it2_end = atlas->items.end();
- it2 != it2_end; ++ it2)
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
if (item)
@@ -350,15 +338,12 @@ void AtlasManager::moveToDeleted(AtlasResource *resource)
AtlasResource::~AtlasResource()
{
- for (std::vector<TextureAtlas*>::iterator it = atlases.begin(),
- it_end = atlases.end(); it != it_end; ++ it)
+ FOR_EACH (std::vector<TextureAtlas*>::iterator, it, atlases)
{
TextureAtlas *const atlas = *it;
if (atlas)
{
- for (std::vector<AtlasItem*>::iterator it2 = atlas->items.begin(),
- it2_end = atlas->items.end();
- it2 != it2_end; ++ it2)
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
if (item)
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index d29e9d723..d352e79c3 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -175,8 +175,7 @@ void EmoteDB::load()
void EmoteDB::unload()
{
- for (EmoteInfos::const_iterator i = mEmoteInfos.begin(),
- i_end = mEmoteInfos.end(); i != i_end; ++ i)
+ FOR_EACH (EmoteInfos::const_iterator, i, mEmoteInfos)
{
if (i->second)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 5d8083374..5fd0da97b 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -326,8 +326,7 @@ void ItemDB::load()
effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
- for (std::vector<Stat>::const_iterator it = extraStats.begin(),
- it_end = extraStats.end(); it != it_end; ++it)
+ FOR_EACH (std::vector<Stat>::const_iterator, it, extraStats)
{
const int value = XML::getProperty(node, it->tag.c_str(), 0);
if (!value)
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index ca96f5f25..542a96a9e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -1024,11 +1024,8 @@ void ResourceManager::scheduleDelete(SDL_Surface *const surface)
void ResourceManager::clearScheduled()
{
BLOCK_START("ResourceManager::clearScheduled")
- for (std::set<SDL_Surface*>::iterator i = deletedSurfaces.begin(),
- i_end = deletedSurfaces.end(); i != i_end; ++i)
- {
+ FOR_EACH (std::set<SDL_Surface*>::iterator, i, deletedSurfaces)
SDL_FreeSurface(*i);
- }
deletedSurfaces.clear();
BLOCK_END("ResourceManager::clearScheduled")
}
@@ -1100,8 +1097,7 @@ void ResourceManager::delayedLoad()
void ResourceManager::removeDelayLoad(const AnimationDelayLoad
*const delayedLoad)
{
- for (DelayedAnimIter it = mDelayedAnimations.begin(),
- it_end = mDelayedAnimations.end(); it != it_end; ++ it)
+ FOR_EACH (DelayedAnimIter, it, mDelayedAnimations)
{
if (*it == delayedLoad)
{
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 28eeb00ed..4af25c8cf 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -62,8 +62,7 @@ Action *SpriteDef::getAction(const std::string &action,
unsigned SpriteDef::findNumber(const unsigned num) const
{
unsigned min = 101;
- for (Actions::const_iterator it = mActions.begin(),
- it_end = mActions.end(); it != it_end; ++ it)
+ FOR_EACH (Actions::const_iterator, it, mActions)
{
const unsigned n = (*it).first;
if (n >= num && n < min)
@@ -107,8 +106,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant)
void SpriteDef::fixDeadAction()
{
- for (ActionsIter it = mActions.begin(), it_end = mActions.end();
- it != it_end; ++ it)
+ FOR_EACH (ActionsIter, it, mActions)
{
ActionMap *const d = (*it).second;
if (!d)
@@ -123,8 +121,7 @@ void SpriteDef::fixDeadAction()
void SpriteDef::substituteAction(std::string complete, std::string with)
{
- for (ActionsConstIter it = mActions.begin(), it_end = mActions.end();
- it != it_end; ++ it)
+ FOR_EACH (ActionsConstIter, it, mActions)
{
ActionMap *const d = (*it).second;
if (!d)
@@ -330,8 +327,7 @@ void SpriteDef::loadAnimation(const XmlNodePtr animationNode,
{
StringVect vals;
splitToStringVector(vals, value, ',');
- for (StringVectCIter it = vals.begin(), it_end = vals.end();
- it != it_end; ++ it)
+ FOR_EACH (StringVectCIter, it, vals)
{
std::string str = *it;
const size_t idx = str.find("-");
@@ -419,27 +415,19 @@ SpriteDef::~SpriteDef()
{
// Actions are shared, so ensure they are deleted only once.
std::set<Action*> actions;
- for (Actions::iterator i = mActions.begin(),
- i_end = mActions.end(); i != i_end; ++i)
+ FOR_EACH (Actions::iterator, i, mActions)
{
- for (ActionMap::iterator it = (*i).second->begin(),
- it_end = (*i).second->end(); it != it_end; ++ it)
- {
+ FOR_EACHP (ActionMap::iterator, it, (*i).second)
actions.insert(it->second);
- }
delete (*i).second;
}
- for (std::set<Action*>::const_iterator i = actions.begin(),
- i_end = actions.end(); i != i_end; ++i)
- {
+ FOR_EACH (std::set<Action*>::const_iterator, i, actions)
delete *i;
- }
mActions.clear();
- for (ImageSetIterator i = mImageSets.begin();
- i != mImageSets.end(); ++i)
+ FOR_EACH (ImageSetIterator, i, mImageSets)
{
if (i->second)
{
@@ -447,6 +435,7 @@ SpriteDef::~SpriteDef()
i->second = nullptr;
}
}
+ mImageSets.clear();
}
SpriteDirection SpriteDef::makeSpriteDirection(const std::string &direction)
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 32f4f1e10..381fe7466 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -142,9 +142,7 @@ std::string Wallpaper::getWallpaper(const int width, const int height)
// Wallpaper filename container
StringVect wallPaperVector;
- for (std::vector<WallpaperData>::const_iterator
- iter = wallpaperData.begin(), iter_end = wallpaperData.end();
- iter != iter_end; ++iter)
+ FOR_EACH (std::vector<WallpaperData>::const_iterator, iter, wallpaperData)
{
wp = *iter;
if (wp.width <= width && wp.height <= height)