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

Member Function Documentation

◆ do_helper()

void Acore::WorldWorldTextBuilder::do_helper ( WorldPacketList data_list,
char *  text 
)
inlineprivate
2589 {
2590 char* pos = text;
2591 while (char* line = lineFromMessage(pos))
2592 {
2593 WorldPacket* data = new WorldPacket();
2594 ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
2595 data_list.push_back(data);
2596 }
2597 }
@ 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:2587

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

Referenced by operator()().

◆ lineFromMessage()

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

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