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
125 : _builder(builder), _msgType(msgType)
126 {
127 _packetCache.resize(TOTAL_LOCALES, nullptr);
128 }
@ TOTAL_LOCALES
Definition: Common.h:76
Builder const & _builder
Definition: CreatureTextMgr.h:175
std::vector< std::pair< WorldPacket *, std::size_t > * > _packetCache
Definition: CreatureTextMgr.h:174
ChatMsg _msgType
Definition: CreatureTextMgr.h:176

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

◆ ~CreatureTextLocalizer()

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

References CreatureTextLocalizer< Builder >::_packetCache.

Member Function Documentation

◆ operator()()

template<class Builder >
void CreatureTextLocalizer< Builder >::operator() ( Player player)
inline
141 {
143 WorldPacket* messageTemplate;
144 std::size_t whisperGUIDpos;
145
146 // create if not cached yet
147 if (!_packetCache[loc_idx])
148 {
149 messageTemplate = new WorldPacket();
150 whisperGUIDpos = _builder(messageTemplate, loc_idx);
151 _packetCache[loc_idx] = new std::pair<WorldPacket*, std::size_t>(messageTemplate, whisperGUIDpos);
152 }
153 else
154 {
155 messageTemplate = _packetCache[loc_idx]->first;
156 whisperGUIDpos = _packetCache[loc_idx]->second;
157 }
158
159 WorldPacket data(*messageTemplate);
160 switch (_msgType)
161 {
164 data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
165 break;
166 default:
167 break;
168 }
169
170 player->SendDirectMessage(&data);
171 }
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:109
uint64 GetRawValue() const
Definition: ObjectGuid.h:142
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5692
WorldSession * GetSession() const
Definition: Player.h:1978
Definition: WorldPacket.h:27
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