summaryrefslogtreecommitdiffstats
path: root/pokemod/Store.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/Store.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
[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/Store.cpp')
-rw-r--r--pokemod/Store.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp
index 1edbca32..e8f1af69 100644
--- a/pokemod/Store.cpp
+++ b/pokemod/Store.cpp
@@ -15,66 +15,67 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "Store.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Store.h"
+// Qt includes
+#include <QMap>
Store::Store(const Store& store) :
- Object("Store", store.pokemod(), store.id())
+ Object("Store", store.parent(), store.id())
{
*this = store;
}
-Store::Store(const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id),
+Store::Store(const Object* parent, const int id) :
+ Object("Store", parent, id),
m_name("")
{
}
-Store::Store(const Store& store, const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id)
+Store::Store(const Store& store, const Object* parent, const int id) :
+ Object("Store", parent, id)
{
*this = store;
}
-Store::Store(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id)
+Store::Store(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Store", parent, id)
{
load(xml, id);
}
bool Store::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Store \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is noe defiend");
- valid = false;
- }
- if (!m_items.size())
- {
- pokemod()->validationMsg("There are no items");
- valid = false;
- }
- QMap<int, bool> valueChecker;
- foreach (int item, m_items)
- {
- if (pokemod()->itemIndex(item) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- if (valueChecker[item])
- pokemod()->validationMsg(QString("Duplicate of item %1").arg(item));
- valueChecker[item] = true;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Store \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is noe defiend");
+// valid = false;
+// }
+// if (!m_items.size())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no items");
+// valid = false;
+// }
+// QMap<int, bool> valueChecker;
+// foreach (int item, m_items)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// if (valueChecker[item])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item));
+// valueChecker[item] = true;
+// }
+// return valid;
}
void Store::load(const QDomElement& xml, int id)
@@ -97,7 +98,7 @@ void Store::setName(const QString& name)
void Store::setItem(const int item, const bool state) throw(BoundsException)
{
- if (pokemod()->itemIndex(item) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
error<BoundsException>("item");
if (state)
{