TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
< WorldPackets::Chat::Chat * > 
_packetCache
 
Builder const_builder
 
ChatMsg _msgType
 

Constructor & Destructor Documentation

template<class Builder>
CreatureTextLocalizer< Builder >::CreatureTextLocalizer ( Builder const builder,
ChatMsg  msgType 
)
inline
119  : _builder(builder), _msgType(msgType)
120  {
122  }
Builder const & _builder
Definition: CreatureTextMgr.h:161
arena_t NULL
Definition: jemalloc_internal.h:624
ChatMsg _msgType
Definition: CreatureTextMgr.h:162
std::vector< WorldPackets::Chat::Chat * > _packetCache
Definition: CreatureTextMgr.h:160
Definition: Common.h:130
template<class Builder>
CreatureTextLocalizer< Builder >::~CreatureTextLocalizer ( )
inline
125  {
126  for (size_t i = 0; i < _packetCache.size(); ++i)
127  delete _packetCache[i];
128  }
std::vector< WorldPackets::Chat::Chat * > _packetCache
Definition: CreatureTextMgr.h:160

Member Function Documentation

template<class Builder>
void CreatureTextLocalizer< Builder >::operator() ( Player player)
inline
131  {
132  LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
133  WorldPackets::Chat::Chat* messageTemplate;
134 
135  // create if not cached yet
136  if (!_packetCache[loc_idx])
137  {
138  messageTemplate = _builder(loc_idx);
139  _packetCache[loc_idx] = messageTemplate;
140  }
141  else
142  messageTemplate = _packetCache[loc_idx];
143 
144  WorldPackets::Chat::Chat message(*messageTemplate);
145 
146  switch (_msgType)
147  {
150  message.SetReceiver(player, loc_idx);
151  break;
152  default:
153  break;
154  }
155 
156  player->SendDirectMessage(message.Write());
157  }
Definition: SharedDefines.h:4246
Builder const & _builder
Definition: CreatureTextMgr.h:161
Definition: ChatPackets.h:150
LocaleConstant
Definition: Common.h:115
Definition: SharedDefines.h:4273
ChatMsg _msgType
Definition: CreatureTextMgr.h:162
std::vector< WorldPackets::Chat::Chat * > _packetCache
Definition: CreatureTextMgr.h:160

+ Here is the call graph for this function:

Member Data Documentation

template<class Builder>
Builder const& CreatureTextLocalizer< Builder >::_builder
private
template<class Builder>
ChatMsg CreatureTextLocalizer< Builder >::_msgType
private
template<class Builder>
std::vector<WorldPackets::Chat::Chat*> CreatureTextLocalizer< Builder >::_packetCache
private

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