diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-20 00:12:12 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-20 00:12:12 +0000 |
| commit | dcb77408505e5fb40f064dd05aaf39f27dcdd524 (patch) | |
| tree | c9de6f2a58d754511b7c821db58f8c0e881a0e1f /pokemod/MoveEffect.cpp | |
| parent | f4f3176a6dcdaf5e463f39a657dd4ca04386a6ad (diff) | |
| download | sigen-dcb77408505e5fb40f064dd05aaf39f27dcdd524.tar.gz sigen-dcb77408505e5fb40f064dd05aaf39f27dcdd524.tar.xz sigen-dcb77408505e5fb40f064dd05aaf39f27dcdd524.zip | |
[FIX] Fraction bounds checking
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@102 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MoveEffect.cpp')
| -rw-r--r-- | pokemod/MoveEffect.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index 8633b549..f7c5835a 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -83,8 +83,10 @@ QDomElement MoveEffect::save() const return xml; } -void MoveEffect::setChance(const Fraction& chance) throw(Exception) +void MoveEffect::setChance(const Fraction& chance) throw(BoundsException) { + if (1 < chance) + error<BoundsException>("chance"); m_chance = chance; } @@ -96,7 +98,7 @@ void MoveEffect::setEffect(const int effect) throw(BoundsException) m_value1 = INT_MAX; m_value2 = INT_MAX; m_value3 = 0; - m_value4.set(1, 1);//, ((effect == E_StealHP) || (effect == E_Counter) || (effect == E_Selfdestruct) || (effect == E_Mirror) || (effect == E_GetMoney) || (effect == E_WaitAndReturn) || (effect == E_Recoil)) ? Fraction::Improper : Fraction::Proper); + m_value4.set(1, 1); } void MoveEffect::setValue1(const int value1) throw(Exception) @@ -158,8 +160,10 @@ void MoveEffect::setValue3(const int value3) m_value3 = value3; } -void MoveEffect::setValue4(const Fraction& value4) throw(Exception) +void MoveEffect::setValue4(const Fraction& value4) throw(BoundsException) { + if ((m_effect != E_StealHP) && (m_effect != E_Counter) && (m_effect != E_Selfdestruct) && (m_effect != E_Mirror) && (m_effect != E_GetMoney) && (m_effect != E_WaitAndReturn) && (m_effect != E_Recoil) && (1 < value4)) + error<BoundsException>("value4"); m_value4 = value4; } |
