Skip to content

Commit

Permalink
[10021] Move item disenchanting static req. checks to server start.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Jun 2, 2010
1 parent c027ae2 commit e40f9ef
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/game/ItemHandler.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/ItemPrototype.h
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions src/game/ObjectMgr.cpp
Expand Up @@ -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<ItemPrototype*>(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<ItemPrototype*>(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<ItemPrototype*>(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<ItemPrototype*>(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<ItemPrototype*>(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<ItemPrototype*>(proto)->DisenchantID = 0;
}
}

if(proto->FoodType >= MAX_PET_DIET)
{
sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType);
Expand Down
17 changes: 6 additions & 11 deletions src/game/Spell.cpp
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion 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__

0 comments on commit e40f9ef

Please sign in to comment.