From 822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 2 May 2008 08:42:08 +0000 Subject: [FIX] Exceptions no longer used in pokemod [DEL] Exception and BugCatcher are no longer needed [ADD] Object.cpp added git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@119 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/CoinListObject.cpp | 59 +++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) (limited to 'pokemod/CoinListObject.cpp') diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp index 499427a5..11b358f5 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -47,38 +47,12 @@ CoinListObject::CoinListObject(const QDomElement& xml, const Object* parent, con load(xml, id); } -bool CoinListObject::validate() const -{ - // TODO: validate -// bool valid = true; -// static_cast(pokemod())->validationMsg(QString("------Object with id %1---").arg(id()), Pokemod::V_Msg); -// if (Item == m_type) -// { -// if (static_cast(pokemod())->itemIndex(m_object) == INT_MAX) -// { -// static_cast(pokemod())->validationMsg("Invalid item"); -// valid = false; -// } -// } -// else if (Species == m_type) -// { -// if (static_cast(pokemod())->speciesIndex(m_object) == INT_MAX) -// { -// static_cast(pokemod())->validationMsg("Invalid Species"); -// valid = false; -// } -// } -// else -// { -// static_cast(pokemod())->validationMsg("Invalid type"); -// valid = false; -// } -// if (!m_amount || ((1 < m_amount) && (Species == m_type))) -// { -// static_cast(pokemod())->validationMsg("Invalid amount"); -// valid = false; -// } -// return valid; +void CoinListObject::validate(QTextStream& stream) +{ + TEST_SETUP(); + TEST(setType, type); + TEST(setObject, object); + TEST(setAmount, amount); } void CoinListObject::load(const QDomElement& xml, int id) @@ -100,25 +74,34 @@ QDomElement CoinListObject::save() const return xml; } -void CoinListObject::setType(const int type) throw(BoundsException) +void CoinListObject::setType(const int type) { if (End <= type) - error("type"); + { + boundsError("type"); + return; + } m_type = type; m_object = INT_MAX; } -void CoinListObject::setObject(const int object) throw(BoundsException) +void CoinListObject::setObject(const int object) { if (((Item == m_type) && (static_cast(pokemod())->itemIndex(object) == INT_MAX)) || ((Species == m_type) && (static_cast(pokemod())->speciesIndex(object) == INT_MAX))) - error("object"); + { + boundsError("object"); + return; + } m_object = object; } -void CoinListObject::setAmount(const int amount) throw(BoundsException) +void CoinListObject::setAmount(const int amount) { if (!amount || ((Species == m_type) && (1 < amount))) - error("amount"); + { + boundsError("amount"); + return; + } m_amount = amount; } -- cgit