mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
77e612cbf7
commit
0bc4bc1d75
8 changed files with 62 additions and 102 deletions
|
|
@ -1207,17 +1207,17 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
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)
|
||||
|
|
@ -1234,7 +1234,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
uint32 procCharges = spellproto->procCharges;
|
||||
if (procCharges)
|
||||
{
|
||||
if (remaincharges <= 0 || remaincharges > (int32)procCharges)
|
||||
if (remaincharges <= 0 || remaincharges > procCharges)
|
||||
remaincharges = procCharges;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
SpellAuraHolderConstBounds 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
iter->second->BuildUpdatePacket(data);
|
||||
}
|
||||
|
||||
GetSession()->SendPacket(&data);
|
||||
|
|
|
|||
|
|
@ -8288,11 +8288,11 @@ void SpellAuraHolder::_AddSpellAuraHolder()
|
|||
// Lookup free slot
|
||||
if (m_target->GetVisibleAurasCount() < MAX_AURAS)
|
||||
{
|
||||
Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
|
||||
Unit::VisibleAuraMap const& visibleAuras = m_target->GetVisibleAuras();
|
||||
for(uint8 i = 0; i < MAX_AURAS; ++i)
|
||||
{
|
||||
Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
|
||||
if(itr == visibleAuras->end())
|
||||
Unit::VisibleAuraMap::const_iterator itr = visibleAuras.find(i);
|
||||
if (itr == visibleAuras.end())
|
||||
{
|
||||
slot = i;
|
||||
// update for out of range group members (on 1 slot use)
|
||||
|
|
@ -8584,8 +8584,8 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount)
|
|||
if (!target || !caster)
|
||||
return;
|
||||
|
||||
bool refresh = stackAmount >= uint32(m_stackAmount);
|
||||
if (stackAmount != uint32(m_stackAmount))
|
||||
bool refresh = stackAmount >= m_stackAmount;
|
||||
if (stackAmount != m_stackAmount)
|
||||
{
|
||||
m_stackAmount = stackAmount;
|
||||
|
||||
|
|
@ -8674,23 +8674,17 @@ bool SpellAuraHolder::IsNeedVisibleSlot(Unit const* caster) const
|
|||
return !m_isPassive || totemAura || HasAreaAuraEffect(m_spellProto);
|
||||
}
|
||||
|
||||
void SpellAuraHolder::SendAuraUpdate(bool remove) const
|
||||
void SpellAuraHolder::BuildUpdatePacket(WorldPacket& data) const
|
||||
{
|
||||
WorldPacket data(SMSG_AURA_UPDATE);
|
||||
data << m_target->GetPackGUID();
|
||||
data << uint8(GetAuraSlot());
|
||||
data << uint32(remove ? 0 : GetId());
|
||||
|
||||
if(remove)
|
||||
{
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
return;
|
||||
}
|
||||
data << uint32(GetId());
|
||||
|
||||
uint8 auraFlags = GetAuraFlags();
|
||||
data << uint8(auraFlags);
|
||||
data << uint8(GetAuraLevel());
|
||||
data << uint8(m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount);
|
||||
|
||||
uint32 stackCount = m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount;
|
||||
data << uint8(stackCount <= 255 ? stackCount : 255);
|
||||
|
||||
if(!(auraFlags & AFLAG_NOT_CASTER))
|
||||
{
|
||||
|
|
@ -8717,6 +8711,20 @@ void SpellAuraHolder::SendAuraUpdate(bool remove) const
|
|||
data << uint32(max_duration);
|
||||
data << uint32(duration);
|
||||
}
|
||||
}
|
||||
|
||||
void SpellAuraHolder::SendAuraUpdate(bool remove) const
|
||||
{
|
||||
WorldPacket data(SMSG_AURA_UPDATE);
|
||||
data << m_target->GetPackGUID();
|
||||
|
||||
if(remove)
|
||||
{
|
||||
data << uint8(GetAuraSlot());
|
||||
data << uint32(0);
|
||||
}
|
||||
else
|
||||
BuildUpdatePacket(data);
|
||||
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class MANGOS_DLL_SPEC SpellAuraHolder
|
|||
void ApplyAuraModifiers(bool apply, bool real = false);
|
||||
void _AddSpellAuraHolder();
|
||||
void _RemoveSpellAuraHolder();
|
||||
void BuildUpdatePacket(WorldPacket& data) const;
|
||||
void SendAuraUpdate(bool remove) const;
|
||||
void HandleSpellSpecificBoosts(bool apply);
|
||||
void CleanupTriggeredSpells();
|
||||
|
|
@ -117,8 +118,8 @@ class MANGOS_DLL_SPEC SpellAuraHolder
|
|||
void SetAuraFlags(uint8 flags) { m_auraFlags = flags; }
|
||||
uint8 GetAuraLevel() const { return m_auraLevel; }
|
||||
void SetAuraLevel(uint8 level) { m_auraLevel = level; }
|
||||
uint8 GetAuraCharges() const { return m_procCharges; }
|
||||
void SetAuraCharges(uint8 charges)
|
||||
uint32 GetAuraCharges() const { return m_procCharges; }
|
||||
void SetAuraCharges(uint32 charges)
|
||||
{
|
||||
if (m_procCharges == charges)
|
||||
return;
|
||||
|
|
@ -139,7 +140,7 @@ class MANGOS_DLL_SPEC SpellAuraHolder
|
|||
|
||||
void SetVisibleAura(bool remove) { m_target->SetVisibleAura(m_auraSlot, remove ? 0 : GetId()); }
|
||||
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
|
||||
void SetLoadedState(ObjectGuid casterGUID, ObjectGuid itemGUID, int32 stackAmount, int32 charges)
|
||||
void SetLoadedState(ObjectGuid const& casterGUID, ObjectGuid const& itemGUID, uint32 stackAmount, uint32 charges)
|
||||
{
|
||||
m_casterGuid = casterGUID;
|
||||
m_castItemGuid = itemGUID;
|
||||
|
|
@ -162,8 +163,8 @@ class MANGOS_DLL_SPEC SpellAuraHolder
|
|||
uint8 m_auraSlot; // Aura slot on unit (for show in client)
|
||||
uint8 m_auraFlags; // Aura info flag (for send data to client)
|
||||
uint8 m_auraLevel; // Aura level (store caster level for correct show level dep amount)
|
||||
uint8 m_procCharges; // Aura charges (0 for infinite)
|
||||
uint8 m_stackAmount; // Aura stack amount
|
||||
uint32 m_procCharges; // Aura charges (0 for infinite)
|
||||
uint32 m_stackAmount; // Aura stack amount
|
||||
|
||||
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
|
||||
DiminishingGroup m_AuraDRGroup:8; // Diminishing
|
||||
|
|
|
|||
|
|
@ -2040,12 +2040,10 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
|
|||
const uint32 spellShrink = 53805;
|
||||
const uint32 spellTransf = 53806;
|
||||
|
||||
if (Aura* pAura = m_caster->GetAura(spellShrink, EFFECT_INDEX_0))
|
||||
if (SpellAuraHolder* holder = m_caster->GetSpellAuraHolder(spellShrink))
|
||||
{
|
||||
uint32 stackNum = pAura->GetStackAmount();
|
||||
|
||||
// chance to become pygmified (5, 10, 15 etc)
|
||||
if (roll_chance_i(stackNum*5))
|
||||
if (roll_chance_i(holder->GetStackAmount() * 5))
|
||||
{
|
||||
m_caster->RemoveAurasDueToSpell(spellShrink);
|
||||
m_caster->CastSpell(m_caster, spellTransf, true);
|
||||
|
|
@ -2053,7 +2051,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_caster->HasAura(spellTransf, EFFECT_INDEX_0))
|
||||
if (m_caster->HasAura(spellTransf))
|
||||
return;
|
||||
|
||||
m_caster->CastSpell(m_caster, spellShrink, true);
|
||||
|
|
|
|||
|
|
@ -4406,7 +4406,7 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex
|
|||
}
|
||||
}
|
||||
|
||||
void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, int32 stackAmount, uint64 casterGUID, Unit *dispeler)
|
||||
void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, uint64 casterGUID, Unit *dispeller)
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId);
|
||||
|
||||
|
|
@ -4424,7 +4424,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, int32 stackAmount,
|
|||
RemoveAuraHolderFromStack(spellId, stackAmount, casterGUID, AURA_REMOVE_BY_DISPEL);
|
||||
|
||||
// backfire damage and silence
|
||||
dispeler->CastCustomSpell(dispeler, 31117, &damage, NULL, NULL, true, NULL, NULL,casterGUID);
|
||||
dispeller->CastCustomSpell(dispeller, 31117, &damage, NULL, NULL, true, NULL, NULL, casterGUID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -4574,14 +4574,14 @@ void Unit::RemoveAurasWithDispelType( DispelType type, uint64 casterGUID )
|
|||
}
|
||||
}
|
||||
|
||||
void Unit::RemoveAuraHolderFromStack(uint32 spellId, int32 stackAmount, uint64 casterGUID, AuraRemoveMode mode)
|
||||
void Unit::RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount, uint64 casterGUID, AuraRemoveMode mode)
|
||||
{
|
||||
SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId);
|
||||
for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter)
|
||||
{
|
||||
if (!casterGUID || iter->second->GetCasterGUID() == casterGUID)
|
||||
{
|
||||
if (iter->second->ModStackAmount(-stackAmount))
|
||||
if (iter->second->ModStackAmount(-int32(stackAmount)))
|
||||
{
|
||||
RemoveSpellAuraHolder(iter->second, mode);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1596,8 +1596,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
void RemoveAllAurasOnDeath();
|
||||
|
||||
// removing specific aura FROM stack by diff reasons and selections
|
||||
void RemoveAuraHolderFromStack(uint32 spellId, int32 stackAmount = 1, uint64 casterGUID = 0, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
|
||||
void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, int32 stackAmount, uint64 casterGUID, Unit *dispeler);
|
||||
void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, uint64 casterGUID = 0, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
|
||||
void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, uint64 casterGUID, Unit *dispeller);
|
||||
|
||||
void DelaySpellAuraHolder(uint32 spellId, int32 delaytime, uint64 casterGUID);
|
||||
|
||||
|
|
@ -1739,7 +1739,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
void removeHatedBy(HostileReference* /*pHostileReference*/ ) { /* nothing to do yet */ }
|
||||
HostileRefManager& getHostileRefManager() { return m_HostileRefManager; }
|
||||
|
||||
uint32 GetVisibleAura(uint8 slot)
|
||||
uint32 GetVisibleAura(uint8 slot) const
|
||||
{
|
||||
VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot);
|
||||
if(itr != m_visibleAuras.end())
|
||||
|
|
@ -1753,8 +1753,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
else
|
||||
m_visibleAuras[slot] = spellid;
|
||||
}
|
||||
VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; }
|
||||
uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); }
|
||||
VisibleAuraMap const& GetVisibleAuras() const { return m_visibleAuras; }
|
||||
uint8 GetVisibleAurasCount() const { return m_visibleAuras.size(); }
|
||||
|
||||
Aura* GetAura(uint32 spellId, SpellEffectIndex effindex);
|
||||
Aura* GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32 familyFlag2 = 0, ObjectGuid casterGuid = ObjectGuid());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11281"
|
||||
#define REVISION_NR "11282"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue