[10332] Save cast item guid for auras also.

This must fix another way duplicate aura adding to DB error.
It also prevent wrong stacking work for weapon equip bufs
in cases when its allowed for both wepoan indepndently apply.
This commit is contained in:
VladimirMangos 2010-08-09 04:36:33 +04:00
parent 59e672f1bc
commit 779e40d5ff
11 changed files with 68 additions and 29 deletions

View file

@ -1144,7 +1144,7 @@ void Pet::_LoadAuras(uint32 timediff)
{
RemoveAllAuras();
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,maxduration0,maxduration1,maxduration2,remaintime0,remaintime1,remaintime2,effIndexMask FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,maxduration0,maxduration1,maxduration2,remaintime0,remaintime1,remaintime2,effIndexMask FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
if(result)
{
@ -1152,19 +1152,20 @@ void Pet::_LoadAuras(uint32 timediff)
{
Field *fields = result->Fetch();
uint64 caster_guid = fields[0].GetUInt64();
uint32 spellid = fields[1].GetUInt32();
uint32 stackcount= fields[2].GetUInt32();
int32 remaincharges = (int32)fields[3].GetUInt32();
uint32 item_lowguid = fields[1].GetUInt32();
uint32 spellid = fields[2].GetUInt32();
uint32 stackcount= fields[3].GetUInt32();
int32 remaincharges = (int32)fields[4].GetUInt32();
int32 damage[MAX_EFFECT_INDEX];
int32 maxduration[MAX_EFFECT_INDEX];
int32 remaintime[MAX_EFFECT_INDEX];
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
damage[i] = (int32)fields[i+4].GetUInt32();
maxduration[i] = (int32)fields[i+7].GetUInt32();
remaintime[i] = (int32)fields[i+10].GetUInt32();
damage[i] = (int32)fields[i+5].GetUInt32();
maxduration[i] = (int32)fields[i+8].GetUInt32();
remaintime[i] = (int32)fields[i+11].GetUInt32();
}
uint32 effIndexMask = (int32)fields[13].GetUInt32();
uint32 effIndexMask = (int32)fields[14].GetUInt32();
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
if(!spellproto)
@ -1213,7 +1214,7 @@ void Pet::_LoadAuras(uint32 timediff)
if (!holder->IsEmptyHolder())
{
holder->SetLoadedState(caster_guid, stackcount, remaincharges);
holder->SetLoadedState(caster_guid, item_lowguid ? MAKE_NEW_GUID(HIGHGUID_ITEM, 0, item_lowguid) : 0, stackcount, remaincharges);
AddSpellAuraHolder(holder);
}
else
@ -1282,7 +1283,13 @@ void Pet::_SaveAuras()
if (!effIndexMask)
continue;
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid, caster_guid, spell, stackcount, remaincharges, basepoints0, basepoints1, basepoints2, maxduration0, maxduration1, maxduration2, remaintime0, remaintime1, remaintime2, effIndexMask) VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u')", m_charmInfo->GetPetNumber(), holder->GetCasterGUID(), holder->GetId(), holder->GetStackAmount(), holder->GetAuraCharges(), damage[EFFECT_INDEX_0], damage[EFFECT_INDEX_1], damage[EFFECT_INDEX_2], maxduration[EFFECT_INDEX_0], maxduration[EFFECT_INDEX_1], maxduration[EFFECT_INDEX_2], remaintime[EFFECT_INDEX_0], remaintime[EFFECT_INDEX_1], remaintime[EFFECT_INDEX_2], effIndexMask);
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, basepoints0, basepoints1, basepoints2, maxduration0, maxduration1, maxduration2, remaintime0, remaintime1, remaintime2, effIndexMask) VALUES "
"('%u', '" UI64FMTD "', '%u', '%u', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u')",
m_charmInfo->GetPetNumber(), holder->GetCasterGUID(), GUID_LOPART(holder->GetCastItemGUID()), holder->GetId(), holder->GetStackAmount(), holder->GetAuraCharges(),
damage[EFFECT_INDEX_0], damage[EFFECT_INDEX_1], damage[EFFECT_INDEX_2],
maxduration[EFFECT_INDEX_0], maxduration[EFFECT_INDEX_1], maxduration[EFFECT_INDEX_2],
remaintime[EFFECT_INDEX_0], remaintime[EFFECT_INDEX_1], remaintime[EFFECT_INDEX_2],
effIndexMask);
}
}
}