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/MapEffect.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'pokemod/MapEffect.cpp') diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index f9f39a24..d17c0df2 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -39,7 +39,7 @@ MapEffect::MapEffect(const Pokemod* pokemod, const int id) : m_name(""), m_coordinate(0, 0), m_existFlag(0, 0), - m_skin(""), + m_skin(192, 128), m_effect(INT_MAX), m_value1(INT_MAX), m_value2(INT_MAX), @@ -168,16 +168,17 @@ void MapEffect::setExistFlag(const Flag& existFlag) m_existFlag = existFlag; } -void MapEffect::setSkin(const QPixmap& skin) throw(Exception) +void MapEffect::setSkin(const QPixmap& skin) throw(SizeException) { - // TODO: check size is 128x128 + if (skin.size() != QSize(192, 128)) + error("skin"); m_skin = skin; } void MapEffect::setEffect(const int effect) throw(BoundsException) { if (E_End <= effect) - throw(BoundsException(className(), "effect")); + error("effect"); m_effect = effect; m_value1 = INT_MAX; m_value2 = INT_MAX; @@ -186,7 +187,7 @@ void MapEffect::setEffect(const int effect) throw(BoundsException) void MapEffect::setValue1(const int value1) throw(UnusedException) { if ((m_effect != E_StrengthBlock) && (m_effect != E_Button)) - throw(UnusedException(className(), "val1")); + error("val1"); m_value1 = value1; } @@ -196,19 +197,19 @@ void MapEffect::setValue2(const int value2) throw(Exception) { case E_Item: if (pokemod()->itemIndex(value2) == INT_MAX) - throw(BoundsException(className(), "val2")); + error("val2"); break; case E_PC: if (PC_End <= value2) - throw(BoundsException(className(), "val2")); + error("val2"); break; case E_StrengthBlock: case E_Button: if (Flag::End <= value2) - throw(BoundsException(className(), "val2")); + error("val2"); break; default: - throw(UnusedException(className(), "val2")); + error("val2"); break; } m_value2 = value2; @@ -217,7 +218,7 @@ void MapEffect::setValue2(const int value2) throw(Exception) void MapEffect::setDirection(const int direction) throw(BoundsException) { if (Pokemod::D_End_None <= direction) - throw(BoundsException(className(), "direction")); + error("direction"); m_direction = direction; } @@ -234,7 +235,7 @@ void MapEffect::setCanMove(const bool canMove) void MapEffect::setDialog(const int dialog) throw(BoundsException) { if (pokemod()->dialogIndex(dialog) == INT_MAX) - throw(BoundsException(className(), "dialog")); + error("dialog"); m_dialog = dialog; } -- cgit