From 1e02a507f0b481465f5b47441479b98a81aee079 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 24 Feb 2008 22:36:40 +0000 Subject: [FIX] KTabWidget now used rather than QTabWidget (though this kills Qt Designer interaction :\ ) [FIX] Minor fixes in PokeModr class [DEL] Ref.{h, cpp} [FIX] Ref enumerations now in Pokemod class [FIX] new/delete used for subclasses in pokemod now [FIX] Inclusion hell in pokemod (should compile faster) [FIX] Spelling typos git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@82 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- Changelog | 13 + battle/Arena.h | 1 - battle/Pokemon.h | 1 - general/Flag.h | 2 - general/general.pro | 6 +- pokemod/Ability.cpp | 38 ++- pokemod/Ability.h | 5 +- pokemod/AbilityEffect.cpp | 30 +- pokemod/Badge.cpp | 29 +- pokemod/Badge.h | 8 +- pokemod/CoinList.cpp | 46 ++-- pokemod/CoinList.h | 5 +- pokemod/Item.cpp | 38 ++- pokemod/Item.h | 5 +- pokemod/ItemEffect.cpp | 26 +- pokemod/Map.cpp | 158 ++++++----- pokemod/Map.h | 17 +- pokemod/MapEffect.cpp | 4 +- pokemod/MapTrainer.cpp | 42 +-- pokemod/MapTrainer.h | 5 +- pokemod/MapWarp.cpp | 30 +- pokemod/MapWarp.h | 2 +- pokemod/MapWildList.cpp | 33 ++- pokemod/MapWildList.h | 5 +- pokemod/Move.cpp | 38 ++- pokemod/Move.h | 5 +- pokemod/MoveEffect.cpp | 6 +- pokemod/Nature.cpp | 16 +- pokemod/Nature.h | 3 +- pokemod/Pokemod.cpp | 589 ++++++++++++++++++++++------------------ pokemod/Pokemod.h | 162 ++++++++--- pokemod/Species.cpp | 174 ++++++------ pokemod/Species.h | 22 +- pokemod/SpeciesEvolution.cpp | 10 +- pokemod/TODO | 21 +- pokemod/Tile.cpp | 40 +-- pokemod/Tile.h | 3 +- pokemodr/BadgeUI.cpp | 7 +- pokemodr/MapWarpUI.cpp | 7 +- pokemodr/NatureUI.cpp | 3 +- pokemodr/PokeModr.cpp | 9 +- pokemodr/SpeciesEvolutionUI.cpp | 7 +- pokemodr/SpeciesUI.cpp | 5 +- pokemodr/TODO | 1 - pokemodr/TileUI.cpp | 11 +- pokemodr/gui/pokemod.ui | 7 +- pokemodr/gui/rules.ui | 7 +- pokemodr/gui/species.ui | 7 +- 48 files changed, 981 insertions(+), 728 deletions(-) diff --git a/Changelog b/Changelog index 99407b3e..203a7250 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,16 @@ +----------------- +Rev: 82 +Date: 24 February 2008 +User: MathStuf +----------------- +[FIX] KTabWidget now used rather than QTabWidget (though this kills Qt Designer interaction :\ ) +[FIX] Minor fixes in PokeModr class +[DEL] Ref.{h, cpp} +[FIX] Ref enumerations now in Pokemod class +[FIX] new/delete used for subclasses in pokemod now +[FIX] Inclusion hell in pokemod (should compile faster) +[FIX] Spelling typos + ----------------- Rev: 81 Date: 24 February 2008 diff --git a/battle/Arena.h b/battle/Arena.h index 0a3e7bd3..3745b065 100644 --- a/battle/Arena.h +++ b/battle/Arena.h @@ -26,7 +26,6 @@ #include #include "Pokemon.h" #include "Team.h" -#include "../gnereal/Ref.h" #include "pokemod/Ability.h" #include "pokemod/Item.h" #include "pokemod/MapTrainer.h" diff --git a/battle/Pokemon.h b/battle/Pokemon.h index f527b72b..5b5b7a8c 100644 --- a/battle/Pokemon.h +++ b/battle/Pokemon.h @@ -28,7 +28,6 @@ #include #include "../general/Frac.h" #include "../general/Ini.h" -#include "../general/Ref.h" #include "../pokemod/Ability.h" #include "../pokemod/Item.h" #include "../pokemod/Nature.h" diff --git a/general/Flag.h b/general/Flag.h index 90fd755e..1b7d5857 100644 --- a/general/Flag.h +++ b/general/Flag.h @@ -25,8 +25,6 @@ #include -#include "Ref.h" - class Flag { public: diff --git a/general/general.pro b/general/general.pro index f394982d..0a434644 100644 --- a/general/general.pro +++ b/general/general.pro @@ -51,8 +51,7 @@ SOURCES += Audio.cpp \ Flag.cpp \ Frac.cpp \ ImageCache.cpp \ - Ini.cpp \ - Ref.cpp + Ini.cpp HEADERS += Audio.h \ BugCatcher.h \ @@ -63,5 +62,4 @@ HEADERS += Audio.h \ ImageCache.h \ Ini.h \ Matrix.h \ - Point.h \ - Ref.h + Point.h diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 234d2dae..8cc1a319 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -29,6 +29,7 @@ #include #include "Pokemod.h" +#include "AbilityEffect.h" #include "Ability.h" Ability::Ability(const Pokemod* par, const int _id) : @@ -49,6 +50,12 @@ Ability::Ability(const Pokemod* par, const QString& fname, const int _id) : load(fname, _id); } +Ability::~Ability() +{ + for (QListIterator i(effects); i.hasNext(); ) + delete i.next(); +} + bool Ability::validate() const { bool valid = true; @@ -61,11 +68,11 @@ bool Ability::validate() const if (getEffectCount()) { QMap idChecker; - for (QListIterator i(effects); i.hasNext(); i.next()) + for (QListIterator i(effects); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -117,8 +124,8 @@ void Ability::save() const throw(Exception) ini.addField("id", id); ini.addField("name", name); ini.save(QString("%1/ability/%2/data.pini").arg(pokemod->getPath()).arg(name)); - for (QListIterator i(effects); i.hasNext(); ) - i.next().save(name); + for (QListIterator i(effects); i.hasNext(); ) + i.next()->save(name); } void Ability::setName(const QString& n) @@ -135,14 +142,14 @@ const AbilityEffect* Ability::getEffect(const int i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects.at(i); + return effects.at(i); } AbilityEffect* Ability::getEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects[i]; + return effects[i]; } const AbilityEffect* Ability::getEffectByID(const int i) const throw(IndexException) @@ -159,7 +166,7 @@ int Ability::getEffectIndex(const int _id) const { for (int i = 0; i < getEffectCount(); ++i) { - if (effects[i].getId() == _id) + if (effects[i]->getId() == _id) return i; } return -1; @@ -172,26 +179,27 @@ int Ability::getEffectCount() const AbilityEffect* Ability::newEffect() { - effects.append(AbilityEffect(pokemod, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new AbilityEffect(pokemod, getNewId())); + return effects[getEffectCount() - 1]; } AbilityEffect* Ability::newEffect(const QString& fname) { - effects.append(AbilityEffect(pokemod, fname, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new AbilityEffect(pokemod, fname, getNewId())); + return effects[getEffectCount() - 1]; } AbilityEffect* Ability::newEffect(const AbilityEffect& e) { - effects.append(AbilityEffect(pokemod, e, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new AbilityEffect(pokemod, e, getNewId())); + return effects[getEffectCount() - 1]; } void Ability::deleteEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); + delete effects[i]; effects.removeAt(i); } @@ -202,6 +210,6 @@ Ability& Ability::operator=(const Ability& rhs) name = rhs.name; effects.clear(); for (int i = 0; i < rhs.getEffectCount(); ++i) - effects.append(AbilityEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); + effects.append(new AbilityEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); return *this; } diff --git a/pokemod/Ability.h b/pokemod/Ability.h index 08532ba0..f1494bc3 100644 --- a/pokemod/Ability.h +++ b/pokemod/Ability.h @@ -30,8 +30,8 @@ #include #include "Object.h" -#include "AbilityEffect.h" +class AbilityEffect; class Pokemod; class Ability : public Object @@ -40,6 +40,7 @@ class Ability : public Object Ability(const Pokemod* par, const int _id); Ability(const Pokemod* par, const Ability& a, const int _id); Ability(const Pokemod* par, const QString& fname, const int _id = -1); + ~Ability(); void load(const QString& fname, const int _id = -1) throw(Exception); void save() const throw(Exception); @@ -66,7 +67,7 @@ class Ability : public Object QString name; - QList effects; + QList effects; }; #endif diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp index e0cc7f5c..c4f5c470 100644 --- a/pokemod/AbilityEffect.cpp +++ b/pokemod/AbilityEffect.cpp @@ -20,8 +20,6 @@ // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// -#include - #include "Pokemod.h" #include "Ability.h" #include "Type.h" @@ -72,11 +70,11 @@ bool AbilityEffect::validate() const switch (effect) { case E_Stats: - if ((ST_HP == val1) || (ST_End_Battle <= val1) || ((val1 == ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) + if ((Pokemod::ST_HP == val1) || (Pokemod::ST_End_Battle <= val1) || ((val1 == Pokemod::ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) ok = false; break; case E_Status: - if (STS_End <= val1) + if (Pokemod::STS_End <= val1) ok = false; break; case E_Ability: @@ -96,7 +94,7 @@ bool AbilityEffect::validate() const ok = false; break; case E_Weather: - if (W_End_All <= val1) + if (Pokemod::W_End_All <= val1) ok = false; break; } @@ -109,7 +107,7 @@ bool AbilityEffect::validate() const switch (effect) { case E_Stats: - if (BM_End <= val2) + if (Pokemod::BM_End <= val2) ok = false; break; case E_Status: @@ -168,7 +166,7 @@ bool AbilityEffect::validate() const switch (trigger) { case T_Weather: - if (W_End_All <= tval1) + if (Pokemod::W_End_All <= tval1) ok = false; break; case T_Type: @@ -180,11 +178,11 @@ bool AbilityEffect::validate() const ok = false; break; case T_StatChange: - if ((ST_HP == tval1) || (ST_End_Battle <= tval1) || ((tval1 == ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) + if ((Pokemod::ST_HP == tval1) || (Pokemod::ST_End_Battle <= tval1) || ((tval1 == Pokemod::ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) ok = false; break; case T_Status: - if (STS_End <= tval1) + if (Pokemod::STS_End <= tval1) ok = false; break; } @@ -272,11 +270,11 @@ void AbilityEffect::setVal1(const int v1) throw(Exception) switch (effect) { case E_Stats: - if ((ST_HP == val1) || (ST_End_Battle <= val1) || ((val1 == ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) + if ((Pokemod::ST_HP == val1) || (Pokemod::ST_End_Battle <= val1) || ((val1 == Pokemod::ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) throw(BoundsException(className, "val1")); break; case E_Status: - if (STS_End <= v1) + if (Pokemod::STS_End <= v1) throw(BoundsException(className, "val1")); break; case E_Ability: @@ -296,7 +294,7 @@ void AbilityEffect::setVal1(const int v1) throw(Exception) throw(BoundsException(className, "val1")); break; case E_Weather: - if (W_End_All <= v1) + if (Pokemod::W_End_All <= v1) throw(BoundsException(className, "val1")); break; default: @@ -311,7 +309,7 @@ void AbilityEffect::setVal2(const int v2) throw(Exception) switch (effect) { case E_Stats: - if (BM_End <= v2) + if (Pokemod::BM_End <= v2) throw(BoundsException(className, "val2")); break; case E_Status: @@ -374,7 +372,7 @@ void AbilityEffect::setTval1(const int tv1) throw(Exception) switch (trigger) { case T_Weather: - if (W_End_All <= tv1) + if (Pokemod::W_End_All <= tv1) throw(BoundsException(className, "tval1")); break; case T_Type: @@ -386,11 +384,11 @@ void AbilityEffect::setTval1(const int tv1) throw(Exception) throw(BoundsException(className, "tval1")); break; case T_StatChange: - if ((ST_HP == tval1) || (ST_End_Battle <= tval1) || ((tval1 == ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) + if ((Pokemod::ST_HP == tval1) || (Pokemod::ST_End_Battle <= tval1) || ((tval1 == Pokemod::ST_SpecialDefense) && !pokemod->getRules()->getSpecialSplit())) throw(BoundsException(className, "tval1")); break; case T_Status: - if (STS_End <= tv1) + if (Pokemod::STS_End <= tv1) throw(BoundsException(className, "tval1")); break; default: diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index cdc150d1..2868f93d 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -21,7 +21,6 @@ // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// -#include "Pokemod.h" #include "Badge.h" Badge::Badge(const Pokemod* par, const int _id) : @@ -29,9 +28,9 @@ Badge::Badge(const Pokemod* par, const int _id) : name(""), obey(0) { - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) stats[i].set(1, 1); - for (int i = 0; i < HM_End_All; ++i) + for (int i = 0; i < Pokemod::HM_End_All; ++i) hm[i] = false; } @@ -83,7 +82,7 @@ void Badge::load(const QString& fname, const int _id) throw(Exception) id = _id; ini.getValue("name", name); ini.getValue("obey", obey, 0); - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) { int j; int k; @@ -91,7 +90,7 @@ void Badge::load(const QString& fname, const int _id) throw(Exception) ini.getValue(QString("stats-%1-d").arg(i), k, 1); stats[i].set(j, k); } - for (int i = 0; i < HM_End_All; ++i) + for (int i = 0; i < Pokemod::HM_End_All; ++i) ini.getValue(QString("hm-%1").arg(i), hm[i], false); } @@ -101,12 +100,12 @@ void Badge::save() const throw(Exception) ini.addField("id", id); ini.addField("name", name); ini.addField("obey", obey); - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) { ini.addField(QString("stats-%1-n").arg(i), stats[i].getNum()); ini.addField(QString("stats-%1-d").arg(i), stats[i].getDenom()); } - for (int i = 0; i < HM_End_All; ++i) + for (int i = 0; i < Pokemod::HM_End_All; ++i) ini.addField(QString("hm-%1").arg(i), hm[i]); ini.save(QString("%1/badge/%2.pini").arg(pokemod->getPath()).arg(name)); } @@ -143,28 +142,28 @@ void Badge::setObey(const int o) throw(BoundsException) void Badge::setStat(const int s, const int n, const int d) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].set(n, d); } void Badge::setStatNum(const int s, const int n) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].setNum(n); } void Badge::setStatDenom(const int s, const int d) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].setDenom(d); } void Badge::setHm(const int h, const bool hb) throw(BoundsException) { - if (HM_End_All <= h) + if (Pokemod::HM_End_All <= h) throw(BoundsException(className, "hm")); hm[h] = hb; } @@ -191,14 +190,14 @@ int Badge::getObey() const Frac Badge::getStat(const int s) const throw(BoundsException) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); return stats[s]; } bool Badge::getHm(const int h) const throw(BoundsException) { - if (HM_End_All <= h) + if (Pokemod::HM_End_All <= h) throw(BoundsException(className, "hm")); return hm[h]; } @@ -209,9 +208,9 @@ Badge& Badge::operator=(const Badge& rhs) return *this; name = rhs.name; obey = rhs.obey; - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) stats[i] = rhs.stats[i]; - for (int i = 0; i < HM_End_All; ++i) + for (int i = 0; i < Pokemod::HM_End_All; ++i) hm[i] = rhs.hm[i]; return *this; } diff --git a/pokemod/Badge.h b/pokemod/Badge.h index 84c43256..c5c3bca5 100644 --- a/pokemod/Badge.h +++ b/pokemod/Badge.h @@ -29,11 +29,9 @@ #include #include -#include #include "Object.h" - -class Pokemod; +#include "Pokemod.h" class Badge : public Object { @@ -67,8 +65,8 @@ class Badge : public Object QString name; int obey; - Frac stats[ST_End_GSC]; - bool hm[HM_End_All]; + Frac stats[Pokemod::ST_End_GSC]; + bool hm[Pokemod::HM_End_All]; }; #endif diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 48bfbc5c..53002fa0 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -28,6 +28,7 @@ #include #include "Pokemod.h" +#include "CoinListObject.h" #include "Item.h" #include "ItemEffect.h" #include "CoinList.h" @@ -51,6 +52,12 @@ CoinList::CoinList(const Pokemod* par, const QString& fname, const int _id) : load(fname, _id); } +CoinList::~CoinList() +{ + for (QListIterator i(items); i.hasNext(); ) + delete i.next(); +} + bool CoinList::validate() const { bool valid = true; @@ -81,15 +88,15 @@ bool CoinList::validate() const QMap idChecker; QMap itemChecker; QMap speciesChecker; - for (QListIterator i(items); i.hasNext(); i.next()) + for (QListIterator i(items); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - if (i.peekNext().getType() == CoinListObject::Item) - ++itemChecker[i.peekNext().getObject()]; - else if (i.peekNext().getType() == CoinListObject::Species) - ++speciesChecker[i.peekNext().getObject()]; + ++idChecker[i.peekNext()->getId()]; + if (i.peekNext()->getType() == CoinListObject::Item) + ++itemChecker[i.peekNext()->getObject()]; + else if (i.peekNext()->getType() == CoinListObject::Species) + ++speciesChecker[i.peekNext()->getObject()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -159,8 +166,8 @@ void CoinList::save() const throw(Exception) ini.addField("name", name); ini.addField("value", value); ini.save(QString("%1/coinlist/%2/data.pini").arg(pokemod->getPath()).arg(name)); - for (QListIterator i(items); i.hasNext(); ) - i.next().save(name); + for (QListIterator i(items); i.hasNext(); ) + i.next()->save(name); } void CoinList::setName(const QString& n) @@ -200,14 +207,14 @@ const CoinListObject* CoinList::getItem(const int i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException(className)); - return &items.at(i); + return items.at(i); } CoinListObject* CoinList::getItem(const int i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException(className)); - return &items[i]; + return items[i]; } const CoinListObject* CoinList::getItemByID(const int i) const throw(IndexException) @@ -224,7 +231,7 @@ int CoinList::getItemIndex(const int _id) const { for (int i = 0; i < getItemCount(); ++i) { - if (items[i].getId() == _id) + if (items[i]->getId() == _id) return i; } return -1; @@ -237,26 +244,27 @@ int CoinList::getItemCount() const CoinListObject* CoinList::newItem() { - items.append(CoinListObject(pokemod, getNewId())); - return &items[getItemCount() - 1]; + items.append(new CoinListObject(pokemod, getNewId())); + return items[getItemCount() - 1]; } CoinListObject* CoinList::newItem(const QString& fname) { - items.append(CoinListObject(pokemod, fname, getNewId())); - return &items[getItemCount() - 1]; + items.append(new CoinListObject(pokemod, fname, getNewId())); + return items[getItemCount() - 1]; } CoinListObject* CoinList::newItem(const CoinListObject& o) { - items.append(CoinListObject(pokemod, o, getNewId())); - return &items[getItemCount() - 1]; + items.append(new CoinListObject(pokemod, o, getNewId())); + return items[getItemCount() - 1]; } void CoinList::deleteItem(const int i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException(className)); + delete items[i]; items.removeAt(i); } @@ -267,6 +275,6 @@ CoinList& CoinList::operator=(const CoinList& rhs) name = rhs.name; items.clear(); for (int i = 0; i < rhs.getItemCount(); ++i) - items.append(CoinListObject(pokemod, *rhs.getItem(i), rhs.getItem(i)->getId())); + items.append(new CoinListObject(pokemod, *rhs.getItem(i), rhs.getItem(i)->getId())); return *this; } diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h index 041177be..09e11aa0 100644 --- a/pokemod/CoinList.h +++ b/pokemod/CoinList.h @@ -30,8 +30,8 @@ #include #include "Object.h" -#include "CoinListObject.h" +class CoinListObject; class Pokemod; class CoinList : public Object @@ -40,6 +40,7 @@ class CoinList : public Object CoinList(const Pokemod* par, const int _id); CoinList(const Pokemod* par, const CoinList& c, const int _id); CoinList(const Pokemod* par, const QString& fname, const int _id = -1); + ~CoinList(); void load(const QString& fname, const int _id = -1) throw(Exception); void save() const throw(Exception); @@ -69,7 +70,7 @@ class CoinList : public Object QString name; int value; - QList items; + QList items; }; #endif diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp index f6293cf7..f2a594d6 100644 --- a/pokemod/Item.cpp +++ b/pokemod/Item.cpp @@ -28,6 +28,7 @@ #include #include "Pokemod.h" +#include "ItemEffect.h" #include "Item.h" Item::Item(const Pokemod* par, const int _id) : @@ -52,6 +53,12 @@ Item::Item(const Pokemod* par, const QString& fname, const int _id) : load(fname, _id); } +Item::~Item() +{ + for (QListIterator i(effects); i.hasNext(); ) + delete i.next(); +} + bool Item::validate() const { bool valid = true; @@ -74,11 +81,11 @@ bool Item::validate() const if (getEffectCount()) { QMap idChecker; - for (QListIterator i(effects); i.hasNext(); i.next()) + for (QListIterator i(effects); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -138,8 +145,8 @@ void Item::save() const throw(Exception) ini.addField("price", price); ini.addField("description", description); ini.save(QString("%1/item/%2/data.pini").arg(pokemod->getPath()).arg(name)); - for (QListIterator i(effects); i.hasNext(); ) - i.next().save(name); + for (QListIterator i(effects); i.hasNext(); ) + i.next()->save(name); } void Item::setName(const QString& n) @@ -200,14 +207,14 @@ const ItemEffect* Item::getEffect(const int i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects.at(i); + return effects.at(i); } ItemEffect* Item::getEffectByID(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects[i]; + return effects[i]; } const ItemEffect* Item::getEffectByID(const int i) const throw(IndexException) @@ -224,7 +231,7 @@ int Item::getEffectIndex(const int _id) const { for (int i = 0; i < getEffectCount(); ++i) { - if (effects[i].getId() == _id) + if (effects[i]->getId() == _id) return i; } return -1; @@ -237,26 +244,27 @@ int Item::getEffectCount() const ItemEffect* Item::newEffect() { - effects.append(ItemEffect(pokemod, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new ItemEffect(pokemod, getNewId())); + return effects[getEffectCount() - 1]; } ItemEffect* Item::newEffect(const QString& fname) { - effects.append(ItemEffect(pokemod, fname, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new ItemEffect(pokemod, fname, getNewId())); + return effects[getEffectCount() - 1]; } ItemEffect* Item::newEffect(const ItemEffect& e) { - effects.append(ItemEffect(pokemod, e, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new ItemEffect(pokemod, e, getNewId())); + return effects[getEffectCount() - 1]; } void Item::deleteEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); + delete effects[i]; effects.removeAt(i); } @@ -271,6 +279,6 @@ Item& Item::operator=(const Item& rhs) description = rhs.description; effects.clear(); for (int i = 0; i < rhs.getEffectCount(); ++i) - effects.append(ItemEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); + effects.append(new ItemEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); return *this; } diff --git a/pokemod/Item.h b/pokemod/Item.h index 9a040789..d5d4e087 100644 --- a/pokemod/Item.h +++ b/pokemod/Item.h @@ -29,8 +29,8 @@ #include #include "Object.h" -#include "ItemEffect.h" +class ItemEffect; class Pokemod; class Item : public Object @@ -39,6 +39,7 @@ class Item : public Object Item(const Pokemod* par, const int _id); Item(const Pokemod* par, const Item& i, const int _id); Item(const Pokemod* par, const QString& fname, const int _id = -1); + ~Item(); void load(const QString& fname, const int _id = -1) throw(Exception); void save() const throw(Exception); @@ -77,7 +78,7 @@ class Item : public Object int price; QString description; - QList effects; + QList effects; }; #endif diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp index 29363252..d2e5b2d2 100644 --- a/pokemod/ItemEffect.cpp +++ b/pokemod/ItemEffect.cpp @@ -20,8 +20,6 @@ // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// -#include - #include "Pokemod.h" #include "MapWildList.h" #include "ItemEffect.h" @@ -173,7 +171,7 @@ bool ItemEffect::validate() const ok = false; break; case E_CureStatus: - if (STS_End <= val2) + if (Pokemod::STS_End <= val2) ok = false; break; case E_StatBoost: @@ -181,7 +179,7 @@ bool ItemEffect::validate() const ok = false; break; case E_ModifyStatBattle: - if (ST_End_Battle <= val2) + if (Pokemod::ST_End_Battle <= val2) ok = false; break; case E_ShieldBattle: @@ -236,7 +234,7 @@ bool ItemEffect::validate() const switch (effect) { case E_StatBoost: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val3) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= val3) ok = false; break; case E_Ball: @@ -259,7 +257,7 @@ bool ItemEffect::validate() const ok = false; break; case B_Stat: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val3) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= val3) ok = false; break; case B_Type: @@ -272,11 +270,11 @@ bool ItemEffect::validate() const switch (val2) { case B2_HPCure: - if (REL_End <= val3) + if (Pokemod::REL_End <= val3) ok = false; break; case B2_StatusCure: - if (STS_End <= val3) + if (Pokemod::STS_End <= val3) ok = false; break; default: @@ -505,7 +503,7 @@ void ItemEffect::setVal2(const int v2) throw(Exception) throw(BoundsException(className, "val2")); break; case E_CureStatus: - if (STS_End <= val2) + if (Pokemod::STS_End <= val2) throw(BoundsException(className, "val2")); break; case E_StatBoost: @@ -513,7 +511,7 @@ void ItemEffect::setVal2(const int v2) throw(Exception) throw(BoundsException(className, "val2")); break; case E_ModifyStatBattle: - if (ST_End_Battle <= val2) + if (Pokemod::ST_End_Battle <= val2) throw(BoundsException(className, "val2")); break; case E_ShieldBattle: @@ -572,7 +570,7 @@ void ItemEffect::setVal3(const int v3) throw(Exception) switch (effect) { case E_StatBoost: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val3) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= val3) throw(BoundsException(className, "val3")); break; case E_Ball: @@ -591,7 +589,7 @@ void ItemEffect::setVal3(const int v3) throw(Exception) throw(BoundsException(className, "val3")); break; case B_Stat: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val3) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= val3) throw(BoundsException(className, "val3")); break; case B_Type: @@ -610,11 +608,11 @@ void ItemEffect::setVal3(const int v3) throw(Exception) switch (val2) { case B2_HPCure: - if (REL_End <= val3) + if (Pokemod::REL_End <= val3) throw(BoundsException(className, "val3")); break; case B2_StatusCure: - if (STS_End <= val3) + if (Pokemod::STS_End <= val3) throw(BoundsException(className, "val3")); break; default: diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index 7a575271..e3adeff5 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -26,6 +26,10 @@ #include #include "Pokemod.h" +#include "MapEffect.h" +#include "MapTrainer.h" +#include "MapWarp.h" +#include "MapWildList.h" #include "Map.h" const QStringList Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building"; @@ -50,6 +54,18 @@ Map::Map(const Pokemod* par, const QString& fname, const int _id) : load(fname, _id); } +Map::~Map() +{ + for (QListIterator i(effects); i.hasNext(); ) + delete i.next(); + for (QListIterator i(trainers); i.hasNext(); ) + delete i.next(); + for (QListIterator i(warps); i.hasNext(); ) + delete i.next(); + for (QListIterator i(wildLists); i.hasNext(); ) + delete i.next(); +} + bool Map::validate() const { bool valid = true; @@ -73,22 +89,22 @@ bool Map::validate() const QMap nameChecker; if (getEffectCount()) { - for (QListIterator i(effects); i.hasNext(); i.next()) + for (QListIterator i(effects); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - if (getWidth() <= i.peekNext().getCoordinate().getX()) + if (getWidth() <= i.peekNext()->getCoordinate().getX()) { pokemod->validationMsg("Invalid x coordinate"); valid = false; } - if (getHeight() <= i.peekNext().getCoordinate().getY()) + if (getHeight() <= i.peekNext()->getCoordinate().getY()) { pokemod->validationMsg("Invalid y coordinate"); valid = false; } - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -113,22 +129,22 @@ bool Map::validate() const pokemod->validationMsg("There are no effects", Pokemod::V_Warn); if (getTrainerCount()) { - for (QListIterator i(trainers); i.hasNext(); i.next()) + for (QListIterator i(trainers); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - if (getWidth() <= i.peekNext().getCoordinate().getX()) + if (getWidth() <= i.peekNext()->getCoordinate().getX()) { pokemod->validationMsg("Invalid x coordinate"); valid = false; } - if (getHeight() <= i.peekNext().getCoordinate().getY()) + if (getHeight() <= i.peekNext()->getCoordinate().getY()) { pokemod->validationMsg("Invalid y coordinate"); valid = false; } - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -153,22 +169,22 @@ bool Map::validate() const pokemod->validationMsg("There are no trainers", Pokemod::V_Warn); if (getWarpCount()) { - for (QListIterator i(warps); i.hasNext(); i.next()) + for (QListIterator i(warps); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - if (getWidth() <= i.peekNext().getCoordinate().getX()) + if (getWidth() <= i.peekNext()->getCoordinate().getX()) { pokemod->validationMsg("Invalid x coordinate"); valid = false; } - if (getHeight() <= i.peekNext().getCoordinate().getY()) + if (getHeight() <= i.peekNext()->getCoordinate().getY()) { pokemod->validationMsg("Invalid y coordinate"); valid = false; } - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -196,11 +212,11 @@ bool Map::validate() const } if (getWildListCount()) { - for (QListIterator i(wildLists); i.hasNext(); i.next()) + for (QListIterator i(wildLists); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -327,14 +343,14 @@ void Map::save() const throw(Exception) ini.addField(QString("tiles-%1-%2").arg(i).arg(j), tiles(i, j)); } ini.save(QString("%1/map/%2/data.pini").arg(pokemod->getPath()).arg(name)); - for (QListIterator i(effects); i.hasNext(); ) - i.next().save(name); - for (QListIterator i(trainers); i.hasNext(); ) - i.next().save(name); - for (QListIterator i(warps); i.hasNext(); ) - i.next().save(name); - for (QListIterator i(wildLists); i.hasNext(); ) - i.next().save(name); + for (QListIterator i(effects); i.hasNext(); ) + i.next()->save(name); + for (QListIterator i(trainers); i.hasNext(); ) + i.next()->save(name); + for (QListIterator i(warps); i.hasNext(); ) + i.next()->save(name); + for (QListIterator i(wildLists); i.hasNext(); ) + i.next()->save(name); } void Map::setName(const QString& n) @@ -437,14 +453,14 @@ const MapEffect* Map::getEffect(const int i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects.at(i); + return effects.at(i); } MapEffect* Map::getEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects[i]; + return effects[i]; } const MapEffect* Map::getEffectByID(const int i) const throw(IndexException) @@ -461,7 +477,7 @@ int Map::getEffectIndex(const int _id) const { for (int i = 0; i < getEffectCount(); ++i) { - if (effects[i].getId() == _id) + if (effects[i]->getId() == _id) return i; } return -1; @@ -474,26 +490,27 @@ int Map::getEffectCount() const MapEffect* Map::newEffect() { - effects.append(MapEffect(pokemod, getNewEffectId())); - return &effects[getEffectCount() - 1]; + effects.append(new MapEffect(pokemod, getNewEffectId())); + return effects[getEffectCount() - 1]; } MapEffect* Map::newEffect(const QString& fname) { - effects.append(MapEffect(pokemod, fname, getNewEffectId())); - return &effects[getEffectCount() - 1]; + effects.append(new MapEffect(pokemod, fname, getNewEffectId())); + return effects[getEffectCount() - 1]; } MapEffect* Map::newEffect(const MapEffect& e) { - effects.append(MapEffect(pokemod, e, getNewEffectId())); - return &effects[getEffectCount() - 1]; + effects.append(new MapEffect(pokemod, e, getNewEffectId())); + return effects[getEffectCount() - 1]; } void Map::deleteEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); + delete effects[i]; effects.removeAt(i); } @@ -501,14 +518,14 @@ const MapTrainer* Map::getTrainer(const int i) const throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException(className)); - return &trainers.at(i); + return trainers.at(i); } MapTrainer* Map::getTrainer(const int i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException(className)); - return &trainers[i]; + return trainers[i]; } const MapTrainer* Map::getTrainerByID(const int i) const throw(IndexException) @@ -525,7 +542,7 @@ int Map::getTrainerIndex(const int _id) const { for (int i = 0; i < getTrainerCount(); ++i) { - if (trainers[i].getId() == _id) + if (trainers[i]->getId() == _id) return i; } return -1; @@ -538,26 +555,27 @@ int Map::getTrainerCount() const MapTrainer* Map::newTrainer() { - trainers.append(MapTrainer(pokemod, getNewTrainerId())); - return &trainers[getTrainerCount() - 1]; + trainers.append(new MapTrainer(pokemod, getNewTrainerId())); + return trainers[getTrainerCount() - 1]; } MapTrainer* Map::newTrainer(const QString& fname) { - trainers.append(MapTrainer(pokemod, fname, getNewTrainerId())); - return &trainers[getTrainerCount() - 1]; + trainers.append(new MapTrainer(pokemod, fname, getNewTrainerId())); + return trainers[getTrainerCount() - 1]; } MapTrainer* Map::newTrainer(const MapTrainer& t) { - trainers.append(MapTrainer(pokemod, t, getNewTrainerId())); - return &trainers[getTrainerCount() - 1]; + trainers.append(new MapTrainer(pokemod, t, getNewTrainerId())); + return trainers[getTrainerCount() - 1]; } void Map::deleteTrainer(const int i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException(className)); + delete trainers[i]; trainers.removeAt(i); } @@ -565,14 +583,14 @@ const MapWarp* Map::getWarp(const int i) const throw(IndexException) { if (getWarpCount() <= i) throw(IndexException(className)); - return &warps.at(i); + return warps.at(i); } MapWarp* Map::getWarp(const int i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException(className)); - return &warps[i]; + return warps[i]; } const MapWarp* Map::getWarpByID(const int i) const throw(IndexException) @@ -589,7 +607,7 @@ int Map::getWarpIndex(const int _id) const { for (int i = 0; i < getWarpCount(); ++i) { - if (warps[i].getId() == _id) + if (warps[i]->getId() == _id) return i; } return -1; @@ -602,26 +620,27 @@ int Map::getWarpCount() const MapWarp* Map::newWarp() { - warps.append(MapWarp(pokemod, getNewWarpId())); - return &warps[getWarpCount() - 1]; + warps.append(new MapWarp(pokemod, getNewWarpId())); + return warps[getWarpCount() - 1]; } MapWarp* Map::newWarp(const QString& fname) { - warps.append(MapWarp(pokemod, fname, getNewWarpId())); - return &warps[getWarpCount() - 1]; + warps.append(new MapWarp(pokemod, fname, getNewWarpId())); + return warps[getWarpCount() - 1]; } MapWarp* Map::newWarp(const MapWarp& w) { - warps.append(MapWarp(pokemod, w, getNewWarpId())); - return &warps[getWarpCount() - 1]; + warps.append(new MapWarp(pokemod, w, getNewWarpId())); + return warps[getWarpCount() - 1]; } void Map::deleteWarp(const int i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException(className)); + delete warps[i]; warps.removeAt(i); } @@ -629,14 +648,14 @@ const MapWildList* Map::getWildList(const int i) const throw(IndexException) { if (getWildListCount() <= i) throw(IndexException(className)); - return &wildLists.at(i); + return wildLists.at(i); } MapWildList* Map::getWildList(const int i) throw(IndexException) { if (getWildListCount() <= i) throw(IndexException(className)); - return &wildLists[i]; + return wildLists[i]; } const MapWildList* Map::getWildListByID(const int i) const throw(IndexException) @@ -653,7 +672,7 @@ int Map::getWildListIndex(const int _id) const { for (int i = 0; i < getWildListCount(); ++i) { - if (wildLists[i].getId() == _id) + if (wildLists[i]->getId() == _id) return i; } return -1; @@ -666,26 +685,27 @@ int Map::getWildListCount() const MapWildList* Map::newWildList() { - wildLists.append(MapWildList(pokemod, getNewWildListId())); - return &wildLists[getWildListCount() - 1]; + wildLists.append(new MapWildList(pokemod, getNewWildListId())); + return wildLists[getWildListCount() - 1]; } MapWildList* Map::newWildList(const QString& fname) { - wildLists.append(MapWildList(pokemod, fname, getNewWildListId())); - return &wildLists[getWildListCount() - 1]; + wildLists.append(new MapWildList(pokemod, fname, getNewWildListId())); + return wildLists[getWildListCount() - 1]; } MapWildList* Map::newWildList(const MapWildList& w) { - wildLists.append(MapWildList(pokemod, w, getNewWildListId())); - return &wildLists[getWildListCount() - 1]; + wildLists.append(new MapWildList(pokemod, w, getNewWildListId())); + return wildLists[getWildListCount() - 1]; } void Map::deleteWildList(const int i) throw(IndexException) { if (getWildListCount() <= i) throw(IndexException(className)); + delete wildLists[i]; wildLists.removeAt(i); } @@ -699,15 +719,15 @@ Map& Map::operator=(const Map& rhs) tiles = rhs.tiles; effects.clear(); for (int i = 0; i < rhs.getEffectCount(); ++i) - effects.append(MapEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); + effects.append(new MapEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); trainers.clear(); for (int i = 0; i < rhs.getTrainerCount(); ++i) - trainers.append(MapTrainer(pokemod, *rhs.getTrainer(i), rhs.getTrainer(i)->getId())); + trainers.append(new MapTrainer(pokemod, *rhs.getTrainer(i), rhs.getTrainer(i)->getId())); warps.clear(); for (int i = 0; i < rhs.getWarpCount(); ++i) - warps.append(MapWarp(pokemod, *rhs.getWarp(i), rhs.getWarp(i)->getId())); + warps.append(new MapWarp(pokemod, *rhs.getWarp(i), rhs.getWarp(i)->getId())); wildLists.clear(); for (int i = 0; i < rhs.getWildListCount(); ++i) - wildLists.append(MapWildList(pokemod, *rhs.getWildList(i), rhs.getWildList(i)->getId())); + wildLists.append(new MapWildList(pokemod, *rhs.getWildList(i), rhs.getWildList(i)->getId())); return *this; } diff --git a/pokemod/Map.h b/pokemod/Map.h index 70697799..2acc5b84 100644 --- a/pokemod/Map.h +++ b/pokemod/Map.h @@ -31,11 +31,11 @@ #include #include "Object.h" -#include "MapEffect.h" -#include "MapTrainer.h" -#include "MapWarp.h" -#include "MapWildList.h" +class MapEffect; +class MapTrainer; +class MapWarp; +class MapWildList; class Pokemod; class Map : public Object @@ -53,6 +53,7 @@ class Map : public Object Map(const Pokemod* par, const int _id); Map(const Pokemod* par, const Map& m, const int _id); Map(const Pokemod* par, const QString& fname, const int _id = -1); + ~Map(); void load(const QString& fname, const int _id = -1) throw(Exception); void save() const throw(Exception); @@ -136,10 +137,10 @@ class Map : public Object int type; Matrix tiles; - QList effects; - QList trainers; - QList warps; - QList wildLists; + QList effects; + QList trainers; + QList warps; + QList wildLists; }; #endif diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 5ca7f96f..484e304f 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -104,7 +104,7 @@ bool MapEffect::validate() const pokemod->validationMsg("Invalid effect"); valid = false; } - if (D_End_None <= direction) + if (Pokemod::D_End_None <= direction) { pokemod->validationMsg("Invalid driection"); valid = false; @@ -247,7 +247,7 @@ void MapEffect::setVal2(const int v2) throw(Exception) void MapEffect::setDirection(const int d) throw(BoundsException) { - if (D_End_None <= d) + if (Pokemod::D_End_None <= d) throw(BoundsException(className, "direction")); direction = d; } diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index cd6b4c98..5688c34f 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -29,6 +29,7 @@ #include "Pokemod.h" #include "Dialog.h" +#include "MapTrainerTeamMember.h" #include "MapTrainer.h" MapTrainer::MapTrainer(const Pokemod* par, const int _id) : @@ -60,6 +61,12 @@ MapTrainer::MapTrainer(const Pokemod* par, const QString& fname, const int _id) load(fname, _id); } +MapTrainer::~MapTrainer() +{ + for (QListIterator i(teamMembers); i.hasNext(); ) + delete i.next(); +} + bool MapTrainer::validate() const { bool valid = true; @@ -74,7 +81,7 @@ bool MapTrainer::validate() const pokemod->validationMsg("Skin could't be found"); valid = false; } - if (D_End_None <= direction) + if (Pokemod::D_End_None <= direction) { pokemod->validationMsg("Invalid direction"); valid = false; @@ -112,11 +119,11 @@ bool MapTrainer::validate() const if (getTeamMemberCount()) { QMap idChecker; - for (QListIterator i(teamMembers); i.hasNext(); i.next()) + for (QListIterator i(teamMembers); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -202,8 +209,8 @@ void MapTrainer::save(const QString& map) const throw(Exception) ini.addField("loseDialog", loseDialog); ini.addField("leadTeamMember", leadTeamMember); ini.save(QString("%1/map/%2/trainer/%3/data.pini").arg(pokemod->getPath()).arg(map).arg(name)); - for (QListIterator i(teamMembers); i.hasNext(); ) - i.next().save(map, name); + for (QListIterator i(teamMembers); i.hasNext(); ) + i.next()->save(map, name); } void MapTrainer::setName(const QString& n) @@ -240,7 +247,7 @@ void MapTrainer::setSight(const int s) void MapTrainer::setDirection(const int d) throw(BoundsException) { - if (D_End_None <= d) + if (Pokemod::D_End_None <= d) throw(BoundsException(className, "direction")); direction = d; } @@ -366,14 +373,14 @@ const MapTrainerTeamMember* MapTrainer::getTeamMember(const int i) const throw(I { if (getTeamMemberCount() <= i) throw(IndexException(className)); - return &teamMembers.at(i); + return teamMembers.at(i); } MapTrainerTeamMember* MapTrainer::getTeamMember(const int i) throw(IndexException) { if (getTeamMemberCount() <= i) throw(IndexException(className)); - return &teamMembers[i]; + return teamMembers[i]; } const MapTrainerTeamMember* MapTrainer::getTeamMemberByID(const int i) const throw(IndexException) @@ -390,7 +397,7 @@ int MapTrainer::getTeamMemberIndex(const int _id) const { for (int i = 0; i < getTeamMemberCount(); ++i) { - if (teamMembers[i].getId() == _id) + if (teamMembers[i]->getId() == _id) return i; } return -1; @@ -403,26 +410,27 @@ int MapTrainer::getTeamMemberCount() const MapTrainerTeamMember* MapTrainer::newTeamMember() { - teamMembers.append(MapTrainerTeamMember(pokemod, getNewId())); - return &teamMembers[getTeamMemberCount() - 1]; + teamMembers.append(new MapTrainerTeamMember(pokemod, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } MapTrainerTeamMember* MapTrainer::newTeamMember(const QString& fname) { - teamMembers.append(MapTrainerTeamMember(pokemod, fname, getNewId())); - return &teamMembers[getTeamMemberCount() - 1]; + teamMembers.append(new MapTrainerTeamMember(pokemod, fname, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } MapTrainerTeamMember* MapTrainer::newTeamMember(const MapTrainerTeamMember& p) { - teamMembers.append(MapTrainerTeamMember(pokemod, p, getNewId())); - return &teamMembers[getTeamMemberCount() - 1]; + teamMembers.append(new MapTrainerTeamMember(pokemod, p, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } void MapTrainer::deleteTeamMember(const int i) throw(IndexException) { if (getTeamMemberCount() <= i) throw(IndexException(className)); + delete teamMembers[i]; teamMembers.removeAt(i); } @@ -444,6 +452,6 @@ MapTrainer& MapTrainer::operator=(const MapTrainer& rhs) leadTeamMember = rhs.leadTeamMember; teamMembers.clear(); for (int i = 0; i < rhs.getTeamMemberCount(); ++i) - teamMembers.append(MapTrainerTeamMember(pokemod, *rhs.getTeamMember(i), rhs.getTeamMember(i)->getId())); + teamMembers.append(new MapTrainerTeamMember(pokemod, *rhs.getTeamMember(i), rhs.getTeamMember(i)->getId())); return *this; } diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h index 168c1053..bf9e07ea 100644 --- a/pokemod/MapTrainer.h +++ b/pokemod/MapTrainer.h @@ -31,8 +31,8 @@ #include #include "Object.h" -#include "MapTrainerTeamMember.h" +class MapTrainerTeamMember; class Pokemod; class MapTrainer : public Object @@ -41,6 +41,7 @@ class MapTrainer : public Object MapTrainer(const Pokemod* par, const int _id); MapTrainer(const Pokemod* par, const MapTrainer& t, const int _id); MapTrainer(const Pokemod* par, const QString& fname, const int _id = -1); + ~MapTrainer(); void load(const QString& fname, const int _id = -1) throw(Exception); void save(const QString& map) const throw(Exception); @@ -104,7 +105,7 @@ class MapTrainer : public Object int loseDialog; int leadTeamMember; - QList teamMembers; + QList teamMembers; }; #endif diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp index 1cc17994..35d56de7 100644 --- a/pokemod/MapWarp.cpp +++ b/pokemod/MapWarp.cpp @@ -41,7 +41,7 @@ MapWarp::MapWarp(const Pokemod* par, const int _id) : workingFlag(0, 0), dialog(-1) { - for (int i = 0; i < D_End; ++i) + for (int i = 0; i < Pokemod::D_End; ++i) from[i] = false; } @@ -66,12 +66,12 @@ bool MapWarp::validate() const pokemod->validationMsg("Name is not defined"); valid = false; } - if (!from[D_Up] && !from[D_Down] && !from[D_Left] && !from[D_Right]) + if (!from[Pokemod::D_Up] && !from[Pokemod::D_Down] && !from[Pokemod::D_Left] && !from[Pokemod::D_Right]) { pokemod->validationMsg("No access from any direction"); valid = false; } - if (D_End_None <= directionOut) + if (Pokemod::D_End_None <= directionOut) { pokemod->validationMsg("Invalid direction out"); valid = false; @@ -115,10 +115,10 @@ void MapWarp::load(const QString& fname, const int _id) throw(Exception) ini.getValue("coordinate-x", i, 0); ini.getValue("coordinate-y", j, 0); coordinate.set(i, j); - ini.getValue("from-up", from[D_Up], false); - ini.getValue("from-down", from[D_Down], false); - ini.getValue("from-left", from[D_Left], false); - ini.getValue("from-right", from[D_Right], false); + ini.getValue("from-up", from[Pokemod::D_Up], false); + ini.getValue("from-down", from[Pokemod::D_Down], false); + ini.getValue("from-left", from[Pokemod::D_Left], false); + ini.getValue("from-right", from[Pokemod::D_Right], false); ini.getValue("directionOut", directionOut); ini.getValue("warpType", warpType); ini.getValue("isBiking", isBiking, false); @@ -138,10 +138,10 @@ void MapWarp::save(const QString& map) const throw(Exception) ini.addField("id", id); ini.addField("coordinate-x", coordinate.getX()); ini.addField("coordinate-y", coordinate.getY()); - ini.addField("from-up", from[D_Up]); - ini.addField("from-down", from[D_Down]); - ini.addField("from-left", from[D_Left]); - ini.addField("from-right", from[D_Right]); + ini.addField("from-up", from[Pokemod::D_Up]); + ini.addField("from-down", from[Pokemod::D_Down]); + ini.addField("from-left", from[Pokemod::D_Left]); + ini.addField("from-right", from[Pokemod::D_Right]); ini.addField("directionOut", directionOut); ini.addField("warpType", warpType); ini.addField("isBiking", isBiking); @@ -177,14 +177,14 @@ void MapWarp::setCoordinateY(const int y) void MapWarp::setFrom(const int d, const bool f) throw(BoundsException) { - if (D_End <= d) + if (Pokemod::D_End <= d) throw(BoundsException(className, "direction")); from[d] = f; } void MapWarp::setDirectionOut(const int d) throw(BoundsException) { - if (D_End <= d) + if (Pokemod::D_End <= d) throw(BoundsException(className, "direction")); directionOut = d; } @@ -267,7 +267,7 @@ Point MapWarp::getCoordinate() const bool MapWarp::getFrom(const int d) const throw(BoundsException) { - if (D_End <= d) + if (Pokemod::D_End <= d) throw(BoundsException(className, "direction")); return from[d]; } @@ -323,7 +323,7 @@ MapWarp& MapWarp::operator=(const MapWarp& rhs) return *this; name = rhs.name; coordinate = rhs.coordinate; - for (int i = 0; i < D_End; ++i) + for (int i = 0; i < Pokemod::D_End; ++i) from[i] = rhs.from[i]; directionOut = rhs.directionOut; warpType = rhs.warpType; diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h index a852b3d2..0a70f695 100644 --- a/pokemod/MapWarp.h +++ b/pokemod/MapWarp.h @@ -90,7 +90,7 @@ class MapWarp : public Object QString name; Point coordinate; - bool from[D_End]; + bool from[Pokemod::D_End]; int directionOut; int warpType; int isBiking; diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp index 68ff881b..737f506d 100644 --- a/pokemod/MapWildList.cpp +++ b/pokemod/MapWildList.cpp @@ -30,6 +30,7 @@ #include "Pokemod.h" #include "Item.h" #include "ItemEffect.h" +#include "MapWildListEncounter.h" #include "MapWildList.h" const QStringList MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash"; @@ -54,6 +55,12 @@ MapWildList::MapWildList(const Pokemod* par, const QString& fname, const int _id load(fname, _id); } +MapWildList::~MapWildList() +{ + for (QListIterator i(encounters); i.hasNext(); ) + delete i.next(); +} + bool MapWildList::validate() const { bool valid = true; @@ -117,6 +124,7 @@ bool MapWildList::validate() const valid = false; } } + // TODO: MapWildList Encounter validation return valid; } @@ -170,8 +178,8 @@ void MapWildList::save(const QString& map) const throw(Exception) ini.addField(QString("time-%1").arg(i), times[i]); ini.addField("scope", scope); ini.save(QString("%1/map/%2/wildlist/%3/data.pini").arg(pokemod->getPath()).arg(map).arg(id)); - for (QListIterator i(encounters); i.hasNext(); ) - i.next().save(map, id); + for (QListIterator i(encounters); i.hasNext(); ) + i.next()->save(map, id); } void MapWildList::setControl(const int c) throw(BoundsException) @@ -267,14 +275,14 @@ const MapWildListEncounter* MapWildList::getEncounter(const int i) const throw(I { if (getEncounterCount() <= i) throw(IndexException(className)); - return &encounters.at(i); + return encounters.at(i); } MapWildListEncounter* MapWildList::getEncounter(const int i) throw(IndexException) { if (getEncounterCount() <= i) throw(IndexException(className)); - return &encounters[i]; + return encounters[i]; } const MapWildListEncounter* MapWildList::getEncounterByID(const int i) const throw(IndexException) @@ -291,7 +299,7 @@ int MapWildList::getEncounterIndex(const int _id) const { for (int i = 0; i < getEncounterCount(); ++i) { - if (encounters[i].getId() == _id) + if (encounters[i]->getId() == _id) return i; } return -1; @@ -304,26 +312,27 @@ int MapWildList::getEncounterCount() const MapWildListEncounter* MapWildList::newEncounter() { - encounters.append(MapWildListEncounter(pokemod, getNewId())); - return &encounters[getEncounterCount() - 1]; + encounters.append(new MapWildListEncounter(pokemod, getNewId())); + return encounters[getEncounterCount() - 1]; } MapWildListEncounter* MapWildList::newEncounter(const QString& fname) { - encounters.append(MapWildListEncounter(pokemod, fname, getNewId())); - return &encounters[getEncounterCount() - 1]; + encounters.append(new MapWildListEncounter(pokemod, fname, getNewId())); + return encounters[getEncounterCount() - 1]; } MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& p) { - encounters.append(MapWildListEncounter(pokemod, p, getNewId())); - return &encounters[getEncounterCount() - 1]; + encounters.append(new MapWildListEncounter(pokemod, p, getNewId())); + return encounters[getEncounterCount() - 1]; } void MapWildList::deleteEncounter(const int i) throw(IndexException) { if (getEncounterCount() <= i) throw(IndexException(className)); + delete encounters[i]; encounters.removeAt(i); } @@ -337,6 +346,6 @@ MapWildList& MapWildList::operator=(const MapWildList& rhs) scope = rhs.scope; encounters.clear(); for (int i = 0; i < rhs.getEncounterCount(); ++i) - newEncounter(*rhs.getEncounter(i)); + encounters.append(new MapWildListEncounter(pokemod, *rhs.getEncounter(i), rhs.getEncounter(i)->getId())); return *this; } diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h index 4a2e1972..6026f18b 100644 --- a/pokemod/MapWildList.h +++ b/pokemod/MapWildList.h @@ -30,8 +30,8 @@ #include #include "Object.h" -#include "MapWildListEncounter.h" +class MapWildListEncounter; class Pokemod; class MapWildList : public Object @@ -52,6 +52,7 @@ class MapWildList : public Object MapWildList(const Pokemod* par, const int _id); MapWildList(const Pokemod* par, const MapWildList& w, const int _id); MapWildList(const Pokemod* par, const QString& fname, const int _id = -1); + ~MapWildList(); void load(const QString& fname, const int _id = -1) throw(Exception); void save(const QString& map) const throw(Exception); @@ -87,7 +88,7 @@ class MapWildList : public Object QList times; int scope; - QList encounters; + QList encounters; }; #endif diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index f79f5c3c..6f8ad323 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -27,6 +27,7 @@ #include #include "Pokemod.h" +#include "MoveEffect.h" #include "Move.h" const QStringList Move::TargetStr = QStringList() << "Player" << "Enemy" << "Both" << "Random"; @@ -63,6 +64,12 @@ Move::Move(const Pokemod* par, const QString& fname, const int _id) : load(fname, _id); } +Move::~Move() +{ + for (QListIterator i(effects); i.hasNext(); ) + delete i.next(); +} + bool Move::validate() const { bool valid = true; @@ -100,11 +107,11 @@ bool Move::validate() const if (getEffectCount()) { QMap idChecker; - for (QListIterator i(effects); i.hasNext(); i.next()) + for (QListIterator i(effects); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -189,8 +196,8 @@ void Move::save() const throw(Exception) ini.addField("sound", sound); ini.addField("description", description); ini.save(QString("%1/move/%2/data.pini").arg(pokemod->getPath()).arg(name)); - for (QListIterator i(effects); i.hasNext(); ) - i.next().save(name); + for (QListIterator i(effects); i.hasNext(); ) + i.next()->save(name); } void Move::setName(const QString& n) @@ -357,14 +364,14 @@ const MoveEffect* Move::getEffect(const int i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects.at(i); + return effects.at(i); } MoveEffect* Move::getEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); - return &effects[i]; + return effects[i]; } const MoveEffect* Move::getEffectByID(const int i) const throw(IndexException) @@ -381,7 +388,7 @@ int Move::getEffectIndex(const int _id) const { for (int i = 0; i < getEffectCount(); ++i) { - if (effects[i].getId() == _id) + if (effects[i]->getId() == _id) return i; } return -1; @@ -394,26 +401,27 @@ int Move::getEffectCount() const MoveEffect* Move::newEffect() { - effects.append(MoveEffect(pokemod, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new MoveEffect(pokemod, getNewId())); + return effects[getEffectCount() - 1]; } MoveEffect* Move::newEffect(const QString& fname) { - effects.append(MoveEffect(pokemod, fname, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new MoveEffect(pokemod, fname, getNewId())); + return effects[getEffectCount() - 1]; } MoveEffect* Move::newEffect(const MoveEffect& e) { - effects.append(MoveEffect(pokemod, e, getNewId())); - return &effects[getEffectCount() - 1]; + effects.append(new MoveEffect(pokemod, e, getNewId())); + return effects[getEffectCount() - 1]; } void Move::deleteEffect(const int i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException(className)); + delete effects[i]; effects.removeAt(i); } @@ -438,6 +446,6 @@ Move& Move::operator=(const Move& rhs) description = rhs.description; effects.clear(); for (int i = 0; i < rhs.getEffectCount(); ++i) - newEffect(*rhs.getEffect(i)); + effects.append(new MoveEffect(pokemod, *rhs.getEffect(i), rhs.getEffect(i)->getId())); return *this; } diff --git a/pokemod/Move.h b/pokemod/Move.h index 76dab95d..b56fbc0e 100644 --- a/pokemod/Move.h +++ b/pokemod/Move.h @@ -30,8 +30,8 @@ #include #include "Object.h" -#include "MoveEffect.h" +class MoveEffect; class Pokemod; class Move : public Object @@ -59,6 +59,7 @@ class Move : public Object Move(const Pokemod* par, const int _id); Move(const Pokemod* par, const Move& m, const int _id); Move(const Pokemod* par, const QString& fname, const int _id = -1); + ~Move(); void load(const QString& fname, const int _id = -1) throw(Exception); void save() const throw(Exception); @@ -127,7 +128,7 @@ class Move : public Object bool sound; QString description; - QList effects; + QList effects; }; #endif diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index e2baf049..7db04244 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -20,8 +20,6 @@ // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// -#include - #include "Pokemod.h" #include "MoveEffect.h" @@ -133,11 +131,11 @@ void MoveEffect::setVal1(const int v1) throw(Exception) break; case E_Status: case E_NeedStatus: - if (STS_End <= v1) + if (Pokemod::STS_End <= v1) throw(BoundsException(className, "val1")); throw; case E_Stat: - if (ST_End_Battle <= v1) + if (Pokemod::ST_End_Battle <= v1) throw(BoundsException(className, "val1")); break; case E_Counter: diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index eaacfab8..fa52ef43 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -28,7 +28,7 @@ Nature::Nature(const Pokemod* par, const int _id) : name(""), weight(1) { - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) stats[i].set(1, 1, Frac::Improper); } @@ -71,7 +71,7 @@ void Nature::load(const QString& fname, const int _id) throw(Exception) int i; int j; ini.getValue("name", name); - for (int k = 0; k < ST_End_GSC; ++k) + for (int k = 0; k < Pokemod::ST_End_GSC; ++k) { ini.getValue(QString("stat-%1-n").arg(k), i, 1); ini.getValue(QString("stat-%1-n").arg(k), j, 1); @@ -84,7 +84,7 @@ void Nature::save() const throw(Exception) { Ini ini; ini.addField("name", name); - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) { ini.addField(QString("stat-%1-n").arg(i), stats[i].getNum()); ini.addField(QString("stat-%1-d").arg(i), stats[i].getNum()); @@ -100,21 +100,21 @@ void Nature::setName(const QString& n) void Nature::setStat(const int s, const int n, const int d) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].set(n, d); } void Nature::setStatNum(const int s, const int n) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].setNum(n); } void Nature::setStatDenom(const int s, const int d) throw(Exception) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); stats[s].setDenom(d); } @@ -133,7 +133,7 @@ QString Nature::getName() const Frac Nature::getStat(const int s) const throw(BoundsException) { - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) + if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s) throw(BoundsException(className, "stat")); return stats[s]; } @@ -148,7 +148,7 @@ Nature& Nature::operator=(const Nature& rhs) if (this == &rhs) return *this; name = rhs.name; - for (int i = 0; i < ST_End_GSC; ++i) + for (int i = 0; i < Pokemod::ST_End_GSC; ++i) stats[i] = rhs.stats[i]; weight = rhs.weight; return *this; diff --git a/pokemod/Nature.h b/pokemod/Nature.h index 94822bfe..59322536 100644 --- a/pokemod/Nature.h +++ b/pokemod/Nature.h @@ -27,7 +27,6 @@ #include #include -#include #include "Object.h" @@ -58,7 +57,7 @@ class Nature : public Object bool validate() const; QString name; - Frac stats[ST_End_GSC]; + Frac stats[Pokemod::ST_End_GSC]; int weight; }; diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 71d77375..b4b94b9c 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -28,11 +28,33 @@ #include #include -#include - +#include "Ability.h" +#include "Author.h" +#include "Badge.h" +#include "CoinList.h" +#include "Dialog.h" +#include "EggGroup.h" +#include "Item.h" +#include "ItemType.h" +#include "Map.h" +#include "Move.h" +#include "Nature.h" +#include "Species.h" +#include "Store.h" +#include "Tile.h" +#include "Time.h" +#include "Type.h" #include "Pokemod.h" const QStringList Pokemod::ValidationStr = QStringList() << "Message" << "Warn" << "Error"; +const QStringList Pokemod::StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "Special" << "Accuracy" << "Evasion"; +const QStringList Pokemod::StatGSCStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special Attack" << "Special Defense" << "Accuracy" << "Evasion"; +const QStringList Pokemod::BattleMemberStr = QStringList() << "Player" << "Enemy"; +const QStringList Pokemod::WeatherStr = QStringList() << "Ice" << "Rain" << "Sun" << "Sand" << "All"; +const QStringList Pokemod::DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None"; +const QStringList Pokemod::RelativeStr = QStringList() << "Less" << "Less or Equal" << "Greater or Equal" << "Greater" << "Equal" << "Not Equal"; +const QStringList Pokemod::StatusStr = QStringList() << "Freeze" << "Paralyze" << "Sleep" << "Poison" << "Toxic Poison" << "Burn" << "Any"; +const QStringList Pokemod::HMStr = QStringList() << "Cut" << "Fly" << "Surf" << "Strength" << "Flash" << "Whirlpool" << "Waterfall" << "Dive" << "Headbutt" << "Rock Smash" << "Defog" << "Rock Climb" << "Heal" << "Escape"; Pokemod::Pokemod() : Object("Pokemod", this, 0), @@ -73,6 +95,40 @@ Pokemod::Pokemod(const QString& fname) : load(fname); } +Pokemod::~Pokemod() +{ + for (QListIterator i(abilities); i.hasNext(); ) + delete i.next(); + for (QListIterator i(authors); i.hasNext(); ) + delete i.next(); + for (QListIterator i(badges); i.hasNext(); ) + delete i.next(); + for (QListIterator i(coinLists); i.hasNext(); ) + delete i.next(); + for (QListIterator i(dialogs); i.hasNext(); ) + delete i.next(); + for (QListIterator i(eggGroups); i.hasNext(); ) + delete i.next(); + for (QListIterator i(items); i.hasNext(); ) + delete i.next(); + for (QListIterator i(itemTypes); i.hasNext(); ) + delete i.next(); + for (QListIterator i(maps); i.hasNext(); ) + delete i.next(); + for (QListIterator i(natures); i.hasNext(); ) + delete i.next(); + for (QListIterator i(species); i.hasNext(); ) + delete i.next(); + for (QListIterator i(stores); i.hasNext(); ) + delete i.next(); + for (QListIterator i(tiles); i.hasNext(); ) + delete i.next(); + for (QListIterator i(times); i.hasNext(); ) + delete i.next(); + for (QListIterator i(types); i.hasNext(); ) + delete i.next(); +} + bool Pokemod::validate() const { bool valid = true; @@ -153,12 +209,12 @@ bool Pokemod::validate() const validationMsg("There are no abilities"); valid = false; } - for (QListIterator i(abilities); i.hasNext(); i.next()) + for (QListIterator i(abilities); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -184,12 +240,12 @@ bool Pokemod::validate() const validationMsg("There are no authors"); valid = false; } - for (QListIterator i(authors); i.hasNext(); i.next()) + for (QListIterator i(authors); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -211,12 +267,12 @@ bool Pokemod::validate() const nameChecker.clear(); if (!getBadgeCount()) validationMsg("There are no badges", V_Warn); - for (QListIterator i(badges); i.hasNext(); i.next()) + for (QListIterator i(badges); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -238,12 +294,12 @@ bool Pokemod::validate() const nameChecker.clear(); if (!getCoinListCount()) validationMsg("There are no coin lists", V_Warn); - for (QListIterator i(coinLists); i.hasNext(); i.next()) + for (QListIterator i(coinLists); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -268,11 +324,11 @@ bool Pokemod::validate() const validationMsg("There are no dialogs"); valid = false; } - for (QListIterator i(dialogs); i.hasNext(); i.next()) + for (QListIterator i(dialogs); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; + ++idChecker[i.peekNext()->getId()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -290,12 +346,12 @@ bool Pokemod::validate() const validationMsg("There are no egg grous"); valid = false; } - for (QListIterator i(eggGroups); i.hasNext(); i.next()) + for (QListIterator i(eggGroups); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -318,12 +374,12 @@ bool Pokemod::validate() const } if (!getItemCount()) validationMsg("There are no items", V_Warn); - for (QListIterator i(items); i.hasNext(); i.next()) + for (QListIterator i(items); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -349,12 +405,12 @@ bool Pokemod::validate() const if (getItemCount()) valid = false; } - for (QListIterator i(itemTypes); i.hasNext(); i.next()) + for (QListIterator i(itemTypes); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -379,12 +435,12 @@ bool Pokemod::validate() const validationMsg("There are no maps"); valid = false; } - for (QListIterator i(maps); i.hasNext(); i.next()) + for (QListIterator i(maps); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -409,12 +465,12 @@ bool Pokemod::validate() const validationMsg("There are no moves"); valid = false; } - for (QListIterator i(moves); i.hasNext(); i.next()) + for (QListIterator i(moves); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -441,12 +497,12 @@ bool Pokemod::validate() const validationMsg("There are no natures"); valid = false; } - for (QListIterator i(natures); i.hasNext(); i.next()) + for (QListIterator i(natures); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -472,12 +528,12 @@ bool Pokemod::validate() const validationMsg("There are no species"); valid = false; } - for (QListIterator i(species); i.hasNext(); i.next()) + for (QListIterator i(species); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -499,12 +555,12 @@ bool Pokemod::validate() const nameChecker.clear(); if (!getStoreCount()) validationMsg("There are no stores", V_Warn); - for (QListIterator i(stores); i.hasNext(); i.next()) + for (QListIterator i(stores); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -526,12 +582,12 @@ bool Pokemod::validate() const nameChecker.clear(); if (getTileCount()) { - for (QListIterator i(tiles); i.hasNext(); i.next()) + for (QListIterator i(tiles); i.hasNext(); i.next()) { - if (!i.peekNext().isValid()) + if (!i.peekNext()->isValid()) valid = false; - ++idChecker[i.peekNext().getId()]; - ++nameChecker[i.peekNext().getName()]; + ++idChecker[i.peekNext()->getId()]; + ++nameChecker[i.peekNext()->getName()]; } for (QMapIterator i(idChecker); i.hasNext(); i.next()) { @@ -562,13 +618,13 @@ bool Pokemod::validate() const validationMsg("There are no times"); valid = false; } - for (QListIterator