TrinityCore
Loading...
Searching...
No Matches
ChatTextBuilder.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ChatTextBuilder.h"
19#include "Chat.h"
20#include "ObjectMgr.h"
21#include <cstdarg>
22
24{
25 BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
26 ChatHandler::BuildChatPacket(data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
27}
28
30{
31 BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
32 return ChatHandler::BuildChatPacket(*data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
33}
34
36{
37 ChatHandler::BuildChatPacket(data, _msgType, _language, _source, _target, _text, 0, "", locale);
38}
39
41{
42 char const* text = sObjectMgr->GetTrinityString(_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 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 ChatHandler::BuildChatPacket(data, _msgType, LANG_UNIVERSAL, _source, _target, text, 0, "", locale);
59}
LocaleConstant
Definition Common.h:48
#define sObjectMgr
Definition ObjectMgr.h:1721
Language
@ LANG_UNIVERSAL
static 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:193
void operator()(WorldPacket &data, LocaleConstant locale) const
void operator()(WorldPacket &data, LocaleConstant locale) const
void operator()(WorldPacket &data, LocaleConstant locale) const
uint32 LanguageID
Definition ObjectMgr.h:482
std::string const & GetText(LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false) const
Definition ObjectMgr.h:496