AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
CreatureTextLocalizer< Builder > Class Template Reference

#include "CreatureTextMgr.h"

Public Member Functions

 CreatureTextLocalizer (Builder const &builder, ChatMsg msgType)
 
 ~CreatureTextLocalizer ()
 
void operator() (Player *player)
 

Private Attributes

std::vector< std::pair< WorldPacket *, std::size_t > * > _packetCache
 
Builder const & _builder
 
ChatMsg _msgType
 

Detailed Description

template<class Builder>
class CreatureTextLocalizer< Builder >

Constructor & Destructor Documentation

◆ CreatureTextLocalizer()

template<class Builder >
CreatureTextLocalizer< Builder >::CreatureTextLocalizer ( Builder const &  builder,
ChatMsg  msgType 
)
inline
124 : _builder(builder), _msgType(msgType)
125 {
126 _packetCache.resize(TOTAL_LOCALES, nullptr);
127 }
@ TOTAL_LOCALES
Definition: Common.h:76
Builder const & _builder
Definition: CreatureTextMgr.h:174
std::vector< std::pair< WorldPacket *, std::size_t > * > _packetCache
Definition: CreatureTextMgr.h:173
ChatMsg _msgType
Definition: CreatureTextMgr.h:175

References CreatureTextLocalizer< Builder >::_packetCache, and TOTAL_LOCALES.

◆ ~CreatureTextLocalizer()

template<class Builder >
CreatureTextLocalizer< Builder >::~CreatureTextLocalizer ( )
inline
130 {
131 for (std::size_t i = 0; i < _packetCache.size(); ++i)
132 {
133 if (_packetCache[i])
134 delete _packetCache[i]->first;
135 delete _packetCache[i];
136 }
137 }

References CreatureTextLocalizer< Builder >::_packetCache.

Member Function Documentation

◆ operator()()

template<class Builder >
void CreatureTextLocalizer< Builder >::operator() ( Player player)
inline
140 {
142 WorldPacket* messageTemplate;
143 std::size_t whisperGUIDpos;
144
145 // create if not cached yet
146 if (!_packetCache[loc_idx])
147 {
148 messageTemplate = new WorldPacket();
149 whisperGUIDpos = _builder(messageTemplate, loc_idx);
150 _packetCache[loc_idx] = new std::pair<WorldPacket*, std::size_t>(messageTemplate, whisperGUIDpos);
151 }
152 else
153 {
154 messageTemplate = _packetCache[loc_idx]->first;
155 whisperGUIDpos = _packetCache[loc_idx]->second;
156 }
157
158 WorldPacket data(*messageTemplate);
159 switch (_msgType)
160 {
163 data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
164 break;
165 default:
166 break;
167 }
168
169 player->SendDirectMessage(&data);
170 }
LocaleConstant
Definition: Common.h:65
std::uint64_t uint64
Definition: Define.h:106
@ CHAT_MSG_MONSTER_WHISPER
Definition: SharedDefines.h:3167
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition: SharedDefines.h:3194
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
uint64 GetRawValue() const
Definition: ObjectGuid.h:142
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5723
WorldSession * GetSession() const
Definition: Player.h:1998
Definition: WorldPacket.h:26
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498

References CreatureTextLocalizer< Builder >::_builder, CreatureTextLocalizer< Builder >::_msgType, CreatureTextLocalizer< Builder >::_packetCache, CHAT_MSG_MONSTER_WHISPER, CHAT_MSG_RAID_BOSS_WHISPER, Object::GetGUID(), ObjectGuid::GetRawValue(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), ByteBuffer::put(), and Player::SendDirectMessage().

Member Data Documentation

◆ _builder

template<class Builder >
Builder const& CreatureTextLocalizer< Builder >::_builder
private

◆ _msgType

template<class Builder >
ChatMsg CreatureTextLocalizer< Builder >::_msgType
private

◆ _packetCache