From 14b6a688570c9bc029de28321779c30e4129577b Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 21 Jul 2010 15:17:29 +0200 Subject: [PATCH] Added new spell disable flag - core will not check if that spell exists in dbc, used for blizz deprecated items/quests Fixed loading of access_requirement --HG-- branch : trunk --- src/server/game/Conditions/DisableMgr.cpp | 27 +++++++++++++---------- src/server/game/Globals/ObjectMgr.cpp | 9 ++++---- src/server/game/Spells/SpellMgr.h | 7 +++--- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index 3a2e186a84..803d607b7f 100644 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -73,12 +73,12 @@ void DisableMgr::LoadDisables() switch (type) { case DISABLE_TYPE_SPELL: - if (!sSpellStore.LookupEntry(entry)) + if (!(sSpellStore.LookupEntry(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL)) { sLog.outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry); continue; } - if (!flags || flags > 7) + if (!flags || flags > 15) { sLog.outErrorDb("Disable flags for spell %u are invalid, skipped.", entry); continue; @@ -198,19 +198,24 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit case DISABLE_TYPE_SPELL: { uint8 flags = itr->second; - if (flags & SPELL_DISABLE_PLAYER && pUnit->GetTypeId() == TYPEID_PLAYER) - return true; - else if (pUnit->GetTypeId() == TYPEID_UNIT) + if (pUnit) { - if (pUnit->ToCreature()->isPet()) + if (flags & SPELL_DISABLE_PLAYER && pUnit->GetTypeId() == TYPEID_PLAYER) + return true; + else if (pUnit->GetTypeId() == TYPEID_UNIT) { - if (flags & SPELL_DISABLE_PET) + if (pUnit->ToCreature()->isPet()) + { + if (flags & SPELL_DISABLE_PET) + return true; + } + else if (flags & SPELL_DISABLE_CREATURE) return true; } - else if (flags & SPELL_DISABLE_CREATURE) - return true; + return false; } - return false; + else if (flags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast + return true; } case DISABLE_TYPE_MAP: if (!pUnit) @@ -247,8 +252,6 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit case DISABLE_TYPE_BATTLEGROUND: case DISABLE_TYPE_ACHIEVEMENT_CRITERIA: return true; - default: - return false; } return false; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b07c9ecc0f..d360b46d94 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2179,7 +2179,7 @@ void ObjectMgr::LoadItemPrototypes() else if (proto->Spells[1].SpellId != -1) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); - if (!spellInfo) + if (!spellInfo && !sDisableMgr.IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, NULL)) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",i,1+1,proto->Spells[1].SpellId); const_cast(proto)->Spells[0].SpellId = 0; @@ -2227,7 +2227,7 @@ void ObjectMgr::LoadItemPrototypes() if (proto->Spells[j].SpellId && proto->Spells[j].SpellId != -1) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); - if (!spellInfo) + if (!spellInfo && !sDisableMgr.IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, NULL)) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",i,j+1,proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; @@ -5826,8 +5826,8 @@ void ObjectMgr::LoadAccessRequirements() uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, level_min, level_max, item, item2, heroic_key, heroic_key2, quest_done, quest_failed_text, heroic_quest_done, heroic_quest_failed_text, heroic_level_min, status FROM access_requirement"); + // 0 1 2 3 4 5 6 7 8 9 10 11 + QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, level_min, level_max, item, item2, heroic_key, heroic_key2, quest_done, quest_failed_text, heroic_quest_done, heroic_quest_failed_text, heroic_level_min FROM access_requirement"); if (!result) { @@ -5865,7 +5865,6 @@ void ObjectMgr::LoadAccessRequirements() ar.questFailedText = fields[8].GetCppString(); ar.heroicQuest = fields[9].GetUInt32(); ar.heroicQuestFailedText = fields[10].GetCppString(); - ar.status = fields[12].GetUInt8(); if (ar.item) { diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index d02efab43b..cc7aac4966 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -52,9 +52,10 @@ enum SpellCategories enum SpellDisableTypes { - SPELL_DISABLE_PLAYER = 1, - SPELL_DISABLE_CREATURE = 2, - SPELL_DISABLE_PET = 4 + SPELL_DISABLE_PLAYER = 0x1, + SPELL_DISABLE_CREATURE = 0x2, + SPELL_DISABLE_PET = 0x4, + SPELL_DISABLE_DEPRECATED_SPELL = 0x8 }; enum SpellEffectTargetTypes