[9509] Move custom data from item spell charges sign to new field NoConsumable.

Some items with negative by defaul charges not expected to be deletedt at no charges.
In past this fixed by using positive charges amount in like cases in different from
expected negative value. Adding new field for avoid this.
This commit is contained in:
VladimirMangos 2010-03-03 09:07:16 +03:00
parent 84e5f7520b
commit 52701a58f6
9 changed files with 130 additions and 94 deletions

View file

@ -586,6 +586,7 @@ struct ItemPrototype
uint32 FoodType;
uint32 MinMoneyLoot;
uint32 MaxMoneyLoot;
uint32 NonConsumable;
// helpers
bool CanChangeEquipStateInCombat() const

View file

@ -2060,6 +2060,31 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", i, proto->HolidayId);
const_cast<ItemPrototype*>(proto)->HolidayId = 0;
}
if(proto->NonConsumable)
{
if (proto->NonConsumable > 1)
{
sLog.outErrorDb("Item (Entry: %u) has wrong NonConsumable (%u), must be 0..1",i,proto->NonConsumable);
const_cast<ItemPrototype*>(proto)->NonConsumable = 1;
}
bool can_be_need = false;
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
if(proto->Spells[j].SpellCharges < 0)
{
can_be_need = true;
break;
}
}
if (!can_be_need)
{
sLog.outErrorDb("Item (Entry: %u) has redundant NonConsumable (%u), item not have negative charges",i,proto->NonConsumable);
const_cast<ItemPrototype*>(proto)->NonConsumable = 0;
}
}
}
// check some dbc referenced items (avoid duplicate reports)

View file

@ -3670,7 +3670,7 @@ void Spell::TakeCastItem()
// item has limited charges
if (proto->Spells[i].SpellCharges)
{
if (proto->Spells[i].SpellCharges < 0)
if (proto->Spells[i].SpellCharges < 0 && !proto->NonConsumable)
expendable = true;
int32 charges = m_CastItem->GetSpellCharges(i);
@ -5553,7 +5553,7 @@ SpellCastResult Spell::CheckItems()
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2)
if (proto->Spells[s].SpellCharges < 0 && !proto->NonConsumable && abs(charges) < 2)
{
++itemcount;
break;