Core/Packets: updated CMSG_SEND_TEXT_EMOTE and SMSG_TEXT_EMOTE to packet class

* dropped deprecated EmoteChatBuilder operator
This commit is contained in:
Ovahlord committed 2022-12-11 12:52:01 +01:00
1 parent 39a2a0c80b
commit 1882d5f8b0
7 files changed
+118 -62

No files matched your search

+19 -59
View File
@@ -21,6 +21,7 @@
#include "Channel.h"
#include "ChannelMgr.h"
#include "Chat.h"
#include "ChatPackets.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
@@ -721,39 +722,7 @@ void WorldSession::HandleEmoteOpcode(WorldPacket& recvData)
_player->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
}
namespace Trinity
{
class EmoteChatBuilder
{
public:
EmoteChatBuilder(Player const& player, uint32 text_emote, uint32 emote_num, Unit const* target)
: i_player(player), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
std::string const name(i_target ? i_target->GetNameForLocaleIdx(loc_idx) : "");
uint32 namlen = name.size();
data.Initialize(SMSG_TEXT_EMOTE, 20 + namlen);
data << i_player.GetGUID();
data << uint32(i_text_emote);
data << uint32(i_emote_num);
data << uint32(namlen);
if (namlen > 1)
data << name;
else
data << uint8(0x00);
}
private:
Player const& i_player;
uint32 i_text_emote;
uint32 i_emote_num;
Unit const* i_target;
};
} // namespace Trinity
void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
void WorldSession::HandleSendTextEmoteOpcode(WorldPackets::Chat::SendTextEmote& packet)
{
if (!GetPlayer()->IsAlive())
return;
@@ -765,22 +734,15 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
return;
}
uint32 text_emote, emoteNum;
ObjectGuid guid;
sScriptMgr->OnPlayerTextEmote(GetPlayer(), packet.SoundIndex, packet.EmoteID, packet.Target);
recvData >> text_emote;
recvData >> emoteNum;
recvData >> guid;
sScriptMgr->OnPlayerTextEmote(GetPlayer(), text_emote, emoteNum, guid);
EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote);
EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(packet.EmoteID);
if (!em)
return;
uint32 emote_anim = em->EmoteID;
Emote emote = static_cast<Emote>(em->EmoteID);
switch (emote_anim)
switch (emote)
{
case EMOTE_STATE_SLEEP:
case EMOTE_STATE_SIT:
@@ -789,36 +751,34 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
break;
case EMOTE_STATE_DANCE:
case EMOTE_STATE_READ:
GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote_anim);
GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
break;
default:
// Only allow text-emotes for "dead" entities (feign death included)
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
break;
GetPlayer()->HandleEmoteCommand(emote_anim);
GetPlayer()->HandleEmoteCommand(emote);
break;
}
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
Unit* unit = ObjectAccessor::GetUnit(*_player, packet.Target);
CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
WorldPackets::Chat::STextEmote textEmote;
textEmote.SourceGUID = _player->GetGUID();
textEmote.EmoteID = packet.EmoteID;
textEmote.SoundIndex = packet.SoundIndex;
if (unit)
textEmote.Target = unit->GetName();
Cell cell(p);
cell.SetNoCreate();
_player->SendMessageToSetInRange(textEmote.Write(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true);
Trinity::EmoteChatBuilder emote_builder(*GetPlayer(), text_emote, emoteNum, unit);
Trinity::LocalizedPacketDo<Trinity::EmoteChatBuilder > emote_do(emote_builder);
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::EmoteChatBuilder > > emote_worker(GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), emote_do);
TypeContainerVisitor<Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::EmoteChatBuilder> >, WorldTypeMapContainer> message(emote_worker);
cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, 0, unit);
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, packet.EmoteID, 0, 0, unit);
//Send scripted event call
if (unit && unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI())
((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote);
((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), packet.EmoteID);
if (emote_anim != EMOTE_ONESHOT_NONE)
if (emote != EMOTE_ONESHOT_NONE)
_player->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Anim);
}
@@ -24,6 +24,7 @@
#include "AuthenticationPackets.h"
#include "BattlegroundPackets.h"
#include "CharacterPackets.h"
#include "ChatPackets.h"
#include "CombatLogPackets.h"
#include "CombatPackets.h"
#include "GuildPackets.h"
@@ -0,0 +1,36 @@
/*
* This file is part of the TrinityCore 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 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 "ChatPackets.h"
void WorldPackets::Chat::SendTextEmote::Read()
{
_worldPacket >> EmoteID;
_worldPacket >> SoundIndex;
_worldPacket >> Target;
}
WorldPacket const* WorldPackets::Chat::STextEmote::Write()
{
_worldPacket << SourceGUID;
_worldPacket << int32(EmoteID);
_worldPacket << int32(SoundIndex);
_worldPacket << int32(Target.length() + 1);
_worldPacket << Target;
return &_worldPacket;
}
@@ -0,0 +1,54 @@
/*
* This file is part of the TrinityCore 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 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 ChatPackets_h__
#define ChatPackets_h__
#include "Packet.h"
namespace WorldPackets
{
namespace Chat
{
class SendTextEmote final : public ClientPacket
{
public:
SendTextEmote(WorldPacket&& packet) : ClientPacket(CMSG_SEND_TEXT_EMOTE, std::move(packet)) { }
void Read() override;
ObjectGuid Target;
int32 EmoteID = 0;
int32 SoundIndex = 0;
};
class STextEmote final : public ServerPacket
{
public:
STextEmote() : ServerPacket(SMSG_TEXT_EMOTE, 21) { }
WorldPacket const* Write() override;
ObjectGuid SourceGUID;
std::string Target;
int32 SoundIndex = 0;
int32 EmoteID = 0;
};
}
}
#endif // ArchaeologyPackets_h__
+1 -1
View File
@@ -610,7 +610,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_TAXINODE_STATUS_QUERY, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleTaxiNodeStatusQueryOpcode );
DEFINE_HANDLER(CMSG_TAXIQUERYAVAILABLENODES, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleTaxiQueryAvailableNodes );
DEFINE_HANDLER(CMSG_TELEPORT_TO_UNIT, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_HANDLER(CMSG_TEXT_EMOTE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleTextEmoteOpcode );
DEFINE_HANDLER(CMSG_SEND_TEXT_EMOTE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleSendTextEmoteOpcode );
DEFINE_HANDLER(CMSG_TIME_ADJUSTMENT_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_HANDLER(CMSG_TIME_SYNC_RESP, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleTimeSyncResp );
DEFINE_HANDLER(CMSG_TIME_SYNC_RESP_FAILED, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
+1 -1
View File
@@ -540,7 +540,7 @@ enum OpcodeClient : uint16
CMSG_TAXIQUERYAVAILABLENODES = 0x6C06,
CMSG_TAXISHOWNODES = 0x0000,
CMSG_TELEPORT_TO_UNIT = 0x4206,
CMSG_TEXT_EMOTE = 0x2E24,
CMSG_SEND_TEXT_EMOTE = 0x2E24,
CMSG_TIME_ADJUSTMENT_RESPONSE = 0x3818,
CMSG_TIME_SYNC_RESP = 0x3B0C,
CMSG_TIME_SYNC_RESP_FAILED = 0x710A,
+6 -1
View File
@@ -99,6 +99,11 @@ namespace WorldPackets
enum class LoginFailureReason : uint8;
}
namespace Chat
{
class SendTextEmote;
}
namespace Combat
{
class AttackSwing;
@@ -996,7 +1001,7 @@ class TC_GAME_API WorldSession
void SendPlayerAmbiguousNotice(std::string const& name);
void SendWrongFactionNotice();
void SendChatRestrictedNotice(ChatRestrictionType restriction);
void HandleTextEmoteOpcode(WorldPacket& recvPacket);
void HandleSendTextEmoteOpcode(WorldPackets::Chat::SendTextEmote& packet);
void HandleChatIgnoredOpcode(WorldPacket& recvPacket);
void HandleUnregisterAddonPrefixesOpcode(WorldPacket& recvPacket);