summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog8
-rw-r--r--general/Audio.cpp1
-rw-r--r--pokemod/Ability.cpp21
-rw-r--r--pokemod/Ability.h9
-rw-r--r--pokemod/AbilityEffect.h3
-rw-r--r--pokemod/Author.h3
-rw-r--r--pokemod/Badge.h3
-rw-r--r--pokemod/CoinList.cpp21
-rw-r--r--pokemod/CoinList.h9
-rw-r--r--pokemod/CoinListObject.h3
-rw-r--r--pokemod/Dialog.h3
-rw-r--r--pokemod/EggGroup.h3
-rw-r--r--pokemod/Item.cpp21
-rw-r--r--pokemod/Item.h9
-rw-r--r--pokemod/ItemEffect.h3
-rw-r--r--pokemod/ItemType.h3
-rw-r--r--pokemod/Map.cpp72
-rw-r--r--pokemod/Map.h21
-rw-r--r--pokemod/MapEffect.h3
-rw-r--r--pokemod/MapTrainer.cpp21
-rw-r--r--pokemod/MapTrainer.h9
-rw-r--r--pokemod/MapTrainerTeamMember.h3
-rw-r--r--pokemod/MapWarp.h3
-rw-r--r--pokemod/MapWildList.cpp21
-rw-r--r--pokemod/MapWildList.h9
-rw-r--r--pokemod/MapWildListEncounter.h3
-rw-r--r--pokemod/Move.cpp21
-rw-r--r--pokemod/Move.h9
-rw-r--r--pokemod/MoveEffect.h3
-rw-r--r--pokemod/Nature.h3
-rw-r--r--pokemod/Object.h4
-rw-r--r--pokemod/Pokemod.cpp307
-rw-r--r--pokemod/Pokemod.h73
-rw-r--r--pokemod/Rules.h3
-rw-r--r--pokemod/Species.cpp72
-rw-r--r--pokemod/Species.h21
-rw-r--r--pokemod/SpeciesAbility.h3
-rw-r--r--pokemod/SpeciesEvolution.h3
-rw-r--r--pokemod/SpeciesItem.h3
-rw-r--r--pokemod/SpeciesMove.h3
-rw-r--r--pokemod/Store.h3
-rw-r--r--pokemod/Tile.h3
-rw-r--r--pokemod/Time.h3
-rw-r--r--pokemod/Trainer.h3
-rw-r--r--pokemod/Type.h3
45 files changed, 469 insertions, 362 deletions
diff --git a/Changelog b/Changelog
index 88fe6077..3fbf2c55 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,12 @@
-----------------
+Rev: 115
+Date: 28 April 2008
+User: MathStuf
+-----------------
+[FIX] Less repetative code in pokemod
+[FIX] clear is no longer inline
+
+-----------------
Rev: 114
Date: 28 April 2008
User: MathStuf
diff --git a/general/Audio.cpp b/general/Audio.cpp
index 75b2e6fd..966cdd15 100644
--- a/general/Audio.cpp
+++ b/general/Audio.cpp
@@ -21,6 +21,7 @@
void Audio::playSFX(const QString& url) throw(OpenException)
{
Phonon::MediaObject* sfx = new Phonon::MediaObject();
+ Q_CHECK_PTR(sfx);
sfx->setCurrentSource(url);
if (sfx->state() == Phonon::ErrorState)
throw(OpenException("Audio", url));
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp
index b8560e2a..3b69d831 100644
--- a/pokemod/Ability.cpp
+++ b/pokemod/Ability.cpp
@@ -147,20 +147,23 @@ int Ability::effectCount() const
AbilityEffect* Ability::newEffect()
{
- m_effects.append(new AbilityEffect(this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new AbilityEffect(this, effectId()));
}
AbilityEffect* Ability::newEffect(const QDomElement& xml)
{
- m_effects.append(new AbilityEffect(xml, this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new AbilityEffect(xml, this, effectId()));
}
AbilityEffect* Ability::newEffect(const AbilityEffect& effect)
{
- m_effects.append(new AbilityEffect(effect, this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new AbilityEffect(effect, this, effectId()));
+}
+
+AbilityEffect* Ability::newEffect(AbilityEffect* effect)
+{
+ m_effects.append(effect);
+ return effect;
}
void Ability::deleteEffect(const int index) throw(IndexException)
@@ -193,3 +196,9 @@ Ability& Ability::operator=(const Ability& rhs)
COPY_SUB(AbilityEffect, effects);
return *this;
}
+
+void Ability::clear()
+{
+ while (effectCount())
+ deleteEffect(0);
+}
diff --git a/pokemod/Ability.h b/pokemod/Ability.h
index 6a845dc4..827befc3 100644
--- a/pokemod/Ability.h
+++ b/pokemod/Ability.h
@@ -61,12 +61,11 @@ class Ability : public Object
Ability& operator=(const Ability& rhs);
private:
bool validate() const;
+
int effectId() const;
- void clear()
- {
- while (effectCount())
- deleteEffect(0);
- }
+ AbilityEffect* newEffect(AbilityEffect* effect);
+
+ void clear();
QString m_name;
QList<AbilityEffect*> m_effects;
diff --git a/pokemod/AbilityEffect.h b/pokemod/AbilityEffect.h
index 424deff4..676de59b 100644
--- a/pokemod/AbilityEffect.h
+++ b/pokemod/AbilityEffect.h
@@ -142,9 +142,6 @@ class AbilityEffect : public Object
AbilityEffect& operator=(const AbilityEffect& rhs);
private:
bool validate() const;
- void clear()
- {
- }
Fraction m_chance;
int m_effect;
diff --git a/pokemod/Author.h b/pokemod/Author.h
index ec6d2e85..6eceeecb 100644
--- a/pokemod/Author.h
+++ b/pokemod/Author.h
@@ -43,9 +43,6 @@ class Author : public Object
Author& operator=(const Author& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
QString m_email;
diff --git a/pokemod/Badge.h b/pokemod/Badge.h
index 80bb46fb..8ce82128 100644
--- a/pokemod/Badge.h
+++ b/pokemod/Badge.h
@@ -57,9 +57,6 @@ class Badge : public Object
Badge& operator=(const Badge& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
QPixmap m_face;
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp
index a2140cd1..10544a69 100644
--- a/pokemod/CoinList.cpp
+++ b/pokemod/CoinList.cpp
@@ -205,20 +205,23 @@ int CoinList::objectCount() const
CoinListObject* CoinList::newObject()
{
- m_objects.append(new CoinListObject(this, objectId()));
- return m_objects[objectCount() - 1];
+ return newObject(new CoinListObject(this, objectId()));
}
CoinListObject* CoinList::newObject(const QDomElement& xml)
{
- m_objects.append(new CoinListObject(xml, this, objectId()));
- return m_objects[objectCount() - 1];
+ return newObject(new CoinListObject(xml, this, objectId()));
}
CoinListObject* CoinList::newObject(const CoinListObject& object)
{
- m_objects.append(new CoinListObject(object, this, objectId()));
- return m_objects[objectCount() - 1];
+ return newObject(new CoinListObject(object, this, objectId()));
+}
+
+CoinListObject* CoinList::newObject(CoinListObject* object)
+{
+ m_objects.append(object);
+ return object;
}
void CoinList::deleteObject(const int index) throw(IndexException)
@@ -251,3 +254,9 @@ CoinList& CoinList::operator=(const CoinList& rhs)
COPY_SUB(CoinListObject, objects);
return *this;
}
+
+void CoinList::clear()
+{
+ while (objectCount())
+ deleteObject(0);
+}
diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h
index 8bd28efb..cd30e41b 100644
--- a/pokemod/CoinList.h
+++ b/pokemod/CoinList.h
@@ -63,12 +63,11 @@ class CoinList : public Object
CoinList& operator=(const CoinList& rhs);
private:
bool validate() const;
+
int objectId() const;
- void clear()
- {
- while (objectCount())
- deleteObject(0);
- }
+ CoinListObject* newObject(CoinListObject* object);
+
+ void clear();
QString m_name;
int m_value;
diff --git a/pokemod/CoinListObject.h b/pokemod/CoinListObject.h
index 4d77c59e..6a0e2f41 100644
--- a/pokemod/CoinListObject.h
+++ b/pokemod/CoinListObject.h
@@ -56,9 +56,6 @@ class CoinListObject : public Object
CoinListObject& operator=(const CoinListObject& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_type;
int m_object;
diff --git a/pokemod/Dialog.h b/pokemod/Dialog.h
index 99925f10..0146a541 100644
--- a/pokemod/Dialog.h
+++ b/pokemod/Dialog.h
@@ -103,9 +103,6 @@ class Dialog : public Object
Dialog& operator=(const Dialog& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_dialog;
};
diff --git a/pokemod/EggGroup.h b/pokemod/EggGroup.h
index 928ff005..89a9d342 100644
--- a/pokemod/EggGroup.h
+++ b/pokemod/EggGroup.h
@@ -42,9 +42,6 @@ class EggGroup : public Object
EggGroup& operator=(const EggGroup& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
};
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp
index 90d0262e..21d3c118 100644
--- a/pokemod/Item.cpp
+++ b/pokemod/Item.cpp
@@ -213,20 +213,23 @@ int Item::effectCount() const
ItemEffect* Item::newEffect()
{
- m_effects.append(new ItemEffect(this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new ItemEffect(this, effectId()));
}
ItemEffect* Item::newEffect(const QDomElement& xml)
{
- m_effects.append(new ItemEffect(xml, this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new ItemEffect(xml, this, effectId()));
}
ItemEffect* Item::newEffect(const ItemEffect& effect)
{
- m_effects.append(new ItemEffect(effect, this, effectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new ItemEffect(effect, this, effectId()));
+}
+
+ItemEffect* Item::newEffect(ItemEffect* effect)
+{
+ m_effects.append(effect);
+ return effect;
}
void Item::deleteEffect(const int index) throw(IndexException)
@@ -263,3 +266,9 @@ Item& Item::operator=(const Item& rhs)
COPY_SUB(ItemEffect, effects);
return *this;
}
+
+void Item::clear()
+{
+ while (effectCount())
+ deleteEffect(0);
+}
diff --git a/pokemod/Item.h b/pokemod/Item.h
index cb33c522..fb0f1fae 100644
--- a/pokemod/Item.h
+++ b/pokemod/Item.h
@@ -69,12 +69,11 @@ class Item : public Object
Item& operator=(const Item& rhs);
private:
bool validate() const;
+
int effectId() const;
- void clear()
- {
- while (effectCount())
- deleteEffect(0);
- }
+ ItemEffect* newEffect(ItemEffect* effect);
+
+ void clear();
QString m_name;
bool m_sellable;
diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h
index 1a7b6501..3fa128c1 100644
--- a/pokemod/ItemEffect.h
+++ b/pokemod/ItemEffect.h
@@ -159,9 +159,6 @@ class ItemEffect : public Object
ItemEffect& operator=(const ItemEffect& rhs);
private:
bool validate() const;
- void clear()
- {
- }
bool m_overworld;
bool m_battle;
diff --git a/pokemod/ItemType.h b/pokemod/ItemType.h
index 7106bfcb..3437bfa8 100644
--- a/pokemod/ItemType.h
+++ b/pokemod/ItemType.h
@@ -56,9 +56,6 @@ class ItemType : public Object
ItemType& operator=(const ItemType& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
int m_computer;
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);
+}
diff --git a/pokemod/Map.h b/pokemod/Map.h
index 23dc0244..cc18040f 100644
--- a/pokemod/Map.h
+++ b/pokemod/Map.h
@@ -128,21 +128,20 @@ class Map : public Object
Map& operator=(const Map& rhs);
private:
bool validate() const;
+
int newEffectId() const;
+ MapEffect* newEffect(MapEffect* effect);
+
int newTrainerId() const;
+ MapTrainer* newTrainer(MapTrainer* trainer);
+
int newWarpId() const;
+ MapWarp* newWarp(MapWarp* warp);
+
int newWildListId() const;
- void clear()
- {
- while (effectCount())
- deleteEffect(0);
- while (trainerCount())
- deleteTrainer(0);
- while (warpCount())
- deleteWarp(0);
- while (wildListCount())
- deleteWildList(0);
- }
+ MapWildList* newWildList(MapWildList* wildList);
+
+ void clear();
QString m_name;
int m_flyWarp;
diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h
index 9db65a2e..c52a3c2c 100644
--- a/pokemod/MapEffect.h
+++ b/pokemod/MapEffect.h
@@ -90,9 +90,6 @@ class MapEffect : public Object
MapEffect& operator=(const MapEffect& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
Point m_coordinate;
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp
index 11c0209f..93ae61cc 100644
--- a/pokemod/MapTrainer.cpp
+++ b/pokemod/MapTrainer.cpp
@@ -289,20 +289,23 @@ int MapTrainer::teamMemberCount() const
MapTrainerTeamMember* MapTrainer::newTeamMember()
{
- m_teamMember.append(new MapTrainerTeamMember(this, newTeamMemberId()));
- return m_teamMember[teamMemberCount() - 1];
+ return newTeamMember(new MapTrainerTeamMember(this, newTeamMemberId()));
}
MapTrainerTeamMember* MapTrainer::newTeamMember(const QDomElement& xml)
{
- m_teamMember.append(new MapTrainerTeamMember(xml, this, newTeamMemberId()));
- return m_teamMember[teamMemberCount() - 1];
+ return newTeamMember(new MapTrainerTeamMember(xml, this, newTeamMemberId()));
}
MapTrainerTeamMember* MapTrainer::newTeamMember(const MapTrainerTeamMember& teamMember)
{
- m_teamMember.append(new MapTrainerTeamMember(teamMember, this, newTeamMemberId()));
- return m_teamMember[teamMemberCount() - 1];
+ return newTeamMember(new MapTrainerTeamMember(teamMember, this, newTeamMemberId()));
+}
+
+MapTrainerTeamMember* MapTrainer::newTeamMember(MapTrainerTeamMember* teamMember)
+{
+ m_teamMember.append(teamMember);
+ return teamMember;
}
void MapTrainer::deleteTeamMember(const int index) throw(IndexException)
@@ -343,3 +346,9 @@ MapTrainer& MapTrainer::operator=(const MapTrainer& rhs)
COPY_SUB(MapTrainerTeamMember, teamMember);
return *this;
}
+
+void MapTrainer::clear()
+{
+ while (teamMemberCount())
+ deleteTeamMember(0);
+}
diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h
index 1011a6a5..12e2471b 100644
--- a/pokemod/MapTrainer.h
+++ b/pokemod/MapTrainer.h
@@ -79,12 +79,11 @@ class MapTrainer : public Object
MapTrainer& operator=(const MapTrainer& rhs);
private:
bool validate() const;
+
int newTeamMemberId() const;
- void clear()
- {
- while (teamMemberCount())
- deleteTeamMember(0);
- }
+ MapTrainerTeamMember* newTeamMember(MapTrainerTeamMember* teamMember);
+
+ void clear();
QString m_name;
int m_trainerClass;
diff --git a/pokemod/MapTrainerTeamMember.h b/pokemod/MapTrainerTeamMember.h
index 2b899574..ffcca93c 100644
--- a/pokemod/MapTrainerTeamMember.h
+++ b/pokemod/MapTrainerTeamMember.h
@@ -51,9 +51,6 @@ class MapTrainerTeamMember : public Object
MapTrainerTeamMember& operator=(const MapTrainerTeamMember& p);
private:
bool validate() const;
- void clear()
- {
- }
int m_species;
int m_level;
diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h
index 75a2d136..678f4408 100644
--- a/pokemod/MapWarp.h
+++ b/pokemod/MapWarp.h
@@ -77,9 +77,6 @@ class MapWarp : public Object
MapWarp& operator=(const MapWarp& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
Point m_coordinate;
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 3aa51d85..5c866aef 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -277,20 +277,23 @@ int MapWildList::encounterCount() const
MapWildListEncounter* MapWildList::newEncounter()
{
- m_encounters.append(new MapWildListEncounter(this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(this, newEncounterId()));
}
MapWildListEncounter* MapWildList::newEncounter(const QDomElement& xml)
{
- m_encounters.append(new MapWildListEncounter(xml, this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(xml, this, newEncounterId()));
}
MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& encounter)
{
- m_encounters.append(new MapWildListEncounter(encounter, this, newEncounterId()));
- return m_encounters[encounterCount() - 1];
+ return newEncounter(new MapWildListEncounter(encounter, this, newEncounterId()));
+}
+
+MapWildListEncounter* MapWildList::newEncounter(MapWildListEncounter* encounter)
+{
+ m_encounters.append(encounter);
+ return encounter;
}
void MapWildList::deleteEncounter(const int index) throw(IndexException)
@@ -326,3 +329,9 @@ MapWildList& MapWildList::operator=(const MapWildList& rhs)
COPY_SUB(MapWildListEncounter, encounters);
return *this;
}
+
+void MapWildList::clear()
+{
+ while (encounterCount())
+ deleteEncounter(0);
+}
diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h
index 866d5c52..8e3e340d 100644
--- a/pokemod/MapWildList.h
+++ b/pokemod/MapWildList.h
@@ -79,12 +79,11 @@ class MapWildList : public Object
MapWildList& operator=(const MapWildList& rhs);
private:
bool validate() const;
+
int newEncounterId() const;
- void clear()
- {
- while (encounterCount())
- deleteEncounter(0);
- }
+ MapWildListEncounter* newEncounter(MapWildListEncounter* encounter);
+
+ void clear();
int m_control;
int m_value;
diff --git a/pokemod/MapWildListEncounter.h b/pokemod/MapWildListEncounter.h
index 46c62afe..800b5855 100644
--- a/pokemod/MapWildListEncounter.h
+++ b/pokemod/MapWildListEncounter.h
@@ -46,9 +46,6 @@ class MapWildListEncounter: public Object
MapWildListEncounter& operator=(const MapWildListEncounter& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_species;
int m_level;
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
index 20e49c21..1c676eac 100644
--- a/pokemod/Move.cpp
+++ b/pokemod/Move.cpp
@@ -368,20 +368,23 @@ int Move::effectCount() const
MoveEffect* Move::newEffect()
{
- m_effects.append(new MoveEffect(this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(this, newEffectId()));
}
MoveEffect* Move::newEffect(const QDomElement& xml)
{
- m_effects.append(new MoveEffect(xml, this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(xml, this, newEffectId()));
}
MoveEffect* Move::newEffect(const MoveEffect& effect)
{
- m_effects.append(new MoveEffect(effect, this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(effect, this, newEffectId()));
+}
+
+MoveEffect* Move::newEffect(MoveEffect* effect)
+{
+ m_effects.append(effect);
+ return effect;
}
void Move::deleteEffect(const int index) throw(IndexException)
@@ -428,3 +431,9 @@ Move& Move::operator=(const Move& rhs)
COPY_SUB(MoveEffect, effects);
return *this;
}
+
+void Move::clear()
+{
+ while (effectCount())
+ deleteEffect(0);
+}
diff --git a/pokemod/Move.h b/pokemod/Move.h
index 576a4346..0e893726 100644
--- a/pokemod/Move.h
+++ b/pokemod/Move.h
@@ -111,12 +111,11 @@ class Move : public Object
Move& operator=(const Move& rhs);
private:
bool validate() const;
+
int newEffectId() const;
- void clear()
- {
- while (effectCount())
- deleteEffect(0);
- }
+ MoveEffect* newEffect(MoveEffect* effect);
+
+ void clear();
QString m_name;
Fraction m_accuracy;
diff --git a/pokemod/MoveEffect.h b/pokemod/MoveEffect.h
index 20c81fd9..93b13857 100644
--- a/pokemod/MoveEffect.h
+++ b/pokemod/MoveEffect.h
@@ -130,9 +130,6 @@ class MoveEffect : public Object
MoveEffect& operator=(const MoveEffect& rhs);
private:
bool validate() const;
- void clear()
- {
- }
Fraction m_chance;
int m_effect;
diff --git a/pokemod/Nature.h b/pokemod/Nature.h
index fd646f9d..c6c007a1 100644
--- a/pokemod/Nature.h
+++ b/pokemod/Nature.h
@@ -48,9 +48,6 @@ class Nature : public Object
Nature& operator=(const Nature& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
Fraction m_stat[Pokemod::ST_End_GSC];
diff --git a/pokemod/Object.h b/pokemod/Object.h
index fc13dc6e..82d18800 100644
--- a/pokemod/Object.h
+++ b/pokemod/Object.h
@@ -91,7 +91,9 @@ class Object
m_valid = false;
warning<T>(message);
}
- virtual void clear() = 0;
+ virtual void clear()
+ {
+ }
private:
int m_id;
const QString m_className;
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index 77ed6011..abb6f482 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -702,20 +702,23 @@ int Pokemod::abilityCount() const
Ability* Pokemod::newAbility()
{
- m_abilities.append(new Ability(this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(this, newAbilityId()));
}
Ability* Pokemod::newAbility(const QDomElement& xml)
{
- m_abilities.append(new Ability(xml, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(xml, this, newAbilityId()));
}
Ability* Pokemod::newAbility(const Ability& ability)
{
- m_abilities.append(new Ability(ability, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(ability, this, newAbilityId()));
+}
+
+Ability* Pokemod::newAbility(Ability* ability)
+{
+ m_abilities.append(ability);
+ return ability;
}
void Pokemod::deleteAbility(const int index) throw(IndexException)
@@ -780,20 +783,23 @@ int Pokemod::authorCount() const
Author* Pokemod::newAuthor()
{
- m_authors.append(new Author(this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(this, newAuthorId()));
}
Author* Pokemod::newAuthor(const QDomElement& xml)
{
- m_authors.append(new Author(xml, this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(xml, this, newAuthorId()));
}
Author* Pokemod::newAuthor(const Author& author)
{
- m_authors.append(new Author(author, this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(author, this, newAuthorId()));
+}
+
+Author* Pokemod::newAuthor(Author* author)
+{
+ m_authors.append(author);
+ return author;
}
void Pokemod::deleteAuthor(const int index) throw(IndexException)
@@ -858,20 +864,23 @@ int Pokemod::badgeCount() const
Badge* Pokemod::newBadge()
{
- m_badges.append(new Badge(this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(this, newBadgeId()));
}
Badge* Pokemod::newBadge(const QDomElement& xml)
{
- m_badges.append(new Badge(xml, this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(xml, this, newBadgeId()));
}
Badge* Pokemod::newBadge(const Badge& badge)
{
- m_badges.append(new Badge(badge, this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(badge, this, newBadgeId()));
+}
+
+Badge* Pokemod::newBadge(Badge* badge)
+{
+ m_badges.append(badge);
+ return badge;
}
void Pokemod::deleteBadge(const int index) throw(IndexException)
@@ -936,20 +945,23 @@ int Pokemod::coinListCount() const
CoinList* Pokemod::newCoinList()
{
- m_coinLists.append(new CoinList(this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(this, newCoinListId()));
}
CoinList* Pokemod::newCoinList(const QDomElement& xml)
{
- m_coinLists.append(new CoinList(xml, this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(xml, this, newCoinListId()));
}
CoinList* Pokemod::newCoinList(const CoinList& coinList)
{
- m_coinLists.append(new CoinList(coinList, this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(coinList, this, newCoinListId()));
+}
+
+CoinList* Pokemod::newCoinList(CoinList* coinList)
+{
+ m_coinLists.append(coinList);
+ return coinList;
}
void Pokemod::deleteCoinList(const int index) throw(IndexException)
@@ -1014,20 +1026,23 @@ int Pokemod::dialogCount() const
Dialog* Pokemod::newDialog()
{
- m_dialogs.append(new Dialog(this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(this, newDialogId()));
}
Dialog* Pokemod::newDialog(const QDomElement& xml)
{
- m_dialogs.append(new Dialog(xml, this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(xml, this, newDialogId()));
}
Dialog* Pokemod::newDialog(const Dialog& dialog)
{
- m_dialogs.append(new Dialog(dialog, this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(dialog, this, newDialogId()));
+}
+
+Dialog* Pokemod::newDialog(Dialog* dialog)
+{
+ m_dialogs.append(dialog);
+ return dialog;
}
void Pokemod::deleteDialog(const int index) throw(IndexException)
@@ -1092,20 +1107,23 @@ int Pokemod::eggGroupCount() const
EggGroup* Pokemod::newEggGroup()
{
- m_eggGroups.append(new EggGroup(this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(this, newEggGroupId()));
}
EggGroup* Pokemod::newEggGroup(const QDomElement& xml)
{
- m_eggGroups.append(new EggGroup(xml, this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(xml, this, newEggGroupId()));
}
EggGroup* Pokemod::newEggGroup(const EggGroup& eggGroup)
{
- m_eggGroups.append(new EggGroup(eggGroup, this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(eggGroup, this, newEggGroupId()));
+}
+
+EggGroup* Pokemod::newEggGroup(EggGroup* eggGroup)
+{
+ m_eggGroups.append(eggGroup);
+ return eggGroup;
}
void Pokemod::deleteEggGroup(const int index) throw(IndexException)
@@ -1170,20 +1188,23 @@ int Pokemod::itemCount() const
Item* Pokemod::newItem()
{
- m_items.append(new Item(this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(this, newItemId()));
}
Item* Pokemod::newItem(const QDomElement& xml)
{
- m_items.append(new Item(xml, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(xml, this, newItemId()));
}
Item* Pokemod::newItem(const Item& item)
{
- m_items.append(new Item(item, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(item, this, newItemId()));
+}
+
+Item* Pokemod::newItem(Item* item)
+{
+ m_items.append(item);
+ return item;
}
void Pokemod::deleteItem(const int index) throw(IndexException)
@@ -1248,20 +1269,23 @@ int Pokemod::itemTypeCount() const
ItemType* Pokemod::newItemType()
{
- m_itemTypes.append(new ItemType(this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(this, newItemTypeId()));
}
ItemType* Pokemod::newItemType(const QDomElement& xml)
{
- m_itemTypes.append(new ItemType(xml, this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(xml, this, newItemTypeId()));
}
ItemType* Pokemod::newItemType(const ItemType& itemType)
{
- m_itemTypes.append(new ItemType(itemType, this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(itemType, this, newItemTypeId()));
+}
+
+ItemType* Pokemod::newItemType(ItemType* itemType)
+{
+ m_itemTypes.append(itemType);
+ return itemType;
}
void Pokemod::deleteItemType(const int index) throw(IndexException)
@@ -1326,20 +1350,23 @@ int Pokemod::mapCount() const
Map* Pokemod::newMap()
{
- m_maps.append(new Map(this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(this, newMapId()));
}
Map* Pokemod::newMap(const QDomElement& xml)
{
- m_maps.append(new Map(xml, this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(xml, this, newMapId()));
}
Map* Pokemod::newMap(const Map& map)
{
- m_maps.append(new Map(map, this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(map, this, newMapId()));
+}
+
+Map* Pokemod::newMap(Map* map)
+{
+ m_maps.append(map);
+ return map;
}
void Pokemod::deleteMap(const int index) throw(IndexException)
@@ -1404,20 +1431,23 @@ int Pokemod::moveCount() const
Move* Pokemod::newMove()
{
- m_moves.append(new Move(this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(this, newMoveId()));
}
Move* Pokemod::newMove(const QDomElement& xml)
{
- m_moves.append(new Move(xml, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(xml, this, newMoveId()));
}
Move* Pokemod::newMove(const Move& move)
{
- m_moves.append(new Move(move, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(move, this, newMoveId()));
+}
+
+Move* Pokemod::newMove(Move* move)
+{
+ m_moves.append(move);
+ return move;
}
void Pokemod::deleteMove(const int index) throw(IndexException)
@@ -1482,20 +1512,23 @@ int Pokemod::natureCount() const
Nature* Pokemod::newNature()
{
- m_natures.append(new Nature(this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(this, newNatureId()));
}
Nature* Pokemod::newNature(const QDomElement& xml)
{
- m_natures.append(new Nature(xml, this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(xml, this, newNatureId()));
}
Nature* Pokemod::newNature(const Nature& nature)
{
- m_natures.append(new Nature(nature, this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(nature, this, newNatureId()));
+}
+
+Nature* Pokemod::newNature(Nature* nature)
+{
+ m_natures.append(nature);
+ return nature;
}
void Pokemod::deleteNature(const int index) throw(IndexException)
@@ -1560,20 +1593,23 @@ int Pokemod::speciesCount() const
Species* Pokemod::newSpecies()
{
- m_species.append(new Species(this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(this, newSpeciesId()));
}
Species* Pokemod::newSpecies(const QDomElement& xml)
{
- m_species.append(new Species(xml, this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(xml, this, newSpeciesId()));
}
Species* Pokemod::newSpecies(const Species& species)
{
- m_species.append(new Species(species, this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(species, this, newSpeciesId()));
+}
+
+Species* Pokemod::newSpecies(Species* species)
+{
+ m_species.append(species);
+ return species;
}
void Pokemod::deleteSpecies(const int index) throw(IndexException)
@@ -1638,20 +1674,23 @@ int Pokemod::storeCount() const
Store* Pokemod::newStore()
{
- m_stores.append(new Store(this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(this, newStoreId()));
}
Store* Pokemod::newStore(const QDomElement& xml)
{
- m_stores.append(new Store(xml, this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(xml, this, newStoreId()));
}
Store* Pokemod::newStore(const Store& store)
{
- m_stores.append(new Store(store, this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(store, this, newStoreId()));
+}
+
+Store* Pokemod::newStore(Store* store)
+{
+ m_stores.append(store);
+ return store;
}
void Pokemod::deleteStore(const int index) throw(IndexException)
@@ -1716,20 +1755,23 @@ int Pokemod::tileCount() const
Tile* Pokemod::newTile()
{
- m_tiles.append(new Tile(this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(this, newTileId()));
}
Tile* Pokemod::newTile(const QDomElement& xml)
{
- m_tiles.append(new Tile(xml, this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(xml, this, newTileId()));
}
Tile* Pokemod::newTile(const Tile& tile)
{
- m_tiles.append(new Tile(tile, this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(tile, this, newTileId()));
+}
+
+Tile* Pokemod::newTile(Tile* tile)
+{
+ m_tiles.append(tile);
+ return tile;
}
void Pokemod::deleteTile(const int index) throw(IndexException)
@@ -1794,20 +1836,23 @@ int Pokemod::timeCount() const
Time* Pokemod::newTime()
{
- m_times.append(new Time(this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(this, newTimeId()));
}
Time* Pokemod::newTime(const QDomElement& xml)
{
- m_times.append(new Time(xml, this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(xml, this, newTimeId()));
}
Time* Pokemod::newTime(const Time& time)
{
- m_times.append(new Time(time, this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(time, this, newTimeId()));
+}
+
+Time* Pokemod::newTime(Time* time)
+{
+ m_times.append(time);
+ return time;
}
void Pokemod::deleteTime(const int index) throw(IndexException)
@@ -1872,20 +1917,23 @@ int Pokemod::trainerCount() const
Trainer* Pokemod::newTrainer()
{
- m_trainers.append(new Trainer(this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(this, newTrainerId()));
}
Trainer* Pokemod::newTrainer(const QDomElement& xml)
{
- m_trainers.append(new Trainer(xml, this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(xml, this, newTrainerId()));
}
Trainer* Pokemod::newTrainer(const Trainer& trainer)
{
- m_trainers.append(new Trainer(trainer, this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(trainer, this, newTrainerId()));
+}
+
+Trainer* Pokemod::newTrainer(Trainer* trainer)
+{
+ m_trainers.append(trainer);
+ return trainer;
}
void Pokemod::deleteTrainer(const int index) throw(IndexException)
@@ -1950,32 +1998,21 @@ int Pokemod::typeCount() const
Type* Pokemod::newType()
{
- if (typeCount())
- {
- m_typeChart.addColumn(Fraction(1, 1));
- m_typeChart.addRow(Fraction(1, 1));
- }
- else
- m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(this, newTypeId()));
- return m_types[typeCount() - 1];
+ return newType(new Type(this, newTypeId()));
}
Type* Pokemod::newType(const QDomElement& xml)
{
- if (typeCount())
- {
- m_typeChart.addColumn(Fraction(1, 1));
- m_typeChart.addRow(Fraction(1, 1));
- }
- else
- m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(xml, this, newTypeId()));
- return m_types[typeCount() - 1];
+ return newType(new Type(xml, this, newTypeId()));
}
Type* Pokemod::newType(const Type& type)
{
+ return newType(new Type(type, this, newTypeId()));
+}
+
+Type* Pokemod::newType(Type* type)
+{
if (typeCount())
{
m_typeChart.addColumn(Fraction(1, 1));
@@ -1983,8 +2020,8 @@ Type* Pokemod::newType(const Type& type)
}
else
m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(type, this, newTypeId()));
- return m_types[typeCount() - 1];
+ m_types.append(type);
+ return type;
}
void Pokemod::deleteType(const int index) throw(IndexException)
@@ -2048,3 +2085,41 @@ Pokemod& Pokemod::operator=(const Pokemod& rhs)
COPY_SUB(Type, types);
return *this;
}
+
+void Pokemod::clear()
+{
+ while (abilityCount())
+ deleteAbility(0);
+ while (authorCount())
+ deleteAuthor(0);
+ while (badgeCount())
+ deleteBadge(0);
+ while (coinListCount())
+ deleteCoinList(0);
+ while (dialogCount())
+ deleteDialog(0);
+ while (eggGroupCount())
+ deleteEggGroup(0);
+ while (itemCount())
+ deleteItem(0);
+ while (itemTypeCount())
+ deleteItemType(0);
+ while (mapCount())
+ deleteMap(0);
+ while (moveCount())
+ deleteMove(0);
+ while (natureCount())
+ deleteNature(0);
+ while (speciesCount())
+ deleteSpecies(0);
+ while (storeCount())
+ deleteStore(0);
+ while (tileCount())
+ deleteTile(0);
+ while (timeCount())
+ deleteTime(0);
+ while (trainerCount())
+ deleteTrainer(0);
+ while (typeCount())
+ deleteType(0);
+}
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h
index b31a8f23..9acc1bb7 100644
--- a/pokemod/Pokemod.h
+++ b/pokemod/Pokemod.h
@@ -418,60 +418,59 @@ class Pokemod : public Object
QStringList* valOutput;
bool validate() const;
+
int newAbilityId() const;
+ Ability* newAbility(Ability* ability);
+
int newAuthorId() const;
+ Author* newAuthor(Author* author);
+
int newBadgeId() const;
+ Badge* newBadge(Badge* badge);
+
int newCoinListId() const;
+ CoinList* newCoinList(CoinList* coinList);
+
int newDialogId() const;
+ Dialog* newDialog(Dialog* dialog);
+
int newEggGroupId() const;
+ EggGroup* newEggGroup(EggGroup* eggGroup);
+
int newItemId() const;
+ Item* newItem(Item* item);
+
int newItemTypeId() const;
+ ItemType* newItemType(ItemType* itemType);
+
int newMapId() const;
+ Map* newMap(Map* map);
+
int newMoveId() const;
+ Move* newMove(Move* move);
+
int newNatureId() const;
+ Nature* newNature(Nature* nature);
+
int newSpeciesId() const;
+ Species* newSpecies(Species* species);
+
int newStoreId() const;
+ Store* newStore(Store* store);
+
int newTileId() const;
+ Tile* newTile(Tile* tile);
+
int newTimeId() const;
+ Time* newTime(Time* time);
+
int newTrainerId() const;
+ Trainer* newTrainer(Trainer* trainer);
+
int newTypeId() const;
- void clear()
- {
- while (abilityCount())
- deleteAbility(0);
- while (authorCount())
- deleteAuthor(0);
- while (badgeCount())
- deleteBadge(0);
- while (coinListCount())
- deleteCoinList(0);
- while (dialogCount())
- deleteDialog(0);
- while (eggGroupCount())
- deleteEggGroup(0);
- while (itemCount())
- deleteItem(0);
- while (itemTypeCount())
- deleteItemType(0);
- while (mapCount())
- deleteMap(0);
- while (moveCount())
- deleteMove(0);
- while (natureCount())
- deleteNature(0);
- while (speciesCount())
- deleteSpecies(0);
- while (storeCount())
- deleteStore(0);
- while (tileCount())
- deleteTile(0);
- while (timeCount())
- deleteTime(0);
- while (trainerCount())
- deleteTrainer(0);
- while (typeCount())
- deleteType(0);
- }
+ Type* newType(Type* type);
+
+ void clear();
void copyDir(const QString& src, const QString& dest) const;
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index 07716c58..39d9b2b0 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -95,9 +95,6 @@ class Rules : public Object
Rules& operator=(const Rules& rhs);
private:
bool validate() const;
- void clear()
- {
- }
bool m_genderAllowed;
bool m_breedingAllowed;
diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp
index f661d2af..a992f6e6 100644
--- a/pokemod/Species.cpp
+++ b/pokemod/Species.cpp
@@ -643,20 +643,23 @@ int Species::abilityCount() const
SpeciesAbility* Species::newAbility()
{
- m_abilities.append(new SpeciesAbility(this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new SpeciesAbility(this, newAbilityId()));
}
SpeciesAbility* Species::newAbility(const QDomElement& xml)
{
- m_abilities.append(new SpeciesAbility(xml, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new SpeciesAbility(xml, this, newAbilityId()));
}
SpeciesAbility* Species::newAbility(const SpeciesAbility& ability)
{
- m_abilities.append(new SpeciesAbility(ability, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new SpeciesAbility(ability, this, newAbilityId()));
+}
+
+SpeciesAbility* Species::newAbility(SpeciesAbility* ability)
+{
+ m_abilities.append(ability);
+ return ability;
}
void Species::deleteAbility(const int index) throw(IndexException)
@@ -721,20 +724,23 @@ int Species::evolutionCount() const
SpeciesEvolution* Species::newEvolution()
{
- m_evolutions.append(new SpeciesEvolution(this, newEvolutionId()));
- return m_evolutions[evolutionCount() - 1];
+ return newEvolution(new SpeciesEvolution(this, newEvolutionId()));
}
SpeciesEvolution* Species::newEvolution(const QDomElement& xml)
{
- m_evolutions.append(new SpeciesEvolution(xml, this, newEvolutionId()));
- return m_evolutions[evolutionCount() - 1];
+ return newEvolution(new SpeciesEvolution(xml, this, newEvolutionId()));
}
SpeciesEvolution* Species::newEvolution(const SpeciesEvolution& evolution)
{
- m_evolutions.append(new SpeciesEvolution(evolution, this, newEvolutionId()));
- return m_evolutions[evolutionCount() - 1];
+ return newEvolution(new SpeciesEvolution(evolution, this, newEvolutionId()));
+}
+
+SpeciesEvolution* Species::newEvolution(SpeciesEvolution* evolution)
+{
+ m_evolutions.append(evolution);
+ return evolution;
}
void Species::deleteEvolution(const int index) throw(IndexException)
@@ -799,20 +805,23 @@ int Species::itemCount() const
SpeciesItem* Species::newItem()
{
- m_items.append(new SpeciesItem(this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new SpeciesItem(this, newItemId()));
}
SpeciesItem* Species::newItem(const QDomElement& xml)
{
- m_items.append(new SpeciesItem(xml, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new SpeciesItem(xml, this, newItemId()));
}
SpeciesItem* Species::newItem(const SpeciesItem& item)
{
- m_items.append(new SpeciesItem(item, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new SpeciesItem(item, this, newItemId()));
+}
+
+SpeciesItem* Species::newItem(SpeciesItem* item)
+{
+ m_items.append(item);
+ return item;
}
void Species::deleteItem(const int index) throw(IndexException)
@@ -877,20 +886,23 @@ int Species::moveCount() const
SpeciesMove* Species::newMove()
{
- m_moves.append(new SpeciesMove(this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new SpeciesMove(this, newMoveId()));
}
SpeciesMove* Species::newMove(const QDomElement& xml)
{
- m_moves.append(new SpeciesMove(xml, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new SpeciesMove(xml, this, newMoveId()));
}
SpeciesMove* Species::newMove(const SpeciesMove& move)
{
- m_moves.append(new SpeciesMove(move, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new SpeciesMove(move, this, newMoveId()));
+}
+
+SpeciesMove* Species::newMove(SpeciesMove* move)
+{
+ m_moves.append(move);
+ return move;
}
void Species::deleteMove(const int index) throw(IndexException)
@@ -945,3 +957,15 @@ Species& Species::operator=(const Species& rhs)
COPY_SUB(SpeciesMove, moves);
return *this;
}
+
+void Species::clear()
+{
+ while (abilityCount())
+ deleteAbility(0);
+ while (evolutionCount())
+ deleteEvolution(0);
+ while (itemCount())
+ deleteItem(0);
+ while (moveCount())
+ deleteMove(0);
+}
diff --git a/pokemod/Species.h b/pokemod/Species.h
index 03eab49e..e17beb77 100644
--- a/pokemod/Species.h
+++ b/pokemod/Species.h
@@ -162,21 +162,20 @@ class Species : public Object
Species& operator=(const Species& rhs);
private:
bool validate() const;
+
int newAbilityId() const;
+ SpeciesAbility* newAbility(SpeciesAbility* ability);
+
int newEvolutionId() const;
+ SpeciesEvolution* newEvolution(SpeciesEvolution* evolution);
+
int newItemId() const;
+ SpeciesItem* newItem(SpeciesItem* item);
+
int newMoveId() const;
- void clear()
- {
- while (abilityCount())
- deleteAbility(0);
- while (evolutionCount())
- deleteEvolution(0);
- while (itemCount())
- deleteItem(0);
- while (moveCount())
- deleteMove(0);
- }
+ SpeciesMove* newMove(SpeciesMove* move);
+
+ void clear();
QString m_name;
bool m_baseStat[Pokemod::ST_End_GSC];
diff --git a/pokemod/SpeciesAbility.h b/pokemod/SpeciesAbility.h
index ef295364..6d3af954 100644
--- a/pokemod/SpeciesAbility.h
+++ b/pokemod/SpeciesAbility.h
@@ -44,9 +44,6 @@ class SpeciesAbility : public Object
SpeciesAbility& operator=(const SpeciesAbility& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_ability;
int m_weight;
diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h
index 0d954605..d9c94e38 100644
--- a/pokemod/SpeciesEvolution.h
+++ b/pokemod/SpeciesEvolution.h
@@ -74,9 +74,6 @@ class SpeciesEvolution : public Object
SpeciesEvolution& operator=(const SpeciesEvolution& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_species;
int m_style;
diff --git a/pokemod/SpeciesItem.h b/pokemod/SpeciesItem.h
index 0b9da2cc..1697e89b 100644
--- a/pokemod/SpeciesItem.h
+++ b/pokemod/SpeciesItem.h
@@ -44,9 +44,6 @@ class SpeciesItem : public Object
SpeciesItem& operator=(const SpeciesItem& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_item;
int m_weight;
diff --git a/pokemod/SpeciesMove.h b/pokemod/SpeciesMove.h
index d641798c..c483a42c 100644
--- a/pokemod/SpeciesMove.h
+++ b/pokemod/SpeciesMove.h
@@ -46,9 +46,6 @@ class SpeciesMove : public Object
SpeciesMove& operator=(const SpeciesMove& rhs);
private:
bool validate() const;
- void clear()
- {
- }
int m_move;
int m_level;
diff --git a/pokemod/Store.h b/pokemod/Store.h
index a13ca982..256b9697 100644
--- a/pokemod/Store.h
+++ b/pokemod/Store.h
@@ -47,9 +47,6 @@ class Store : public Object
Store& operator=(const Store& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
QList<int> m_items;
diff --git a/pokemod/Tile.h b/pokemod/Tile.h
index 2525aed8..d13a4b51 100644
--- a/pokemod/Tile.h
+++ b/pokemod/Tile.h
@@ -68,9 +68,6 @@ class Tile : public Object
Tile& operator=(const Tile& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
QPixmap m_sprite;
diff --git a/pokemod/Time.h b/pokemod/Time.h
index 00b2b6df..74998ac2 100644
--- a/pokemod/Time.h
+++ b/pokemod/Time.h
@@ -46,9 +46,6 @@ class Time : public Object
Time& operator=(const Time& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
int m_hour;
diff --git a/pokemod/Trainer.h b/pokemod/Trainer.h
index dabaf685..28e74239 100644
--- a/pokemod/Trainer.h
+++ b/pokemod/Trainer.h
@@ -51,9 +51,6 @@ class Trainer : public Object
Trainer& operator=(const Trainer& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
int m_moneyFactor;
diff --git a/pokemod/Type.h b/pokemod/Type.h
index 1d00dd51..8d8fc867 100644
--- a/pokemod/Type.h
+++ b/pokemod/Type.h
@@ -47,9 +47,6 @@ class Type : public Object
Type& operator=(const Type& rhs);
private:
bool validate() const;
- void clear()
- {
- }
QString m_name;
Fraction m_stab;