mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/PacketIO: updated totem packets
This commit is contained in:
@@ -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)
|
||||
{
|
||||
@@ -55,19 +54,20 @@ void Totem::Update(uint32 time)
|
||||
void Totem::InitStats(uint32 duration)
|
||||
{
|
||||
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
|
||||
if (GetOwner()->GetTypeId() == TYPEID_PLAYER
|
||||
&& m_Properties->Slot >= SUMMON_SLOT_TOTEM
|
||||
&& m_Properties->Slot < MAX_TOTEM_SLOT)
|
||||
if (Player* owner = GetOwner()->ToPlayer())
|
||||
{
|
||||
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
|
||||
data << uint8(m_Properties->Slot - 1);
|
||||
data << GetGUID();
|
||||
data << uint32(duration);
|
||||
data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
GetOwner()->ToPlayer()->SendDirectMessage(&data);
|
||||
if (m_Properties->Slot >= SUMMON_SLOT_TOTEM && m_Properties->Slot < MAX_TOTEM_SLOT)
|
||||
{
|
||||
WorldPackets::Totem::TotemCreated data;
|
||||
data.Totem = GetGUID();
|
||||
data.Slot = m_Properties->Slot - SUMMON_SLOT_TOTEM;
|
||||
data.Duration = duration;
|
||||
data.SpellID = GetUInt32Value(UNIT_CREATED_BY_SPELL);
|
||||
owner->SendDirectMessage(data.Write());
|
||||
}
|
||||
|
||||
// set display id depending on caster's race
|
||||
SetDisplayId(GetOwner()->GetModelForTotem(PlayerTotemType(m_Properties->ID)));
|
||||
SetDisplayId(owner->GetModelForTotem(PlayerTotemType(m_Properties->ID)));
|
||||
}
|
||||
|
||||
Minion::InitStats(duration);
|
||||
|
||||
@@ -16,25 +16,23 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "DBCStores.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Spell.h"
|
||||
#include "Totem.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "Player.h"
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameObjectPackets.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Log.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "Totem.h"
|
||||
#include "TotemPackets.h"
|
||||
|
||||
void WorldSession::HandleUseItemOpcode(WorldPackets::Spells::UseItem& packet)
|
||||
{
|
||||
@@ -444,18 +442,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->m_mover != _player)
|
||||
return;
|
||||
|
||||
uint8 slotId;
|
||||
ObjectGuid guid;
|
||||
recvPacket >> slotId;
|
||||
recvPacket >> guid;
|
||||
uint8 slotId = totemDestroyed.Slot;
|
||||
slotId += SUMMON_SLOT_TOTEM;
|
||||
|
||||
++slotId;
|
||||
if (slotId >= MAX_TOTEM_SLOT)
|
||||
return;
|
||||
|
||||
@@ -463,7 +458,7 @@ void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket)
|
||||
return;
|
||||
|
||||
Creature* totem = GetPlayer()->GetMap()->GetCreature(_player->m_SummonSlot[slotId]);
|
||||
if (totem && totem->IsTotem() && totem->GetGUID() == guid)
|
||||
if (totem && totem->IsTotem() && totem->GetGUID() == totemDestroyed.TotemGUID)
|
||||
totem->ToTotem()->UnSummon();
|
||||
}
|
||||
|
||||
|
||||
43
src/server/game/Server/Packets/TotemPackets.cpp
Normal file
43
src/server/game/Server/Packets/TotemPackets.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://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 >> TotemGUID;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Totem::TotemCreated::Write()
|
||||
{
|
||||
_worldPacket << Slot;
|
||||
_worldPacket << Totem;
|
||||
_worldPacket << int32(Duration);
|
||||
_worldPacket << int32(SpellID);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Totem::TotemMoved::Write()
|
||||
{
|
||||
_worldPacket << uint8(Slot);
|
||||
_worldPacket << uint8(NewSlot);
|
||||
_worldPacket << Totem;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
66
src/server/game/Server/Packets/TotemPackets.h
Normal file
66
src/server/game/Server/Packets/TotemPackets.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://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;
|
||||
|
||||
ObjectGuid TotemGUID;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
class TotemCreated final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
TotemCreated() : ServerPacket(SMSG_TOTEM_CREATED, 25) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid Totem;
|
||||
int32 SpellID = 0;
|
||||
int32 Duration = 0;
|
||||
int8 Slot = 0;
|
||||
};
|
||||
|
||||
class TotemMoved final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
TotemMoved() : ServerPacket(SMSG_TOTEM_MOVED, 18) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid Totem;
|
||||
uint8 Slot = 0;
|
||||
uint8 NewSlot = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TotemPackets_h__
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "Packets/TalentPackets.h"
|
||||
#include "Packets/TicketPackets.h"
|
||||
#include "Packets/TokenPackets.h"
|
||||
#include "Packets/TotemPackets.h"
|
||||
#include "Packets/TradePackets.h"
|
||||
#include "Packets/VehiclePackets.h"
|
||||
#include "Packets/VoidStoragePackets.h"
|
||||
@@ -783,7 +784,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_TIME_SYNC_RESPONSE_FAILED, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_TOGGLE_DIFFICULTY, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_TOGGLE_PVP, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleTogglePvP );
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_TOTEM_DESTROYED, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleTotemDestroyed );
|
||||
DEFINE_HANDLER(CMSG_TOTEM_DESTROYED, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Totem::TotemDestroyed, &WorldSession::HandleTotemDestroyed);
|
||||
DEFINE_HANDLER(CMSG_TOY_SET_FAVORITE, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_TRAINER_BUY_SPELL, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::NPC::TrainerBuySpell, &WorldSession::HandleTrainerBuySpellOpcode);
|
||||
DEFINE_HANDLER(CMSG_TRAINER_LIST, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::NPC::Hello, &WorldSession::HandleTrainerListOpcode);
|
||||
@@ -1682,8 +1683,8 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TIME_SYNC_REQUEST, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TITLE_EARNED, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TITLE_LOST, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TOTEM_CREATED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TOTEM_MOVED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TOTEM_CREATED, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TOTEM_MOVED, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TRADE_STATUS, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TRADE_UPDATED, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_TRAINER_BUY_FAILED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
|
||||
@@ -28,10 +28,8 @@
|
||||
#include "AddonMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "World.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Packet.h"
|
||||
#include "Cryptography/BigNumber.h"
|
||||
#include "Opcodes.h"
|
||||
#include "AccountMgr.h"
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -525,6 +523,11 @@ namespace WorldPackets
|
||||
class RequestWowTokenMarketPrice;
|
||||
}
|
||||
|
||||
namespace Totem
|
||||
{
|
||||
class TotemDestroyed;
|
||||
}
|
||||
|
||||
namespace Trade
|
||||
{
|
||||
class AcceptTrade;
|
||||
@@ -1350,7 +1353,7 @@ class WorldSession
|
||||
|
||||
void HandleSetActionBarToggles(WorldPackets::Character::SetActionBarToggles& packet);
|
||||
|
||||
void HandleTotemDestroyed(WorldPacket& recvData);
|
||||
void HandleTotemDestroyed(WorldPackets::Totem::TotemDestroyed& totemDestroyed);
|
||||
void HandleDismissCritter(WorldPacket& recvData);
|
||||
|
||||
//Battleground
|
||||
|
||||
Reference in New Issue
Block a user