From 682054970cfb0295ea6905d05d170fa5b59e1ad8 Mon Sep 17 00:00:00 2001 From: Justin Wienckowski Date: Mon, 15 Apr 2019 02:06:48 -0700 Subject: [PATCH] Zone::IsSpellBlocked should correctly handle spellid 0 (all spells) blocked in a region (type 2). --- zone/zone.cpp | 55 +++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 923e37a39..90e7fafc7 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1952,46 +1952,37 @@ bool Zone::IsSpellBlocked(uint32 spell_id, const glm::vec3& location) } } + // If all spells are blocked and this is an exception, it is not blocked + if (block_all && exception) + { + return false; + } + for (int x = 0; x < totalBS; x++) { - // If spellid is 0, block all spells in the zone - if (block_all) + // Spellid of 0 matches all spells + if (0 != blocked_spells[x].spellid && spell_id != blocked_spells[x].spellid) { - // If the same zone has entries other than spellid 0, they act as exceptions and are allowed - if (exception) - { - return false; - } - else + continue; + } + + switch (blocked_spells[x].type) + { + case 1: { return true; + break; } - } - else - { - if (spell_id != blocked_spells[x].spellid) + case 2: + { + if (IsWithinAxisAlignedBox(location, blocked_spells[x].m_Location - blocked_spells[x].m_Difference, blocked_spells[x].m_Location + blocked_spells[x].m_Difference)) + return true; + break; + } + default: { continue; - } - - switch (blocked_spells[x].type) - { - case 1: - { - return true; - break; - } - case 2: - { - if (IsWithinAxisAlignedBox(location, blocked_spells[x].m_Location - blocked_spells[x].m_Difference, blocked_spells[x].m_Location + blocked_spells[x].m_Difference)) - return true; - break; - } - default: - { - continue; - break; - } + break; } } }