summaryrefslogtreecommitdiff
path: root/src/graphic/spriteset.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 19:13:26 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 19:13:26 +0000
commit405c23831a4e1363f26f848215c8140f6d6d9f78 (patch)
treeedf8b8838f055a1b5d024a3976b49f5cddfa8c50 /src/graphic/spriteset.cpp
parente645ad2a139c332937813dd2a1e5424ded182e26 (diff)
downloadmana-405c23831a4e1363f26f848215c8140f6d6d9f78.tar.gz
mana-405c23831a4e1363f26f848215c8140f6d6d9f78.tar.bz2
mana-405c23831a4e1363f26f848215c8140f6d6d9f78.tar.xz
mana-405c23831a4e1363f26f848215c8140f6d6d9f78.zip
Added a 'dtor' helper functor to delete objects in arrays and containers using STL algorithms.
Diffstat (limited to 'src/graphic/spriteset.cpp')
-rw-r--r--src/graphic/spriteset.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/graphic/spriteset.cpp b/src/graphic/spriteset.cpp
index e0a1ef36..96ba4313 100644
--- a/src/graphic/spriteset.cpp
+++ b/src/graphic/spriteset.cpp
@@ -25,13 +25,13 @@
#include "../resources/image.h"
+#include "../utils/dtor.h"
+
Spriteset::Spriteset(Image *img, int width, int height)
{
- int x, y;
-
- for (y = 0; y + height <= img->getHeight(); y += height)
+ for (int y = 0; y + height <= img->getHeight(); y += height)
{
- for (x = 0; x + width <= img->getWidth(); x += width)
+ for (int x = 0; x + width <= img->getWidth(); x += width)
{
spriteset.push_back(img->getSubImage(x, y, width, height));
}
@@ -40,7 +40,5 @@ Spriteset::Spriteset(Image *img, int width, int height)
Spriteset::~Spriteset()
{
- for (unsigned int i = 0; i < spriteset.size(); i++) {
- delete spriteset[i];
- }
+ for_each(spriteset.begin(), spriteset.end(), make_dtor(spriteset));
}