diff --git a/src/game/Objects/Object.cpp b/src/game/Objects/Object.cpp index 62c3b5b7a..1d15627a3 100644 --- a/src/game/Objects/Object.cpp +++ b/src/game/Objects/Object.cpp @@ -356,7 +356,28 @@ void WorldObject::DirectSendPublicValueUpdate(uint32 index, uint32 count) if (abort) return; + UpdateMask updateMask; + updateMask.SetCount(m_valuesCount); + for (int i = 0; i < count; i++) + updateMask.SetBit(index + i); + + DirectSendPublicValueUpdate(updateMask); +} + +void WorldObject::DirectSendPublicValueUpdate(std::initializer_list indexes) +{ + UpdateMask updateMask; + updateMask.SetCount(m_valuesCount); + for (auto const& index : indexes) + updateMask.SetBit(index); + + DirectSendPublicValueUpdate(updateMask); +} + +void WorldObject::DirectSendPublicValueUpdate(UpdateMask& updateMask) +{ UpdateData data; + ByteBuffer& buf = data.AddUpdateBlockAndGetBuffer(); buf << uint8(UPDATETYPE_VALUES); #if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 @@ -365,15 +386,17 @@ void WorldObject::DirectSendPublicValueUpdate(uint32 index, uint32 count) buf << GetGUID(); #endif - UpdateMask updateMask; - updateMask.SetCount(m_valuesCount); - for (int i = 0; i < count; i++) - updateMask.SetBit(index + i); - buf << (uint8)updateMask.GetBlockCount(); buf.append(updateMask.GetMask(), updateMask.GetLength()); - for (int i = 0; i < count; i++) - buf << uint32(m_uint32Values[index + i]); + + for (uint16 index = 0; index < m_valuesCount; ++index) + { + if (updateMask.GetBit(index)) + { + buf << uint32(m_uint32Values[index]); + m_uint32Values_mirror[index] = m_uint32Values[index]; + } + } WorldPacket packet; data.BuildPacket(&packet); diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index 7b4e46829..0c2cf5a98 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -870,6 +870,8 @@ class WorldObject : public Object virtual void SendMessageToSetInRange(WorldPacket* data, float dist, bool self) const; void SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver) const; void DirectSendPublicValueUpdate(uint32 index, uint32 count = 1); + void DirectSendPublicValueUpdate(UpdateMask& updateMask); + void DirectSendPublicValueUpdate(std::initializer_list indexes); void PlayDistanceSound(uint32 sound_id, Player const* target = nullptr) const; void PlayDirectSound(uint32 sound_id, Player const* target = nullptr) const; diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 3a81fac89..dd74f9460 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -44,6 +44,7 @@ #include "PathFinder.h" #include "CharacterDatabaseCache.h" #include "ZoneScript.h" +#include "UpdateMask.h" using namespace Spells; @@ -5276,10 +5277,27 @@ void Spell::SendChannelUpdate(uint32 time, bool interrupted) if (!time) { - // Reset of channel values has to be done after a few delay. - // Else, we have some visual bugs (arcane projectile, last tick) - ChannelResetEvent* event = new ChannelResetEvent(m_casterUnit); - m_casterUnit->m_Events.AddEventAtOffset(event, (interrupted ? 1 : 1000)); + if (interrupted) + { + // Send update directly on interrupt to fix animation if recasting channeled spell + m_casterUnit->SetChannelObjectGuid(ObjectGuid()); + m_casterUnit->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); + m_casterUnit->DirectSendPublicValueUpdate({ UNIT_FIELD_CHANNEL_OBJECT , UNIT_FIELD_CHANNEL_OBJECT + 1 , UNIT_CHANNEL_SPELL }); + + if (Player* pPlayer = m_casterUnit->ToPlayer()) + { + WorldPacket data(MSG_CHANNEL_UPDATE, 4); + data << uint32(time); + pPlayer->SendDirectMessage(&data); + } + } + else + { + // Reset of channel values has to be done after a few delay. + // Else, we have some visual bugs (arcane projectile, last tick) + ChannelResetEvent* event = new ChannelResetEvent(m_casterUnit); + m_casterUnit->m_Events.AddEventAtOffset(event, 1000); + } } else if (Player* pPlayer = m_casterUnit->ToPlayer()) { @@ -5336,6 +5354,34 @@ void Spell::SendChannelStart(uint32 duration) } m_timer = duration; + + if (m_spellInfo->HasAttribute(SPELL_ATTR_EX_IS_CHANNELED)) + { + WorldPacket data(SMSG_SPELL_UPDATE_CHAIN_TARGETS); + data << m_caster->GetObjectGuid(); + data << uint32(m_spellInfo->Id); + size_t count_pos = data.wpos(); + data << uint32(0); + uint32 hit = 0; + for (TargetList::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) + { + if (((itr->effectMask & (1 << EFFECT_INDEX_0)) && itr->reflectResult == SPELL_MISS_NONE && + m_CastItem) || itr->targetGUID != m_caster->GetObjectGuid()) + { + if (Unit* target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID)) + { + ++hit; + data << target->GetObjectGuid(); + } + } + } + if (hit) + { + data.put(count_pos, hit); + m_caster->SendMessageToSet(&data, true); + } + } + if (m_casterUnit) { if (target)