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
116 : _builder(builder), _msgType(msgType)
117 {
118 _packetCache.resize(TOTAL_LOCALES, nullptr);
119 }
@ TOTAL_LOCALES
Definition Common.h:128
Builder const & _builder
Definition CreatureTextMgr.h:166
std::vector< std::pair< WorldPacket *, std::size_t > * > _packetCache
Definition CreatureTextMgr.h:165
ChatMsg _msgType
Definition CreatureTextMgr.h:167

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

◆ ~CreatureTextLocalizer()

template<class Builder >
CreatureTextLocalizer< Builder >::~CreatureTextLocalizer ( )
inline
122 {
123 for (std::size_t i = 0; i < _packetCache.size(); ++i)
124 {
125 if (_packetCache[i])
126 delete _packetCache[i]->first;
127 delete _packetCache[i];
128 }
129 }

References CreatureTextLocalizer< Builder >::_packetCache.

Member Function Documentation

◆ operator()()

template<class Builder >
void CreatureTextLocalizer< Builder >::operator() ( Player player)
inline
132 {
134 WorldPacket* messageTemplate;
135 std::size_t whisperGUIDpos;
136
137 // create if not cached yet
138 if (!_packetCache[loc_idx])
139 {
140 messageTemplate = new WorldPacket();
141 whisperGUIDpos = _builder(messageTemplate, loc_idx);
142 _packetCache[loc_idx] = new std::pair<WorldPacket*, std::size_t>(messageTemplate, whisperGUIDpos);
143 }
144 else
145 {
146 messageTemplate = _packetCache[loc_idx]->first;
147 whisperGUIDpos = _packetCache[loc_idx]->second;
148 }
149
150 WorldPacket data(*messageTemplate);
151 switch (_msgType)
152 {
155 data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
156 break;
157 default:
158 break;
159 }
160
161 player->SendDirectMessage(&data);
162 }
LocaleConstant
Definition Common.h:117
std::uint64_t uint64
Definition Define.h:106
@ CHAT_MSG_MONSTER_WHISPER
Definition SharedDefines.h:3417
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3444
uint64 GetRawValue() const
Definition ObjectGuid.h:142
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5711
WorldSession * GetSession() const
Definition Player.h:1998
Definition WorldPacket.h:26
LocaleConstant GetSessionDbLocaleIndex() const
Definition WorldSession.h:560

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: