diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-19 18:12:17 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-19 18:12:17 +0000 |
| commit | fe31331e2807634ae659e372358bac5781de9130 (patch) | |
| tree | 6b208974e3f141e9b22152526e2d42e967bfd4ec /pokemod/Tile.cpp | |
| parent | 6679f5cffa9d35a23b76605ddfbf3257f882b6ee (diff) | |
[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
Diffstat (limited to 'pokemod/Tile.cpp')
| -rw-r--r-- | pokemod/Tile.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
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<SizeException>("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<BoundsException>("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<BoundsException>("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<UnusedException>("under"); if ((under == id()) || (pokemod()->tileIndex(under) == INT_MAX)) - throw(BoundsException(className(), "under")); + error<BoundsException>("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<BoundsException>("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<UnusedException>("forceDirection"); if (Pokemod::D_End <= forceDirection) - throw(BoundsException(className(), "forceDirection")); + error<BoundsException>("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<BoundsException>("direction"); return m_from[direction]; } |
