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
129 : _builder(builder), _msgType(msgType)
130 {
131 _packetCache.resize(TOTAL_LOCALES, nullptr);
132 }
@ TOTAL_LOCALES
Definition Common.h:136
Builder const & _builder
Definition CreatureTextMgr.h:179
std::vector< std::pair< WorldPacket *, std::size_t > * > _packetCache
Definition CreatureTextMgr.h:178
ChatMsg _msgType
Definition CreatureTextMgr.h:180

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

◆ ~CreatureTextLocalizer()

template<class Builder >
CreatureTextLocalizer< Builder >::~CreatureTextLocalizer ( )
inline
135 {
136 for (std::size_t i = 0; i < _packetCache.size(); ++i)
137 {
138 if (_packetCache[i])
139 delete _packetCache[i]->first;
140 delete _packetCache[i];
141 }
142 }

References CreatureTextLocalizer< Builder >::_packetCache.

Member Function Documentation

◆ operator()()

template<class Builder >
void CreatureTextLocalizer< Builder >::operator() ( Player player)
inline
145 {
147 WorldPacket* messageTemplate;
148 std::size_t whisperGUIDpos;
149
150 // create if not cached yet
151 if (!_packetCache[loc_idx])
152 {
153 messageTemplate = new WorldPacket();
154 whisperGUIDpos = _builder(messageTemplate, loc_idx);
155 _packetCache[loc_idx] = new std::pair<WorldPacket*, std::size_t>(messageTemplate, whisperGUIDpos);
156 }
157 else
158 {
159 messageTemplate = _packetCache[loc_idx]->first;
160 whisperGUIDpos = _packetCache[loc_idx]->second;
161 }
162
163 WorldPacket data(*messageTemplate);
164 switch (_msgType)
165 {
168 data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
169 break;
170 default:
171 break;
172 }
173
174 player->SendDirectMessage(&data);
175 }
LocaleConstant
Definition Common.h:125
std::uint64_t uint64
Definition Define.h:106
@ CHAT_MSG_MONSTER_WHISPER
Definition SharedDefines.h:3400
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3427
uint64 GetRawValue() const
Definition ObjectGuid.h:145
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5852
WorldSession * GetSession() const
Definition Player.h:2030
Definition WorldPacket.h:26
LocaleConstant GetSessionDbLocaleIndex() const
Definition WorldSession.h:623

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


The documentation for this class was generated from the following file: