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 "ChatCommand.h"
23#include "ChatPackets.h"
24#include "Common.h"
25#include "GridNotifiersImpl.h"
26#include "Group.h"
27#include "Language.h"
28#include "ObjectAccessor.h"
29#include "ObjectMgr.h"
30#include "Optional.h"
31#include "Player.h"
32#include "RealmList.h"
33#include "StringConvert.h"
34#include "World.h"
35#include "WorldSession.h"
36
37Player* ChatHandler::GetPlayer() const { return m_session ? m_session->GetPlayer() : nullptr; }
38
40{
41 char* start = strtok(pos, "\n");
42 pos = nullptr;
43 return start;
44}
45
46char const* ChatHandler::GetTrinityString(uint32 entry) const
47{
48 return m_session->GetTrinityString(entry);
49}
50
51bool ChatHandler::HasPermission(uint32 permission) const
52{
53 return m_session->HasPermission(permission);
54}
55
56std::string ChatHandler::GetNameLink() const
57{
60
61bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
62{
63 WorldSession* target_session = nullptr;
64 uint32 target_account = 0;
65
66 if (target)
67 target_session = target->GetSession();
68 else if (!guid.IsEmpty())
69 target_account = sCharacterCache->GetCharacterAccountIdByGuid(guid);
70
71 if (!target_session && !target_account)
72 {
75 return true;
76 }
77
78 return HasLowerSecurityAccount(target_session, target_account, strong);
79}
80
81bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_account, bool strong)
82{
83 uint32 target_sec;
84
85 // allow everything from console and RA console
86 if (!m_session)
87 return false;
88
89 // ignore only for non-players for non strong checks (when allow apply command at least to same sec level)
91 return false;
92
93 if (target)
94 target_sec = target->GetSecurity();
95 else if (target_account)
96 target_sec = AccountMgr::GetSecurity(target_account, sRealmList->GetCurrentRealmId().Realm);
97 else
98 return true; // caller must report error for (target == nullptr && target_account == 0)
99
100 AccountTypes target_ac_sec = AccountTypes(target_sec);
101 if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
102 {
105 return true;
106 }
107
108 return false;
109}
110
111void ChatHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
112{
113 std::string msg(str);
114
115 // Replace every "|" with "||" in msg
116 if (escapeCharacters)
117 StringReplaceAll(&msg, "|"sv, "||"sv);
118
120 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
121 {
122 packet.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
123 m_session->SendPacket(packet.Write());
124 }
125}
126
128{
130 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
131 {
132 packet.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
133 sWorld->SendGlobalMessage(packet.Write());
134 }
135}
136
138{
140 for (std::string_view line : Trinity::Tokenize(str, '\n', true))
141 {
142 packet.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
143 sWorld->SendGlobalGMMessage(packet.Write());
144 }
145}
146
151
152void ChatHandler::SendSysMessage(std::string_view messageFormat, fmt::printf_args messageFormatArgs) noexcept
153{
154 SendSysMessage(StringVPrintf(messageFormat, messageFormatArgs));
155}
156
157std::string ChatHandler::StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs) noexcept try
158{
159 return fmt::vsprintf<char>(messageFormat, messageFormatArgs);
160}
161catch (std::exception const& formatError)
162{
163 return fmt::format(R"(An error occurred formatting string "{}" : {})", messageFormat, formatError.what());
164}
165
166bool ChatHandler::_ParseCommands(std::string_view text)
167{
169 return true;
170
171 // Pretend commands don't exist for regular players
173 return false;
174
175 // Send error message for GMs
178 return true;
179}
180
181bool ChatHandler::ParseCommands(std::string_view text)
182{
183 ASSERT(!text.empty());
184
185 // chat case (.command or !command format)
186 if ((text[0] != '!') && (text[0] != '.'))
187 return false;
188
189 // ignore single . and ! in line
190 if (text.length() < 2)
191 return false;
192
193 // ignore messages staring from many dots.
194 if (text[1] == text[0])
195 return false;
196
197 // ignore messages with separator after .
199 return false;
200
201 return _ParseCommands(text.substr(1));
202}
203
205{
206 if (!m_session)
207 return nullptr;
208
209 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
210 if (!selected)
211 return m_session->GetPlayer();
212
214}
215
217{
218 if (!m_session)
219 return nullptr;
220
221 if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
222 return selected;
223
224 return m_session->GetPlayer();
225}
226
228{
229 if (!m_session)
230 return nullptr;
231
233
234 if (!guid)
235 return GetNearbyGameObject();
236
238}
239
247
249{
250 if (!m_session)
251 return nullptr;
252
253 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
254 if (!selected)
255 return m_session->GetPlayer();
256
257 // first try with selected target
258 Player* targetPlayer = ObjectAccessor::FindConnectedPlayer(selected);
259 // if the target is not a player, then return self
260 if (!targetPlayer)
261 targetPlayer = m_session->GetPlayer();
262
263 return targetPlayer;
264}
265
266char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
267{
268 // skip empty
269 if (!text)
270 return nullptr;
271
272 // skip spaces
273 while (*text == ' '||*text == '\t'||*text == '\b')
274 ++text;
275
276 if (!*text)
277 return nullptr;
278
279 // return non link case
280 if (text[0] != '|')
281 return strtok(text, " ");
282
283 // [name] Shift-click form |color|linkType:key|h[name]|h|r
284 // or
285 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
286
287 char* check = strtok(text, "|"); // skip color
288 if (!check)
289 return nullptr; // end of data
290
291 char* cLinkType = strtok(nullptr, ":"); // linktype
292 if (!cLinkType)
293 return nullptr; // end of data
294
295 if (strcmp(cLinkType, linkType) != 0)
296 {
297 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
299 return nullptr;
300 }
301
302 char* cKeys = strtok(nullptr, "|"); // extract keys and values
303 char* cKeysTail = strtok(nullptr, "");
304
305 char* cKey = strtok(cKeys, ":|"); // extract key
306 if (something1)
307 *something1 = strtok(nullptr, ":|"); // extract something
308
309 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
310 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
311 return cKey;
312}
313
314char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1)
315{
316 // skip empty
317 if (!text)
318 return nullptr;
319
320 // skip spaces
321 while (*text == ' '||*text == '\t'||*text == '\b')
322 ++text;
323
324 if (!*text)
325 return nullptr;
326
327 // return non link case
328 if (text[0] != '|')
329 return strtok(text, " ");
330
331 // [name] Shift-click form |color|linkType:key|h[name]|h|r
332 // or
333 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
334 // or
335 // [name] Shift-click form |linkType:key|h[name]|h|r
336
337 char* tail;
338
339 if (text[1] == 'c')
340 {
341 char* check = strtok(text, "|"); // skip color
342 if (!check)
343 return nullptr; // end of data
344
345 tail = strtok(nullptr, ""); // tail
346 }
347 else
348 tail = text+1; // skip first |
349
350 char* cLinkType = strtok(tail, ":"); // linktype
351 if (!cLinkType)
352 return nullptr; // end of data
353
354 for (int i = 0; linkTypes[i]; ++i)
355 {
356 if (strcmp(cLinkType, linkTypes[i]) == 0)
357 {
358 char* cKeys = strtok(nullptr, "|"); // extract keys and values
359 char* cKeysTail = strtok(nullptr, "");
360
361 char* cKey = strtok(cKeys, ":|"); // extract key
362 if (something1)
363 *something1 = strtok(nullptr, ":|"); // extract something
364
365 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
366 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
367 if (found_idx)
368 *found_idx = i;
369 return cKey;
370 }
371 }
372
373 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
375 return nullptr;
376}
377
379{
380 if (!m_session)
381 return nullptr;
382
383 Player* pl = m_session->GetPlayer();
384 GameObject* obj = nullptr;
388 return obj;
389}
390
392{
393 if (!m_session)
394 return nullptr;
395 auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
396 if (bounds.first != bounds.second)
397 return bounds.first->second;
398 return nullptr;
399}
400
402{
403 if (!m_session)
404 return nullptr;
405 // Select the first alive creature or a dead one if not found
406 Creature* creature = nullptr;
407 auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
408 for (auto it = bounds.first; it != bounds.second; ++it)
409 {
410 creature = it->second;
411 if (it->second->IsAlive())
412 break;
413 }
414 return creature;
415}
416
418{
419 GUID_LINK_PLAYER = 0, // must be first for selection in not link case
423
424static char const* const guidKeys[] =
425{
426 "Hplayer",
427 "Hcreature",
428 "Hgameobject",
429 nullptr
430};
431
433{
434 int type = 0;
435
436 // |color|Hcreature:creature_guid|h[name]|h|r
437 // |color|Hgameobject:go_guid|h[name]|h|r
438 // |color|Hplayer:name|h[name]|h|r
439 char* idS = extractKeyFromLink(text, guidKeys, &type);
440 if (!idS)
441 return 0;
442
443 switch (type)
444 {
445 case GUID_LINK_PLAYER:
446 {
447 guidHigh = HighGuid::Player;
448 std::string name = idS;
449 if (!normalizePlayerName(name))
450 return 0;
451
452 if (Player* player = ObjectAccessor::FindPlayerByName(name))
453 return player->GetGUID().GetCounter();
454
455 ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
456 return guid.GetCounter();
457 }
459 {
460 guidHigh = HighGuid::Creature;
461 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(UI64LIT(0));
462 return lowguid;
463 }
465 {
466 guidHigh = HighGuid::GameObject;
467 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(UI64LIT(0));
468 return lowguid;
469 }
470 }
471
472 // unknown type?
473 return 0;
474}
475
477{
478 // |color|Hplayer:name|h[name]|h|r
479 char* name_str = extractKeyFromLink(text, "Hplayer");
480 if (!name_str)
481 return "";
482
483 std::string name = name_str;
484 if (!normalizePlayerName(name))
485 return "";
486
487 return name;
488}
489
490bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*= nullptr*/, std::string* player_name /*= nullptr*/)
491{
492 if (args && *args)
493 {
494 std::string name = extractPlayerNameFromLink(args);
495 if (name.empty())
496 {
499 return false;
500 }
501
503
504 // if allowed player pointer
505 if (player)
506 *player = pl;
507
508 // if need guid value from DB (in name case for check player existence)
509 ObjectGuid guid = !pl && (player_guid || player_name) ? sCharacterCache->GetCharacterGuidByName(name) : ObjectGuid::Empty;
510
511 // if allowed player guid (if no then only online players allowed)
512 if (player_guid)
513 *player_guid = pl ? pl->GetGUID() : guid;
514
515 if (player_name)
516 *player_name = pl || !guid.IsEmpty() ? name : "";
517 }
518 else
519 {
520 // populate strtok buffer to prevent crashes
521 static char dummy[1] = "";
522 strtok(dummy, "");
523
525 // if allowed player pointer
526 if (player)
527 *player = pl;
528 // if allowed player guid (if no then only online players allowed)
529 if (player_guid)
530 *player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty;
531
532 if (player_name)
533 *player_name = pl ? pl->GetName() : "";
534 }
535
536 // some from req. data must be provided (note: name is empty if player does not exist)
537 if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
538 {
541 return false;
542 }
543
544 return true;
545}
546
548{
549 if (!args || !*args)
550 return nullptr;
551
552 if (*args == '"')
553 return strtok(args+1, "\"");
554 else
555 {
556 // skip spaces
557 while (*args == ' ')
558 {
559 args += 1;
560 continue;
561 }
562
563 // return nullptr if we reached the end of the string
564 if (!*args)
565 return nullptr;
566
567 // since we skipped all spaces, we expect another token now
568 if (*args == '"')
569 {
570 // return an empty string if there are 2 "" in a row.
571 // strtok doesn't handle this case
572 if (*(args + 1) == '"')
573 {
574 strtok(args, " ");
575 static char arg[1];
576 arg[0] = '\0';
577 return arg;
578 }
579 else
580 return strtok(args + 1, "\"");
581 }
582 else
583 return nullptr;
584 }
585}
586
588{
589 Player* pl = m_session->GetPlayer();
590 return pl != chr && pl->IsVisibleGloballyFor(chr);
591}
592
597
602
603std::string ChatHandler::playerLink(std::string const& name) const
604{
605 if (m_session)
606 return Trinity::StringFormat("|cffffffff|Hplayer:{0}|h[{0}]|h|r", name);
607 else
608 return name;
609}
610
611std::string ChatHandler::GetNameLink(Player* chr) const
612{
613 return playerLink(chr->GetName());
614}
615
616char const* CliHandler::GetTrinityString(uint32 entry) const
617{
618 return sObjectMgr->GetTrinityStringForDBCLocale(entry);
619}
620
621void CliHandler::SendSysMessage(std::string_view str, bool /*escapeCharacters*/)
622{
624 m_print(m_callbackArg, "\r\n");
625}
626
627bool CliHandler::ParseCommands(std::string_view str)
628{
629 if (str.empty())
630 return false;
631 // Console allows using commands both with and without leading indicator
632 if (str[0] == '.' || str[0] == '!')
633 str = str.substr(1);
634 return _ParseCommands(str);
635}
636
637std::string CliHandler::GetNameLink() const
638{
640}
641
643{
644 return true;
645}
646
647bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
648{
649 player = nullptr;
650 guid.Clear();
651
652 if (cname)
653 {
654 std::string name = cname;
655 if (!name.empty())
656 {
657 if (!normalizePlayerName(name))
658 {
661 return false;
662 }
663
665 if (offline)
666 guid = sCharacterCache->GetCharacterGuidByName(name);
667 }
668 }
669
670 if (player)
671 {
672 group = player->GetGroup();
673 if (!guid || !offline)
674 guid = player->GetGUID();
675 }
676 else
677 {
678 if (getSelectedPlayer())
679 player = getSelectedPlayer();
680 else
681 player = m_session->GetPlayer();
682
683 if (!guid || !offline)
684 guid = player->GetGUID();
685 group = player->GetGroup();
686 }
687
688 return true;
689}
690
692{
693 return sWorld->GetDefaultDbcLocale();
694}
695
697{
698 return sObjectMgr->GetDBCLocaleIndex();
699}
700
701std::string const AddonChannelCommandHandler::PREFIX = "TrinityCore";
702
704{
705 if (str.length() < 5)
706 return false;
707 char opcode = str[0];
708 echo = &str[1];
709
710 switch (opcode)
711 {
712 case 'p': // p Ping
713 SendAck();
714 return true;
715 case 'h': // h Issue human-readable command
716 case 'i': // i Issue command
717 {
718 if (!str[5])
719 return false;
720 humanReadable = (opcode == 'h');
721 std::string_view cmd = str.substr(5);
722 if (_ParseCommands(cmd)) // actual command starts at str[5]
723 {
724 if (!hadAck)
725 SendAck();
727 SendFailed();
728 else
729 SendOK();
730 }
731 else
732 {
734 SendFailed();
735 }
736 return true;
737 }
738 default:
739 return false;
740 }
741}
742
749
750void AddonChannelCommandHandler::SendAck() // a Command acknowledged, no body
751{
752 ASSERT(echo);
753 char ack[6] = "a";
754 memcpy(ack + 1, echo, 4);
755 ack[5] = '\0';
756 Send(ack);
757 hadAck = true;
758}
759
760void AddonChannelCommandHandler::SendOK() // o Command OK, no body
761{
762 ASSERT(echo);
763 char ok[6] = "o";
764 memcpy(ok + 1, echo, 4);
765 ok[5] = '\0';
766 Send(ok);
767}
768
769void AddonChannelCommandHandler::SendFailed() // f Command failed, no body
770{
771 ASSERT(echo);
772 char fail[6] = "f";
773 memcpy(fail + 1, echo, 4);
774 fail[5] = '\0';
775 Send(fail);
776}
777
778// m Command message, message in body
779void AddonChannelCommandHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
780{
781 ASSERT(echo);
782 if (!hadAck)
783 SendAck();
784
785 std::string msg = "m";
786 msg.append(echo, 4);
787 std::string body(str);
788 if (escapeCharacters)
789 StringReplaceAll(&body, "|"sv, "||"sv);
790
791 size_t pos, lastpos;
792 for (lastpos = 0, pos = body.find('\n', lastpos); pos != std::string::npos; lastpos = pos + 1, pos = body.find('\n', lastpos))
793 {
794 std::string line(msg);
795 line.append(body, lastpos, pos - lastpos);
796 Send(line);
797 }
798 msg.append(body, lastpos, pos - lastpos);
799 Send(msg);
800}
#define sCharacterCache
GuidLinkType
Definition Chat.cpp:418
@ GUID_LINK_CREATURE
Definition Chat.cpp:420
@ GUID_LINK_GAMEOBJECT
Definition Chat.cpp:421
@ GUID_LINK_PLAYER
Definition Chat.cpp:419
static char const *const guidKeys[]
Definition Chat.cpp:424
LocaleConstant
Definition Common.h:51
@ LOCALE_enUS
Definition Common.h:52
AccountTypes
Definition Common.h:42
#define STRING_VIEW_FMT_ARG(str)
Definition Define.h:147
#define UI64LIT(N)
Definition Define.h:139
uint32_t uint32
Definition Define.h:154
#define ASSERT
Definition Errors.h:80
#define SIZE_OF_GRIDS
Definition GridDefines.h:40
@ 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:109
bool normalizePlayerName(std::string &name)
#define sObjectMgr
Definition ObjectMgr.h:1885
#define sRealmList
Definition RealmList.h:93
@ LANG_UNIVERSAL
@ LANG_ADDON
@ CHAT_MSG_WHISPER
@ CHAT_MSG_SYSTEM
void StringReplaceAll(std::string *str, std::string_view text, std::string_view replacement)
Definition Util.cpp:865
static uint32 GetSecurity(uint32 accountId, int32 realmId)
char const * echo
Definition Chat.h:176
void Send(std::string const &msg)
Definition Chat.cpp:743
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition Chat.cpp:779
static std::string const PREFIX
Definition Chat.h:162
bool ParseCommands(std::string_view str) override
Definition Chat.cpp:703
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
char * extractKeyFromLink(char *text, char const *linkType, char **something1=nullptr)
Definition Chat.cpp:266
Player * getSelectedPlayerOrSelf()
Definition Chat.cpp:248
virtual bool HasPermission(uint32 permission) const
Definition Chat.cpp:51
std::string playerLink(std::string const &name) const
Definition Chat.cpp:603
char * extractQuotedArg(char *args)
Definition Chat.cpp:547
Unit * getSelectedUnit()
Definition Chat.cpp:216
void SendGlobalGMSysMessage(const char *str)
Definition Chat.cpp:137
virtual LocaleConstant GetSessionDbLocaleIndex() const
Definition Chat.cpp:598
Player * getSelectedPlayer()
Definition Chat.cpp:204
WorldSession * GetSession()
Definition Chat.h:42
void SendGlobalSysMessage(const char *str)
Definition Chat.cpp:127
bool HasSentErrorMessage() const
Definition Chat.h:126
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:593
virtual std::string GetNameLink() const
Definition Chat.cpp:56
WorldSession * m_session
Definition Chat.h:132
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:401
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition Chat.cpp:61
Creature * getSelectedCreature()
Definition Chat.cpp:240
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:391
static std::string StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs) noexcept
Definition Chat.cpp:157
void SetSentErrorMessage(bool val)
Definition Chat.h:127
Player * GetPlayer() const
Definition Chat.cpp:37
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:62
WorldObject * getSelectedObject()
Definition Chat.cpp:227
virtual bool ParseCommands(std::string_view text)
Definition Chat.cpp:181
bool GetPlayerGroupAndGUIDByName(const char *cname, Player *&player, Group *&group, ObjectGuid &guid, bool offline=false)
Definition Chat.cpp:647
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:111
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:587
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=nullptr, std::string *player_name=nullptr)
Definition Chat.cpp:490
std::string extractPlayerNameFromLink(char *text)
Definition Chat.cpp:476
bool _ParseCommands(std::string_view text)
Definition Chat.cpp:166
GameObject * GetNearbyGameObject()
Definition Chat.cpp:378
static char * LineFromMessage(char *&pos)
Definition Chat.cpp:39
ObjectGuid::LowType extractLowGuidFromLink(char *text, HighGuid &guidHigh)
Definition Chat.cpp:432
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition Chat.cpp:81
virtual char const * GetTrinityString(uint32 entry) const
Definition Chat.cpp:46
LocaleConstant GetSessionDbLocaleIndex() const override
Definition Chat.cpp:696
LocaleConstant GetSessionDbcLocale() const override
Definition Chat.cpp:691
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition Chat.cpp:621
void * m_callbackArg
Definition Chat.h:155
Print * m_print
Definition Chat.h:156
bool ParseCommands(std::string_view str) override
Definition Chat.cpp:627
char const * GetTrinityString(uint32 entry) const override
Definition Chat.cpp:616
bool needReportToTarget(Player *chr) const override
Definition Chat.cpp:642
std::string GetNameLink() const override
Definition Chat.cpp:637
Definition Group.h:205
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:465
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:461
LowType GetCounter() const
Definition ObjectGuid.h:336
static ObjectGuid const Empty
Definition ObjectGuid.h:314
bool IsEmpty() const
Definition ObjectGuid.h:362
uint64 LowType
Definition ObjectGuid.h:321
void Clear()
Definition ObjectGuid.h:329
WorldSession * GetSession() const
Definition Player.h:2272
bool IsVisibleGloballyFor(Player const *player) const
Definition Player.cpp:24528
Unit * GetSelectedUnit() const
Definition Player.cpp:24894
Group * GetGroup(Optional< uint8 > partyIndex)
Definition Player.h:2796
Definition Unit.h:635
ObjectGuid GetTarget() const
Definition Unit.h:1831
Map * GetMap() const
Definition Object.h:411
std::string const & GetName() const
Definition Object.h:342
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string_view message, uint32 achievementId=0, std::string_view channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string_view addonPrefix="")
WorldPacket const * Write() override
Player session in the World.
char const * GetTrinityString(uint32 entry) const
AccountTypes GetSecurity() const
LocaleConstant GetSessionDbLocaleIndex() const
LocaleConstant GetSessionDbcLocale() const
Player * GetPlayer() const
bool HasPermission(uint32 permissionId)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
#define sWorld
Definition World.h:916
@ CONFIG_GM_LOWER_SECURITY
Definition World.h:122
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:57
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
@ RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR
Definition RBAC.h:86
@ RBAC_PERM_CHECK_FOR_LOWER_SECURITY
Definition RBAC.h:100
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:179