diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-09-04 20:09:57 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-09-04 20:09:57 +0000 |
commit | ef36048760f80708ac1eaccbc2a21e7a700dc2ab (patch) | |
tree | adf7bde9971d56e55cdf1bb88880ccecc0451e6f | |
parent | fd3706906e3408b497c61dcc54294dee8e6dbaf7 (diff) | |
download | mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.gz mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.bz2 mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.tar.xz mana-client-ef36048760f80708ac1eaccbc2a21e7a700dc2ab.zip |
Introduced another template to make deleting all values in a container easier.
Inspired by qDeleteAll() from Qt.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/being.cpp | 3 | ||||
-rw-r--r-- | src/beingmanager.cpp | 3 | ||||
-rw-r--r-- | src/channelmanager.cpp | 3 | ||||
-rw-r--r-- | src/flooritemmanager.cpp | 4 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/shop.cpp | 4 | ||||
-rw-r--r-- | src/gui/skill.cpp | 4 | ||||
-rw-r--r-- | src/gui/windowcontainer.cpp | 4 | ||||
-rw-r--r-- | src/map.cpp | 9 | ||||
-rw-r--r-- | src/resources/imageset.cpp | 4 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 3 | ||||
-rw-r--r-- | src/resources/monsterinfo.cpp | 4 | ||||
-rw-r--r-- | src/utils/dtor.h | 7 |
14 files changed, 33 insertions, 33 deletions
@@ -1,3 +1,13 @@ +2008-09-04 Bjørn Lindeijer <bjorn@lindeijer.nl> + + * src/map.cpp, src/gui/setup.cpp, src/gui/shop.cpp, + src/gui/windowcontainer.cpp, src/gui/skill.cpp, src/beingmanager.cpp, + src/flooritemmanager.cpp, src/channelmanager.cpp, src/being.cpp, + src/utils/dtor.h, src/resources/imageset.cpp, + src/resources/monsterinfo.cpp, src/resources/itemdb.cpp: Introduced + another template to make deleting all values in a container easier. + Inspired by qDeleteAll() from Qt. + 2008-08-20 Roderic Morris <roderic@ccs.neu.edu> * src/gui/guildlistbox.cpp, src/gui/guildwindow.h, @@ -10,7 +20,7 @@ src/net/guildhandler.h, src/net/partyhandler.cpp, src/net/guildhandler.cpp, src/net/chatserver/party.cpp, src/net/chatserver/guild.cpp, src/net/chatserver/party.h, - src/net/chatserver/guild.h, src/winver.h: fix svn properties and + src/net/chatserver/guild.h, src/winver.h: Fix svn properties and id tags. 2008-08-19 Bjørn Lindeijer <bjorn@lindeijer.nl> diff --git a/src/being.cpp b/src/being.cpp index 2f7debfd..cf2e3772 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -22,7 +22,6 @@ */ #include "being.h" -#include <algorithm> #include <cassert> #include <cmath> @@ -84,7 +83,7 @@ Being::Being(int id, int job, Map *map): Being::~Being() { - std::for_each(mSprites.begin(), mSprites.end(), make_dtor(mSprites)); + delete_all(mSprites); clearPath(); for ( std::list<Particle *>::iterator i = mChildParticleEffects.begin(); diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 214a1995..a58c97e7 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -21,7 +21,6 @@ * $Id$ */ -#include <algorithm> #include <cassert> #include "beingmanager.h" @@ -148,7 +147,7 @@ void BeingManager::clear() mBeings.remove(player_node); } - for_each(mBeings.begin(), mBeings.end(), make_dtor(mBeings)); + delete_all(mBeings); mBeings.clear(); if (player_node) diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index 91c20e98..3c66f4bb 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -21,7 +21,6 @@ * $Id$ */ -#include <algorithm> #include <list> #include "channelmanager.h" @@ -36,7 +35,7 @@ ChannelManager::ChannelManager() ChannelManager::~ChannelManager() { - for_each(mChannels.begin(), mChannels.end(), make_dtor(mChannels)); + delete_all(mChannels); mChannels.clear(); } diff --git a/src/flooritemmanager.cpp b/src/flooritemmanager.cpp index 8a00cc51..c28755fb 100644 --- a/src/flooritemmanager.cpp +++ b/src/flooritemmanager.cpp @@ -21,8 +21,6 @@ * $Id$ */ -#include <algorithm> - #include "flooritemmanager.h" #include "floor_item.h" @@ -50,7 +48,7 @@ void FloorItemManager::destroy(FloorItem *item) void FloorItemManager::clear() { - for_each(mFloorItems.begin(), mFloorItems.end(), make_dtor(mFloorItems)); + delete_all(mFloorItems); mFloorItems.clear(); } diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 22b91ed4..53e7a9f1 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -92,7 +92,7 @@ Setup::Setup(): Setup::~Setup() { - for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); + delete_all(mTabs); } void Setup::action(const gcn::ActionEvent &event) diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index effe8858..c5e257da 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -25,8 +25,6 @@ #include "../utils/dtor.h" -#include <algorithm> - ShopItems::~ShopItems() { clear(); @@ -59,7 +57,7 @@ ShopItem* ShopItems::at(int i) void ShopItems::clear() { - std::for_each(mShopItems.begin(), mShopItems.end(), make_dtor(mShopItems)); + delete_all(mShopItems); mShopItems.clear(); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 6cc7a294..49037cbd 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -21,8 +21,6 @@ * $Id$ */ -#include <algorithm> - #include <guichan/widgets/label.hpp> #include <guichan/widgets/container.hpp> #include <guichan/widgets/icon.hpp> @@ -78,7 +76,7 @@ SkillDialog::SkillDialog(): SkillDialog::~SkillDialog() { - for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); + delete_all(mTabs); } void SkillDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/windowcontainer.cpp b/src/gui/windowcontainer.cpp index d10c519c..006dbf44 100644 --- a/src/gui/windowcontainer.cpp +++ b/src/gui/windowcontainer.cpp @@ -21,15 +21,13 @@ * $Id$ */ -#include <algorithm> - #include "windowcontainer.h" #include "../utils/dtor.h" void WindowContainer::logic() { - for_each(mDeathList.begin(), mDeathList.end(), make_dtor(mDeathList)); + delete_all(mDeathList); mDeathList.clear(); gcn::Container::logic(); diff --git a/src/map.cpp b/src/map.cpp index 28d07022..888ea3a8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -23,7 +23,6 @@ #include "map.h" -#include <algorithm> #include <queue> #include <cassert> @@ -161,13 +160,13 @@ Map::~Map() { // delete metadata, layers, tilesets and overlays delete[] mMetaTiles; - for (int i=0; i < NB_BLOCKTYPES; i++) + for (int i = 0; i < NB_BLOCKTYPES; i++) { delete[] mOccupation[i]; } - for_each(mLayers.begin(), mLayers.end(), make_dtor(mLayers)); - for_each(mTilesets.begin(), mTilesets.end(), make_dtor(mTilesets)); - for_each(mOverlays.begin(), mOverlays.end(), make_dtor(mOverlays)); + delete_all(mLayers); + delete_all(mTilesets); + delete_all(mOverlays); } void Map::initializeOverlays() diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 5618abfa..04faf0a3 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -21,8 +21,6 @@ * $Id$ */ -#include <algorithm> - #include "imageset.h" #include "../log.h" @@ -46,7 +44,7 @@ ImageSet::ImageSet(Image *img, int width, int height) ImageSet::~ImageSet() { - for_each(mImages.begin(), mImages.end(), make_dtor(mImages)); + delete_all(mImages); } Image* diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index ada9482f..202f4ba7 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -21,7 +21,6 @@ * $Id$ */ -#include <algorithm> #include <cassert> #include <libxml/tree.h> @@ -196,7 +195,7 @@ void ItemDB::unload() delete mUnknown; mUnknown = NULL; - for_each(mItemInfos.begin(), mItemInfos.end(), make_dtor(mItemInfos)); + delete_all(mItemInfos); mItemInfos.clear(); mLoaded = false; } diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 0af09c53..263810de 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -21,8 +21,6 @@ * $Id$ */ -#include <algorithm> - #include "monsterinfo.h" #include "../utils/dtor.h" @@ -35,7 +33,7 @@ MonsterInfo::MonsterInfo(): MonsterInfo::~MonsterInfo() { // kill vectors in mSoundEffects - for_each(mSounds.begin(), mSounds.end(), make_dtor(mSounds)); + delete_all(mSounds); mSounds.clear(); } diff --git a/src/utils/dtor.h b/src/utils/dtor.h index f2c6c1b8..516fd916 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -24,6 +24,7 @@ #ifndef _TMW_UTILS_DTOR_H #define _TMW_UTILS_DTOR_H +#include <algorithm> #include <functional> #include <utility> @@ -46,4 +47,10 @@ inline dtor<typename Cont::value_type> make_dtor(Cont const&) return dtor<typename Cont::value_type>(); } +template<typename Container> +inline void delete_all(Container &c) +{ + std::for_each(c.begin(), c.end(), make_dtor(c)); +} + #endif |