TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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)
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
146{
148}
149
150bool ChatHandler::_ParseCommands(std::string_view text)
151{
153 return true;
154
155 // Pretend commands don't exist for regular players
157 return false;
158
159 // Send error message for GMs
162 return true;
163}
164
165bool ChatHandler::ParseCommands(std::string_view text)
166{
167 ASSERT(!text.empty());
168
169 // chat case (.command or !command format)
170 if ((text[0] != '!') && (text[0] != '.'))
171 return false;
172
173 // ignore single . and ! in line
174 if (text.length() < 2)
175 return false;
176
177 // ignore messages staring from many dots.
178 if (text[1] == text[0])
179 return false;
180
181 // ignore messages with separator after .
183 return false;
184
185 return _ParseCommands(text.substr(1));
186}
187
188size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag,
189 std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/,
190 uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/)
191{
192 size_t receiverGUIDPos = 0;
194 data << uint8(chatType);
195 data << int32(language);
196 data << uint64(senderGUID);
197 data << uint32(0); // some flags
198 switch (chatType)
199 {
208 data << uint32(senderName.length() + 1);
209 data << senderName;
210 receiverGUIDPos = data.wpos();
211 data << uint64(receiverGUID);
212 if (receiverGUID && !receiverGUID.IsPlayer() && !receiverGUID.IsPet())
213 {
214 data << uint32(receiverName.length() + 1);
215 data << receiverName;
216 }
217 break;
219 data << uint32(senderName.length() + 1);
220 data << senderName;
221 receiverGUIDPos = data.wpos();
222 data << uint64(receiverGUID);
223 break;
227 receiverGUIDPos = data.wpos();
228 data << uint64(receiverGUID);
229 if (receiverGUID && !receiverGUID.IsPlayer())
230 {
231 data << uint32(receiverName.length() + 1);
232 data << receiverName;
233 }
234 break;
237 receiverGUIDPos = data.wpos();
238 data << uint64(receiverGUID);
239 break;
240 default:
241 if (gmMessage)
242 {
243 data << uint32(senderName.length() + 1);
244 data << senderName;
245 }
246
247 if (chatType == CHAT_MSG_CHANNEL)
248 {
249 ASSERT(channelName.length() > 0);
250 data << channelName;
251 }
252
253 receiverGUIDPos = data.wpos();
254 data << uint64(receiverGUID);
255 break;
256 }
257
258 data << uint32(message.length() + 1);
259 data << message;
260 data << uint8(chatTag);
261
262 if (chatType == CHAT_MSG_ACHIEVEMENT || chatType == CHAT_MSG_GUILD_ACHIEVEMENT)
263 data << uint32(achievementId);
264
265 return receiverGUIDPos;
266}
267
268size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string_view message,
269 uint32 achievementId /*= 0*/, std::string const& channelName /*= ""*/, LocaleConstant locale /*= DEFAULT_LOCALE*/)
270{
271 ObjectGuid senderGUID;
272 std::string senderName = "";
273 uint8 chatTag = 0;
274 bool gmMessage = false;
275 ObjectGuid receiverGUID;
276 std::string receiverName = "";
277 if (sender)
278 {
279 senderGUID = sender->GetGUID();
280 senderName = sender->GetNameForLocaleIdx(locale);
281 if (Player const* playerSender = sender->ToPlayer())
282 {
283 chatTag = playerSender->GetChatTag();
284 gmMessage = playerSender->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM_CHAT);
285 }
286 }
287
288 if (receiver)
289 {
290 receiverGUID = receiver->GetGUID();
291 receiverName = receiver->GetNameForLocaleIdx(locale);
292 }
293
294 return BuildChatPacket(data, chatType, language, senderGUID, receiverGUID, message, chatTag, senderName, receiverName, achievementId, gmMessage, channelName);
295}
296
298{
299 if (!m_session)
300 return nullptr;
301
302 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
303 if (!selected)
304 return m_session->GetPlayer();
305
307}
308
310{
311 if (!m_session)
312 return nullptr;
313
314 if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
315 return selected;
316
317 return m_session->GetPlayer();
318}
319
321{
322 if (!m_session)
323 return nullptr;
324
326
327 if (!guid)
328 return GetNearbyGameObject();
329
331}
332
334{
335 if (!m_session)
336 return nullptr;
337
339}
340
342{
343 if (!m_session)
344 return nullptr;
345
346 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
347 if (!selected)
348 return m_session->GetPlayer();
349
350 // first try with selected target
351 Player* targetPlayer = ObjectAccessor::FindConnectedPlayer(selected);
352 // if the target is not a player, then return self
353 if (!targetPlayer)
354 targetPlayer = m_session->GetPlayer();
355
356 return targetPlayer;
357}
358
359char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
360{
361 // skip empty
362 if (!text)
363 return nullptr;
364
365 // skip spaces
366 while (*text == ' '||*text == '\t'||*text == '\b')
367 ++text;
368
369 if (!*text)
370 return nullptr;
371
372 // return non link case
373 if (text[0] != '|')
374 return strtok(text, " ");
375
376 // [name] Shift-click form |color|linkType:key|h[name]|h|r
377 // or
378 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
379
380 char* check = strtok(text, "|"); // skip color
381 if (!check)
382 return nullptr; // end of data
383
384 char* cLinkType = strtok(nullptr, ":"); // linktype
385 if (!cLinkType)
386 return nullptr; // end of data
387
388 if (strcmp(cLinkType, linkType) != 0)
389 {
390 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
392 return nullptr;
393 }
394
395 char* cKeys = strtok(nullptr, "|"); // extract keys and values
396 char* cKeysTail = strtok(nullptr, "");
397
398 char* cKey = strtok(cKeys, ":|"); // extract key
399 if (something1)
400 *something1 = strtok(nullptr, ":|"); // extract something
401
402 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
403 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
404 return cKey;
405}
406
407char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1)
408{
409 // skip empty
410 if (!text)
411 return nullptr;
412
413 // skip spaces
414 while (*text == ' '||*text == '\t'||*text == '\b')
415 ++text;
416
417 if (!*text)
418 return nullptr;
419
420 // return non link case
421 if (text[0] != '|')
422 return strtok(text, " ");
423
424 // [name] Shift-click form |color|linkType:key|h[name]|h|r
425 // or
426 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
427 // or
428 // [name] Shift-click form |linkType:key|h[name]|h|r
429
430 char* tail;
431
432 if (text[1] == 'c')
433 {
434 char* check = strtok(text, "|"); // skip color
435 if (!check)
436 return nullptr; // end of data
437
438 tail = strtok(nullptr, ""); // tail
439 }
440 else
441 tail = text+1; // skip first |
442
443 char* cLinkType = strtok(tail, ":"); // linktype
444 if (!cLinkType)
445 return nullptr; // end of data
446
447 for (int i = 0; linkTypes[i]; ++i)
448 {
449 if (strcmp(cLinkType, linkTypes[i]) == 0)
450 {
451 char* cKeys = strtok(nullptr, "|"); // extract keys and values
452 char* cKeysTail = strtok(nullptr, "");
453
454 char* cKey = strtok(cKeys, ":|"); // extract key
455 if (something1)
456 *something1 = strtok(nullptr, ":|"); // extract something
457
458 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
459 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
460 if (found_idx)
461 *found_idx = i;
462 return cKey;
463 }
464 }
465
466 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
468 return nullptr;
469}
470
472{
473 if (!m_session)
474 return nullptr;
475
476 Player* pl = m_session->GetPlayer();
477 GameObject* obj = nullptr;
481 return obj;
482}
483
485{
486 if (!m_session)
487 return nullptr;
488 auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
489 if (bounds.first != bounds.second)
490 return bounds.first->second;
491 return nullptr;
492}
493
495{
496 if (!m_session)
497 return nullptr;
498 // Select the first alive creature or a dead one if not found
499 Creature* creature = nullptr;
500 auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
501 for (auto it = bounds.first; it != bounds.second; ++it)
502 {
503 creature = it->second;
504 if (it->second->IsAlive())
505 break;
506 }
507 return creature;
508}
509
511{
512 GUID_LINK_PLAYER = 0, // must be first for selection in not link case
516
517static char const* const guidKeys[] =
518{
519 "Hplayer",
520 "Hcreature",
521 "Hgameobject",
522 nullptr
523};
524
526{
527 int type = 0;
528
529 // |color|Hcreature:creature_guid|h[name]|h|r
530 // |color|Hgameobject:go_guid|h[name]|h|r
531 // |color|Hplayer:name|h[name]|h|r
532 char* idS = extractKeyFromLink(text, guidKeys, &type);
533 if (!idS)
534 return 0;
535
536 switch (type)
537 {
538 case GUID_LINK_PLAYER:
539 {
540 guidHigh = HighGuid::Player;
541 std::string name = idS;
542 if (!normalizePlayerName(name))
543 return 0;
544
545 if (Player* player = ObjectAccessor::FindPlayerByName(name))
546 return player->GetGUID().GetCounter();
547
548 ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
549 return guid.GetCounter();
550
551 }
553 {
554 guidHigh = HighGuid::Unit;
555 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
556 return lowguid;
557 }
559 {
560 guidHigh = HighGuid::GameObject;
561 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
562 return lowguid;
563 }
564 }
565
566 // unknown type?
567 return 0;
568}
569
571{
572 // |color|Hplayer:name|h[name]|h|r
573 char* name_str = extractKeyFromLink(text, "Hplayer");
574 if (!name_str)
575 return "";
576
577 std::string name = name_str;
578 if (!normalizePlayerName(name))
579 return "";
580
581 return name;
582}
583
584bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/)
585{
586 if (args && *args)
587 {
588 std::string name = extractPlayerNameFromLink(args);
589 if (name.empty())
590 {
593 return false;
594 }
595
597
598 // if allowed player pointer
599 if (player)
600 *player = pl;
601
602 // if need guid value from DB (in name case for check player existence)
603 ObjectGuid guid = !pl && (player_guid || player_name) ? sCharacterCache->GetCharacterGuidByName(name) : ObjectGuid::Empty;
604
605 // if allowed player guid (if no then only online players allowed)
606 if (player_guid)
607 *player_guid = pl ? pl->GetGUID() : guid;
608
609 if (player_name)
610 *player_name = pl || guid ? name : "";
611 }
612 else
613 {
614 // populate strtok buffer to prevent crashes
615 static char dummy[1] = "";
616 strtok(dummy, "");
617
619 // if allowed player pointer
620 if (player)
621 *player = pl;
622 // if allowed player guid (if no then only online players allowed)
623 if (player_guid)
624 *player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty;
625
626 if (player_name)
627 *player_name = pl ? pl->GetName() : "";
628 }
629
630 // some from req. data must be provided (note: name is empty if player does not exist)
631 if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
632 {
635 return false;
636 }
637
638 return true;
639}
640
642{
643 if (!args || !*args)
644 return nullptr;
645
646 if (*args == '"')
647 return strtok(args+1, "\"");
648 else
649 {
650 // skip spaces
651 while (*args == ' ')
652 {
653 args += 1;
654 continue;
655 }
656
657 // return nullptr if we reached the end of the string
658 if (!*args)
659 return nullptr;
660
661 // since we skipped all spaces, we expect another token now
662 if (*args == '"')
663 {
664 // return an empty string if there are 2 "" in a row.
665 // strtok doesn't handle this case
666 if (*(args + 1) == '"')
667 {
668 strtok(args, " ");
669 static char arg[1];
670 arg[0] = '\0';
671 return arg;
672 }
673 else
674 return strtok(args + 1, "\"");
675 }
676 else
677 return nullptr;
678 }
679}
680
682{
683 Player* pl = m_session->GetPlayer();
684 return pl != chr && pl->IsVisibleGloballyFor(chr);
685}
686
688{
690}
691
693{
695}
696
697std::string ChatHandler::GetNameLink(Player* chr) const
698{
699 return playerLink(chr->GetName());
700}
701
702char const* CliHandler::GetTrinityString(uint32 entry) const
703{
704 return sObjectMgr->GetTrinityStringForDBCLocale(entry);
705}
706
707void CliHandler::SendSysMessage(std::string_view str, bool /*escapeCharacters*/)
708{
710 m_print(m_callbackArg, "\r\n");
711}
712
713bool CliHandler::ParseCommands(std::string_view str)
714{
715 if (str.empty())
716 return false;
717 // Console allows using commands both with and without leading indicator
718 if (str[0] == '.' || str[0] == '!')
719 str = str.substr(1);
720 return _ParseCommands(str);
721}
722
723std::string CliHandler::GetNameLink() const
724{
726}
727
729{
730 return true;
731}
732
733bool ChatHandler::GetPlayerGroupAndGUIDByName(char const* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
734{
735 player = nullptr;
736 guid.Clear();
737
738 if (cname)
739 {
740 std::string name = cname;
741 if (!name.empty())
742 {
743 if (!normalizePlayerName(name))
744 {
747 return false;
748 }
749
751 if (offline)
752 guid = sCharacterCache->GetCharacterGuidByName(name);
753 }
754 }
755
756 if (player)
757 {
758 group = player->GetGroup();
759 if (!guid || !offline)
760 guid = player->GetGUID();
761 }
762 else
763 {
764 if (getSelectedPlayer())
765 player = getSelectedPlayer();
766 else
767 player = m_session->GetPlayer();
768
769 if (!guid || !offline)
770 guid = player->GetGUID();
771 group = player->GetGroup();
772 }
773
774 return true;
775}
776
778{
779 return sWorld->GetDefaultDbcLocale();
780}
781
783{
784 return sObjectMgr->GetDBCLocaleIndex();
785}
786
788{
789 if (str.length() < 17)
790 return false;
791 if (!StringStartsWith(str, "TrinityCore\t"))
792 return false;
793 char opcode = str[12];
794 echo = &str[13];
795
796 switch (opcode)
797 {
798 case 'p': // p Ping
799 SendAck();
800 return true;
801 case 'h': // h Issue human-readable command
802 case 'i': // i Issue command
803 {
804 if (!str[17])
805 return false;
806 humanReadable = (opcode == 'h');
807 std::string_view cmd = str.substr(17);
808 if (_ParseCommands(cmd)) // actual command starts at str[17]
809 {
810 if (!hadAck)
811 SendAck();
813 SendFailed();
814 else
815 SendOK();
816 }
817 else
818 {
820 SendFailed();
821 }
822 return true;
823 }
824 default:
825 return false;
826 }
827}
828
829void AddonChannelCommandHandler::Send(std::string const& msg)
830{
831 WorldPacket data;
833 GetSession()->SendPacket(&data);
834}
835
836void AddonChannelCommandHandler::SendAck() // a Command acknowledged, no body
837{
838 ASSERT(echo);
839 char ack[18] = "TrinityCore\ta";
840 memcpy(ack+13, echo, 4);
841 ack[17] = '\0';
842 Send(ack);
843 hadAck = true;
844}
845
846void AddonChannelCommandHandler::SendOK() // o Command OK, no body
847{
848 ASSERT(echo);
849 char ok[18] = "TrinityCore\to";
850 memcpy(ok+13, echo, 4);
851 ok[17] = '\0';
852 Send(ok);
853}
854
855void AddonChannelCommandHandler::SendFailed() // f Command failed, no body
856{
857 ASSERT(echo);
858 char fail[18] = "TrinityCore\tf";
859 memcpy(fail + 13, echo, 4);
860 fail[17] = '\0';
861 Send(fail);
862}
863
864// m Command message, message in body
865void AddonChannelCommandHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
866{
867 ASSERT(echo);
868 if (!hadAck)
869 SendAck();
870
871 std::string msg = "TrinityCore\tm";
872 msg.append(echo, 4);
873 std::string body(str);
874 if (escapeCharacters)
875 boost::replace_all(body, "|", "||");
876 size_t pos, lastpos;
877 for (lastpos = 0, pos = body.find('\n', lastpos); pos != std::string::npos; lastpos = pos + 1, pos = body.find('\n', lastpos))
878 {
879 std::string line(msg);
880 line.append(body, lastpos, pos - lastpos);
881 Send(line);
882 }
883 msg.append(body, lastpos, pos - lastpos);
884 Send(msg);
885}
#define sCharacterCache
GuidLinkType
Definition: Chat.cpp:511
@ GUID_LINK_CREATURE
Definition: Chat.cpp:513
@ GUID_LINK_GAMEOBJECT
Definition: Chat.cpp:514
@ GUID_LINK_PLAYER
Definition: Chat.cpp:512
static char const *const guidKeys[]
Definition: Chat.cpp:517
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
uint64_t uint64
Definition: Define.h:132
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)
Definition: ObjectMgr.cpp:142
#define sObjectMgr
Definition: ObjectMgr.h:1723
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)
Definition: AccountMgr.cpp:289
char const * echo
Definition: Chat.h:173
void Send(std::string const &msg)
Definition: Chat.cpp:829
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition: Chat.cpp:865
bool ParseCommands(std::string_view str) override
Definition: Chat.cpp:787
size_t wpos() const
Definition: ByteBuffer.h:321
char * extractKeyFromLink(char *text, char const *linkType, char **something1=nullptr)
Definition: Chat.cpp:359
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:341
bool GetPlayerGroupAndGUIDByName(char const *cname, Player *&player, Group *&group, ObjectGuid &guid, bool offline=false)
Definition: Chat.cpp:733
virtual bool HasPermission(uint32 permission) const
Definition: Chat.cpp:41
std::string playerLink(std::string const &name) const
Definition: Chat.h:119
char * extractQuotedArg(char *args)
Definition: Chat.cpp:641
Unit * getSelectedUnit()
Definition: Chat.cpp:309
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:135
Player * getSelectedPlayer()
Definition: Chat.cpp:297
WorldSession * GetSession()
Definition: Chat.h:46
void SendGlobalSysMessage(const char *str)
Definition: Chat.cpp:125
bool HasSentErrorMessage() const
Definition: Chat.h:125
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:687
virtual std::string GetNameLink() const
Definition: Chat.cpp:46
WorldSession * m_session
Definition: Chat.h:131
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition: Chat.cpp:494
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:692
void PSendSysMessage(const char *fmt, Args &&... args)
Definition: Chat.h:69
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:51
Creature * getSelectedCreature()
Definition: Chat.cpp:333
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition: Chat.cpp:484
void SetSentErrorMessage(bool val)
Definition: Chat.h:126
Player * GetPlayer() const
Definition: Chat.cpp:34
WorldObject * getSelectedObject()
Definition: Chat.cpp:320
virtual bool ParseCommands(std::string_view text)
Definition: Chat.cpp:165
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:681
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=nullptr, std::string *player_name=nullptr)
Definition: Chat.cpp:584
std::string extractPlayerNameFromLink(char *text)
Definition: Chat.cpp:570
bool _ParseCommands(std::string_view text)
Definition: Chat.cpp:150
GameObject * GetNearbyGameObject()
Definition: Chat.cpp:471
ObjectGuid::LowType extractLowGuidFromLink(char *text, HighGuid &guidHigh)
Definition: Chat.cpp:525
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:188
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:36
int GetSessionDbLocaleIndex() const override
Definition: Chat.cpp:782
LocaleConstant GetSessionDbcLocale() const override
Definition: Chat.cpp:777
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition: Chat.cpp:707
void * m_callbackArg
Definition: Chat.h:154
Print * m_print
Definition: Chat.h:155
bool ParseCommands(std::string_view str) override
Definition: Chat.cpp:713
char const * GetTrinityString(uint32 entry) const override
Definition: Chat.cpp:702
bool needReportToTarget(Player *chr) const override
Definition: Chat.cpp:728
std::string GetNameLink() const override
Definition: Chat.cpp:723
Definition: Group.h:165
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:496
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:492
LowType GetCounter() const
Definition: ObjectGuid.h:158
static ObjectGuid const Empty
Definition: ObjectGuid.h:132
bool IsPlayer() const
Definition: ObjectGuid.h:181
uint32 LowType
Definition: ObjectGuid.h:134
bool IsPet() const
Definition: ObjectGuid.h:176
void Clear()
Definition: ObjectGuid.h:151
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:77
static Player * ToPlayer(Object *o)
Definition: Object.h:179
Definition: Player.h:915
WorldSession * GetSession() const
Definition: Player.h:1712
Group * GetGroup()
Definition: Player.h:2150
bool IsVisibleGloballyFor(Player const *player) const
Definition: Player.cpp:22267
Unit * GetSelectedUnit() const
Definition: Player.cpp:22531
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.
Definition: WorldSession.h:456
char const * GetTrinityString(uint32 entry) const
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
AccountTypes GetSecurity() const
Definition: WorldSession.h:497
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:644
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:643
Player * GetPlayer() const
Definition: WorldSession.h:500
bool HasPermission(uint32 permissionId)
@ SMSG_GM_MESSAGECHAT
Definition: Opcodes.h:976
@ SMSG_MESSAGECHAT
Definition: Opcodes.h:179
#define sWorld
Definition: World.h:893
Realm realm
Definition: World.cpp:3589
@ 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