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