Core/Packets: updated CMSG_SEND_TEXT_EMOTE and SMSG_TEXT_EMOTE to packet class
* dropped deprecated EmoteChatBuilder operator
This commit is contained in:
1 parent
39a2a0c80b
commit
1882d5f8b0
7 files changed
+118
-62
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user