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

#include "ChatTextBuilder.h"

Public Member Functions

 AcoreStringChatBuilder (WorldObject const *obj, ChatMsg msgType, uint32 textId, WorldObject const *target=nullptr, va_list *args=nullptr)
 
void operator() (WorldPacket &data, LocaleConstant locale) const
 

Private Attributes

WorldObject const * _source
 
ChatMsg _msgType
 
uint32 _textId
 
WorldObject const * _target
 
va_list * _args
 

Detailed Description

Constructor & Destructor Documentation

◆ AcoreStringChatBuilder()

Acore::AcoreStringChatBuilder::AcoreStringChatBuilder ( WorldObject const *  obj,
ChatMsg  msgType,
uint32  textId,
WorldObject const *  target = nullptr,
va_list *  args = nullptr 
)
inline
68 : _source(obj), _msgType(msgType), _textId(textId), _target(target), _args(args) { }
uint32 _textId
Definition: ChatTextBuilder.h:75
va_list * _args
Definition: ChatTextBuilder.h:77
WorldObject const * _target
Definition: ChatTextBuilder.h:76
WorldObject const * _source
Definition: ChatTextBuilder.h:73
ChatMsg _msgType
Definition: ChatTextBuilder.h:74

Member Function Documentation

◆ operator()()

void Acore::AcoreStringChatBuilder::operator() ( WorldPacket data,
LocaleConstant  locale 
) const
41{
42 char const* text = sObjectMgr->GetAcoreString(_textId, locale);
43
44 if (_args)
45 {
46 // we need copy va_list before use or original va_list will corrupted
47 va_list ap;
48 va_copy(ap, *_args);
49
50 static std::size_t const BufferSize = 2048;
51 char strBuffer[BufferSize];
52 vsnprintf(strBuffer, BufferSize, text, ap);
53 va_end(ap);
54
55 ChatHandler::BuildChatPacket(data, _msgType, LANG_UNIVERSAL, _source, _target, strBuffer, 0, "", locale);
56 }
57 else
58 {
60 }
61}
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
#define sObjectMgr
Definition: ObjectMgr.h:1635
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

References ChatHandler::BuildChatPacket(), LANG_UNIVERSAL, and sObjectMgr.

Member Data Documentation

◆ _args

va_list* Acore::AcoreStringChatBuilder::_args
private

◆ _msgType

ChatMsg Acore::AcoreStringChatBuilder::_msgType
private

◆ _source

WorldObject const* Acore::AcoreStringChatBuilder::_source
private

◆ _target

WorldObject const* Acore::AcoreStringChatBuilder::_target
private

◆ _textId

uint32 Acore::AcoreStringChatBuilder::_textId
private