AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::WorldWorldTextBuilder Class Reference

Public Types

typedef std::vector< WorldPacket * > WorldPacketList
 

Public Member Functions

 WorldWorldTextBuilder (uint32 textId, va_list *args=nullptr)
 
void operator() (WorldPacketList &data_list, LocaleConstant loc_idx)
 

Private Member Functions

char * lineFromMessage (char *&pos)
 
void do_helper (WorldPacketList &data_list, char *text)
 

Private Attributes

uint32 i_textId
 
va_list * i_args
 

Detailed Description

Member Typedef Documentation

◆ WorldPacketList

Constructor & Destructor Documentation

◆ WorldWorldTextBuilder()

Acore::WorldWorldTextBuilder::WorldWorldTextBuilder ( uint32  textId,
va_list *  args = nullptr 
)
inlineexplicit
2311: i_textId(textId), i_args(args) {}
uint32 i_textId
Definition World.cpp:2345
va_list * i_args
Definition World.cpp:2346

Member Function Documentation

◆ do_helper()

void Acore::WorldWorldTextBuilder::do_helper ( WorldPacketList data_list,
char *  text 
)
inlineprivate
2335 {
2336 char* pos = text;
2337 while (char* line = lineFromMessage(pos))
2338 {
2339 WorldPacket* data = new WorldPacket();
2340 ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
2341 data_list.push_back(data);
2342 }
2343 }
@ CHAT_MSG_SYSTEM
Definition SharedDefines.h:3152
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
char * lineFromMessage(char *&pos)
Definition World.cpp:2333
static std::size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition Chat.cpp:265
Definition WorldPacket.h:26

References ChatHandler::BuildChatPacket(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, and lineFromMessage().

Referenced by operator()().

◆ lineFromMessage()

char * Acore::WorldWorldTextBuilder::lineFromMessage ( char *&  pos)
inlineprivate
2333{ char* start = strtok(pos, "\n"); pos = nullptr; return start; }

Referenced by do_helper().

◆ operator()()

void Acore::WorldWorldTextBuilder::operator() ( WorldPacketList data_list,
LocaleConstant  loc_idx 
)
inline
2313 {
2314 std::string strtext = sObjectMgr->GetAcoreString(i_textId, loc_idx);
2315 char const* text = strtext.c_str();
2316
2317 if (i_args)
2318 {
2319 // we need copy va_list before use or original va_list will corrupted
2320 va_list ap;
2321 va_copy(ap, *i_args);
2322
2323 char str[2048];
2324 vsnprintf(str, 2048, text, ap);
2325 va_end(ap);
2326
2327 do_helper(data_list, &str[0]);
2328 }
2329 else
2330 do_helper(data_list, (char*)text);
2331 }
#define sObjectMgr
Definition ObjectMgr.h:1636
void do_helper(WorldPacketList &data_list, char *text)
Definition World.cpp:2334

References do_helper(), i_args, i_textId, and sObjectMgr.

Member Data Documentation

◆ i_args

va_list* Acore::WorldWorldTextBuilder::i_args
private

Referenced by operator()().

◆ i_textId

uint32 Acore::WorldWorldTextBuilder::i_textId
private

Referenced by operator()().


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