[11282] Use uint32 datatype for aura charges and stacks

* Some spells have StackAmount > 255, for example 22735, 54314
* In SMSG_AURA_UPDATE maximum stack amount is limited by 255
* Move duplicate code into SpellAuraHolder::BuildUpdatePacket function
* Cleanup some weird type casts in _LoadAuras
This commit is contained in:
zergtmn 2011-03-25 14:40:09 +05:00
parent 77e612cbf7
commit 0bc4bc1d75
8 changed files with 62 additions and 102 deletions

View file

@ -15943,20 +15943,20 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
{
Field *fields = result->Fetch();
ObjectGuid caster_guid = fields[0].GetUInt64();
uint32 item_lowguid = fields[1].GetUInt64();
uint32 item_lowguid = fields[1].GetUInt32();
uint32 spellid = fields[2].GetUInt32();
uint32 stackcount = fields[3].GetUInt32();
int32 remaincharges = (int32)fields[4].GetUInt32();
uint32 remaincharges = 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+5].GetUInt32();
maxduration[i] = (int32)fields[i+8].GetUInt32();
remaintime[i] = (int32)fields[i+11].GetUInt32();
damage[i] = fields[i+5].GetInt32();
maxduration[i] = fields[i+8].GetInt32();
remaintime[i] = fields[i+11].GetInt32();
}
uint32 effIndexMask = (int32)fields[14].GetUInt32();
uint32 effIndexMask = fields[14].GetUInt32();
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
if (!spellproto)
@ -15968,7 +15968,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
// prevent wrong values of remaincharges
if (spellproto->procCharges)
{
if (remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges)
if (remaincharges <= 0 || remaincharges > spellproto->procCharges)
remaincharges = spellproto->procCharges;
}
else
@ -20150,59 +20150,12 @@ void Player::SendAurasForTarget(Unit *target)
WorldPacket data(SMSG_AURA_UPDATE_ALL);
data << target->GetPackGUID();
if(!target->GetVisibleAuras()->empty()) // speedup things
Unit::VisibleAuraMap const& visibleAuras = target->GetVisibleAuras();
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras.begin(); itr != visibleAuras.end(); ++itr)
{
Unit::VisibleAuraMap const *visibleAuras = target->GetVisibleAuras();
for(Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
{
SpellAuraHolderBounds bounds = target->GetSpellAuraHolderBounds(itr->second);
for (SpellAuraHolderMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter)
{
SpellAuraHolder *holder = iter->second;
data << uint8(holder->GetAuraSlot());
data << uint32(holder->GetId());
if(holder->GetId())
{
uint8 auraFlags = holder->GetAuraFlags();
// flags
data << uint8(auraFlags);
// level
data << uint8(holder->GetAuraLevel());
// charges
if (holder->GetAuraCharges())
data << uint8(holder->GetAuraCharges() * holder->GetStackAmount());
else
data << uint8(holder->GetStackAmount());
if(!(auraFlags & AFLAG_NOT_CASTER)) // packed GUID of caster
{
data.appendPackGUID(holder->GetCasterGUID());
}
if(auraFlags & AFLAG_DURATION) // include aura duration
{
// take highest - to display icon even if stun fades
uint32 max_duration = 0;
uint32 duration = 0;
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (Aura *aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i)))
{
if (uint32(aura->GetAuraMaxDuration()) > max_duration)
{
max_duration = aura->GetAuraMaxDuration();
duration = aura->GetAuraDuration();
}
}
}
data << uint32(max_duration);
data << uint32(duration);
}
}
}
}
SpellAuraHolderConstBounds bounds = target->GetSpellAuraHolderBounds(itr->second);
for (SpellAuraHolderMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter)
iter->second->BuildUpdatePacket(data);
}
GetSession()->SendPacket(&data);