diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-29 01:18:47 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-29 01:18:47 +0000 |
commit | 40d6f3579a23c50a5570de3f511a407924703ec1 (patch) | |
tree | deba50e4749e2bcdf3bb7ff7bb2aa57ab1121178 /pokemod/Map.cpp | |
parent | 72e08e3222064d72d7a6f1bf9fcb294b22569c06 (diff) | |
download | sigen-40d6f3579a23c50a5570de3f511a407924703ec1.tar.gz sigen-40d6f3579a23c50a5570de3f511a407924703ec1.tar.xz sigen-40d6f3579a23c50a5570de3f511a407924703ec1.zip |
[FIX] Less repetative code in pokemod
[FIX] clear is no longer inline
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@115 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Map.cpp')
-rw-r--r-- | pokemod/Map.cpp | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index b97e414e..d1aece20 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -345,20 +345,23 @@ int Map::effectCount() const MapEffect* Map::newEffect() { - m_effects.append(new MapEffect(this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MapEffect(this, newEffectId())); } MapEffect* Map::newEffect(const QDomElement& xml) { - m_effects.append(new MapEffect(xml, this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MapEffect(xml, this, newEffectId())); } MapEffect* Map::newEffect(const MapEffect& effect) { - m_effects.append(new MapEffect(effect, this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MapEffect(effect, this, newEffectId())); +} + +MapEffect* Map::newEffect(MapEffect* effect) +{ + m_effects.append(effect); + return effect; } void Map::deleteEffect(const int index) throw(IndexException) @@ -423,20 +426,23 @@ int Map::trainerCount() const MapTrainer* Map::newTrainer() { - m_trainers.append(new MapTrainer(this, newTrainerId())); - return m_trainers[trainerCount() - 1]; + return newTrainer(new MapTrainer(this, newTrainerId())); } MapTrainer* Map::newTrainer(const QDomElement& xml) { - m_trainers.append(new MapTrainer(xml, this, newTrainerId())); - return m_trainers[trainerCount() - 1]; + return newTrainer(new MapTrainer(xml, this, newTrainerId())); } MapTrainer* Map::newTrainer(const MapTrainer& trainer) { - m_trainers.append(new MapTrainer(trainer, this, newTrainerId())); - return m_trainers[trainerCount() - 1]; + return newTrainer(new MapTrainer(trainer, this, newTrainerId())); +} + +MapTrainer* Map::newTrainer(MapTrainer* trainer) +{ + m_trainers.append(trainer); + return trainer; } void Map::deleteTrainer(const int index) throw(IndexException) @@ -501,20 +507,23 @@ int Map::warpCount() const MapWarp* Map::newWarp() { - m_warps.append(new MapWarp(this, newWarpId())); - return m_warps[warpCount() - 1]; + return newWarp(new MapWarp(this, newWarpId())); } MapWarp* Map::newWarp(const QDomElement& xml) { - m_warps.append(new MapWarp(xml, this, newWarpId())); - return m_warps[warpCount() - 1]; + return newWarp(new MapWarp(xml, this, newWarpId())); } MapWarp* Map::newWarp(const MapWarp& warp) { - m_warps.append(new MapWarp(warp, this, newWarpId())); - return m_warps[warpCount() - 1]; + return newWarp(new MapWarp(warp, this, newWarpId())); +} + +MapWarp* Map::newWarp(MapWarp* warp) +{ + m_warps.append(warp); + return warp; } void Map::deleteWarp(const int index) throw(IndexException) @@ -579,20 +588,23 @@ int Map::wildListCount() const MapWildList* Map::newWildList() { - m_wildLists.append(new MapWildList(this, newWildListId())); - return m_wildLists[wildListCount() - 1]; + return newWildList(new MapWildList(this, newWildListId())); } MapWildList* Map::newWildList(const QDomElement& xml) { - m_wildLists.append(new MapWildList(xml, this, newWildListId())); - return m_wildLists[wildListCount() - 1]; + return newWildList(new MapWildList(xml, this, newWildListId())); } MapWildList* Map::newWildList(const MapWildList& wildList) { - m_wildLists.append(new MapWildList(wildList, this, newWildListId())); - return m_wildLists[wildListCount() - 1]; + return newWildList(new MapWildList(wildList, this, newWildListId())); +} + +MapWildList* Map::newWildList(MapWildList* wildList) +{ + m_wildLists.append(wildList); + return wildList; } void Map::deleteWildList(const int index) throw(IndexException) @@ -631,3 +643,15 @@ Map& Map::operator=(const Map& rhs) COPY_SUB(MapWildList, wildLists); return *this; } + +void Map::clear() +{ + while (effectCount()) + deleteEffect(0); + while (trainerCount()) + deleteTrainer(0); + while (warpCount()) + deleteWarp(0); + while (wildListCount()) + deleteWildList(0); +} |