[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;

View file

@ -33,8 +33,8 @@ const char CreatureInfoAddonInfofmt[]="iiiiiis";
const char EquipmentInfofmt[]="iiii";
const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis";
const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii";
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii";
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii";
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii";
const char PageTextfmt[]="isi";
const char InstanceTemplatesrcfmt[]="iiiiffffs";
const char InstanceTemplatedstfmt[]="iiiiffffi";

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9508"
#define REVISION_NR "9509"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_9375_01_characters_character_glyphs"
#define REVISION_DB_MANGOS "required_9482_01_mangos_spell_proc_event"
#define REVISION_DB_MANGOS "required_9509_01_mangos_item_template"
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
#endif // __REVISION_SQL_H__