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
1405: i_textId(textId), i_args(args) {}
uint32 i_textId
Definition World.cpp:1439
va_list * i_args
Definition World.cpp:1440

Member Function Documentation

◆ do_helper()

void Acore::WorldWorldTextBuilder::do_helper ( WorldPacketList data_list,
char *  text 
)
inlineprivate
1429 {
1430 char* pos = text;
1431 while (char* line = lineFromMessage(pos))
1432 {
1433 WorldPacket* data = new WorldPacket();
1434 ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
1435 data_list.push_back(data);
1436 }
1437 }
@ CHAT_MSG_SYSTEM
Definition SharedDefines.h:3391
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
char * lineFromMessage(char *&pos)
Definition World.cpp:1427
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
1427{ 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
1407 {
1408 std::string strtext = sObjectMgr->GetAcoreString(i_textId, loc_idx);
1409 char const* text = strtext.c_str();
1410
1411 if (i_args)
1412 {
1413 // we need copy va_list before use or original va_list will corrupted
1414 va_list ap;
1415 va_copy(ap, *i_args);
1416
1417 char str[2048];
1418 vsnprintf(str, 2048, text, ap);
1419 va_end(ap);
1420
1421 do_helper(data_list, &str[0]);
1422 }
1423 else
1424 do_helper(data_list, (char*)text);
1425 }
#define sObjectMgr
Definition ObjectMgr.h:1650
void do_helper(WorldPacketList &data_list, char *text)
Definition World.cpp:1428

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: