mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[6819] [2008_11_12_01_character_character_aura.sql] Fixed storing stacked auras
This commit is contained in:
parent
5a580d954b
commit
5905aec683
7 changed files with 127 additions and 67 deletions
|
|
@ -13842,7 +13842,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i)
|
||||
SetUInt32Value(i, 0);
|
||||
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
|
@ -13852,10 +13852,11 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
uint64 caster_guid = fields[0].GetUInt64();
|
||||
uint32 spellid = fields[1].GetUInt32();
|
||||
uint32 effindex = fields[2].GetUInt32();
|
||||
int32 damage = (int32)fields[3].GetUInt32();
|
||||
int32 maxduration = (int32)fields[4].GetUInt32();
|
||||
int32 remaintime = (int32)fields[5].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[6].GetUInt32();
|
||||
uint32 stackcount = fields[3].GetUInt32();
|
||||
int32 damage = (int32)fields[4].GetUInt32();
|
||||
int32 maxduration = (int32)fields[5].GetUInt32();
|
||||
int32 remaintime = (int32)fields[6].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[7].GetUInt32();
|
||||
|
||||
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
|
||||
if(!spellproto)
|
||||
|
|
@ -13892,11 +13893,15 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
|
||||
continue;
|
||||
|
||||
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
|
||||
if(!damage)
|
||||
damage = aura->GetModifier()->m_amount;
|
||||
aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
|
||||
AddAura(aura);
|
||||
for(uint32 i=0; i<stackcount; i++)
|
||||
{
|
||||
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
|
||||
if(!damage)
|
||||
damage = aura->GetModifier()->m_amount;
|
||||
aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
|
||||
AddAura(aura);
|
||||
sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex);
|
||||
}
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
|
|
@ -14934,31 +14939,54 @@ void Player::_SaveAuras()
|
|||
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
AuraMap const& auras = GetAuras();
|
||||
for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
|
||||
if (auras.empty())
|
||||
return;
|
||||
|
||||
spellEffectPair lastEffectPair = auras.begin()->first;
|
||||
uint32 stackCounter = 1;
|
||||
|
||||
for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
|
||||
{
|
||||
SpellEntry const *spellInfo = itr->second->GetSpellProto();
|
||||
|
||||
//skip all auras from spells that are passive or need a shapeshift
|
||||
if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost())
|
||||
continue;
|
||||
|
||||
//do not save single target auras (unless they were cast by the player)
|
||||
if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
|
||||
continue;
|
||||
|
||||
uint8 i;
|
||||
// or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras
|
||||
for (i = 0; i < 3; i++)
|
||||
if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT ||
|
||||
spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH)
|
||||
break;
|
||||
|
||||
if (i == 3)
|
||||
if(itr == auras.end() || lastEffectPair != itr->first)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex());
|
||||
CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')",
|
||||
GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges));
|
||||
AuraMap::const_iterator itr2 = itr;
|
||||
// save previous spellEffectPair to db
|
||||
itr2--;
|
||||
SpellEntry const *spellInfo = itr2->second->GetSpellProto();
|
||||
|
||||
//skip all auras from spells that are passive or need a shapeshift
|
||||
if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost()))
|
||||
{
|
||||
//do not save single target auras (unless they were cast by the player)
|
||||
if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
|
||||
{
|
||||
uint8 i;
|
||||
// or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras
|
||||
for (i = 0; i < 3; i++)
|
||||
if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT ||
|
||||
spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH)
|
||||
break;
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')",
|
||||
GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(itr == auras.end())
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastEffectPair == itr->first)
|
||||
stackCounter++;
|
||||
else
|
||||
{
|
||||
lastEffectPair = itr->first;
|
||||
stackCounter = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue