aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-12-17 21:49:29 +0100
committerShauren <shauren.trinity@gmail.com>2016-12-17 21:49:29 +0100
commitbc758991140e961ceac46b17b766b0d54b8129fb (patch)
tree21f7035264fc10f8c049939c6b87f09432207ad1
parent1530c956979f9d4b56b9e585dbc16d7660e609b1 (diff)
Core/Auras: Resend spell modifiers after teleporting
Closes #18440
-rw-r--r--src/server/game/Entities/Player/Player.cpp113
-rw-r--r--src/server/game/Entities/Player/Player.h3
2 files changed, 90 insertions, 26 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index afcf846a6f8..c8ba1b45341 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -21139,44 +21139,48 @@ bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod
void Player::AddSpellMod(SpellModifier* mod, bool apply)
{
TC_LOG_DEBUG("spells", "Player::AddSpellMod: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), mod->spellId);
- OpcodeServer opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
- WorldPackets::Spells::SetSpellModifier packet(opcode);
+ if (!IsLoading())
+ {
+ OpcodeServer opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
- int i = 0;
- flag128 _mask;
+ WorldPackets::Spells::SetSpellModifier packet(opcode);
- /// @todo Implement sending of bulk modifiers instead of single
- packet.Modifiers.resize(1);
- WorldPackets::Spells::SpellModifier& spellMod = packet.Modifiers[0];
+ int i = 0;
+ flag128 _mask;
- spellMod.ModIndex = mod->op;
+ /// @todo Implement sending of bulk modifiers instead of single
+ packet.Modifiers.resize(1);
+ WorldPackets::Spells::SpellModifier& spellMod = packet.Modifiers[0];
- for (int eff = 0; eff < 128; ++eff)
- {
- if (eff != 0 && (eff % 32) == 0)
- _mask[i++] = 0;
+ spellMod.ModIndex = mod->op;
- _mask[i] = uint32(1) << (eff - (32 * i));
- if (mod->mask & _mask)
+ for (int eff = 0; eff < 128; ++eff)
{
- WorldPackets::Spells::SpellModifierData modData;
+ if (eff != 0 && (eff % 32) == 0)
+ _mask[i++] = 0;
+
+ _mask[i] = uint32(1) << (eff - (32 * i));
+ if (mod->mask & _mask)
+ {
+ WorldPackets::Spells::SpellModifierData modData;
- for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr)
- if ((*itr)->type == mod->type && (*itr)->mask & _mask)
- modData.ModifierValue += (*itr)->value;
+ for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr)
+ if ((*itr)->type == mod->type && (*itr)->mask & _mask)
+ modData.ModifierValue += (*itr)->value;
- modData.ModifierValue += apply ? mod->value : -(mod->value);
- if (mod->type == SPELLMOD_PCT)
- modData.ModifierValue = 1.0f + (modData.ModifierValue * 0.01f);
+ modData.ModifierValue += apply ? mod->value : -(mod->value);
+ if (mod->type == SPELLMOD_PCT)
+ modData.ModifierValue = 1.0f + (modData.ModifierValue * 0.01f);
- modData.ClassIndex = eff;
+ modData.ClassIndex = eff;
- spellMod.ModifierData.push_back(modData);
+ spellMod.ModifierData.push_back(modData);
+ }
}
- }
- SendDirectMessage(packet.Write());
+ SendDirectMessage(packet.Write());
+ }
if (apply)
m_spellMods[mod->op].push_back(mod);
@@ -21320,6 +21324,62 @@ void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
m_spellModTakingSpell = apply ? spell : NULL;
}
+void Player::SendSpellModifiers() const
+{
+ WorldPackets::Spells::SetSpellModifier flatMods(SMSG_SET_FLAT_SPELL_MODIFIER);
+ WorldPackets::Spells::SetSpellModifier pctMods(SMSG_SET_PCT_SPELL_MODIFIER);
+ for (uint8 i = 0; i < MAX_SPELLMOD; ++i)
+ {
+ WorldPackets::Spells::SpellModifier flatMod;
+ flatMod.ModifierData.resize(128);
+ WorldPackets::Spells::SpellModifier pctMod;
+ pctMod.ModifierData.resize(128);
+ flatMod.ModIndex = pctMod.ModIndex = i;
+ for (uint8 j = 0; j < 128; ++j)
+ {
+ flag128 mask;
+ mask[j / 32] = 1u << (j % 32);
+
+ flatMod.ModifierData[j].ClassIndex = j;
+ flatMod.ModifierData[j].ModifierValue = 0.0f;
+ pctMod.ModifierData[j].ClassIndex = j;
+ pctMod.ModifierData[j].ModifierValue = 1.0f;
+
+ for (SpellModifier* mod : m_spellMods[i])
+ {
+ if (mod->mask & mask)
+ {
+ if (mod->type == SPELLMOD_FLAT)
+ flatMod.ModifierData[j].ModifierValue += mod->value;
+ else
+ pctMod.ModifierData[j].ModifierValue += mod->value;
+ }
+ }
+
+ pctMod.ModifierData[j].ModifierValue = 1.0f + (pctMod.ModifierData[j].ModifierValue * 0.01f);
+ }
+
+ flatMod.ModifierData.erase(std::remove_if(flatMod.ModifierData.begin(), flatMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod)
+ {
+ return G3D::fuzzyEq(mod.ModifierValue, 0.0f);
+ }), flatMod.ModifierData.end());
+
+ pctMod.ModifierData.erase(std::remove_if(pctMod.ModifierData.begin(), pctMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod)
+ {
+ return G3D::fuzzyEq(mod.ModifierValue, 1.0f);
+ }), pctMod.ModifierData.end());
+
+ flatMods.Modifiers.emplace_back(std::move(flatMod));
+ pctMods.Modifiers.emplace_back(std::move(flatMod));
+ }
+
+ if (!flatMods.Modifiers.empty())
+ SendDirectMessage(flatMods.Write());
+
+ if (!pctMods.Modifiers.empty())
+ SendDirectMessage(pctMods.Write());
+}
+
// send Proficiency
void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const
{
@@ -23076,6 +23136,9 @@ void Player::SendInitialPacketsBeforeAddToMap()
// worldServerInfo.XRealmPvpAlert; /// @todo
SendDirectMessage(worldServerInfo.Write());
+ // Spell modifiers
+ SendSpellModifiers();
+
// SMSG_ACCOUNT_MOUNT_UPDATE
WorldPackets::Misc::AccountMountUpdate mountUpdate;
mountUpdate.IsFullUpdate = true;
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 8166b0c3fc8..a9d12310683 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1823,6 +1823,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = nullptr);
void DropModCharge(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
+ void SendSpellModifiers() const;
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
uint32 GetLastPotionId() const { return m_lastPotionId; }
@@ -2690,7 +2691,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
JoinedChannelsList m_channels;
- uint8 m_cinematic;
+ uint8 m_cinematic;
uint32 m_movie;