/* * Copyright 2007-2008 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ // Header include #include "Sigmod.h" // Sigmod includes #include "Ability.h" #include "Author.h" #include "Badge.h" #include "CoinList.h" #include "EggGroup.h" #include "GlobalScript.h" #include "Item.h" #include "ItemType.h" #include "Macros.h" #include "Map.h" #include "Move.h" #include "Nature.h" #include "Rules.h" #include "Skin.h" #include "Sound.h" #include "Species.h" #include "Sprite.h" #include "Status.h" #include "Store.h" #include "Tile.h" #include "Time.h" #include "Trainer.h" #include "Type.h" #include "Weather.h" // Qt includes #include Sigmod::Sigmod::Sigmod() : Object(NULL, 0), m_title(""), m_version(""), m_description(""), m_singlePlayer(true), m_startMap(INT_MAX), m_startWarp(INT_MAX), m_typechart(0, 0), m_rules(new Rules(this)) { } Sigmod::Sigmod::Sigmod(const Sigmod& sigmod) : Object(NULL, 0), m_rules(new Rules(this)) { *this = sigmod; } Sigmod::Sigmod::Sigmod(const QDomElement& xml) : Object(NULL, 0), m_rules(new Rules(this)) { load(xml); } Sigmod::Sigmod::~Sigmod() { delete m_rules; clear(); } void Sigmod::Sigmod::validate() { TEST_BEGIN(); if (m_title.isEmpty()) emit(error("Title is empty")); if (m_version.isEmpty()) emit(error("Version is empty")); if (m_description.isEmpty()) emit(warning("Description is empty")); if (m_singlePlayer) { const Map* map = mapById(m_startMap); if (!map) emit(error("Invalid starting map")); else if (!map->warpById(m_startWarp)) emit(error("Invalid starting warp")); } if ((m_typechart.width() != typeCount()) || (m_typechart.height() != typeCount())) emit(error("Type chart is invalid")); TEST_CHILD(m_rules); QSet idChecker; QSet nameChecker; QSet timeChecker; if (abilityCount() < m_rules->maxAbilities()) emit(error("There are too few abilities")); TEST_SUB_BEGIN(Ability, abilities); TEST_SUB("ability", id); TEST_SUB("ability", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!authorCount()) emit(error("There are no authors")); TEST_SUB_BEGIN(Author, authors); TEST_SUB("author", id); TEST_SUB("author", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!badgeCount()) emit(error("There are no badges")); TEST_SUB_BEGIN(Badge, badges); TEST_SUB("badge", id); TEST_SUB("badge", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!coinListCount()) emit(warning("There are no coin lists")); TEST_SUB_BEGIN(CoinList, coinLists); TEST_SUB("coin list", id); TEST_SUB("coin list", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (m_rules->breedingAllowed()) { if (!eggGroupCount()) emit(error("There are no egg groups")); TEST_SUB_BEGIN(EggGroup, eggGroups); TEST_SUB("egg group", id); TEST_SUB("egg group", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); } if (!globalScriptCount()) emit(warning("There are no global scripts")); TEST_SUB_BEGIN(GlobalScript, globalScripts); TEST_SUB("global script", id); TEST_SUB("global script", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!itemCount()) emit(warning("There are no items")); TEST_SUB_BEGIN(Item, items); TEST_SUB("item", id); TEST_SUB("item", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!itemTypeCount() && itemCount()) emit(error("There are no item types")); TEST_SUB_BEGIN(ItemType, itemTypes); TEST_SUB("item type", id); TEST_SUB("item type", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!mapCount()) emit(error("There are no maps")); TEST_SUB_BEGIN(Map, maps); TEST_SUB("map", id); TEST_SUB("map", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!moveCount()) emit(error("There are no moves")); TEST_SUB_BEGIN(Move, moves); TEST_SUB("move", id); TEST_SUB("move", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (natureCount() < m_rules->maxNatures()) emit(error("There are too few natures")); TEST_SUB_BEGIN(Nature, natures); TEST_SUB("nature", id); TEST_SUB("nature", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); TEST_SUB_BEGIN(Skin, skins); TEST_SUB("skin", id); TEST_SUB("skin", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!soundCount()) emit(warning("There are no sounds")); TEST_SUB_BEGIN(Sound, sounds); TEST_SUB("sound", id); TEST_SUB("sound", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!speciesCount()) emit(error("There are no species")); TEST_SUB_BEGIN(Species, species); TEST_SUB("species", id); TEST_SUB("species", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!statusCount()) emit(error("There are no status effects")); TEST_SUB_BEGIN(Status, status); TEST_SUB("status", id); TEST_SUB("status", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!storeCount()) emit(warning("There are no stores")); TEST_SUB_BEGIN(Store, stores); TEST_SUB("store", id); TEST_SUB("store", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!tileCount()) emit(error("There are no tiles")); TEST_SUB_BEGIN(Tile, tiles); TEST_SUB("tile", id); TEST_SUB("tile", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!trainerCount()) emit(warning("There are no trainers")); TEST_SUB_BEGIN(Trainer, trainers); TEST_SUB("trainer", id); TEST_SUB("trainer", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!timeCount()) emit(error("There are no times")); TEST_SUB_BEGIN(Time, times); TEST_SUB("time", id); TEST_SUB("time", name); if (timeChecker.contains((60 * object->hour()) + object->minute())) emit(error(subclass("time", QString("%1:%2").arg(object->hour(), object->minute())))); timeChecker.insert((60 * object->hour()) + object->minute()); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!typeCount()) emit(error("There are no types")); TEST_SUB_BEGIN(Type, types); TEST_SUB("type", id); TEST_SUB("type", name); TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); if (!weatherCount()) emit(warning("There are no weathers")); TEST_SUB_BEGIN(Weather, weathers); TEST_SUB("weather", id); TEST_SUB("weather", name); TEST_SUB_END(); TEST_END(); } void Sigmod::Sigmod::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(title); LOAD(version); LOAD(description); LOAD(singlePlayer); LOAD(startMap); LOAD(startWarp); m_rules->load(xml.firstChildElement("Rules")); LOAD_SUB(newAbility, Ability); LOAD_SUB(newAuthor, Author); LOAD_SUB(newBadge, Badge); LOAD_SUB(newCoinList, CoinList); LOAD_SUB(newEggGroup, EggGroup); LOAD_SUB(newGlobalScript, GlobalScript); LOAD_SUB(newItem, Item); LOAD_SUB(newItemType, ItemType); LOAD_SUB(newMap, Map); LOAD_SUB(newMove, Move); LOAD_SUB(newNature, Nature); LOAD_SUB(newSkin, Skin); LOAD_SUB(newSound, Sound); LOAD_SUB(newSpecies, Species); LOAD_SUB(newSprite, Sprite); LOAD_SUB(newStatus, Status); LOAD_SUB(newStore, Store); LOAD_SUB(newTile, Tile); LOAD_SUB(newTime, Time); LOAD_SUB(newTrainer, Trainer); LOAD_SUB(newType, Type); LOAD_SUB(newWeather, Weather); LOAD_MATRIX(typechart); m_typechart.resize(typeCount(), typeCount()); } QDomElement Sigmod::Sigmod::save() const { QDomElement xml = QDomDocument().createElement(className()); SAVE(title); SAVE(version); SAVE(description); SAVE(singlePlayer); SAVE(startMap); SAVE(startWarp); SAVE_Rules(rules); SAVE_MATRIX(typechart); SAVE_SUB(Ability, abilities); SAVE_SUB(Author, authors); SAVE_SUB(Badge, badges); SAVE_SUB(CoinList, coinLists); SAVE_SUB(EggGroup, eggGroups); SAVE_SUB(GlobalScript, globalScripts); SAVE_SUB(Item, items); SAVE_SUB(ItemType, itemTypes); SAVE_SUB(Map, maps); SAVE_SUB(Move, moves); SAVE_SUB(Nature, natures); SAVE_SUB(Skin, skins); SAVE_SUB(Sound, sounds); SAVE_SUB(Species, species); SAVE_SUB(Sprite, sprites); SAVE_SUB(Status, status); SAVE_SUB(Store, stores); SAVE_SUB(Tile, tiles); SAVE_SUB(Time, times); SAVE_SUB(Trainer, trainers); SAVE_SUB(Type, types); SAVE_SUB(Weather, weathers); return xml; } SETTER(Sigmod, QString&, Title, title) SETTER(Sigmod, QString&, Version, version) SETTER(Sigmod, QString&, Description, description) SETTER(Sigmod, bool, SinglePlayer, singlePlayer) SETTER(Sigmod, int, StartMap, startMap) SETTER(Sigmod, int, StartWarp, startWarp) SETTER_MATRIX(Sigmod, Sigcore::Fraction&, Typechart, typechart, multiplier) void Sigmod::Sigmod::setRules(const Rules& rules) { *m_rules = rules; } void Sigmod::Sigmod::setRules(const QDomElement& xml) { m_rules->load(xml); } GETTER(Sigmod, QString, title) GETTER(Sigmod, QString, version) GETTER(Sigmod, QString, description) GETTER(Sigmod, bool, singlePlayer) GETTER(Sigmod, int, startMap) GETTER(Sigmod, int, startWarp) const Sigcore::Matrix* Sigmod::Sigmod::typechart() const { return &m_typechart; } Sigcore::Matrix* Sigmod::Sigmod::typechart() { return &m_typechart; } Sigcore::Fraction Sigmod::Sigmod::typechart(const int attack, const int defense) const { return m_typechart(attack, defense); } const Sigmod::Rules* Sigmod::Sigmod::rules() const { return m_rules; } Sigmod::Rules* Sigmod::Sigmod::rules() { return m_rules; } CHECK(Sigmod, QString&, title) CHECK(Sigmod, QString&, version) CHECK(Sigmod, QString&, description) CHECK(Sigmod, bool, singlePlayer) CHECK_BEGIN(Sigmod, int, startMap) if (!m_singlePlayer) { emit(error(unused("startMap"))); return false; } if (!mapById(startMap)) EBOUNDS_IDX(startMap); CHECK_END() CHECK_BEGIN(Sigmod, int, startWarp) if (!m_singlePlayer) { emit(error(unused("startWarp"))); return false; } const Map* map = mapById(m_startMap); if (!map) EBOUNDS_IDX(m_startMap); IBOUNDS(startWarp, map, warp); CHECK_END() CHECK_BOUNDS(Sigmod, Sigcore::Fraction&, typechart, 0, INT_MAX) const Sigmod::Ability* Sigmod::Sigmod::ability(const int index) const { if (index < abilityCount()) return m_abilities.at(index); return NULL; } Sigmod::Ability* Sigmod::Sigmod::ability(const int index) { if (index < abilityCount()) return m_abilities[index]; return NULL; } const Sigmod::Ability* Sigmod::Sigmod::abilityById(const int id) const { return ability(abilityIndex(id)); } Sigmod::Ability* Sigmod::Sigmod::abilityById(const int id) { return ability(abilityIndex(id)); } int Sigmod::Sigmod::abilityIndex(const int id) const { for (int i = 0; i < abilityCount(); ++i) { if (m_abilities[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::abilityCount() const { return m_abilities.size(); } Sigmod::Ability* Sigmod::Sigmod::newAbility() { return newAbility(new Ability(this, newAbilityId())); } Sigmod::Ability* Sigmod::Sigmod::newAbility(const QDomElement& xml) { return newAbility(new Ability(xml, this, newAbilityId())); } Sigmod::Ability* Sigmod::Sigmod::newAbility(const Ability& ability) { return newAbility(new Ability(ability, this, newAbilityId())); } Sigmod::Ability* Sigmod::Sigmod::newAbility(Ability* ability) { m_abilities.append(ability); return ability; } void Sigmod::Sigmod::deleteAbility(const int index) { if (index < abilityCount()) { delete m_abilities[index]; m_abilities.removeAt(index); } } void Sigmod::Sigmod::deleteAbilityById(const int id) { deleteAbility(abilityIndex(id)); } int Sigmod::Sigmod::newAbilityId() const { int i = 0; while ((i < abilityCount()) && (abilityIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Author* Sigmod::Sigmod::author(const int index) const { if (index < authorCount()) return m_authors.at(index); return NULL; } Sigmod::Author* Sigmod::Sigmod::author(const int index) { if (index < authorCount()) return m_authors[index]; return NULL; } const Sigmod::Author* Sigmod::Sigmod::authorById(const int id) const { return author(authorIndex(id)); } Sigmod::Author* Sigmod::Sigmod::authorById(const int id) { return author(authorIndex(id)); } int Sigmod::Sigmod::authorIndex(const int id) const { for (int i = 0; i < authorCount(); ++i) { if (m_authors[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::authorCount() const { return m_authors.size(); } Sigmod::Author* Sigmod::Sigmod::newAuthor() { return newAuthor(new Author(this, newAuthorId())); } Sigmod::Author* Sigmod::Sigmod::newAuthor(const QDomElement& xml) { return newAuthor(new Author(xml, this, newAuthorId())); } Sigmod::Author* Sigmod::Sigmod::newAuthor(const Author& author) { return newAuthor(new Author(author, this, newAuthorId())); } Sigmod::Author* Sigmod::Sigmod::newAuthor(Author* author) { m_authors.append(author); return author; } void Sigmod::Sigmod::deleteAuthor(const int index) { if (index < authorCount()) { delete m_authors[index]; m_authors.removeAt(index); } } void Sigmod::Sigmod::deleteAuthorById(const int id) { deleteAuthor(authorIndex(id)); } int Sigmod::Sigmod::newAuthorId() const { int i = 0; while ((i < authorCount()) && (authorIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Badge* Sigmod::Sigmod::badge(const int index) const { if (index < badgeCount()) return m_badges.at(index); return NULL; } Sigmod::Badge* Sigmod::Sigmod::badge(const int index) { if (index < badgeCount()) return m_badges[index]; return NULL; } const Sigmod::Badge* Sigmod::Sigmod::badgeById(const int id) const { return badge(badgeIndex(id)); } Sigmod::Badge* Sigmod::Sigmod::badgeById(const int id) { return badge(badgeIndex(id)); } int Sigmod::Sigmod::badgeIndex(const int id) const { for (int i = 0; i < badgeCount(); ++i) { if (m_badges[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::badgeCount() const { return m_badges.size(); } Sigmod::Badge* Sigmod::Sigmod::newBadge() { return newBadge(new Badge(this, newBadgeId())); } Sigmod::Badge* Sigmod::Sigmod::newBadge(const QDomElement& xml) { return newBadge(new Badge(xml, this, newBadgeId())); } Sigmod::Badge* Sigmod::Sigmod::newBadge(const Badge& badge) { return newBadge(new Badge(badge, this, newBadgeId())); } Sigmod::Badge* Sigmod::Sigmod::newBadge(Badge* badge) { m_badges.append(badge); return badge; } void Sigmod::Sigmod::deleteBadge(const int index) { if (index < badgeCount()) { delete m_badges[index]; m_badges.removeAt(index); } } void Sigmod::Sigmod::deleteBadgeById(const int id) { deleteBadge(badgeIndex(id)); } int Sigmod::Sigmod::newBadgeId() const { int i = 0; while ((i < badgeCount()) && (badgeIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::CoinList* Sigmod::Sigmod::coinList(const int index) const { if (index < coinListCount()) return m_coinLists.at(index); return NULL; } Sigmod::CoinList* Sigmod::Sigmod::coinList(const int index) { if (index < coinListCount()) return m_coinLists[index]; return NULL; } const Sigmod::CoinList* Sigmod::Sigmod::coinListById(const int id) const { return coinList(coinListIndex(id)); } Sigmod::CoinList* Sigmod::Sigmod::coinListById(const int id) { return coinList(coinListIndex(id)); } int Sigmod::Sigmod::coinListIndex(const int id) const { for (int i = 0; i < coinListCount(); ++i) { if (m_coinLists[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::coinListCount() const { return m_coinLists.size(); } Sigmod::CoinList* Sigmod::Sigmod::newCoinList() { return newCoinList(new CoinList(this, newCoinListId())); } Sigmod::CoinList* Sigmod::Sigmod::newCoinList(const QDomElement& xml) { return newCoinList(new CoinList(xml, this, newCoinListId())); } Sigmod::CoinList* Sigmod::Sigmod::newCoinList(const CoinList& coinList) { return newCoinList(new CoinList(coinList, this, newCoinListId())); } Sigmod::CoinList* Sigmod::Sigmod::newCoinList(CoinList* coinList) { m_coinLists.append(coinList); return coinList; } void Sigmod::Sigmod::deleteCoinList(const int index) { if (index < coinListCount()) { delete m_coinLists[index]; m_coinLists.removeAt(index); } } void Sigmod::Sigmod::deleteCoinListById(const int id) { deleteCoinList(coinListIndex(id)); } int Sigmod::Sigmod::newCoinListId() const { int i = 0; while ((i < coinListCount()) && (coinListIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::EggGroup* Sigmod::Sigmod::eggGroup(const int index) const { if (index < eggGroupCount()) return m_eggGroups.at(index); return NULL; } Sigmod::EggGroup* Sigmod::Sigmod::eggGroup(const int index) { if (index < eggGroupCount()) return m_eggGroups[index]; return NULL; } const Sigmod::EggGroup* Sigmod::Sigmod::eggGroupById(const int id) const { return eggGroup(eggGroupIndex(id)); } Sigmod::EggGroup* Sigmod::Sigmod::eggGroupById(const int id) { return eggGroup(eggGroupIndex(id)); } int Sigmod::Sigmod::eggGroupIndex(const int id) const { for (int i = 0; i < eggGroupCount(); ++i) { if (m_eggGroups[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::eggGroupCount() const { return m_eggGroups.size(); } Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup() { return newEggGroup(new EggGroup(this, newEggGroupId())); } Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(const QDomElement& xml) { return newEggGroup(new EggGroup(xml, this, newEggGroupId())); } Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(const EggGroup& eggGroup) { return newEggGroup(new EggGroup(eggGroup, this, newEggGroupId())); } Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(EggGroup* eggGroup) { m_eggGroups.append(eggGroup); return eggGroup; } void Sigmod::Sigmod::deleteEggGroup(const int index) { if (index < eggGroupCount()) { delete m_eggGroups[index]; m_eggGroups.removeAt(index); } } void Sigmod::Sigmod::deleteEggGroupById(const int id) { deleteEggGroup(eggGroupIndex(id)); } int Sigmod::Sigmod::newEggGroupId() const { int i = 0; while ((i < eggGroupCount()) && (eggGroupIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::GlobalScript* Sigmod::Sigmod::globalScript(const int index) const { if (index < globalScriptCount()) return m_globalScripts.at(index); return NULL; } Sigmod::GlobalScript* Sigmod::Sigmod::globalScript(const int index) { if (index < globalScriptCount()) return m_globalScripts[index]; return NULL; } const Sigmod::GlobalScript* Sigmod::Sigmod::globalScriptById(const int id) const { return globalScript(globalScriptIndex(id)); } Sigmod::GlobalScript* Sigmod::Sigmod::globalScriptById(const int id) { return globalScript(globalScriptIndex(id)); } int Sigmod::Sigmod::globalScriptIndex(const int id) const { for (int i = 0; i < globalScriptCount(); ++i) { if (m_globalScripts[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::globalScriptCount() const { return m_globalScripts.size(); } Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript() { return newGlobalScript(new GlobalScript(this, newGlobalScriptId())); } Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(const QDomElement& xml) { return newGlobalScript(new GlobalScript(xml, this, newGlobalScriptId())); } Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(const GlobalScript& globalScript) { return newGlobalScript(new GlobalScript(globalScript, this, newGlobalScriptId())); } Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(GlobalScript* globalScript) { m_globalScripts.append(globalScript); return globalScript; } void Sigmod::Sigmod::deleteGlobalScript(const int index) { if (index < globalScriptCount()) { delete m_globalScripts[index]; m_globalScripts.removeAt(index); } } void Sigmod::Sigmod::deleteGlobalScriptById(const int id) { deleteGlobalScript(globalScriptIndex(id)); } int Sigmod::Sigmod::newGlobalScriptId() const { int i = 0; while ((i < globalScriptCount()) && (globalScriptIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Item* Sigmod::Sigmod::item(const int index) const { if (index < itemCount()) return m_items.at(index); return NULL; } Sigmod::Item* Sigmod::Sigmod::item(const int index) { if (index < itemCount()) return m_items[index]; return NULL; } const Sigmod::Item* Sigmod::Sigmod::itemById(const int id) const { return item(itemIndex(id)); } Sigmod::Item* Sigmod::Sigmod::itemById(const int id) { return item(itemIndex(id)); } int Sigmod::Sigmod::itemIndex(const int id) const { for (int i = 0; i < itemCount(); ++i) { if (m_items[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::itemCount() const { return m_items.size(); } Sigmod::Item* Sigmod::Sigmod::newItem() { return newItem(new Item(this, newItemId())); } Sigmod::Item* Sigmod::Sigmod::newItem(const QDomElement& xml) { return newItem(new Item(xml, this, newItemId())); } Sigmod::Item* Sigmod::Sigmod::newItem(const Item& item) { return newItem(new Item(item, this, newItemId())); } Sigmod::Item* Sigmod::Sigmod::newItem(Item* item) { m_items.append(item); return item; } void Sigmod::Sigmod::deleteItem(const int index) { if (index < itemCount()) { delete m_items[index]; m_items.removeAt(index); } } void Sigmod::Sigmod::deleteItemById(const int id) { deleteItem(itemIndex(id)); } int Sigmod::Sigmod::newItemId() const { int i = 0; while ((i < itemCount()) && (itemIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::ItemType* Sigmod::Sigmod::itemType(const int index) const { if (index < itemTypeCount()) return m_itemTypes.at(index); return NULL; } Sigmod::ItemType* Sigmod::Sigmod::itemType(const int index) { if (index < itemTypeCount()) return m_itemTypes[index]; return NULL; } const Sigmod::ItemType* Sigmod::Sigmod::itemTypeById(const int id) const { return itemType(itemTypeIndex(id)); } Sigmod::ItemType* Sigmod::Sigmod::itemTypeById(const int id) { return itemType(itemTypeIndex(id)); } int Sigmod::Sigmod::itemTypeIndex(const int id) const { for (int i = 0; i < itemTypeCount(); ++i) { if (m_itemTypes[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::itemTypeCount() const { return m_itemTypes.size(); } Sigmod::ItemType* Sigmod::Sigmod::newItemType() { return newItemType(new ItemType(this, newItemTypeId())); } Sigmod::ItemType* Sigmod::Sigmod::newItemType(const QDomElement& xml) { return newItemType(new ItemType(xml, this, newItemTypeId())); } Sigmod::ItemType* Sigmod::Sigmod::newItemType(const ItemType& itemType) { return newItemType(new ItemType(itemType, this, newItemTypeId())); } Sigmod::ItemType* Sigmod::Sigmod::newItemType(ItemType* itemType) { m_itemTypes.append(itemType); return itemType; } void Sigmod::Sigmod::deleteItemType(const int index) { if (index < itemTypeCount()) { delete m_itemTypes[index]; m_itemTypes.removeAt(index); } } void Sigmod::Sigmod::deleteItemTypeById(const int id) { deleteItemType(itemTypeIndex(id)); } int Sigmod::Sigmod::newItemTypeId() const { int i = 0; while ((i < itemTypeCount()) && (itemTypeIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Map* Sigmod::Sigmod::map(const int index) const { if (index < mapCount()) return m_maps.at(index); return NULL; } Sigmod::Map* Sigmod::Sigmod::map(const int index) { if (index < mapCount()) return m_maps[index]; return NULL; } const Sigmod::Map* Sigmod::Sigmod::mapById(const int id) const { return map(mapIndex(id)); } Sigmod::Map* Sigmod::Sigmod::mapById(const int id) { return map(mapIndex(id)); } int Sigmod::Sigmod::mapIndex(const int id) const { for (int i = 0; i < mapCount(); ++i) { if (m_maps[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::mapCount() const { return m_maps.size(); } Sigmod::Map* Sigmod::Sigmod::newMap() { return newMap(new Map(this, newMapId())); } Sigmod::Map* Sigmod::Sigmod::newMap(const QDomElement& xml) { return newMap(new Map(xml, this, newMapId())); } Sigmod::Map* Sigmod::Sigmod::newMap(const Map& map) { return newMap(new Map(map, this, newMapId())); } Sigmod::Map* Sigmod::Sigmod::newMap(Map* map) { m_maps.append(map); return map; } void Sigmod::Sigmod::deleteMap(const int index) { if (index < mapCount()) { delete m_maps[index]; m_maps.removeAt(index); } } void Sigmod::Sigmod::deleteMapById(const int id) { deleteMap(mapIndex(id)); } int Sigmod::Sigmod::newMapId() const { int i = 0; while ((i < mapCount()) && (mapIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Move* Sigmod::Sigmod::move(const int index) const { if (index < moveCount()) return m_moves.at(index); return NULL; } Sigmod::Move* Sigmod::Sigmod::move(const int index) { if (index < moveCount()) return m_moves[index]; return NULL; } const Sigmod::Move* Sigmod::Sigmod::moveById(const int id) const { return move(moveIndex(id)); } Sigmod::Move* Sigmod::Sigmod::moveById(const int id) { return move(moveIndex(id)); } int Sigmod::Sigmod::moveIndex(const int id) const { for (int i = 0; i < moveCount(); ++i) { if (m_moves[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::moveCount() const { return m_moves.size(); } Sigmod::Move* Sigmod::Sigmod::newMove() { return newMove(new Move(this, newMoveId())); } Sigmod::Move* Sigmod::Sigmod::newMove(const QDomElement& xml) { return newMove(new Move(xml, this, newMoveId())); } Sigmod::Move* Sigmod::Sigmod::newMove(const Move& move) { return newMove(new Move(move, this, newMoveId())); } Sigmod::Move* Sigmod::Sigmod::newMove(Move* move) { m_moves.append(move); return move; } void Sigmod::Sigmod::deleteMove(const int index) { if (index < moveCount()) { delete m_moves[index]; m_moves.removeAt(index); } } void Sigmod::Sigmod::deleteMoveById(const int id) { deleteMove(moveIndex(id)); } int Sigmod::Sigmod::newMoveId() const { int i = 0; while ((i < moveCount()) && (moveIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Nature* Sigmod::Sigmod::nature(const int index) const { if (index < natureCount()) return m_natures.at(index); return NULL; } Sigmod::Nature* Sigmod::Sigmod::nature(const int index) { if (index < natureCount()) return m_natures[index]; return NULL; } const Sigmod::Nature* Sigmod::Sigmod::natureById(const int id) const { return nature(natureIndex(id)); } Sigmod::Nature* Sigmod::Sigmod::natureById(const int id) { return nature(natureIndex(id)); } int Sigmod::Sigmod::natureIndex(const int id) const { for (int i = 0; i < natureCount(); ++i) { if (m_natures[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::natureCount() const { return m_natures.size(); } Sigmod::Nature* Sigmod::Sigmod::newNature() { return newNature(new Nature(this, newNatureId())); } Sigmod::Nature* Sigmod::Sigmod::newNature(const QDomElement& xml) { return newNature(new Nature(xml, this, newNatureId())); } Sigmod::Nature* Sigmod::Sigmod::newNature(const Nature& nature) { return newNature(new Nature(nature, this, newNatureId())); } Sigmod::Nature* Sigmod::Sigmod::newNature(Nature* nature) { m_natures.append(nature); return nature; } void Sigmod::Sigmod::deleteNature(const int index) { if (index < natureCount()) { delete m_natures[index]; m_natures.removeAt(index); } } void Sigmod::Sigmod::deleteNatureById(const int id) { deleteNature(natureIndex(id)); } int Sigmod::Sigmod::newNatureId() const { int i = 0; while ((i < natureCount()) && (natureIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Skin* Sigmod::Sigmod::skin(const int index) const { if (index < skinCount()) return m_skins.at(index); return NULL; } Sigmod::Skin* Sigmod::Sigmod::skin(const int index) { if (index < skinCount()) return m_skins[index]; return NULL; } const Sigmod::Skin* Sigmod::Sigmod::skinById(const int id) const { return skin(skinIndex(id)); } Sigmod::Skin* Sigmod::Sigmod::skinById(const int id) { return skin(skinIndex(id)); } int Sigmod::Sigmod::skinIndex(const int id) const { for (int i = 0; i < skinCount(); ++i) { if (m_skins[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::skinCount() const { return m_skins.size(); } Sigmod::Skin* Sigmod::Sigmod::newSkin() { return newSkin(new Skin(this, newSkinId())); } Sigmod::Skin* Sigmod::Sigmod::newSkin(const QDomElement& xml) { return newSkin(new Skin(xml, this, newSkinId())); } Sigmod::Skin* Sigmod::Sigmod::newSkin(const Skin& skin) { return newSkin(new Skin(skin, this, newSkinId())); } Sigmod::Skin* Sigmod::Sigmod::newSkin(Skin* skin) { m_skins.append(skin); return skin; } void Sigmod::Sigmod::deleteSkin(const int index) { if (index < skinCount()) { delete m_skins[index]; m_skins.removeAt(index); } } void Sigmod::Sigmod::deleteSkinById(const int id) { deleteSkin(skinIndex(id)); } int Sigmod::Sigmod::newSkinId() const { int i = 0; while ((i < skinCount()) && (skinIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Sound* Sigmod::Sigmod::sound(const int index) const { if (index < soundCount()) return m_sounds.at(index); return NULL; } Sigmod::Sound* Sigmod::Sigmod::sound(const int index) { if (index < soundCount()) return m_sounds[index]; return NULL; } const Sigmod::Sound* Sigmod::Sigmod::soundById(const int id) const { return sound(soundIndex(id)); } Sigmod::Sound* Sigmod::Sigmod::soundById(const int id) { return sound(soundIndex(id)); } int Sigmod::Sigmod::soundIndex(const int id) const { for (int i = 0; i < soundCount(); ++i) { if (m_sounds[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::soundCount() const { return m_sounds.size(); } Sigmod::Sound* Sigmod::Sigmod::newSound() { return newSound(new Sound(this, newSoundId())); } Sigmod::Sound* Sigmod::Sigmod::newSound(const QDomElement& xml) { return newSound(new Sound(xml, this, newSoundId())); } Sigmod::Sound* Sigmod::Sigmod::newSound(const Sound& sound) { return newSound(new Sound(sound, this, newSoundId())); } Sigmod::Sound* Sigmod::Sigmod::newSound(Sound* sound) { m_sounds.append(sound); return sound; } void Sigmod::Sigmod::deleteSound(const int index) { if (index < soundCount()) { delete m_sounds[index]; m_sounds.removeAt(index); } } void Sigmod::Sigmod::deleteSoundById(const int id) { deleteSound(soundIndex(id)); } int Sigmod::Sigmod::newSoundId() const { int i = 0; while ((i < soundCount()) && (soundIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Species* Sigmod::Sigmod::species(const int index) const { if (index < speciesCount()) return m_species.at(index); return NULL; } Sigmod::Species* Sigmod::Sigmod::species(const int index) { if (index < speciesCount()) return m_species[index]; return NULL; } const Sigmod::Species* Sigmod::Sigmod::speciesById(const int id) const { return species(speciesIndex(id)); } Sigmod::Species* Sigmod::Sigmod::speciesById(const int id) { return species(speciesIndex(id)); } int Sigmod::Sigmod::speciesIndex(const int id) const { for (int i = 0; i < speciesCount(); ++i) { if (m_species[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::speciesCount() const { return m_species.size(); } Sigmod::Species* Sigmod::Sigmod::newSpecies() { return newSpecies(new Species(this, newSpeciesId())); } Sigmod::Species* Sigmod::Sigmod::newSpecies(const QDomElement& xml) { return newSpecies(new Species(xml, this, newSpeciesId())); } Sigmod::Species* Sigmod::Sigmod::newSpecies(const Species& species) { return newSpecies(new Species(species, this, newSpeciesId())); } Sigmod::Species* Sigmod::Sigmod::newSpecies(Species* species) { m_species.append(species); return species; } void Sigmod::Sigmod::deleteSpecies(const int index) { if (index < speciesCount()) { delete m_species[index]; m_species.removeAt(index); } } void Sigmod::Sigmod::deleteSpeciesById(const int id) { deleteSpecies(speciesIndex(id)); } int Sigmod::Sigmod::newSpeciesId() const { int i = 0; while ((i < speciesCount()) && (speciesIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Sprite* Sigmod::Sigmod::sprite(const int index) const { if (index < spriteCount()) return m_sprites.at(index); return NULL; } Sigmod::Sprite* Sigmod::Sigmod::sprite(const int index) { if (index < spriteCount()) return m_sprites[index]; return NULL; } const Sigmod::Sprite* Sigmod::Sigmod::spriteById(const int id) const { return sprite(spriteIndex(id)); } Sigmod::Sprite* Sigmod::Sigmod::spriteById(const int id) { return sprite(spriteIndex(id)); } int Sigmod::Sigmod::spriteIndex(const int id) const { for (int i = 0; i < spriteCount(); ++i) { if (m_sprites[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::spriteCount() const { return m_sprites.size(); } Sigmod::Sprite* Sigmod::Sigmod::newSprite() { return newSprite(new Sprite(this, newSpriteId())); } Sigmod::Sprite* Sigmod::Sigmod::newSprite(const QDomElement& xml) { return newSprite(new Sprite(xml, this, newSpriteId())); } Sigmod::Sprite* Sigmod::Sigmod::newSprite(const Sprite& sprite) { return newSprite(new Sprite(sprite, this, newSpriteId())); } Sigmod::Sprite* Sigmod::Sigmod::newSprite(Sprite* sprite) { m_sprites.append(sprite); return sprite; } void Sigmod::Sigmod::deleteSprite(const int index) { if (index < spriteCount()) { delete m_sprites[index]; m_sprites.removeAt(index); } } void Sigmod::Sigmod::deleteSpriteById(const int id) { deleteSprite(spriteIndex(id)); } int Sigmod::Sigmod::newSpriteId() const { int i = 0; while ((i < spriteCount()) && (spriteIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Status* Sigmod::Sigmod::status(const int index) const { if (index < statusCount()) return m_status.at(index); return NULL; } Sigmod::Status* Sigmod::Sigmod::status(const int index) { if (index < statusCount()) return m_status[index]; return NULL; } const Sigmod::Status* Sigmod::Sigmod::statusById(const int id) const { return status(statusIndex(id)); } Sigmod::Status* Sigmod::Sigmod::statusById(const int id) { return status(statusIndex(id)); } int Sigmod::Sigmod::statusIndex(const int id) const { for (int i = 0; i < statusCount(); ++i) { if (m_status[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::statusCount() const { return m_status.size(); } Sigmod::Status* Sigmod::Sigmod::newStatus() { return newStatus(new Status(this, newStatusId())); } Sigmod::Status* Sigmod::Sigmod::newStatus(const QDomElement& xml) { return newStatus(new Status(xml, this, newStatusId())); } Sigmod::Status* Sigmod::Sigmod::newStatus(const Status& status) { return newStatus(new Status(status, this, newStatusId())); } Sigmod::Status* Sigmod::Sigmod::newStatus(Status* status) { m_status.append(status); return status; } void Sigmod::Sigmod::deleteStatus(const int index) { if (index < statusCount()) { delete m_status[index]; m_status.removeAt(index); } } void Sigmod::Sigmod::deleteStatusById(const int id) { deleteStatus(statusIndex(id)); } int Sigmod::Sigmod::newStatusId() const { int i = 0; while ((i < statusCount()) && (statusIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Store* Sigmod::Sigmod::store(const int index) const { if (index < storeCount()) return m_stores.at(index); return NULL; } Sigmod::Store* Sigmod::Sigmod::store(const int index) { if (index < storeCount()) return m_stores[index]; return NULL; } const Sigmod::Store* Sigmod::Sigmod::storeById(const int id) const { return store(storeIndex(id)); } Sigmod::Store* Sigmod::Sigmod::storeById(const int id) { return store(storeIndex(id)); } int Sigmod::Sigmod::storeIndex(const int id) const { for (int i = 0; i < storeCount(); ++i) { if (m_stores[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::storeCount() const { return m_stores.size(); } Sigmod::Store* Sigmod::Sigmod::newStore() { return newStore(new Store(this, newStoreId())); } Sigmod::Store* Sigmod::Sigmod::newStore(const QDomElement& xml) { return newStore(new Store(xml, this, newStoreId())); } Sigmod::Store* Sigmod::Sigmod::newStore(const Store& store) { return newStore(new Store(store, this, newStoreId())); } Sigmod::Store* Sigmod::Sigmod::newStore(Store* store) { m_stores.append(store); return store; } void Sigmod::Sigmod::deleteStore(const int index) { if (index < storeCount()) { delete m_stores[index]; m_stores.removeAt(index); } } void Sigmod::Sigmod::deleteStoreById(const int id) { deleteStore(storeIndex(id)); } int Sigmod::Sigmod::newStoreId() const { int i = 0; while ((i < storeCount()) && (storeIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Tile* Sigmod::Sigmod::tile(const int index) const { if (index < tileCount()) return m_tiles.at(index); return NULL; } Sigmod::Tile* Sigmod::Sigmod::tile(const int index) { if (index < tileCount()) return m_tiles[index]; return NULL; } const Sigmod::Tile* Sigmod::Sigmod::tileById(const int id) const { return tile(tileIndex(id)); } Sigmod::Tile* Sigmod::Sigmod::tileById(const int id) { return tile(tileIndex(id)); } int Sigmod::Sigmod::tileIndex(const int id) const { for (int i = 0; i < tileCount(); ++i) { if (m_tiles[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::tileCount() const { return m_tiles.size(); } Sigmod::Tile* Sigmod::Sigmod::newTile() { return newTile(new Tile(this, newTileId())); } Sigmod::Tile* Sigmod::Sigmod::newTile(const QDomElement& xml) { return newTile(new Tile(xml, this, newTileId())); } Sigmod::Tile* Sigmod::Sigmod::newTile(const Tile& tile) { return newTile(new Tile(tile, this, newTileId())); } Sigmod::Tile* Sigmod::Sigmod::newTile(Tile* tile) { m_tiles.append(tile); return tile; } void Sigmod::Sigmod::deleteTile(const int index) { if (index < tileCount()) { delete m_tiles[index]; m_tiles.removeAt(index); } } void Sigmod::Sigmod::deleteTileById(const int id) { deleteTile(tileIndex(id)); } int Sigmod::Sigmod::newTileId() const { int i = 0; while ((i < tileCount()) && (tileIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Time* Sigmod::Sigmod::time(const int index) const { if (index < timeCount()) return m_times.at(index); return NULL; } Sigmod::Time* Sigmod::Sigmod::time(const int index) { if (index < timeCount()) return m_times[index]; return NULL; } const Sigmod::Time* Sigmod::Sigmod::timeById(const int id) const { return time(timeIndex(id)); } Sigmod::Time* Sigmod::Sigmod::timeById(const int id) { return time(timeIndex(id)); } int Sigmod::Sigmod::timeIndex(const int id) const { for (int i = 0; i < timeCount(); ++i) { if (m_times[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::timeCount() const { return m_times.size(); } Sigmod::Time* Sigmod::Sigmod::newTime() { return newTime(new Time(this, newTimeId())); } Sigmod::Time* Sigmod::Sigmod::newTime(const QDomElement& xml) { return newTime(new Time(xml, this, newTimeId())); } Sigmod::Time* Sigmod::Sigmod::newTime(const Time& time) { return newTime(new Time(time, this, newTimeId())); } Sigmod::Time* Sigmod::Sigmod::newTime(Time* time) { m_times.append(time); return time; } void Sigmod::Sigmod::deleteTime(const int index) { if (index < timeCount()) { delete m_times[index]; m_times.removeAt(index); } } void Sigmod::Sigmod::deleteTimeById(const int id) { deleteTime(timeIndex(id)); } int Sigmod::Sigmod::newTimeId() const { int i = 0; while ((i < timeCount()) && (timeIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Trainer* Sigmod::Sigmod::trainer(const int index) const { if (index < trainerCount()) return m_trainers.at(index); return NULL; } Sigmod::Trainer* Sigmod::Sigmod::trainer(const int index) { if (index < trainerCount()) return m_trainers[index]; return NULL; } const Sigmod::Trainer* Sigmod::Sigmod::trainerById(const int id) const { return trainer(trainerIndex(id)); } Sigmod::Trainer* Sigmod::Sigmod::trainerById(const int id) { return trainer(trainerIndex(id)); } int Sigmod::Sigmod::trainerIndex(const int id) const { for (int i = 0; i < trainerCount(); ++i) { if (m_trainers[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::trainerCount() const { return m_trainers.size(); } Sigmod::Trainer* Sigmod::Sigmod::newTrainer() { return newTrainer(new Trainer(this, newTrainerId())); } Sigmod::Trainer* Sigmod::Sigmod::newTrainer(const QDomElement& xml) { return newTrainer(new Trainer(xml, this, newTrainerId())); } Sigmod::Trainer* Sigmod::Sigmod::newTrainer(const Trainer& trainer) { return newTrainer(new Trainer(trainer, this, newTrainerId())); } Sigmod::Trainer* Sigmod::Sigmod::newTrainer(Trainer* trainer) { m_trainers.append(trainer); return trainer; } void Sigmod::Sigmod::deleteTrainer(const int index) { if (index < trainerCount()) { delete m_trainers[index]; m_trainers.removeAt(index); } } void Sigmod::Sigmod::deleteTrainerById(const int id) { deleteTrainer(trainerIndex(id)); } int Sigmod::Sigmod::newTrainerId() const { int i = 0; while ((i < trainerCount()) && (trainerIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Type* Sigmod::Sigmod::type(const int index) const { if (index < typeCount()) return m_types.at(index); return NULL; } Sigmod::Type* Sigmod::Sigmod::type(const int index) { if (index < typeCount()) return m_types[index]; return NULL; } const Sigmod::Type* Sigmod::Sigmod::typeById(const int id) const { return type(typeIndex(id)); } Sigmod::Type* Sigmod::Sigmod::typeById(const int id) { return type(typeIndex(id)); } int Sigmod::Sigmod::typeIndex(const int id) const { for (int i = 0; i < typeCount(); ++i) { if (m_types[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::typeCount() const { return m_types.size(); } Sigmod::Type* Sigmod::Sigmod::newType() { return newType(new Type(this, newTypeId())); } Sigmod::Type* Sigmod::Sigmod::newType(const QDomElement& xml) { return newType(new Type(xml, this, newTypeId())); } Sigmod::Type* Sigmod::Sigmod::newType(const Type& type) { return newType(new Type(type, this, newTypeId())); } Sigmod::Type* Sigmod::Sigmod::newType(Type* type) { m_types.append(type); m_typechart.resize(typeCount(), typeCount(), Sigcore::Fraction(1, 1)); return type; } void Sigmod::Sigmod::deleteType(const int index) { if (index < typeCount()) { delete m_types[index]; m_types.removeAt(index); m_typechart.resize(typeCount(), typeCount(), Sigcore::Fraction(1, 1)); } } void Sigmod::Sigmod::deleteTypeById(const int id) { deleteType(typeIndex(id)); } int Sigmod::Sigmod::newTypeId() const { int i = 0; while ((i < typeCount()) && (typeIndex(i) != INT_MAX)) ++i; return i; } const Sigmod::Weather* Sigmod::Sigmod::weather(const int index) const { if (index < weatherCount()) return m_weathers.at(index); return NULL; } Sigmod::Weather* Sigmod::Sigmod::weather(const int index) { if (index < weatherCount()) return m_weathers[index]; return NULL; } const Sigmod::Weather* Sigmod::Sigmod::weatherById(const int id) const { return weather(weatherIndex(id)); } Sigmod::Weather* Sigmod::Sigmod::weatherById(const int id) { return weather(weatherIndex(id)); } int Sigmod::Sigmod::weatherIndex(const int id) const { for (int i = 0; i < weatherCount(); ++i) { if (m_weathers[i]->id() == id) return i; } return INT_MAX; } int Sigmod::Sigmod::weatherCount() const { return m_weathers.size(); } Sigmod::Weather* Sigmod::Sigmod::newWeather() { return newWeather(new Weather(this, newWeatherId())); } Sigmod::Weather* Sigmod::Sigmod::newWeather(const QDomElement& xml) { return newWeather(new Weather(xml, this, newWeatherId())); } Sigmod::Weather* Sigmod::Sigmod::newWeather(const Weather& weather) { return newWeather(new Weather(weather, this, newWeatherId())); } Sigmod::Weather* Sigmod::Sigmod::newWeather(Weather* weather) { m_weathers.append(weather); return weather; } void Sigmod::Sigmod::deleteWeather(const int index) { if (index < weatherCount()) { delete m_weathers[index]; m_weathers.removeAt(index); } } void Sigmod::Sigmod::deleteWeatherById(const int id) { deleteWeather(weatherIndex(id)); } int Sigmod::Sigmod::newWeatherId() const { int i = 0; while ((i < weatherCount()) && (weatherIndex(i) != INT_MAX)) ++i; return i; } Sigmod::Sigmod& Sigmod::Sigmod::operator=(const Sigmod& rhs) { if (this == &rhs) return *this; clear(); COPY(title); COPY(version); COPY(description); COPY(singlePlayer); COPY(startMap); COPY(startWarp); COPY(typechart); COPY_Rules(rules); COPY_SUB(Ability, abilities); COPY_SUB(Author, authors); COPY_SUB(Badge, badges); COPY_SUB(CoinList, coinLists); COPY_SUB(EggGroup, eggGroups); COPY_SUB(GlobalScript, globalScripts); COPY_SUB(Item, items); COPY_SUB(ItemType, itemTypes); COPY_SUB(Map, maps); COPY_SUB(Move, moves); COPY_SUB(Nature, natures); COPY_SUB(Skin, skins); COPY_SUB(Sound, sounds); COPY_SUB(Species, species); COPY_SUB(Sprite, sprites); COPY_SUB(Status, status); COPY_SUB(Store, stores); COPY_SUB(Tile, tiles); COPY_SUB(Time, times); COPY_SUB(Trainer, trainers); COPY_SUB(Type, types); COPY_SUB(Weather, weathers); m_typechart.resize(typeCount(), typeCount()); return *this; } void Sigmod::Sigmod::clear() { qDeleteAll(m_abilities); m_abilities.clear(); qDeleteAll(m_authors); m_authors.clear(); qDeleteAll(m_badges); m_badges.clear(); qDeleteAll(m_coinLists); m_coinLists.clear(); qDeleteAll(m_eggGroups); m_eggGroups.clear(); qDeleteAll(m_globalScripts); m_globalScripts.clear(); qDeleteAll(m_items); m_items.clear(); qDeleteAll(m_itemTypes); m_itemTypes.clear(); qDeleteAll(m_maps); m_maps.clear(); qDeleteAll(m_moves); m_moves.clear(); qDeleteAll(m_natures); m_natures.clear(); qDeleteAll(m_skins); m_skins.clear(); qDeleteAll(m_sounds); m_sounds.clear(); qDeleteAll(m_species); m_species.clear(); qDeleteAll(m_sprites); m_sprites.clear(); qDeleteAll(m_status); m_status.clear(); qDeleteAll(m_stores); m_stores.clear(); qDeleteAll(m_tiles); m_tiles.clear(); qDeleteAll(m_times); m_times.clear(); qDeleteAll(m_trainers); m_trainers.clear(); qDeleteAll(m_types); m_types.clear(); qDeleteAll(m_weathers); m_weathers.clear(); }