From 00da6b5977574a0564169172227d8aab45be188f Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 3 Jan 2015 21:07:56 -0800 Subject: 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. --- src/map/magic-interpreter-base.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/map/magic-interpreter-base.cpp') 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(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); } -- cgit v1.2.3-70-g09d2