summaryrefslogtreecommitdiff
path: root/src/map/magic-interpreter-base.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2015-01-03 21:07:56 -0800
committerBen Longbons <b.r.longbons@gmail.com>2015-01-03 21:58:26 -0800
commit00da6b5977574a0564169172227d8aab45be188f (patch)
treedd52eee506a98e1eb9fcdea52e7db25079a7ad28 /src/map/magic-interpreter-base.cpp
parent4c91abd6a020ee030114ae3f22d8f6066e7528be (diff)
downloadtmwa-00da6b5977574a0564169172227d8aab45be188f.tar.gz
tmwa-00da6b5977574a0564169172227d8aab45be188f.tar.bz2
tmwa-00da6b5977574a0564169172227d8aab45be188f.tar.xz
tmwa-00da6b5977574a0564169172227d8aab45be188f.zip
Switch MATCH to separate begin/end macros
The for loop trick turned out to be very prone to infinite loops at runtime. It's better to force compiler errors even if it's ugly.
Diffstat (limited to 'src/map/magic-interpreter-base.cpp')
-rw-r--r--src/map/magic-interpreter-base.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index 7fde979..e0392e4 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -314,22 +314,22 @@ const effect_set_t *spellguard_check_sub(spellguard_check_t *check,
if (guard == nullptr)
return nullptr;
- MATCH (*guard)
+ MATCH_BEGIN (*guard)
{
- CASE (const GuardCondition&, s)
+ MATCH_CASE (const GuardCondition&, s)
{
if (!magic_eval_int(env, s.s_condition))
return nullptr;
}
- CASE (const GuardComponents&, s)
+ MATCH_CASE (const GuardComponents&, s)
{
copy_components(&check->components, s.s_components);
}
- CASE (const GuardCatalysts&, s)
+ MATCH_CASE (const GuardCatalysts&, s)
{
copy_components(&check->catalysts, s.s_catalysts);
}
- CASE (const GuardChoice&, s)
+ MATCH_CASE (const GuardChoice&, s)
{
spellguard_check_t altcheck = *check;
const effect_set_t *retval;
@@ -351,15 +351,15 @@ const effect_set_t *spellguard_check_sub(spellguard_check_t *check,
return spellguard_check_sub(check, s.s_alt, caster,
env, near_miss);
}
- CASE (const GuardMana&, s)
+ MATCH_CASE (const GuardMana&, s)
{
check->mana += magic_eval_int(env, s.s_mana);
}
- CASE (const GuardCastTime&, s)
+ MATCH_CASE (const GuardCastTime&, s)
{
check->casttime += static_cast<interval_t>(magic_eval_int(env, s.s_casttime));
}
- CASE (const effect_set_t&, s_effect)
+ MATCH_CASE (const effect_set_t&, s_effect)
{
if (spellguard_can_satisfy(check, caster, env, near_miss))
return &s_effect;
@@ -367,6 +367,7 @@ const effect_set_t *spellguard_check_sub(spellguard_check_t *check,
return nullptr;
}
}
+ MATCH_END ();
return spellguard_check_sub(check, guard->next, caster, env, near_miss);
}