From 9ef443c2868552460a4657f0535903eb232d660e Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 15 Mar 2009 17:18:59 -0600 Subject: Replace hack code in Spell::EffectOpenLock by generic way for check lock key items/skills --HG-- branch : trunk --- src/game/Spell.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/game/Spell.cpp') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index eb0f7ad5af3..11b1ab94bc7 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4087,6 +4087,7 @@ uint8 Spell::CanCast(bool strict) { // check for lock - key pair (checked by client also, just prevent cheating bool ok_key = false; + bool req_key = false; for(int it = 0; it < 8; ++it) { switch(lockInfo->Type[it]) @@ -4095,6 +4096,7 @@ uint8 Spell::CanCast(bool strict) break; case LOCK_KEY_ITEM: { + req_key = true; if(lockInfo->Index[it]) { if(m_CastItem && m_CastItem->GetEntry()==lockInfo->Index[it]) @@ -4104,30 +4106,22 @@ uint8 Spell::CanCast(bool strict) } case LOCK_KEY_SKILL: { + req_key = true; if(uint32(m_spellInfo->EffectMiscValue[i])!=lockInfo->Index[it]) break; - switch(lockInfo->Index[it]) - { - case LOCKTYPE_HERBALISM: - if(((Player*)m_caster)->HasSkill(SKILL_HERBALISM)) - ok_key =true; - break; - case LOCKTYPE_MINING: - if(((Player*)m_caster)->HasSkill(SKILL_MINING)) - ok_key =true; - break; - default: - ok_key =true; - break; - } + SkillType skill = SkillByLockType(LockType(lockInfo->Index[it])); + if(skill==SKILL_NONE) + ok_key =true; + else if(((Player*)m_caster)->HasSkill(skill)) + ok_key =true; } } if(ok_key) break; } - if(!ok_key) + if(!ok_key && req_key) return SPELL_FAILED_BAD_TARGETS; } -- cgit v1.2.3