From e823b30f4f8013072e84b761ea43b7d5d63d4b28 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 2 Jun 2010 14:55:47 +0400 Subject: [PATCH] [10021] Move item disenchanting static req. checks to server start. --- src/game/ItemHandler.cpp | 14 +++++++------- src/game/ItemPrototype.h | 2 +- src/game/ObjectMgr.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/game/Spell.cpp | 17 ++++++----------- src/shared/revision_nr.h | 2 +- 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 2501be9c9..41796a76b 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -414,13 +414,13 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) data << pProto->Socket[s].Color; data << pProto->Socket[s].Content; } - data << pProto->socketBonus; - data << pProto->GemProperties; - data << pProto->RequiredDisenchantSkill; - data << pProto->ArmorDamageModifier; - data << pProto->Duration; // added in 2.4.2.8209, duration (seconds) - data << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory - data << pProto->HolidayId; // Holiday.dbc? + data << uint32(pProto->socketBonus); + data << uint32(pProto->GemProperties); + data << int32(pProto->RequiredDisenchantSkill); + data << float(pProto->ArmorDamageModifier); + data << uint32(pProto->Duration); // added in 2.4.2.8209, duration (seconds) + data << uint32(pProto->ItemLimitCategory); // WotLK, ItemLimitCategory + data << uint32(pProto->HolidayId); // Holiday.dbc? SendPacket( &data ); } else diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index 97300d914..053c68e7d 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -586,7 +586,7 @@ struct ItemPrototype _Socket Socket[MAX_ITEM_PROTO_SOCKETS]; uint32 socketBonus; // id from SpellItemEnchantment.dbc uint32 GemProperties; // id from GemProperties.dbc - uint32 RequiredDisenchantSkill; + int32 RequiredDisenchantSkill; float ArmorDamageModifier; uint32 Duration; // negative = realtime, positive = ingame time uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index eea0b4495..a59fc8857 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -2058,6 +2058,44 @@ void ObjectMgr::LoadItemPrototypes() if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties); + if (proto->RequiredDisenchantSkill < -1) + { + sLog.outErrorDb("Item (Entry: %u) has wrong RequiredDisenchantSkill (%i), set to (-1).",i,proto->RequiredDisenchantSkill); + const_cast(proto)->RequiredDisenchantSkill = -1; + } + else if (proto->RequiredDisenchantSkill != -1) + { + if (proto->Quality > ITEM_QUALITY_EPIC || proto->Quality < ITEM_QUALITY_UNCOMMON) + { + sLog.outErrorDb("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable quality (%u), reset it.",i,proto->RequiredDisenchantSkill,proto->Quality); + const_cast(proto)->RequiredDisenchantSkill = -1; + } + else if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR) + { + sLog.outErrorDb("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable item class (%u), reset it.",i,proto->RequiredDisenchantSkill,proto->Class); + const_cast(proto)->RequiredDisenchantSkill = -1; + } + } + + if (proto->DisenchantID) + { + if (proto->Quality > ITEM_QUALITY_EPIC || proto->Quality < ITEM_QUALITY_UNCOMMON) + { + sLog.outErrorDb("Item (Entry: %u) has wrong quality (%u) for disenchanting, remove disenchanting loot id.",i,proto->Quality); + const_cast(proto)->DisenchantID = 0; + } + else if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR) + { + sLog.outErrorDb("Item (Entry: %u) has wrong item class (%u) for disenchanting, remove disenchanting loot id.",i,proto->Class); + const_cast(proto)->DisenchantID = 0; + } + else if (proto->RequiredDisenchantSkill < 0) + { + sLog.outErrorDb("Item (Entry: %u) marked as non-disenchantable by RequiredDisenchantSkill == -1, remove disenchanting loot id.",i); + const_cast(proto)->DisenchantID = 0; + } + } + if(proto->FoodType >= MAX_PET_DIET) { sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 85fb3b658..c06273bb0 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5871,19 +5871,14 @@ SpellCastResult Spell::CheckItems() if(!itemProto) return SPELL_FAILED_CANT_BE_DISENCHANTED; - uint32 item_quality = itemProto->Quality; - // 2.0.x addon: Check player enchanting level against the item disenchanting requirements - uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; - if (item_disenchantskilllevel == uint32(-1)) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - if (item_disenchantskilllevel > p_caster->GetSkillValue(SKILL_ENCHANTING)) - return SPELL_FAILED_LOW_CASTLEVEL; - if(item_quality > 4 || item_quality < 2) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - if(itemProto->Class != ITEM_CLASS_WEAPON && itemProto->Class != ITEM_CLASS_ARMOR) - return SPELL_FAILED_CANT_BE_DISENCHANTED; + // must have disenchant loot (other static req. checked at item prototype loading) if (!itemProto->DisenchantID) return SPELL_FAILED_CANT_BE_DISENCHANTED; + + // 2.0.x addon: Check player enchanting level against the item disenchanting requirements + int32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; + if (item_disenchantskilllevel > int32(p_caster->GetSkillValue(SKILL_ENCHANTING))) + return SPELL_FAILED_LOW_CASTLEVEL; break; } case SPELL_EFFECT_PROSPECTING: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 396d5b0f7..01d913377 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10020" + #define REVISION_NR "10021" #endif // __REVISION_NR_H__