diff options
-rw-r--r-- | src/server/game/Entities/Totem/Totem.cpp | 15 | ||||
-rw-r--r-- | src/server/game/Handlers/SpellHandler.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Server/Packets/AllPackets.h | 1 | ||||
-rw-r--r-- | src/server/game/Server/Packets/TotemPackets.cpp | 33 | ||||
-rw-r--r-- | src/server/game/Server/Packets/TotemPackets.h | 54 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.h | 6 |
6 files changed, 104 insertions, 14 deletions
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 294306bd9a5..a906d986325 100644 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -19,12 +19,11 @@ #include "Totem.h" #include "Group.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Player.h" #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellInfo.h" -#include "WorldPacket.h" +#include "TotemPackets.h" Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner, false) { @@ -60,12 +59,12 @@ void Totem::InitStats(uint32 duration) uint32 slot = m_Properties->Slot; if (slot >= SUMMON_SLOT_TOTEM_FIRE && slot < MAX_TOTEM_SLOT) { - WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4); - data << uint8(m_Properties->Slot - 1); - data << uint64(GetGUID()); - data << uint32(duration); - data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL)); - GetOwner()->ToPlayer()->SendDirectMessage(&data); + WorldPackets::Totem::TotemCreated data; + data.Totem = GetGUID(); + data.Slot = slot - SUMMON_SLOT_TOTEM_FIRE; + data.Duration = duration; + data.SpellID = GetUInt32Value(UNIT_CREATED_BY_SPELL); + owner->SendDirectMessage(data.Write()); } // set display id depending on caster's race diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 9baa16cba72..540d09e806d 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -34,6 +34,7 @@ #include "SpellAuraEffects.h" #include "SpellMgr.h" #include "Totem.h" +#include "TotemPackets.h" #include "World.h" #include "WorldPacket.h" @@ -556,17 +557,15 @@ void WorldSession::HandleCancelChanneling(WorldPacket& recvData) mover->InterruptSpell(CURRENT_CHANNELED_SPELL); } -void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket) +void WorldSession::HandleTotemDestroyed(WorldPackets::Totem::TotemDestroyed& totemDestroyed) { // ignore for remote control state if (_player->GetUnitBeingMoved() != _player) return; - uint8 slotId; + uint8 slotId = totemDestroyed.Slot; + slotId += SUMMON_SLOT_TOTEM_FIRE; - recvPacket >> slotId; - - ++slotId; if (slotId >= MAX_TOTEM_SLOT) return; diff --git a/src/server/game/Server/Packets/AllPackets.h b/src/server/game/Server/Packets/AllPackets.h index 843d6290821..8d5ee66bd7c 100644 --- a/src/server/game/Server/Packets/AllPackets.h +++ b/src/server/game/Server/Packets/AllPackets.h @@ -22,6 +22,7 @@ #include "QueryPackets.h" #include "QuestPackets.h" #include "SpellPackets.h" +#include "TotemPackets.h" #include "WorldStatePackets.h" #endif // AllPackets_h__ diff --git a/src/server/game/Server/Packets/TotemPackets.cpp b/src/server/game/Server/Packets/TotemPackets.cpp new file mode 100644 index 00000000000..5ed1963a2fc --- /dev/null +++ b/src/server/game/Server/Packets/TotemPackets.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "TotemPackets.h" + +void WorldPackets::Totem::TotemDestroyed::Read() +{ + _worldPacket >> Slot; +} + +WorldPacket const* WorldPackets::Totem::TotemCreated::Write() +{ + _worldPacket << Slot; + _worldPacket << Totem; + _worldPacket << Duration; + _worldPacket << SpellID; + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/TotemPackets.h b/src/server/game/Server/Packets/TotemPackets.h new file mode 100644 index 00000000000..60c5f05b677 --- /dev/null +++ b/src/server/game/Server/Packets/TotemPackets.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TotemPackets_h__ +#define TotemPackets_h__ + +#include "Packet.h" +#include "ObjectGuid.h" + +namespace WorldPackets +{ + namespace Totem + { + class TotemDestroyed final : public ClientPacket + { + public: + TotemDestroyed(WorldPacket&& packet) : ClientPacket(CMSG_TOTEM_DESTROYED, std::move(packet)) { } + + void Read() override; + + uint8 Slot = 0; + }; + + class TotemCreated final : public ServerPacket + { + public: + TotemCreated() : ServerPacket(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4) { } + + WorldPacket const* Write() override; + + uint8 Slot = 0; + ObjectGuid Totem; + uint32 Duration = 0; + uint32 SpellID = 0; + + }; + } +} + +#endif // TotemPackets_h__ diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index b29b633b061..8b828ed77ad 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -92,6 +92,10 @@ namespace WorldPackets { class QueryQuestInfo; } + namespace Totem + { + class TotemDestroyed; + } } enum AccountDataType @@ -828,7 +832,7 @@ class TC_GAME_API WorldSession void HandleSetActionBarToggles(WorldPacket& recvData); - void HandleTotemDestroyed(WorldPacket& recvData); + void HandleTotemDestroyed(WorldPackets::Totem::TotemDestroyed& totemDestroyed); void HandleDismissCritter(WorldPacket& recvData); //Battleground |