TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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{
59}
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
148{
150}
151
152std::string ChatHandler::StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs)
153{
154 return fmt::vsprintf<char>(messageFormat, messageFormatArgs);
155}
156
157bool ChatHandler::_ParseCommands(std::string_view text)
158{
160 return true;
161
162 // Pretend commands don't exist for regular players
164 return false;
165
166 // Send error message for GMs
169 return true;
170}
171
172bool ChatHandler::ParseCommands(std::string_view text)
173{
174 ASSERT(!text.empty());
175
176 // chat case (.command or !command format)
177 if ((text[0] != '!') && (text[0] != '.'))
178 return false;
179
180 // ignore single . and ! in line
181 if (text.length() < 2)
182 return false;
183
184 // ignore messages staring from many dots.
185 if (text[1] == text[0])
186 return false;
187
188 // ignore messages with separator after .
190 return false;
191
192 return _ParseCommands(text.substr(1));
193}
194
196{
197 if (!m_session)
198 return nullptr;
199
200 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
201 if (!selected)
202 return m_session->GetPlayer();
203
205}
206
208{
209 if (!m_session)
210 return nullptr;
211
212 if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
213 return selected;
214
215 return m_session->GetPlayer();
216}
217
219{
220 if (!m_session)
221 return nullptr;
222
224
225 if (!guid)
226 return GetNearbyGameObject();
227
229}
230
232{
233 if (!m_session)
234 return nullptr;
235
237}
238
240{
241 if (!m_session)
242 return nullptr;
243
244 ObjectGuid selected = m_session->GetPlayer()->GetTarget();
245 if (!selected)
246 return m_session->GetPlayer();
247
248 // first try with selected target
249 Player* targetPlayer = ObjectAccessor::FindConnectedPlayer(selected);
250 // if the target is not a player, then return self
251 if (!targetPlayer)
252 targetPlayer = m_session->GetPlayer();
253
254 return targetPlayer;
255}
256
257char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
258{
259 // skip empty
260 if (!text)
261 return nullptr;
262
263 // skip spaces
264 while (*text == ' '||*text == '\t'||*text == '\b')
265 ++text;
266
267 if (!*text)
268 return nullptr;
269
270 // return non link case
271 if (text[0] != '|')
272 return strtok(text, " ");
273
274 // [name] Shift-click form |color|linkType:key|h[name]|h|r
275 // or
276 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
277
278 char* check = strtok(text, "|"); // skip color
279 if (!check)
280 return nullptr; // end of data
281
282 char* cLinkType = strtok(nullptr, ":"); // linktype
283 if (!cLinkType)
284 return nullptr; // end of data
285
286 if (strcmp(cLinkType, linkType) != 0)
287 {
288 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
290 return nullptr;
291 }
292
293 char* cKeys = strtok(nullptr, "|"); // extract keys and values
294 char* cKeysTail = strtok(nullptr, "");
295
296 char* cKey = strtok(cKeys, ":|"); // extract key
297 if (something1)
298 *something1 = strtok(nullptr, ":|"); // extract something
299
300 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
301 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
302 return cKey;
303}
304
305char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1)
306{
307 // skip empty
308 if (!text)
309 return nullptr;
310
311 // skip spaces
312 while (*text == ' '||*text == '\t'||*text == '\b')
313 ++text;
314
315 if (!*text)
316 return nullptr;
317
318 // return non link case
319 if (text[0] != '|')
320 return strtok(text, " ");
321
322 // [name] Shift-click form |color|linkType:key|h[name]|h|r
323 // or
324 // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
325 // or
326 // [name] Shift-click form |linkType:key|h[name]|h|r
327
328 char* tail;
329
330 if (text[1] == 'c')
331 {
332 char* check = strtok(text, "|"); // skip color
333 if (!check)
334 return nullptr; // end of data
335
336 tail = strtok(nullptr, ""); // tail
337 }
338 else
339 tail = text+1; // skip first |
340
341 char* cLinkType = strtok(tail, ":"); // linktype
342 if (!cLinkType)
343 return nullptr; // end of data
344
345 for (int i = 0; linkTypes[i]; ++i)
346 {
347 if (strcmp(cLinkType, linkTypes[i]) == 0)
348 {
349 char* cKeys = strtok(nullptr, "|"); // extract keys and values
350 char* cKeysTail = strtok(nullptr, "");
351
352 char* cKey = strtok(cKeys, ":|"); // extract key
353 if (something1)
354 *something1 = strtok(nullptr, ":|"); // extract something
355
356 strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
357 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
358 if (found_idx)
359 *found_idx = i;
360 return cKey;
361 }
362 }
363
364 strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
366 return nullptr;
367}
368
370{
371 if (!m_session)
372 return nullptr;
373
374 Player* pl = m_session->GetPlayer();
375 GameObject* obj = nullptr;
379 return obj;
380}
381
383{
384 if (!m_session)
385 return nullptr;
386 auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
387 if (bounds.first != bounds.second)
388 return bounds.first->second;
389 return nullptr;
390}
391
393{
394 if (!m_session)
395 return nullptr;
396 // Select the first alive creature or a dead one if not found
397 Creature* creature = nullptr;
398 auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
399 for (auto it = bounds.first; it != bounds.second; ++it)
400 {
401 creature = it->second;
402 if (it->second->IsAlive())
403 break;
404 }
405 return creature;
406}
407
409{
410 GUID_LINK_PLAYER = 0, // must be first for selection in not link case
414
415static char const* const guidKeys[] =
416{
417 "Hplayer",
418 "Hcreature",
419 "Hgameobject",
420 nullptr
421};
422
424{
425 int type = 0;
426
427 // |color|Hcreature:creature_guid|h[name]|h|r
428 // |color|Hgameobject:go_guid|h[name]|h|r
429 // |color|Hplayer:name|h[name]|h|r
430 char* idS = extractKeyFromLink(text, guidKeys, &type);
431 if (!idS)
432 return 0;
433
434 switch (type)
435 {
436 case GUID_LINK_PLAYER:
437 {
438 guidHigh = HighGuid::Player;
439 std::string name = idS;
440 if (!normalizePlayerName(name))
441 return 0;
442
443 if (Player* player = ObjectAccessor::FindPlayerByName(name))
444 return player->GetGUID().GetCounter();
445
446 ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
447 if (guid.IsEmpty())
448 return 0;
449
450 return guid.GetCounter();
451 }
453 {
454 guidHigh = HighGuid::Creature;
455 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(UI64LIT(0));
456 return lowguid;
457 }
459 {
460 guidHigh = HighGuid::GameObject;
461 ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(UI64LIT(0));
462 return lowguid;
463 }
464 }
465
466 // unknown type?
467 return 0;
468}
469
471{
472 // |color|Hplayer:name|h[name]|h|r
473 char* name_str = extractKeyFromLink(text, "Hplayer");
474 if (!name_str)
475 return "";
476
477 std::string name = name_str;
478 if (!normalizePlayerName(name))
479 return "";
480
481 return name;
482}
483
484bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*= nullptr*/, std::string* player_name /*= nullptr*/)
485{
486 if (args && *args)
487 {
488 std::string name = extractPlayerNameFromLink(args);
489 if (name.empty())
490 {
493 return false;
494 }
495
497
498 // if allowed player pointer
499 if (player)
500 *player = pl;
501
502 // if need guid value from DB (in name case for check player existence)
503 ObjectGuid guid = !pl && (player_guid || player_name) ? sCharacterCache->GetCharacterGuidByName(name) : ObjectGuid::Empty;
504
505 // if allowed player guid (if no then only online players allowed)
506 if (player_guid)
507 *player_guid = pl ? pl->GetGUID() : guid;
508
509 if (player_name)
510 *player_name = pl || !guid.IsEmpty() ? name : "";
511 }
512 else
513 {
514 // populate strtok buffer to prevent crashes
515 static char dummy[1] = "";
516 strtok(dummy, "");
517
519 // if allowed player pointer
520 if (player)
521 *player = pl;
522 // if allowed player guid (if no then only online players allowed)
523 if (player_guid)
524 *player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty;
525
526 if (player_name)
527 *player_name = pl ? pl->GetName() : "";
528 }
529
530 // some from req. data must be provided (note: name is empty if player does not exist)
531 if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
532 {
535 return false;
536 }
537
538 return true;
539}
540
542{
543 if (!args || !*args)
544 return nullptr;
545
546 if (*args == '"')
547 return strtok(args+1, "\"");
548 else
549 {
550 // skip spaces
551 while (*args == ' ')
552 {
553 args += 1;
554 continue;
555 }
556
557 // return nullptr if we reached the end of the string
558 if (!*args)
559 return nullptr;
560
561 // since we skipped all spaces, we expect another token now
562 if (*args == '"')
563 {
564 // return an empty string if there are 2 "" in a row.
565 // strtok doesn't handle this case
566 if (*(args + 1) == '"')
567 {
568 strtok(args, " ");
569 static char arg[1];
570 arg[0] = '\0';
571 return arg;
572 }
573 else
574 return strtok(args + 1, "\"");
575 }
576 else
577 return nullptr;
578 }
579}
580
582{
583 Player* pl = m_session->GetPlayer();
584 return pl != chr && pl->IsVisibleGloballyFor(chr);
585}
586
588{
590}
591
593{
595}
596
597std::string ChatHandler::playerLink(std::string const& name) const
598{
599 if (m_session)
600 return Trinity::StringFormat("|cffffffff|Hplayer:{0}|h[{0}]|h|r", name);
601 else
602 return name;
603}
604
605std::string ChatHandler::GetNameLink(Player* chr) const
606{
607 return playerLink(chr->GetName());
608}
609
610char const* CliHandler::GetTrinityString(uint32 entry) const
611{
612 return sObjectMgr->GetTrinityStringForDBCLocale(entry);
613}
614
615void CliHandler::SendSysMessage(std::string_view str, bool /*escapeCharacters*/)
616{
618 m_print(m_callbackArg, "\r\n");
619}
620
621bool CliHandler::ParseCommands(std::string_view str)
622{
623 if (str.empty())
624 return false;
625 // Console allows using commands both with and without leading indicator
626 if (str[0] == '.' || str[0] == '!')
627 str = str.substr(1);
628 return _ParseCommands(str);
629}
630
631std::string CliHandler::GetNameLink() const
632{
634}
635
637{
638 return true;
639}
640
641bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
642{
643 player = nullptr;
644 guid.Clear();
645
646 if (cname)
647 {
648 std::string name = cname;
649 if (!name.empty())
650 {
651 if (!normalizePlayerName(name))
652 {
655 return false;
656 }
657
659 if (offline)
660 guid = sCharacterCache->GetCharacterGuidByName(name);
661 }
662 }
663
664 if (player)
665 {
666 group = player->GetGroup();
667 if (!guid || !offline)
668 guid = player->GetGUID();
669 }
670 else
671 {
672 if (getSelectedPlayer())
673 player = getSelectedPlayer();
674 else
675 player = m_session->GetPlayer();
676
677 if (!guid || !offline)
678 guid = player->GetGUID();
679 group = player->GetGroup();
680 }
681
682 return true;
683}
684
686{
687 return sWorld->GetDefaultDbcLocale();
688}
689
691{
692 return sObjectMgr->GetDBCLocaleIndex();
693}
694
695std::string const AddonChannelCommandHandler::PREFIX = "TrinityCore";
696
698{
699 if (str.length() < 5)
700 return false;
701 char opcode = str[0];
702 echo = &str[1];
703
704 switch (opcode)
705 {
706 case 'p': // p Ping
707 SendAck();
708 return true;
709 case 'h': // h Issue human-readable command
710 case 'i': // i Issue command
711 {
712 if (!str[5])
713 return false;
714 humanReadable = (opcode == 'h');
715 std::string_view cmd = str.substr(5);
716 if (_ParseCommands(cmd)) // actual command starts at str[5]
717 {
718 if (!hadAck)
719 SendAck();
721 SendFailed();
722 else
723 SendOK();
724 }
725 else
726 {
728 SendFailed();
729 }
730 return true;
731 }
732 default:
733 return false;
734 }
735}
736
737void AddonChannelCommandHandler::Send(std::string const& msg)
738{
741 GetSession()->SendPacket(chat.Write());
742}
743
744void AddonChannelCommandHandler::SendAck() // a Command acknowledged, no body
745{
746 ASSERT(echo);
747 char ack[6] = "a";
748 memcpy(ack + 1, echo, 4);
749 ack[5] = '\0';
750 Send(ack);
751 hadAck = true;
752}
753
754void AddonChannelCommandHandler::SendOK() // o Command OK, no body
755{
756 ASSERT(echo);
757 char ok[6] = "o";
758 memcpy(ok + 1, echo, 4);
759 ok[5] = '\0';
760 Send(ok);
761}
762
763void AddonChannelCommandHandler::SendFailed() // f Command failed, no body
764{
765 ASSERT(echo);
766 char fail[6] = "f";
767 memcpy(fail + 1, echo, 4);
768 fail[5] = '\0';
769 Send(fail);
770}
771
772// m Command message, message in body
773void AddonChannelCommandHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
774{
775 ASSERT(echo);
776 if (!hadAck)
777 SendAck();
778
779 std::string msg = "m";
780 msg.append(echo, 4);
781 std::string body(str);
782 if (escapeCharacters)
783 StringReplaceAll(&body, "|"sv, "||"sv);
784
785 size_t pos, lastpos;
786 for (lastpos = 0, pos = body.find('\n', lastpos); pos != std::string::npos; lastpos = pos + 1, pos = body.find('\n', lastpos))
787 {
788 std::string line(msg);
789 line.append(body, lastpos, pos - lastpos);
790 Send(line);
791 }
792 msg.append(body, lastpos, pos - lastpos);
793 Send(msg);
794}
#define sCharacterCache
GuidLinkType
Definition: Chat.cpp:409
@ GUID_LINK_CREATURE
Definition: Chat.cpp:411
@ GUID_LINK_GAMEOBJECT
Definition: Chat.cpp:412
@ GUID_LINK_PLAYER
Definition: Chat.cpp:410
static char const *const guidKeys[]
Definition: Chat.cpp:415
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:141
#define UI64LIT(N)
Definition: Define.h:133
uint32_t uint32
Definition: Define.h:148
#define ASSERT
Definition: Errors.h:68
#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:77
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:156
#define sObjectMgr
Definition: ObjectMgr.h:1985
#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)
Definition: AccountMgr.cpp:297
char const * echo
Definition: Chat.h:175
void Send(std::string const &msg)
Definition: Chat.cpp:737
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition: Chat.cpp:773
static std::string const PREFIX
Definition: Chat.h:161
bool ParseCommands(std::string_view str) override
Definition: Chat.cpp:697
char * extractKeyFromLink(char *text, char const *linkType, char **something1=nullptr)
Definition: Chat.cpp:257
Player * getSelectedPlayerOrSelf()
Definition: Chat.cpp:239
virtual bool HasPermission(uint32 permission) const
Definition: Chat.cpp:51
std::string playerLink(std::string const &name) const
Definition: Chat.cpp:597
char * extractQuotedArg(char *args)
Definition: Chat.cpp:541
Unit * getSelectedUnit()
Definition: Chat.cpp:207
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:137
virtual LocaleConstant GetSessionDbLocaleIndex() const
Definition: Chat.cpp:592
Player * getSelectedPlayer()
Definition: Chat.cpp:195
WorldSession * GetSession()
Definition: Chat.h:42
void SendGlobalSysMessage(const char *str)
Definition: Chat.cpp:127
bool HasSentErrorMessage() const
Definition: Chat.h:125
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:587
virtual std::string GetNameLink() const
Definition: Chat.cpp:56
WorldSession * m_session
Definition: Chat.h:131
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition: Chat.cpp:392
static std::string StringVPrintf(std::string_view messageFormat, fmt::printf_args messageFormatArgs)
Definition: Chat.cpp:152
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:61
Creature * getSelectedCreature()
Definition: Chat.cpp:231
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition: Chat.cpp:382
void SetSentErrorMessage(bool val)
Definition: Chat.h:126
Player * GetPlayer() const
Definition: Chat.cpp:37
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:61
WorldObject * getSelectedObject()
Definition: Chat.cpp:218
virtual bool ParseCommands(std::string_view text)
Definition: Chat.cpp:172
bool GetPlayerGroupAndGUIDByName(const char *cname, Player *&player, Group *&group, ObjectGuid &guid, bool offline=false)
Definition: Chat.cpp:641
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:111
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:581
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=nullptr, std::string *player_name=nullptr)
Definition: Chat.cpp:484
std::string extractPlayerNameFromLink(char *text)
Definition: Chat.cpp:470
bool _ParseCommands(std::string_view text)
Definition: Chat.cpp:157
GameObject * GetNearbyGameObject()
Definition: Chat.cpp:369
static char * LineFromMessage(char *&pos)
Definition: Chat.cpp:39
ObjectGuid::LowType extractLowGuidFromLink(char *text, HighGuid &guidHigh)
Definition: Chat.cpp:423
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:690
LocaleConstant GetSessionDbcLocale() const override
Definition: Chat.cpp:685
void SendSysMessage(std::string_view, bool escapeCharacters) override
Definition: Chat.cpp:615
void * m_callbackArg
Definition: Chat.h:154
Print * m_print
Definition: Chat.h:155
bool ParseCommands(std::string_view str) override
Definition: Chat.cpp:621
char const * GetTrinityString(uint32 entry) const override
Definition: Chat.cpp:610
bool needReportToTarget(Player *chr) const override
Definition: Chat.cpp:636
std::string GetNameLink() const override
Definition: Chat.cpp:631
Definition: Group.h:205
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:463
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:459
LowType GetCounter() const
Definition: ObjectGuid.h:296
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
bool IsEmpty() const
Definition: ObjectGuid.h:322
uint64 LowType
Definition: ObjectGuid.h:281
void Clear()
Definition: ObjectGuid.h:289
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:195
WorldSession * GetSession() const
Definition: Player.h:2207
bool IsVisibleGloballyFor(Player const *player) const
Definition: Player.cpp:24151
Unit * GetSelectedUnit() const
Definition: Player.cpp:24517
Group * GetGroup(Optional< uint8 > partyIndex)
Definition: Player.h:2719
Definition: Unit.h:632
ObjectGuid GetTarget() const
Definition: Unit.h:1811
Map * GetMap() const
Definition: Object.h:773
std::string const & GetName() const
Definition: Object.h:704
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.
Definition: WorldSession.h:979
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:909
@ CONFIG_GM_LOWER_SECURITY
Definition: World.h:120
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)
Default TC string format function.
Definition: StringFormat.h:39
@ 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