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

Member Function Documentation

◆ do_helper()

void Acore::WorldWorldTextBuilder::do_helper ( WorldPacketList data_list,
char *  text 
)
inlineprivate
2594 {
2595 char* pos = text;
2596 while (char* line = lineFromMessage(pos))
2597 {
2598 WorldPacket* data = new WorldPacket();
2599 ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
2600 data_list.push_back(data);
2601 }
2602 }
@ CHAT_MSG_SYSTEM
Definition: SharedDefines.h:3152
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
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:264
Definition: WorldPacket.h:26
char * lineFromMessage(char *&pos)
Definition: World.cpp:2592

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

Referenced by operator()().

◆ lineFromMessage()

char * Acore::WorldWorldTextBuilder::lineFromMessage ( char *&  pos)
inlineprivate
2592{ 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
2573 {
2574 char const* text = sObjectMgr->GetAcoreString(i_textId, loc_idx);
2575
2576 if (i_args)
2577 {
2578 // we need copy va_list before use or original va_list will corrupted
2579 va_list ap;
2580 va_copy(ap, *i_args);
2581
2582 char str[2048];
2583 vsnprintf(str, 2048, text, ap);
2584 va_end(ap);
2585
2586 do_helper(data_list, &str[0]);
2587 }
2588 else
2589 do_helper(data_list, (char*)text);
2590 }
#define sObjectMgr
Definition: ObjectMgr.h:1635
void do_helper(WorldPacketList &data_list, char *text)
Definition: World.cpp:2593

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()().