TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trinity::WorldWorldTextBuilder Class Reference

Public Types

typedef std::vector
< WorldPackets::Packet * > 
WorldPacketList
 

Public Member Functions

 WorldWorldTextBuilder (uint32 textId, va_list *args=NULL)
 
void operator() (WorldPacketList &dataList, LocaleConstant locale)
 

Static Public Attributes

static size_t const BufferSize = 2048
 

Private Member Functions

void do_helper (WorldPacketList &dataList, char *text)
 

Private Attributes

uint32 i_textId
 
va_list * i_args
 

Member Typedef Documentation

Constructor & Destructor Documentation

Trinity::WorldWorldTextBuilder::WorldWorldTextBuilder ( uint32  textId,
va_list *  args = NULL 
)
inlineexplicit
2399 : i_textId(textId), i_args(args) { }
uint32 i_textId
Definition: World.cpp:2435
va_list * i_args
Definition: World.cpp:2436

Member Function Documentation

void Trinity::WorldWorldTextBuilder::do_helper ( WorldPacketList dataList,
char *  text 
)
inlineprivate
2425  {
2426  while (char* line = ChatHandler::LineFromMessage(text))
2427  {
2429  packet->Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
2430  packet->Write();
2431  dataList.push_back(packet);
2432  }
2433  }
Definition: SharedDefines.h:961
static char * LineFromMessage(char *&pos)
Definition: Chat.h:63
Definition: ChatPackets.h:150
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
Definition: SharedDefines.h:4231

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Trinity::WorldWorldTextBuilder::operator() ( WorldPacketList dataList,
LocaleConstant  locale 
)
inline
2402  {
2403  char const* text = sObjectMgr->GetTrinityString(i_textId, locale);
2404 
2405  char strBuffer[BufferSize];
2406  if (i_args)
2407  {
2408  // we need copy va_list before use or original va_list will corrupted
2409  va_list ap;
2410  va_copy(ap, *i_args);
2411  vsnprintf(strBuffer, BufferSize, text, ap);
2412  va_end(ap);
2413  }
2414  else
2415  {
2416  std::strncpy(strBuffer, text, BufferSize);
2417  strBuffer[BufferSize - 1] = '\0';
2418  }
2419 
2420  do_helper(dataList, strBuffer);
2421  }
uint32 i_textId
Definition: World.cpp:2435
static size_t const BufferSize
Definition: World.cpp:2397
void do_helper(WorldPacketList &dataList, char *text)
Definition: World.cpp:2424
#define sObjectMgr
Definition: ObjectMgr.h:1567
va_list * i_args
Definition: World.cpp:2436
#define vsnprintf
Definition: Common.h:78

+ Here is the call graph for this function:

Member Data Documentation

size_t const Trinity::WorldWorldTextBuilder::BufferSize = 2048
static
va_list* Trinity::WorldWorldTextBuilder::i_args
private
uint32 Trinity::WorldWorldTextBuilder::i_textId
private

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