19 #ifndef TRINITYCORE_CHAT_H
20 #define TRINITYCORE_CHAT_H
45 ChatCommand(
char const* name,
uint32 permission,
bool allowConsole, pHandler handler, std::string help, std::vector<ChatCommand> childCommands = std::vector<ChatCommand>())
46 : Name(
ASSERT_NOTNULL(name)), Permission(permission), AllowConsole(allowConsole), Handler(handler), Help(
std::move(help)), ChildCommands(
std::move(childCommands)) { }
63 static char*
LineFromMessage(
char*& pos) {
char* start = strtok(pos,
"\n"); pos =
NULL;
return start; }
66 virtual char const* GetTrinityString(
uint32 entry)
const;
67 virtual void SendSysMessage(
char const* str,
bool escapeCharacters =
false);
69 void SendSysMessage(
uint32 entry);
71 template<
typename... Args>
77 template<
typename... Args>
80 SendSysMessage(PGetParseString(entry, std::forward<Args>(args)...).c_str());
83 template<
typename... Args>
89 bool ParseCommands(
const char* text);
91 static std::vector<ChatCommand>
const& getCommandTable();
93 bool isValidChatMessage(
const char* msg);
94 void SendGlobalSysMessage(
const char *str);
96 bool hasStringAbbr(
const char* name,
const char* part);
99 virtual bool isAvailable(
ChatCommand const& cmd)
const;
102 virtual bool needReportToTarget(
Player* chr)
const;
104 virtual int GetSessionDbLocaleIndex()
const;
106 bool HasLowerSecurity(
Player* target,
ObjectGuid guid,
bool strong =
false);
107 bool HasLowerSecurityAccount(
WorldSession* target,
uint32 account,
bool strong =
false);
109 void SendGlobalGMSysMessage(
const char *str);
110 Player* getSelectedPlayer();
112 Unit* getSelectedUnit();
115 Player* getSelectedPlayerOrSelf();
117 char* extractKeyFromLink(
char* text,
char const* linkType,
char** something1 =
NULL);
118 char* extractKeyFromLink(
char* text,
char const*
const* linkTypes,
int* found_idx,
char** something1 =
NULL);
121 void extractOptFirstArg(
char* args,
char** arg1,
char** arg2);
122 char* extractQuotedArg(
char* args);
124 uint32 extractSpellIdFromLink(
char* text);
126 GameTele const* extractGameTeleFromLink(
char* text);
127 bool GetPlayerGroupAndGUIDByName(
const char* cname,
Player*& player,
Group*& group,
ObjectGuid& guid,
bool offline =
false);
128 std::string extractPlayerNameFromLink(
char* text);
130 bool extractPlayerTarget(
char* args,
Player** player,
ObjectGuid* player_guid =
NULL, std::string* player_name =
NULL);
132 std::string
playerLink(std::string
const& name)
const {
return m_session ?
"|cffffffff|Hplayer:"+name+
"|h["+name+
"]|h|r" : name; }
133 std::string GetNameLink(
Player* chr)
const;
142 bool ShowHelpForCommand(std::vector<ChatCommand>
const& table,
const char* cmd);
145 static bool SetDataForCommandInTable(std::vector<ChatCommand>& table,
const char* text,
uint32 permission, std::string
const& help, std::string
const& fullcommand);
146 bool ExecuteCommandInTable(std::vector<ChatCommand>
const& table,
const char* text, std::string
const& fullcmd);
147 bool ShowHelpForSubCommands(std::vector<ChatCommand>
const& table,
char const* cmd,
char const* subcmd);
160 typedef void Print(
void*,
char const*);
161 explicit CliHandler(
void* callbackArg, Print* zprint) : m_callbackArg(callbackArg), m_print(zprint) { }
167 void SendSysMessage(
const char *str,
bool escapeCharacters)
override;
void PSendSysMessage(uint32 entry, Args &&...args)
Definition: Chat.h:78
virtual int GetSessionDbLocaleIndex() const
Definition: Chat.cpp:1067
static bool LoadCommandTable()
Definition: Chat.h:139
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
T * ASSERT_NOTNULL(T *pointer)
Definition: Errors.h:58
ChatHandler(WorldSession *session)
Definition: Chat.h:60
virtual bool isAvailable(ChatCommand const &cmd) const
Definition: Chat.cpp:72
static bool load_command_table
Definition: Chat.h:153
static char * LineFromMessage(char *&pos)
Definition: Chat.h:63
std::string PGetParseString(uint32 entry, Args &&...args) const
Definition: Chat.h:84
arena_t NULL
Definition: jemalloc_internal.h:624
#define false
Definition: CascPort.h:18
Definition: ObjectMgr.h:125
void Print(void *, char const *)
Definition: Chat.h:160
Role Based Access Control related classes definition.
Definition: Creature.h:467
std::string Help
Definition: Chat.h:52
WorldSession * m_session
Definition: Chat.h:150
uint64 LowType
Definition: ObjectGuid.h:199
#define bool
Definition: CascPort.h:16
CliHandler(void *callbackArg, Print *zprint)
Definition: Chat.h:161
uint32 Permission
Definition: Chat.h:49
bool HasPermission(uint32) const override
Definition: Chat.h:166
Print * m_print
Definition: Chat.h:175
char const * Name
Definition: Chat.h:48
LocaleConstant
Definition: Common.h:115
virtual std::string GetNameLink() const
Definition: Chat.h:101
bool sentErrorMessage
Definition: Chat.h:154
uint32_t uint32
Definition: Define.h:150
Definition: GameObject.h:880
virtual ~ChatHandler()
Definition: Chat.h:61
static void SetLoadCommandTable(bool val)
Definition: Chat.h:140
ChatCommand(char const *name, uint32 permission, bool allowConsole, pHandler handler, std::string help, std::vector< ChatCommand > childCommands=std::vector< ChatCommand >())
Definition: Chat.h:45
ChatHandler()
Definition: Chat.h:144
bool HasSentErrorMessage() const
Definition: Chat.h:137
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
std::vector< ChatCommand > ChildCommands
Definition: Chat.h:53
#define TC_GAME_API
Definition: Define.h:134
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Player session in the World.
Definition: WorldSession.h:882
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
Definition: ObjectGuid.h:189
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:1056
virtual bool HasPermission(uint32 permission) const
Definition: Chat.h:100
pHandler Handler
Definition: Chat.h:51
bool AllowConsole
Definition: Chat.h:50
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
void * m_callbackArg
Definition: Chat.h:174