diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-27 15:15:17 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-27 15:15:17 +0000 |
| commit | 807071d35159de0660f9df31c48d5bf895ca3622 (patch) | |
| tree | a1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/Pokemod.cpp | |
| parent | f444f5a45e9325644a360f656176d47d7f540f52 (diff) | |
| download | sigen-807071d35159de0660f9df31c48d5bf895ca3622.tar.gz sigen-807071d35159de0660f9df31c48d5bf895ca3622.tar.xz sigen-807071d35159de0660f9df31c48d5bf895ca3622.zip | |
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative
[FIX] Headers included for better detection of invalid headers
[FIX] Validation code commented out so it can be done better
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
| -rw-r--r-- | pokemod/Pokemod.cpp | 577 |
1 files changed, 289 insertions, 288 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 1d84fffc..e4191a85 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -15,11 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -// Qt includes -#include <QBuffer> -#include <QMap> -#include <QTextStream> -#include <QTime> +// Header include +#include "Pokemod.h" // Pokemod includes #include "Ability.h" @@ -40,8 +37,11 @@ #include "Trainer.h" #include "Type.h" -// Header include -#include "Pokemod.h" +// Qt includes +#include <QBuffer> +#include <QMap> +#include <QTextStream> +#include <QTime> const QStringList Pokemod::ValidationStr = QStringList() << "Message" << "Warn" << "Error"; const QStringList Pokemod::StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "Special" << "Accuracy" << "Evasion"; @@ -54,7 +54,7 @@ const QStringList Pokemod::StatusStr = QStringList() << "Freeze" << "Paralyze" < 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), + Object("Pokemod", NULL, 0), valOutput(NULL), m_title(""), m_version(""), @@ -75,14 +75,14 @@ Pokemod::Pokemod() : } Pokemod::Pokemod(const Pokemod& pokemod) : - Object("Pokemod", this, 0), + Object("Pokemod", NULL, 0), m_rules(this) { *this = pokemod; } Pokemod::Pokemod(const QDomElement& xml) : - Object("Pokemod", this, 0), + Object("Pokemod", NULL, 0), valOutput(NULL), m_rules(this) { @@ -96,284 +96,285 @@ Pokemod::~Pokemod() bool Pokemod::validate() const { - bool valid = true; - validationMsg(QString("Pokemod \"%1\"").arg(m_title), V_Msg); - if (m_title == "") - { - validationMsg("Title is not defined"); - valid = false; - } - if (m_version == "") - { - validationMsg("Version is not defined"); - valid = false; - } - if (m_description == "") - validationMsg("Description is not defined", V_Warn); - if (mapIndex(m_startMap)) - { - if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX) - { - validationMsg("Invalid starting warp"); - valid = false; - } - } - else - { - validationMsg("Invalid starting map"); - valid = false; - } - if (m_superPCUname == "") - validationMsg("Super PC username not defined", V_Warn); - if (m_superPCPasswd == "") - validationMsg("Super PC password not defined", V_Warn); - if ((m_typeChart.width() != typeCount()) || (m_typeChart.height() != typeCount())) - { - validationMsg("TypeChart is invalid"); - valid = false; - } - if (!m_rules.isValid()) - valid = false; - QMap<int, bool> idChecker; - QMap<int, bool> timeChecker; - if (m_rules.abilityAllowed()) - { - if (!abilityCount()) - { - validationMsg("There are no abilities"); - valid = false; - } - foreach (Ability* ability, m_abilities) - { - if (!ability->isValid()) - valid = false; - if (idChecker[ability->id()]) - validationMsg(QString("Duplicate ability with id %1").arg(ability->id())); - idChecker[ability->id()] = true; - } - idChecker.clear(); - } - if (!authorCount()) - { - validationMsg("There are no authors"); - valid = false; - } - foreach (Author* author, m_authors) - { - if (!author->isValid()) - valid = false; - if (idChecker[author->id()]) - validationMsg(QString("Duplicate author with id %1").arg(author->id())); - idChecker[author->id()] = true; - } - idChecker.clear(); - if (!badgeCount()) - validationMsg("There are no badges", V_Warn); - foreach (Badge* badge, m_badges) - { - if (!badge->isValid()) - valid = false; - if (idChecker[badge->id()]) - validationMsg(QString("Duplicate badge with id %1").arg(badge->id())); - idChecker[badge->id()] = true; - } - idChecker.clear(); - if (!coinListCount()) - validationMsg("There are no coin lists", V_Warn); - foreach (CoinList* coinList, m_coinLists) - { - if (!coinList->isValid()) - valid = false; - if (idChecker[coinList->id()]) - validationMsg(QString("Duplicate coin list with id %1").arg(coinList->id())); - idChecker[coinList->id()] = true; - } - idChecker.clear(); - if (!dialogCount()) - { - validationMsg("There are no dialogs"); - valid = false; - } - foreach (Dialog* dialog, m_dialogs) - { - if (!dialog->isValid()) - valid = false; - if (idChecker[dialog->id()]) - validationMsg(QString("Duplicate dialog with id %1").arg(dialog->id())); - idChecker[dialog->id()] = true; - } - idChecker.clear(); - if (m_rules.breedingAllowed()) - { - if (!eggGroupCount()) - { - validationMsg("There are no egg grous"); - valid = false; - } - foreach (EggGroup* eggGroup, m_eggGroups) - { - if (!eggGroup->isValid()) - valid = false; - if (idChecker[eggGroup->id()]) - validationMsg(QString("Duplicate egg group with id %1").arg(eggGroup->id())); - idChecker[eggGroup->id()] = true; - } - idChecker.clear(); - } - if (!itemCount()) - validationMsg("There are no m_items", V_Warn); - foreach (Item* item, m_items) - { - if (!item->isValid()) - valid = false; - if (idChecker[item->id()]) - validationMsg(QString("Duplicate item with id %1").arg(item->id())); - idChecker[item->id()] = true; - } - idChecker.clear(); - if (!itemTypeCount()) - { - validationMsg("There are no item types", itemCount() ? V_Error : V_Warn); - if (itemCount()) - valid = false; - } - foreach (ItemType* itemType, m_itemTypes) - { - if (!itemType->isValid()) - valid = false; - if (idChecker[itemType->id()]) - validationMsg(QString("Duplicate item type with id %1").arg(itemType->id())); - idChecker[itemType->id()] = true; - } - idChecker.clear(); - if (!mapCount()) - { - validationMsg("There are no m_maps"); - valid = false; - } - foreach (Map* map, m_maps) - { - if (!map->isValid()) - valid = false; - if (idChecker[map->id()]) - validationMsg(QString("Duplicate map with id %1").arg(map->id())); - idChecker[map->id()] = true; - } - idChecker.clear(); - if (!moveCount()) - { - validationMsg("There are no m_moves"); - valid = false; - } - foreach (Move* move, m_moves) - { - if (!move->isValid()) - valid = false; - if (idChecker[move->id()]) - validationMsg(QString("Duplicate move with id %1").arg(move->id())); - idChecker[move->id()] = true; - } - idChecker.clear(); - if (m_rules.natureAllowed()) - { - if (!natureCount()) - { - validationMsg("There are no natures"); - valid = false; - } - foreach (Nature* nature, m_natures) - { - if (!nature->isValid()) - valid = false; - if (idChecker[nature->id()]) - validationMsg(QString("Duplicate ability with id %1").arg(nature->id())); - idChecker[nature->id()] = true; - } - idChecker.clear(); - } - if (!speciesCount()) - { - validationMsg("There are no m_species"); - valid = false; - } - foreach (Species* m_species, m_species) - { - if (!m_species->isValid()) - valid = false; - if (idChecker[m_species->id()]) - validationMsg(QString("Duplicate m_species with id %1").arg(m_species->id())); - idChecker[m_species->id()] = true; - } - idChecker.clear(); - if (!storeCount()) - validationMsg("There are no m_stores", V_Warn); - foreach (Store* store, m_stores) - { - if (!store->isValid()) - valid = false; - if (idChecker[store->id()]) - validationMsg(QString("Duplicate store with id %1").arg(store->id())); - idChecker[store->id()] = true; - } - idChecker.clear(); - if (!tileCount()) - { - validationMsg("There are no m_tiles"); - valid = false; - } - foreach (Tile* tile, m_tiles) - { - if (!tile->isValid()) - valid = false; - if (idChecker[tile->id()]) - validationMsg(QString("Duplicate tile with id %1").arg(tile->id())); - idChecker[tile->id()] = true; - } - idChecker.clear(); - if (!trainerCount()) - { - validationMsg("There are no times", Pokemod::V_Warn); - } - foreach (Trainer* trainer, m_trainers) - { - if (!trainer->isValid()) - valid = false; - if (idChecker[trainer->id()]) - validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id())); - idChecker[trainer->id()] = true; - } - idChecker.clear(); - if (!timeCount()) - { - validationMsg("There are no times"); - valid = false; - } - foreach (Time* time, m_times) - { - if (!time->isValid()) - valid = false; - if (idChecker[time->id()]) - validationMsg(QString("Duplicate time with id %1").arg(time->id())); - idChecker[time->id()] = true; - if (timeChecker[(60 * time->hour()) + time->minute()]) - validationMsg(QString("Duplicate time at %1:%2").arg(time->hour()).arg(time->minute())); - timeChecker[(60 * time->hour()) + time->minute()] = true; - } - idChecker.clear(); - if (!typeCount()) - { - validationMsg("There are no types"); - valid = false; - } - foreach (Type* type, m_types) - { - if (!type->isValid()) - valid = false; - if (idChecker[type->id()]) - validationMsg(QString("Duplicate type with id %1").arg(type->id())); - idChecker[type->id()] = true; - } - return valid; + // TODO: validate +// bool valid = true; +// validationMsg(QString("Pokemod \"%1\"").arg(m_title), V_Msg); +// if (m_title == "") +// { +// validationMsg("Title is not defined"); +// valid = false; +// } +// if (m_version == "") +// { +// validationMsg("Version is not defined"); +// valid = false; +// } +// if (m_description == "") +// validationMsg("Description is not defined", V_Warn); +// if (mapIndex(m_startMap)) +// { +// if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX) +// { +// validationMsg("Invalid starting warp"); +// valid = false; +// } +// } +// else +// { +// validationMsg("Invalid starting map"); +// valid = false; +// } +// if (m_superPCUname == "") +// validationMsg("Super PC username not defined", V_Warn); +// if (m_superPCPasswd == "") +// validationMsg("Super PC password not defined", V_Warn); +// if ((m_typeChart.width() != typeCount()) || (m_typeChart.height() != typeCount())) +// { +// validationMsg("TypeChart is invalid"); +// valid = false; +// } +// if (!m_rules.isValid()) +// valid = false; +// QMap<int, bool> idChecker; +// QMap<int, bool> timeChecker; +// if (m_rules.abilityAllowed()) +// { +// if (!abilityCount()) +// { +// validationMsg("There are no abilities"); +// valid = false; +// } +// foreach (Ability* ability, m_abilities) +// { +// if (!ability->isValid()) +// valid = false; +// if (idChecker[ability->id()]) +// validationMsg(QString("Duplicate ability with id %1").arg(ability->id())); +// idChecker[ability->id()] = true; +// } +// idChecker.clear(); +// } +// if (!authorCount()) +// { +// validationMsg("There are no authors"); +// valid = false; +// } +// foreach (Author* author, m_authors) +// { +// if (!author->isValid()) +// valid = false; +// if (idChecker[author->id()]) +// validationMsg(QString("Duplicate author with id %1").arg(author->id())); +// idChecker[author->id()] = true; +// } +// idChecker.clear(); +// if (!badgeCount()) +// validationMsg("There are no badges", V_Warn); +// foreach (Badge* badge, m_badges) +// { +// if (!badge->isValid()) +// valid = false; +// if (idChecker[badge->id()]) +// validationMsg(QString("Duplicate badge with id %1").arg(badge->id())); +// idChecker[badge->id()] = true; +// } +// idChecker.clear(); +// if (!coinListCount()) +// validationMsg("There are no coin lists", V_Warn); +// foreach (CoinList* coinList, m_coinLists) +// { +// if (!coinList->isValid()) +// valid = false; +// if (idChecker[coinList->id()]) +// validationMsg(QString("Duplicate coin list with id %1").arg(coinList->id())); +// idChecker[coinList->id()] = true; +// } +// idChecker.clear(); +// if (!dialogCount()) +// { +// validationMsg("There are no dialogs"); +// valid = false; +// } +// foreach (Dialog* dialog, m_dialogs) +// { +// if (!dialog->isValid()) +// valid = false; +// if (idChecker[dialog->id()]) +// validationMsg(QString("Duplicate dialog with id %1").arg(dialog->id())); +// idChecker[dialog->id()] = true; +// } +// idChecker.clear(); +// if (m_rules.breedingAllowed()) +// { +// if (!eggGroupCount()) +// { +// validationMsg("There are no egg grous"); +// valid = false; +// } +// foreach (EggGroup* eggGroup, m_eggGroups) +// { +// if (!eggGroup->isValid()) +// valid = false; +// if (idChecker[eggGroup->id()]) +// validationMsg(QString("Duplicate egg group with id %1").arg(eggGroup->id())); +// idChecker[eggGroup->id()] = true; +// } +// idChecker.clear(); +// } +// if (!itemCount()) +// validationMsg("There are no m_items", V_Warn); +// foreach (Item* item, m_items) +// { +// if (!item->isValid()) +// valid = false; +// if (idChecker[item->id()]) +// validationMsg(QString("Duplicate item with id %1").arg(item->id())); +// idChecker[item->id()] = true; +// } +// idChecker.clear(); +// if (!itemTypeCount()) +// { +// validationMsg("There are no item types", itemCount() ? V_Error : V_Warn); +// if (itemCount()) +// valid = false; +// } +// foreach (ItemType* itemType, m_itemTypes) +// { +// if (!itemType->isValid()) +// valid = false; +// if (idChecker[itemType->id()]) +// validationMsg(QString("Duplicate item type with id %1").arg(itemType->id())); +// idChecker[itemType->id()] = true; +// } +// idChecker.clear(); +// if (!mapCount()) +// { +// validationMsg("There are no m_maps"); +// valid = false; +// } +// foreach (Map* map, m_maps) +// { +// if (!map->isValid()) +// valid = false; +// if (idChecker[map->id()]) +// validationMsg(QString("Duplicate map with id %1").arg(map->id())); +// idChecker[map->id()] = true; +// } +// idChecker.clear(); +// if (!moveCount()) +// { +// validationMsg("There are no m_moves"); +// valid = false; +// } +// foreach (Move* move, m_moves) +// { +// if (!move->isValid()) +// valid = false; +// if (idChecker[move->id()]) +// validationMsg(QString("Duplicate move with id %1").arg(move->id())); +// idChecker[move->id()] = true; +// } +// idChecker.clear(); +// if (m_rules.natureAllowed()) +// { +// if (!natureCount()) +// { +// validationMsg("There are no natures"); +// valid = false; +// } +// foreach (Nature* nature, m_natures) +// { +// if (!nature->isValid()) +// valid = false; +// if (idChecker[nature->id()]) +// validationMsg(QString("Duplicate ability with id %1").arg(nature->id())); +// idChecker[nature->id()] = true; +// } +// idChecker.clear(); +// } +// if (!speciesCount()) +// { +// validationMsg("There are no m_species"); +// valid = false; +// } +// foreach (Species* m_species, m_species) +// { +// if (!m_species->isValid()) +// valid = false; +// if (idChecker[m_species->id()]) +// validationMsg(QString("Duplicate m_species with id %1").arg(m_species->id())); +// idChecker[m_species->id()] = true; +// } +// idChecker.clear(); +// if (!storeCount()) +// validationMsg("There are no m_stores", V_Warn); +// foreach (Store* store, m_stores) +// { +// if (!store->isValid()) +// valid = false; +// if (idChecker[store->id()]) +// validationMsg(QString("Duplicate store with id %1").arg(store->id())); +// idChecker[store->id()] = true; +// } +// idChecker.clear(); +// if (!tileCount()) +// { +// validationMsg("There are no m_tiles"); +// valid = false; +// } +// foreach (Tile* tile, m_tiles) +// { +// if (!tile->isValid()) +// valid = false; +// if (idChecker[tile->id()]) +// validationMsg(QString("Duplicate tile with id %1").arg(tile->id())); +// idChecker[tile->id()] = true; +// } +// idChecker.clear(); +// if (!trainerCount()) +// { +// validationMsg("There are no times", Pokemod::V_Warn); +// } +// foreach (Trainer* trainer, m_trainers) +// { +// if (!trainer->isValid()) +// valid = false; +// if (idChecker[trainer->id()]) +// validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id())); +// idChecker[trainer->id()] = true; +// } +// idChecker.clear(); +// if (!timeCount()) +// { +// validationMsg("There are no times"); +// valid = false; +// } +// foreach (Time* time, m_times) +// { +// if (!time->isValid()) +// valid = false; +// if (idChecker[time->id()]) +// validationMsg(QString("Duplicate time with id %1").arg(time->id())); +// idChecker[time->id()] = true; +// if (timeChecker[(60 * time->hour()) + time->minute()]) +// validationMsg(QString("Duplicate time at %1:%2").arg(time->hour()).arg(time->minute())); +// timeChecker[(60 * time->hour()) + time->minute()] = true; +// } +// idChecker.clear(); +// if (!typeCount()) +// { +// validationMsg("There are no types"); +// valid = false; +// } +// foreach (Type* type, m_types) +// { +// if (!type->isValid()) +// valid = false; +// if (idChecker[type->id()]) +// validationMsg(QString("Duplicate type with id %1").arg(type->id())); +// idChecker[type->id()] = true; +// } +// return valid; } void Pokemod::load(const QDomElement& xml, const int) throw(Exception) |
