diff options
| author | megamage <none@none> | 2009-03-15 17:18:59 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2009-03-15 17:18:59 -0600 |
| commit | 9ef443c2868552460a4657f0535903eb232d660e (patch) | |
| tree | fd8fa08b212f932447be883ff0190705e6adac02 /src/game/Spell.cpp | |
| parent | 1a8528b3dbd448a89d6f518ea22d823d67d4a187 (diff) | |
Replace hack code in Spell::EffectOpenLock by generic way for check lock key items/skills
--HG--
branch : trunk
Diffstat (limited to 'src/game/Spell.cpp')
| -rw-r--r-- | src/game/Spell.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
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; } |
