summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWildList.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/MapWildList.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
downloadsigen-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/MapWildList.cpp')
-rw-r--r--pokemod/MapWildList.cpp187
1 files changed, 94 insertions, 93 deletions
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 1b239e8b..3bc04a18 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -15,42 +15,42 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "MapWildList.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Item.h"
#include "ItemEffect.h"
#include "MapWildListEncounter.h"
+#include "Pokemod.h"
-// Header include
-#include "MapWildList.h"
+// Qt includes
+#include <QMap>
const QStringList MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash";
MapWildList::MapWildList(const MapWildList& wildList) :
- Object("MapWildList", wildList.pokemod(), wildList.id())
+ Object("MapWildList", wildList.parent(), wildList.id())
{
*this = wildList;
}
-MapWildList::MapWildList(const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id),
+MapWildList::MapWildList(const Object* parent, const int id) :
+ Object("MapWildList", parent, id),
m_control(INT_MAX),
m_value(INT_MAX),
m_scope(INT_MAX)
{
}
-MapWildList::MapWildList(const MapWildList& wildList, const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id)
+MapWildList::MapWildList(const MapWildList& wildList, const Object* parent, const int id) :
+ Object("MapWildList", parent, id)
{
*this = wildList;
}
-MapWildList::MapWildList(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id)
+MapWildList::MapWildList(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapWildList", parent, id)
{
load(xml, id);
}
@@ -62,79 +62,80 @@ MapWildList::~MapWildList()
bool MapWildList::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Wild List with id %1---").arg(id()), Pokemod::V_Msg);
- if (End <= m_control)
- {
- pokemod()->validationMsg("Invalid control");
- valid = false;
- }
- else if (m_control == Fishing)
- {
- bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
- {
- const Item* item = pokemod()->item(i);
- for (int j = 0; (j < item->effectCount()) && !ok; ++j)
- {
- const ItemEffect* effect = item->effect(j);
- ok = ((effect->effect() == ItemEffect::E_Fish) && (effect->value2() == m_value));
- }
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid fishing value");
- valid = false;
- }
- }
- QMap<int, bool> idChecker;
- foreach (int time, m_times)
- {
- if (pokemod()->timeIndex(time) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid time");
- valid = false;
- }
- if (idChecker[time])
- pokemod()->validationMsg(QString("Duplicate of time %1").arg(time));
- idChecker[time] = true;
- }
- idChecker.clear();
- if (m_scope != INT_MAX)
- {
- bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
- {
- const Item* item = pokemod()->item(i);
- for (int j = 0; (j < item->effectCount()) && !ok; ++j)
- {
- const ItemEffect* effect = item->effect(j);
- ok = ((effect->effect() == ItemEffect::E_Scope) && (effect->value2() == m_scope));
- }
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid scope");
- valid = false;
- }
- }
- if (encounterCount())
- {
- foreach (MapWildListEncounter* encounter, m_encounters)
- {
- if (!encounter->isValid())
- valid = false;
- if (idChecker[encounter->id()])
- pokemod()->validationMsg(QString("Duplicate encounter with id %1").arg(encounter->id()));
- idChecker[encounter->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg(QString("No effects"));
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Wild List with id %1---").arg(id()), Pokemod::V_Msg);
+// if (End <= m_control)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid control");
+// valid = false;
+// }
+// else if (m_control == Fishing)
+// {
+// bool ok = false;
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
+// for (int j = 0; (j < item->effectCount()) && !ok; ++j)
+// {
+// const ItemEffect* effect = item->effect(j);
+// ok = ((effect->effect() == ItemEffect::E_Fish) && (effect->value2() == m_value));
+// }
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid fishing value");
+// valid = false;
+// }
+// }
+// QMap<int, bool> idChecker;
+// foreach (int time, m_times)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->timeIndex(time) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid time");
+// valid = false;
+// }
+// if (idChecker[time])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of time %1").arg(time));
+// idChecker[time] = true;
+// }
+// idChecker.clear();
+// if (m_scope != INT_MAX)
+// {
+// bool ok = false;
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
+// for (int j = 0; (j < item->effectCount()) && !ok; ++j)
+// {
+// const ItemEffect* effect = item->effect(j);
+// ok = ((effect->effect() == ItemEffect::E_Scope) && (effect->value2() == m_scope));
+// }
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid scope");
+// valid = false;
+// }
+// }
+// if (encounterCount())
+// {
+// foreach (MapWildListEncounter* encounter, m_encounters)
+// {
+// if (!encounter->isValid())
+// valid = false;
+// if (idChecker[encounter->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate encounter with id %1").arg(encounter->id()));
+// idChecker[encounter->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("No effects"));
+// valid = false;
+// }
+// return valid;
}
void MapWildList::load(const QDomElement& xml, int id)
@@ -171,9 +172,9 @@ void MapWildList::setValue(const int value) throw(Exception)
if (m_control != Fishing)
error<UnusedException>("value");
bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
{
- const Item* item = pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
for (int j = 0; (j < item->effectCount()) && !ok; ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -187,7 +188,7 @@ void MapWildList::setValue(const int value) throw(Exception)
void MapWildList::setTime(const int time, const bool state) throw(BoundsException)
{
- if (pokemod()->timeIndex(time) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->timeIndex(time) == INT_MAX)
error<BoundsException>("time");
if (state)
{
@@ -203,9 +204,9 @@ void MapWildList::setScope(const int scope) throw(BoundsException)
if (scope != INT_MAX)
{
bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
{
- const Item* item = pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
for (int j = 0; (j < item->effectCount()) && !ok; ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -279,19 +280,19 @@ int MapWildList::encounterCount() const
MapWildListEncounter* MapWildList::newEncounter()
{
- m_encounters.append(new MapWildListEncounter(pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const QDomElement& xml)
{
- m_encounters.append(new MapWildListEncounter(xml, pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(xml, this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& encounter)
{
- m_encounters.append(new MapWildListEncounter(encounter, pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(encounter, this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}