refactor(Core/Packet): Chat (#9509)

* Chat

* .

* Update GameObject.cpp

* Update Object.cpp

* Update Player.cpp
This commit is contained in:
IntelligentQuantum
2022-01-08 13:41:06 +03:30
committed by GitHub
parent 03efc110a0
commit 725b1266b4
20 changed files with 153 additions and 48 deletions

View File

@@ -18,6 +18,7 @@
#ifndef AllPackets_h__
#define AllPackets_h__
#include "ChatPackets.h"
#include "CharacterPackets.h"
#include "MiscPackets.h"
#include "WorldStatePackets.h"

View File

@@ -0,0 +1,39 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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 "ChatPackets.h"
WorldPacket const* WorldPackets::Chat::Emote::Write()
{
_worldPacket << EmoteID;
_worldPacket << Guid;
return &_worldPacket;
}
void WorldPackets::Chat::EmoteClient::Read()
{
_worldPacket >> EmoteID;
}
WorldPacket const* WorldPackets::Chat::ChatServerMessage::Write()
{
_worldPacket << int32(MessageID);
_worldPacket << StringParam;
return &_worldPacket;
}

View File

@@ -0,0 +1,62 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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 ChatPackets_h__
#define ChatPackets_h__
#include "Packet.h"
#include "ObjectGuid.h"
namespace WorldPackets
{
namespace Chat
{
class Emote final : public ServerPacket
{
public:
Emote() : ServerPacket(SMSG_EMOTE, 4 + 8) { }
WorldPacket const* Write() override;
uint32 EmoteID = 0;
ObjectGuid Guid;
};
class EmoteClient final : public ClientPacket
{
public:
EmoteClient(WorldPacket&& packet) : ClientPacket(CMSG_EMOTE, std::move(packet)) { }
void Read() override;
uint32 EmoteID = 0;
};
class ChatServerMessage final : public ServerPacket
{
public:
ChatServerMessage() : ServerPacket(SMSG_CHAT_SERVER_MESSAGE, 4 + 20) { }
WorldPacket const* Write() override;
int32 MessageID = 0;
std::string StringParam;
};
}
}
#endif // ChatPackets_h__

View File

@@ -785,7 +785,7 @@ void OpcodeTable::Initialize()
/*0x28E*/ DEFINE_HANDLER(CMSG_GROUP_RAID_CONVERT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupRaidConvertOpcode );
/*0x28F*/ DEFINE_HANDLER(CMSG_GROUP_ASSISTANT_LEADER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupAssistantLeaderOpcode );
/*0x290*/ DEFINE_HANDLER(CMSG_BUYBACK_ITEM, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBuybackItem );
/*0x291*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_SERVER_MESSAGE, STATUS_NEVER);
/*0x291*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_CHAT_SERVER_MESSAGE, STATUS_NEVER);
/*0x292*/ DEFINE_HANDLER(CMSG_SET_SAVED_INSTANCE_EXTEND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetSavedInstanceExtend );
/*0x293*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_LFG_OFFER_CONTINUE, STATUS_NEVER);
/*0x294*/ DEFINE_HANDLER(CMSG_TEST_DROP_RATE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );

View File

@@ -684,7 +684,7 @@ enum Opcodes : uint16
CMSG_GROUP_RAID_CONVERT = 0x28E,
CMSG_GROUP_ASSISTANT_LEADER = 0x28F,
CMSG_BUYBACK_ITEM = 0x290,
SMSG_SERVER_MESSAGE = 0x291,
SMSG_CHAT_SERVER_MESSAGE = 0x291,
CMSG_SET_SAVED_INSTANCE_EXTEND = 0x292,
SMSG_LFG_OFFER_CONTINUE = 0x293,
CMSG_TEST_DROP_RATE = 0x294,

View File

@@ -71,6 +71,11 @@ namespace lfg
namespace WorldPackets
{
namespace Chat
{
class EmoteClient;
}
namespace Character
{
class LogoutCancel;
@@ -583,7 +588,7 @@ public: // opcodes handlers
void HandleZoneUpdateOpcode(WorldPacket& recvPacket);
void HandleSetSelectionOpcode(WorldPacket& recvPacket);
void HandleStandStateChangeOpcode(WorldPacket& recvPacket);
void HandleEmoteOpcode(WorldPacket& recvPacket);
void HandleEmoteOpcode(WorldPackets::Chat::EmoteClient& packet);
void HandleContactListOpcode(WorldPacket& recvPacket);
void HandleAddFriendOpcode(WorldPacket& recvPacket);
void HandleDelFriendOpcode(WorldPacket& recvPacket);