TrinityCore
Loading...
Searching...
No Matches
Chat.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 "Chat.h"
19#include "AccountMgr.h"
20#include "CellImpl.h"
21#include "CharacterCache.h"
22#include "GridNotifiersImpl.h"
23#include "Language.h"
24#include "ObjectAccessor.h"
25#include "ObjectMgr.h"
26#include "Optional.h"
27#include "Player.h"
28#include "Realm.h"
29#include "StringConvert.h"
30#include "World.h"
31#include "WorldSession.h"
32#include <boost/algorithm/string/replace.hpp>
33
34Player* ChatHandler::GetPlayer() const { return m_session ? m_session->GetPlayer() : nullptr; }
35
36char const* ChatHandler::GetTrinityString(uint32 entry) const
37{
38 return m_session->GetTrinityString(entry);
39}
40
41bool ChatHandler::HasPermission(uint32 permission) const
42{
43 return m_session->HasPermission(permission);
44}
45
46std::string ChatHandler::GetNameLink() const
47{
49}
50
51bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
52{
53 WorldSession* target_session = nullptr;
54 uint32 target_account = 0;
55
56 if (target)
57 target_session = target->GetSession();
58 else if (!guid.IsEmpty())
59 target_account = sCharacterCache->GetCharacterAccountIdByGuid(guid);
60
61 if (!target_session && !target_account)
62 {
65 return true;
66 }
67
68 return HasLowerSecurityAccount(target_session, target_account, strong);
69}
70
71bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_account, bool strong)
72{
73 uint32 target_sec;
74
75 // allow everything from console and RA console
76 if (!m_session)
77 return false;
78
79 // ignore only for non-players for non strong checks (when allow apply command at least to same sec level)
81 return false;
82
83 if (target)
84 target_sec = target->GetSecurity();
85 else if (target_account)
86 target_sec = AccountMgr::GetSecurity(target_account, realm.Id.Realm);
87 else
88 return true; // caller must report error for (target == nullptr && target_account == 0)
89
90 AccountTypes target_ac_sec = AccountTypes(target_sec);
91 if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
92 {
95 return true;
96 }
97
98 return false;
99}
100
101void ChatHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
102{
103 std::string msg{ str };
104
105 // Replace every "|" with "||" in msg
106 if (escapeCharacters && msg.find('|') != std::string::npos)
107 {
108 std::vector<std::string_view> tokens = Trinity::Tokenize(msg, '|', true);
109 std::ostringstream stream;
110 for (size_t i = 0; i < tokens.size() - 1; ++i)
111 stream << tokens[i] << "||";
112 stream << tokens[tokens.size() - 1];
113
114 msg = stream.str();
115 }
116
117 WorldPacket data;
118 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
119 {
120 BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
121 m_session->SendPacket(&data);
122 }
123}
124
126{
127 WorldPacket data;
128 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
129 {
130 BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
131 sWorld->SendGlobalMessage(&data);
132 }
133}
134
136{
137 WorldPacket data;
138 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
139 {
140 BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
141 sWorld->SendGlobalGMMessage(&data);
142 }
143}
144
149
150std::string ChatHandler::StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs)
151{
152 return fmt::vsprintf<char>(messageFormat, messageFormatArgs);
153}
154
155bool ChatHandler::_ParseCommands(std::string_view text)
156{
158 return true;
159
160 // Pretend commands don't exist for regular players
162 return false;
163
164 // Send error message for GMs
167 return true;
168}
169
170bool ChatHandler::ParseCommands(std::string_view text)
171{
172 ASSERT(!text.empty());
173
174 // chat case (.command or !command format)
175 if ((text[0] != '!') && (text[0] != '.'))
176 return false;
177
178 // ignore single . and ! in line
179 if (text.length() < 2)
180 return false;
181
182 // ignore messages staring from many dots.
183 if (text[1] == text[0])
184 return false;
185
186 // ignore messages with separator after .
188 return false;
189
190 return _ParseCommands(text.substr(1));
191}
192
193size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag,
194 std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/,
195 uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/)
196{
197 size_t receiverGUIDPos = 0;
199 data << uint8(chatType);
200 data << int32(language);
201 data << senderGUID;
202 data << uint32(0); // some flags
203 switch (chatType)
204 {
213 data << uint32(senderName.length() + 1);
214 data << senderName;
215 receiverGUIDPos = data.wpos();
216 data << receiverGUID;
217 if (!receiverGUID.IsEmpty() && !receiverGUID.IsPlayer() && !receiverGUID.IsPet())
218 {
219 data << uint32(receiverName.length() + 1);
220 data << receiverName;
221 }
222 break;
224 data << uint32(senderName.length() + 1);
225 data << senderName;
226 receiverGUIDPos = data.wpos();
227 data << receiverGUID;
228 break;
232 receiverGUIDPos = data.wpos();
233 data << receiverGUID;
234 if (!receiverGUID.IsEmpty() && !receiverGUID.IsPlayer())
235 {
236 data << uint32(receiverName.length() + 1);
237 data << receiverName;
238 }
239 break;
242 receiverGUIDPos = data.wpos();
243 data << receiverGUID;
244 break;
245 default:
246 if (gmMessage)
247 {
248 data << uint32(senderName.length() + 1);
249 data << senderName;
250 }
251
252 if (chatType == CHAT_MSG_CHANNEL)
253 {
254 ASSERT(channelName.length() > 0);
255 data << channelName;
256 }
257
258 receiverGUIDPos = data.wpos();
259 data << receiverGUID;
260 break;
261 }
262
263 data << uint32(message.length() + 1);
264 data << message;
265 data << uint8(chatTag);
266
267 if (chatType == CHAT_MSG_ACHIEVEMENT || chatType == CHAT_MSG_GUILD_ACHIEVEMENT)
268 data << uint32(achievementId);
269
270 return receiverGUIDPos;
271}
272
273size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string_view message,
274 uint32 achievementId /*= 0*/, std::string const& channelName /*= ""*/, LocaleConstant locale /*= DEFAULT_LOCALE*/)
275{
276 ObjectGuid senderGUID;
277 std::string senderName = "";
278 uint8 chatTag = 0;
279 bool gmMessage = false;
280 ObjectGuid receiverGUID;
281 std::string receiverName = "";
282 if (sender)
283 {
284 senderGUID = sender->GetGUID();
285 senderName = sender->GetNameForLocaleIdx(locale);
286 if (Player const* playerSender = sender->ToPlayer())
287 {
288 chatTag = playerSender->GetChatTag();
289 gmMessage = playerSender->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM_CHAT);
290 }
291 }
292
293 if (receiver)
294 {
295 receiverGUID = receiver->GetGUID();
296 receiverName = receiver->GetNameForLocaleIdx(locale);
297 }
298
299 return BuildChatPacket(data, chatType, language, senderGUID, receiverGUID, message, chatTag, senderName, receiverName, achievementId, gmMessage, channelName);
300}
301
303{
304 if (!m_session)
305 return nullptr;
306
307 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
308 if (!selected)
309 return m_session->GetPlayer();
310
312}
313
315{
316 if (!m_session)
317 return nullptr;
318
319 if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
320 return selected;
321
322 return m_session->GetPlayer();
323}
324
326{
327 if (!m_session)
328 return nullptr;
329
331
332 if (!guid)
333 return GetNearbyGameObject();
334
336}
337
345
347{
348 if (!m_session)
349 return nullptr;
350
351 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
352 if (!selected)
353 return m_session->GetPlayer();
354
355 // first try with selected target
356 Player* targetPlayer = ObjectAccessor::FindConnectedPlayer(selected);
357 // if the target is not a player, then return self
358 if (!targetPlayer)
359 targetPlayer = m_session->GetPlayer();
360
361 return targetPlayer;
362}
363
364char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
365{
366 // skip empty
367 if (!text)
368 return nullptr;
369
370 // skip spaces
371 while (*text == ' '||*text == '\t'||*text == '\b')
372 ++text;
373
374 if (!*text)
375 return nullptr;
376
377 // return non link case
378 if (text[0] != '|')
379 return strtok(text, " ");
380
381 // [name] Shift-click form |color|linkType:key|h[name]|h|r
382 // or
383 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
384
385 char* check = strtok(text, "|"); // skip color
386 if (!check)
387 return nullptr; // end of data
388
389 char* cLinkType = strtok(nullptr, ":"); // linktype
390 if (!cLinkType)
391 return nullptr; // end of data
392
393 if (strcmp(cLinkType, linkType) != 0)
394 {
395 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
397 return nullptr;
398 }
399
400 char* cKeys = strtok(nullptr, "|"); // extract keys and values
401 char* cKeysTail = strtok(nullptr, "");
402
403 char* cKey = strtok(cKeys, ":|"); // extract key
404 if (something1)
405 *something1 = strtok(nullptr, ":|"); // extract something
406
407 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
408 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
409 return cKey;
410}
411
412char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1)
413{
414 // skip empty
415 if (!text)
416 return nullptr;
417
418 // skip spaces
419 while (*text == ' '||*text == '\t'||*text == '\b')
420 ++text;
421
422 if (!*text)
423 return nullptr;
424
425 // return non link case
426 if (text[0] != '|')
427 return strtok(text, " ");
428
429 // [name] Shift-click form |color|linkType:key|h[name]|h|r
430 // or
431 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
432 // or
433 // [name] Shift-click form |linkType:key|h[name]|h|r
434
435 char* tail;
436
437 if (text[1] == 'c')
438 {
439 char* check = strtok(text, "|"); // skip color
440 if (!check)
441 return nullptr; // end of data
442
443 tail = strtok(nullptr, ""); // tail
444 }
445 else
446 tail = text+1; // skip first |
447
448 char* cLinkType = strtok(tail, ":"); // linktype
449 if (!cLinkType)
450 return nullptr; // end of data
451
452 for (int i = 0; linkTypes[i]; ++i)
453 {
454 if (strcmp(cLinkType, linkTypes[i]) == 0)
455 {
456 char* cKeys = strtok(nullptr, "|"); // extract keys and values
457 char* cKeysTail = strtok(nullptr, "");
458
459 char* cKey = strtok(cKeys, ":|"); // extract key
460 if (something1)
461 *something1 = strtok(nullptr, ":|"); // extract something
462
463 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
464 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
465 if (found_idx)
466 *found_idx = i;
467 return cKey;
468 }
469 }
470
471 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
473 return nullptr;
474}
475
477{
478 if (!m_session)
479 return nullptr;
480
481 Player* pl = m_session->GetPlayer();
482 GameObject* obj = nullptr;
486 return obj;
487}
488
490{
491 if (!m_session)
492 return nullptr;
493 auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
494 if (bounds.first != bounds.second)
495 return bounds.first->second;
496 return nullptr;
497}
498
500{
501 if (!m_session)
502 return nullptr;
503 // Select the first alive creature or a dead one if not found
504 Creature* creature = nullptr;
505 auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
506 for (auto it = bounds.first; it != bounds.second; ++it)
507 {
508 creature = it->second;
509 if (it->second->IsAlive())
510 break;
511 }
512 return creature;
513}
514
516{
517 GUID_LINK_PLAYER = 0, // must be first for selection in not link case
521
522static char const* const guidKeys[] =
523{
524 "Hplayer",
525 "Hcreature",
526 "Hgameobject",
527 nullptr
528};
529
531{
532 int type = 0;
533
534 // |color|Hcreature:creature_guid|h[name]|h|r
535 // |color|Hgameobject:go_guid|h[name]|h|r
536 // |color|Hplayer:name|h[name]|h|r
537 char* idS = extractKeyFromLink(text, guidKeys, &type);
538 if (!idS)
539 return 0;
540
541 switch (type)
542 {
543 case GUID_LINK_PLAYER:
544 {
545 guidHigh = HighGuid::Player;
546 std::string name = idS;
547 if (!normalizePlayerName(name))
548 return 0;
549
550 if (Player* player = ObjectAccessor::FindPlayerByName(name))
551 return player->GetGUID().GetCounter();
552
553 ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
554 return guid.GetCounter();
555
556 }
558 {
559 guidHigh = HighGuid::Unit;
560 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
561 return lowguid;
562 }
564 {
565 guidHigh = HighGuid::GameObject;
566 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
567 return lowguid;
568 }
569 }
570
571 // unknown type?
572 return 0;
573}
574
576{
577 // |color|Hplayer:name|h[name]|h|r
578 char* name_str = extractKeyFromLink(text, "Hplayer");
579 if (!name_str)
580 return "";
581
582 std::string name = name_str;
583 if (!normalizePlayerName(name))
584 return "";
585
586 return name;
587}
588
589bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/)
590{
591 if (args && *args)
592 {
593 std::string name = extractPlayerNameFromLink(args);
594 if (name.empty())
595 {
598 return false;
599 }
600
602
603 // if allowed player pointer
604 if (player)
605 *player = pl;
606
607 // if need guid value from DB (in name case for check player existence)
608 ObjectGuid guid = !pl && (player_guid || player_name) ? sCharacterCache->GetCharacterGuidByName(name) : ObjectGuid::Empty;
609
610 // if allowed player guid (if no then only online players allowed)
611 if (player_guid)
612 *player_guid = pl ? pl->GetGUID() : guid;
613
614 if (player_name)
615 *player_name = pl || !guid.IsEmpty() ? name : "";
616 }
617 else
618 {
619 // populate strtok buffer to prevent crashes
620 static char dummy[1] = "";
621 strtok(dummy, "");
622
624 // if allowed player pointer
625 if (player)
626 *player = pl;
627 // if allowed player guid (if no then only online players allowed)
628 if (player_guid)
629 *player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty;
630
631 if (player_name)
632 *player_name = pl ? pl->GetName() : "";
633 }
634
635 // some from req. data must be provided (note: name is empty if player does not exist)
636 if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
637 {
640 return false;
641 }
642
643 return true;
644}
645
647{
648 if (!args || !*args)
649 return nullptr;
650
651 if (*args == '"')
652 return strtok(args+1, "\"");
653 else
654 {
655 // skip spaces
656 while (*args == ' ')
657 {
658 args += 1;
659 continue;
660 }
661
662 // return nullptr if we reached the end of the string
663 if (!*args)
664 return nullptr;
665
666 // since we skipped all spaces, we expect another token now
667 if (*args == '"')
668 {
669 // return an empty string if there are 2 "" in a row.
670 // strtok doesn't handle this case
671 if (*(args + 1) == '"')
672 {
673 strtok(args, " ");
674 static char arg[1];
675 arg[0] = '\0';
676 return arg;
677 }
678 else
679 return strtok(args + 1, "\"");
680 }
681 else
682 return nullptr;
683 }
684}
685
687{
688 Player* pl = m_session->GetPlayer();
689 return pl != chr && pl->IsVisibleGloballyFor(chr);
690}
691
696
701
702std::string ChatHandler::GetNameLink(Player const* chr) const
703{
704 return playerLink(chr->GetName());
705}
706
707char const* CliHandler::GetTrinityString(uint32 entry) const
708{
709 return sObjectMgr->GetTrinityStringForDBCLocale(entry);
710}
711
712void CliHandler::SendSysMessage(std::string_view str, bool /*escapeCharacters*/)
713{
715 m_print(m_callbackArg, "\r\n");
716}
717
718bool CliHandler::ParseCommands(std::string_view str)
719{
720 if (str.empty())
721 return false;
722 // Console allows using commands both with and without leading indicator
723 if (str[0] == '.' || str[0] == '!')
724 str = str.substr(1);
725 return _ParseCommands(str);
726}
727
728std::string CliHandler::GetNameLink() const
729{
731}
732
734{
735 return true;
736}
737
738bool ChatHandler::GetPlayerGroupAndGUIDByName(char const* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
739{
740 player = nullptr;
741 guid.Clear();
742
743 if (cname)
744 {
745 std::string name = cname;
746 if (!name.empty())
747 {
748 if (!normalizePlayerName(name))
749 {
752 return false;
753 }
754
756 if (offline)
757 guid = sCharacterCache->GetCharacterGuidByName(name);
758 }
759 }
760
761 if (player)
762 {
763 group = player->GetGroup();
764 if (!guid || !offline)
765 guid = player->GetGUID();
766 }
767 else
768 {
769 if (getSelectedPlayer())
770 player = getSelectedPlayer();
771 else
772 player = m_session->GetPlayer();
773
774 if (!guid || !offline)
775 guid = player->GetGUID();
776 group = player->GetGroup();
777 }
778
779 return true;
780}
781
783{
784 return sWorld->GetDefaultDbcLocale();
785}
786
788{
789 return sObjectMgr->GetDBCLocaleIndex();
790}
791
793{
794 if (str.length() < 17)
795 return false;
796 if (!StringStartsWith(str, "TrinityCore\t"))
797 return false;
798 char opcode = str[12];
799 echo = &str[13];
800
801 switch (opcode)
802 {
803 case 'p': // p Ping
804 SendAck();
805 return true;
806 case 'h': // h Issue human-readable command
807 case 'i': // i Issue command
808 {
809 if (!str[17])
810 return false;
811 humanReadable = (opcode == 'h');
812 std::string_view cmd = str.substr(17);
813 if (_ParseCommands(cmd)) // actual command starts at str[17]
814 {
815 if (!hadAck)
816 SendAck();
818 SendFailed();
819 else
820 SendOK();
821 }
822 else
823 {
825 SendFailed();
826 }
827 return true;
828 }
829 default:
830 return false;
831 }
832}
833
840
841void AddonChannelCommandHandler::SendAck() // a Command acknowledged, no body
842{
843 ASSERT(echo);
844 char ack[18] = "TrinityCore\ta";
845 memcpy(ack+13, echo, 4);
846 ack[17] = '\0';
847 Send(ack);
848 hadAck = true;
849}
850
851void AddonChannelCommandHandler::SendOK() // o Command OK, no body
852{
853 ASSERT(echo);
854 char ok[18] = "TrinityCore\to";
855 memcpy(ok+13, echo, 4);
856 ok[17] = '\0';
857 Send(ok);
858}
859
860void AddonChannelCommandHandler::SendFailed() // f Command failed, no body
861{
862 ASSERT(echo);
863 char fail[18] = "TrinityCore\tf";
864 memcpy(fail + 13, echo, 4);
865 fail[17] = '\0';
866 Send(fail);
867}
868
869// m Command message, message in body
870void AddonChannelCommandHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
871{
872 ASSERT(echo);
873 if (!hadAck)
874 SendAck();
875
876 std::string msg = "TrinityCore\tm";
877 msg.append(echo, 4);
878 std::string body(str);
879 if (escapeCharacters)
880 boost::replace_all(body, "|", "||");
881 size_t pos, lastpos;
882 for (lastpos = 0, pos = body.find('\n', lastpos); pos != std::string::npos; lastpos = pos + 1, pos = body.find('\n', lastpos))
883 {
884 std::string line(msg);
885 line.append(body, lastpos, pos - lastpos);
886 Send(line);
887 }
888 msg.append(body, lastpos, pos - lastpos);
889 Send(msg);
890}
#define sCharacterCache
GuidLinkType
Definition Chat.cpp:516
@ GUID_LINK_CREATURE
Definition Chat.cpp:518
@ GUID_LINK_GAMEOBJECT
Definition Chat.cpp:519
@ GUID_LINK_PLAYER
Definition Chat.cpp:517
static char const *const guidKeys[]
Definition Chat.cpp:522
LocaleConstant
Definition Common.h:48
AccountTypes
Definition Common.h:39
uint8_t uint8
Definition Define.h:135
#define STRING_VIEW_FMT_ARG(str)
Definition Define.h:126
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define ASSERT
Definition Errors.h:68
#define SIZE_OF_GRIDS
Definition GridDefines.h:38
@ LANG_CONSOLE_COMMAND
Definition Language.h:214
@ LANG_CMD_INVALID
Definition Language.h:38
@ LANG_YOURS_SECURITY_IS_LOW
Definition Language.h:460
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:570
@ LANG_WRONG_LINK_TYPE
Definition Language.h:585
HighGuid
Definition ObjectGuid.h:63
bool normalizePlayerName(std::string &name)
#define sObjectMgr
Definition ObjectMgr.h:1721
Language
@ LANG_UNIVERSAL
@ LANG_ADDON
ChatMsg
@ CHAT_MSG_MONSTER_WHISPER
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_WHISPER_FOREIGN
@ CHAT_MSG_GUILD_ACHIEVEMENT
@ CHAT_MSG_BG_SYSTEM_ALLIANCE
@ CHAT_MSG_WHISPER
@ CHAT_MSG_MONSTER_PARTY
@ CHAT_MSG_SYSTEM
@ CHAT_MSG_ACHIEVEMENT
@ CHAT_MSG_RAID_BOSS_EMOTE
@ CHAT_MSG_BATTLENET
@ CHAT_MSG_MONSTER_EMOTE
@ CHAT_MSG_MONSTER_SAY
@ CHAT_MSG_MONSTER_YELL
@ CHAT_MSG_BG_SYSTEM_HORDE
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
@ CHAT_MSG_CHANNEL
bool StringStartsWith(std::string_view haystack, std::string_view needle)
Definition Util.h:363
static uint32 GetSecurity(uint32 accountId, int32 realmId)
char const * echo
Definition Chat.h:181
void Send(std::string const &msg)
Definition Chat.cpp:834
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition Chat.cpp:870
bool ParseCommands(std::string_view str) override
Definition Chat.cpp:792
size_t wpos() const
Definition ByteBuffer.h:321
char * extractKeyFromLink(char *text, char const *linkType, char **something1=nullptr)
Definition Chat.cpp:364
Player * getSelectedPlayerOrSelf()
Definition Chat.cpp:346
bool GetPlayerGroupAndGUIDByName(char const *cname, Player *&player, Group *&group, ObjectGuid &guid, bool offline=false)
Definition Chat.cpp:738
virtual bool HasPermission(uint32 permission) const
Definition Chat.cpp:41
std::string playerLink(std::string const &name) const
Definition Chat.h:127
char * extractQuotedArg(char *args)
Definition Chat.cpp:646
Unit * getSelectedUnit()
Definition Chat.cpp:314
void SendGlobalGMSysMessage(const char *str)
Definition Chat.cpp:135
Player * getSelectedPlayer()
Definition Chat.cpp:302
WorldSession * GetSession()
Definition Chat.h:46
void SendGlobalSysMessage(const char *str)
Definition Chat.cpp:125
bool HasSentErrorMessage() const
Definition Chat.h:133
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:692
virtual std::string GetNameLink() const
Definition Chat.cpp:46
WorldSession * m_session
Definition Chat.h:139
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:499
static std::string StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs)
Definition Chat.cpp:150
virtual int GetSessionDbLocaleIndex() const
Definition Chat.cpp:697
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition Chat.cpp:51
Creature * getSelectedCreature()
Definition Chat.cpp:338
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:489
void SetSentErrorMessage(bool val)
Definition Chat.h:134
Player * GetPlayer() const
Definition Chat.cpp:34
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:69
WorldObject * getSelectedObject()
Definition Chat.cpp:325
virtual bool ParseCommands(std::string_view text)
Definition Chat.cpp:170
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:101
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:686
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=nullptr, std::string *player_name=nullptr)
Definition Chat.cpp:589
std::string extractPlayerNameFromLink(char *text)
Definition Chat.cpp:575
bool _ParseCommands(std::string_view text)
Definition Chat.cpp:155
GameObject * GetNearbyGameObject()
Definition Chat.cpp:476
ObjectGuid::LowType extractLowGuidFromLink(char *text, HighGuid &guidHigh)
Definition Chat.cpp:530
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition Chat.cpp:71
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
virtual char const * GetTrinityString(uint32 entry) const
Definition Chat.cpp:36
int GetSessionDbLocaleIndex() const override
Definition Chat.cpp:787
LocaleConstant GetSessionDbcLocale() const override
Definition Chat.cpp:782
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition Chat.cpp:712
void * m_callbackArg
Definition Chat.h:162
Print * m_print
Definition Chat.h:163
bool ParseCommands(std::string_view str) override
Definition Chat.cpp:718
char const * GetTrinityString(uint32 entry) const override
Definition Chat.cpp:707
bool needReportToTarget(Player *chr) const override
Definition Chat.cpp:733
std::string GetNameLink() const override
Definition Chat.cpp:728
Definition Group.h:165
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:496
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:492
LowType GetCounter() const
Definition ObjectGuid.h:156
static ObjectGuid const Empty
Definition ObjectGuid.h:140
bool IsEmpty() const
Definition ObjectGuid.h:172
uint32 LowType
Definition ObjectGuid.h:142
void Clear()
Definition ObjectGuid.h:150
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
static Player * ToPlayer(Object *o)
Definition Object.h:180
WorldSession * GetSession() const
Definition Player.h:1719
Group * GetGroup()
Definition Player.h:2171
bool IsVisibleGloballyFor(Player const *player) const
Definition Player.cpp:22113
Unit * GetSelectedUnit() const
Definition Player.cpp:22377
Definition Unit.h:769
ObjectGuid GetTarget() const
Definition Unit.h:1797
Map * GetMap() const
Definition Object.h:449
std::string const & GetName() const
Definition Object.h:382
virtual std::string const & GetNameForLocaleIdx(LocaleConstant) const
Definition Object.h:385
void Initialize(uint16 opcode, size_t newres=200)
Definition WorldPacket.h:73
Player session in the World.
char const * GetTrinityString(uint32 entry) const
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
AccountTypes GetSecurity() const
LocaleConstant GetSessionDbLocaleIndex() const
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
bool HasPermission(uint32 permissionId)
@ SMSG_GM_MESSAGECHAT
Definition Opcodes.h:976
@ SMSG_MESSAGECHAT
Definition Opcodes.h:179
#define sWorld
Definition World.h:900
Realm realm
Definition World.cpp:3605
@ CONFIG_GM_LOWER_SECURITY
Definition World.h:108
TC_GAME_API Player * FindPlayerByName(std::string_view name)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
TC_GAME_API bool TryExecuteCommand(ChatHandler &handler, std::string_view cmd)
static constexpr char COMMAND_DELIMITER
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Util.cpp:56
@ RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR
Definition RBAC.h:86
@ RBAC_PERM_CAN_IGNORE_LOWER_SECURITY_CHECK
Definition RBAC.h:100
@ RBAC_PERM_COMMAND_GM_CHAT
Definition RBAC.h:246
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:168
uint32 Realm
Definition Realm.h:44
RealmHandle Id
Definition Realm.h:67