From fe31331e2807634ae659e372358bac5781de9130 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 19 Apr 2008 18:12:17 +0000 Subject: [FIX] IndexException is more explicit [FIX] Added SizeException for image validation [FIX] QPixmaps are now verified [FIX] Classes now use error and warning rather than throwing [FIX] Deleted Object.cpp git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@100 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Tile.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'pokemod/Tile.cpp') diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index ba6bb9ab..80f7d7b4 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -35,6 +35,7 @@ Tile::Tile(const Tile& tile) : Tile::Tile(const Pokemod* pokemod, const int id) : Object("Tile", pokemod, id), m_name(""), + m_sprite(64, 64), m_wildChance(1, 1), m_hmType(INT_MAX), m_under(INT_MAX), @@ -134,16 +135,17 @@ void Tile::setName(const QString& name) m_name = name; } -void Tile::setSprite(const QPixmap& sprite) throw(Exception) +void Tile::setSprite(const QPixmap& sprite) throw(SizeException) { - // TODO: check dimension + if (sprite.size() != QSize(64, 64)) + error("sprte"); m_sprite = sprite; } void Tile::setFrom(const int direction, const bool state) throw(BoundsException) { if (Pokemod::D_End <= direction) - throw(BoundsException(className(), "direction")); + error("direction"); m_from[direction] = state; } @@ -155,7 +157,7 @@ void Tile::setWildChance(const Fraction& wildChance) throw(Exception) void Tile::setHMType(const int hmType) throw(BoundsException) { if (Pokemod::HM_End <= hmType) - throw(BoundsException(className(), "hmType")); + error("hmType"); m_hmType = hmType; m_under = INT_MAX; } @@ -165,9 +167,9 @@ void Tile::setUnder(const int under) throw(Exception) if (m_hmType != INT_MAX) { if ((m_hmType != Pokemod::HM_Whirlpool) || (m_hmType != Pokemod::HM_Cut) || (m_hmType != Pokemod::HM_RockSmash)) - throw(UnusedException(className(), "under")); + error("under"); if ((under == id()) || (pokemod()->tileIndex(under) == INT_MAX)) - throw(BoundsException(className(), "under")); + error("under"); } m_under = under; } @@ -175,7 +177,7 @@ void Tile::setUnder(const int under) throw(Exception) void Tile::setForceType(const int forceType) throw(BoundsException) { if (End <= forceType) - throw(BoundsException(className(), "forceType")); + error("forceType"); m_forceType = forceType; } @@ -184,9 +186,9 @@ void Tile::setForceDirection(const int forceDirection) throw(Exception) if (m_forceType != INT_MAX) { if (m_forceType == Stop) - throw(UnusedException(className(), "forceDirection")); + error("forceDirection"); if (Pokemod::D_End <= forceDirection) - throw(BoundsException(className(), "forceDirection")); + error("forceDirection"); } m_forceDirection = forceDirection; } @@ -204,7 +206,7 @@ QPixmap Tile::sprite() const bool Tile::from(const int direction) const throw(BoundsException) { if (Pokemod::D_End <= direction) - throw(BoundsException(className(), "direction")); + warning("direction"); return m_from[direction]; } -- cgit