31 static std::vector<ChatCommand> commandTableCache;
37 std::vector<ChatCommand> cmds =
sScriptMgr->GetChatCommands();
38 commandTableCache.swap(cmds);
46 Field* fields = result->Fetch();
50 }
while (result->NextRow());
54 return commandTableCache;
65 return std::string(str);
70 return m_session->GetSkyFireString(entry);
86 target_account =
sObjectMgr->GetPlayerAccountIdByGUID(guid);
88 if (!target_session && !target_account)
112 else if (target_account)
118 if (
m_session->GetSecurity() < target_ac_sec || (strong &&
m_session->GetSecurity() <= target_ac_sec))
143 else if (tolower(*name) != tolower(*part))
158 char* buf = strdup(str);
176 char* buf = strdup(str);
182 sWorld->SendGlobalMessage(&data);
194 char* buf = strdup(str);
200 sWorld->SendGlobalGMMessage(&data);
225 va_start(ap, format);
233 char const* oldtext = text;
234 std::string cmd =
"";
236 while (*text !=
' ' && *text !=
'\0')
242 while (*text ==
' ') ++text;
250 if (strlen(
table[i].Name) > cmd.length())
257 if (strcmp(
table[j].Name, cmd.c_str()) == 0)
268 if (!
table[i].ChildCommands.empty())
289 if ((
table[i].Handler)(
this,
table[i].Name[0] !=
'\0' ? text : oldtext))
299 std::string areaName =
"Unknown";
300 std::string zoneName =
"Unknown";
303 areaName = area->m_AreaName;
305 zoneName = zone->m_AreaName;
308 sLog->outCommand(
m_session->GetAccountId(),
"Command: %s [Player: %s (Guid: %u) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected %s: %s (GUID: %u)]",
321 if (!
table[i].Help.empty())
335 std::string cmd =
"";
337 while (*text !=
' ' && *text !=
'\0')
343 while (*text ==
' ') ++text;
348 if (
table[i].Name != cmd)
352 if (!
table[i].ChildCommands.empty())
364 SF_LOG_ERROR(
"sql.sql",
"Table `command` have unexpected subcommand '%s' in command '%s', skip.", text, fullcommand.c_str());
368 if (
table[i].Permission != permission)
369 SF_LOG_INFO(
"misc",
"Table `command` overwrite for command '%s' default permission (%u) by %u", fullcommand.c_str(),
table[i].Permission, permission);
371 table[i].Permission = permission;
372 table[i].Help = help;
380 SF_LOG_ERROR(
"sql.sql",
"Table `command` have not existed command '%s', skip.", cmd.c_str());
382 SF_LOG_ERROR(
"sql.sql",
"Table `command` have not existed subcommand '%s' in command '%s', skip.", cmd.c_str(), fullcommand.c_str());
393 std::string fullcmd = text;
398 if (text[0] !=
'!' && text[0] !=
'.')
403 if (strlen(text) < 2)
408 if ((text[0] ==
'.' && text[1] ==
'.') || (text[0] ==
'!' && text[1] ==
'!'))
412 if (text[0] ==
'!' || text[0] ==
'.')
441 if (strlen(message) > 255)
447 const char validSequence[6] =
"cHhhr";
448 const char* validSequenceIterator = validSequence;
449 const std::string validCommands =
"cHhr|";
454 message = strchr(message,
'|');
460 char commandChar = *message;
461 if (validCommands.find(commandChar) == std::string::npos)
468 if (commandChar == *validSequenceIterator)
470 if (validSequenceIterator == validSequence + 4)
471 validSequenceIterator = validSequence;
473 ++validSequenceIterator;
503 list +=
table[i].Name;
505 if (!
table[i].ChildCommands.empty())
537 char const* subcmd = (*cmd) ? strtok(NULL,
" ") :
"";
539 if (!
table[i].ChildCommands.empty() && subcmd && *subcmd)
545 if (!
table[i].Help.empty())
548 if (!
table[i].ChildCommands.empty())
552 return !
table[i].Help.empty();
563 if (strlen(
table[i].Name))
566 if (!
table[i].Help.empty())
569 if (!
table[i].ChildCommands.empty())
573 return !
table[i].Help.empty();
581 std::string
const& senderName , std::string
const& receiverName ,
582 uint32 achievementId ,
bool gmMessage , std::string
const& channelName ,
583 std::string
const& addonPrefix )
587 bool hasSenderName =
false;
588 bool hasReceiverName =
false;
589 bool hasChannelName =
false;
590 bool hasGroupGUID =
false;
591 bool hasGuildGUID =
false;
592 bool hasPrefix =
false;
613 hasReceiverName = receiverName.length();
621 hasSenderName = senderName.length();
624 hasSenderName = senderName.length();
630 hasReceiverName = receiverName.length();
634 hasChannelName = channelName.length();
635 hasSenderName = senderName.length();
639 hasSenderName = senderName.length();
644 hasPrefix = addonPrefix.length();
708 if (message.length())
719 data.
WriteBits(receiverName.length(), 11);
761 data <<
uint8(chatType);
763 if (hasAchievementId)
764 data <<
uint32(achievementId);
785 data <<
uint8(language);
787 if (message.length())
800 uint32 achievementId , std::string
const& channelName ,
LocaleConstant locale , std::string
const& addonPrefix )
803 std::string senderName =
"";
805 bool gmMessage =
false;
807 std::string receiverName =
"";
810 senderGUID = sender->
GetGUID();
814 chatTag = playerSender->GetChatTag();
821 receiverGUID = receiver->
GetGUID();
825 return BuildChatPacket(data, chatType, language, senderGUID, receiverGUID, message, chatTag, senderName, receiverName, achievementId, gmMessage, channelName, addonPrefix);
846 if (
Unit* selected =
m_session->GetPlayer()->GetSelectedUnit())
880 while (*text ==
' ' || *text ==
'\t' || *text ==
'\b')
888 return strtok(text,
" ");
894 char* check = strtok(text,
"|");
898 char* cLinkType = strtok(NULL,
":");
902 if (strcmp(cLinkType, linkType) != 0)
909 char* cKeys = strtok(NULL,
"|");
910 char* cKeysTail = strtok(NULL,
"");
912 char* cKey = strtok(cKeys,
":|");
914 *something1 = strtok(NULL,
":|");
916 strtok(cKeysTail,
"]");
928 while (*text ==
' ' || *text ==
'\t' || *text ==
'\b')
936 return strtok(text,
" ");
948 char* check = strtok(text,
"|");
952 tail = strtok(NULL,
"");
957 char* cLinkType = strtok(tail,
":");
961 for (
int i = 0; linkTypes[i]; ++i)
963 if (strcmp(cLinkType, linkTypes[i]) == 0)
965 char* cKeys = strtok(NULL,
"|");
966 char* cKeysTail = strtok(NULL,
"");
968 char* cKey = strtok(cKeys,
":|");
970 *something1 = strtok(NULL,
":|");
972 strtok(cKeysTail,
"]");
1050 char* param1_str = NULL;
1075 uint32 glyph_prop_id = param1_str ? (
uint32)atol(param1_str) : 0;
1078 if (!glyphPropEntry)
1081 return glyphPropEntry->
SpellId;
1097 if (cId[0] >=
'0' || cId[0] >=
'9')
1098 if (
uint32 id = atoi(cId))
1134 std::string name = idS;
1139 return player->GetGUID();
1177 std::string name = name_str;
1203 uint64 guid = !pl && (player_guid || player_name) ?
sObjectMgr->GetPlayerGUIDByName(name) : 0;
1207 *player_guid = pl ? pl->
GetGUID() : guid;
1210 *player_name = pl || guid ? name :
"";
1220 *player_guid = pl ? pl->
GetGUID() : 0;
1223 *player_name = pl ? pl->
GetName() :
"";
1227 if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
1239 char* p1 = strtok(args,
" ");
1240 char* p2 = strtok(NULL,
" ");
1261 return strtok(args + 1,
"\"");
1264 char* space = strtok(args,
"\"");
1267 return strtok(NULL,
"\"");
1279 return m_session->GetSessionDbcLocale();
1284 return m_session->GetSessionDbLocaleIndex();
1294 return sObjectMgr->GetSkyFireStringForDBCLocale(entry);
1326 std::string name = cname;
1338 guid =
sObjectMgr->GetPlayerGUIDByName(name.c_str());
1345 if (!guid || !offline)
1355 if (!guid || !offline)
1365 return sWorld->GetDefaultDbcLocale();
const AuthHandler table[]
static char const *const spellKeys[]
static char const *const guidKeys[]
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
AreaTableEntry const * GetAreaEntryByAreaID(uint32 area_id)
TypeMapContainer< AllGridObjectTypes > GridTypeMapContainer
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
@ LANG_YOURS_SECURITY_IS_LOW
#define SF_LOG_ERROR(filterType__,...)
#define SF_LOG_INFO(filterType__,...)
uint32 GUID_LOPART(uint64 x)
char const * GetLogNameForGuid(uint64 guid)
bool IS_PET_GUID(uint64 guid)
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
bool IS_PLAYER_GUID(uint64 guid)
bool normalizePlayerName(std::string &name)
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
@ CHAT_MSG_BG_SYSTEM_ALLIANCE
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
@ CHAT_MSG_INSTANCE_LEADER
@ CHAT_MSG_RAID_BOSS_WHISPER
@ CHAT_MSG_BG_SYSTEM_HORDE
@ CHAT_MSG_RAID_BOSS_EMOTE
@ CHAT_MSG_GUILD_ACHIEVEMENT
@ CHAT_MSG_MONSTER_WHISPER
static AccountTypes GetSecurity(uint32 accountId)
static bool IsPlayerAccount(AccountTypes gmlevel)
bool WriteBit(uint32 bit)
void WriteString(std::string const &str)
void WriteBits(T value, size_t bits)
void WriteByteSeq(uint8 b)
static bool LoadCommandTable()
virtual std::string GetNameLink() const
GameTele const * extractGameTeleFromLink(char *text)
bool HasLowerSecurity(Player *target, uint64 guid, bool strong=false)
static void SetLoadCommandTable(bool val)
bool ParseCommands(const char *text)
virtual bool isAvailable(ChatCommand const &cmd) const
std::string PGetParseString(int32 entry,...) const
void extractOptFirstArg(char *args, char **arg1, char **arg2)
static bool SetDataForCommandInTable(std::vector< ChatCommand > &table, const char *text, uint32 permission, std::string const &help, std::string const &fullcommand)
GameObject * GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry)
std::string playerLink(std::string const &name) const
static bool load_command_table
char * extractQuotedArg(char *args)
void SendGlobalGMSysMessage(const char *str)
bool ExecuteCommandInTable(std::vector< ChatCommand > const &table, const char *text, std::string const &fullcmd)
Player * getSelectedPlayer()
void SendGlobalSysMessage(const char *str)
bool HasSentErrorMessage() const
virtual LocaleConstant GetSessionDbcLocale() const
bool isValidChatMessage(const char *msg)
virtual bool HasPermission(uint32 permission) const
virtual int GetSessionDbLocaleIndex() const
bool hasStringAbbr(const char *name, const char *part)
Creature * getSelectedCreature()
uint32 extractSpellIdFromLink(char *text)
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
void PSendSysMessage(const char *format,...) ATTR_PRINTF(2
static size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const &message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="", std::string const &addonPrefix="")
void SetSentErrorMessage(bool val)
WorldObject * getSelectedObject()
uint64 extractGuidFromLink(char *text)
static char * LineFromMessage(char *&pos)
bool ShowHelpForSubCommands(std::vector< ChatCommand > const &table, char const *cmd, char const *subcmd)
bool extractPlayerTarget(char *args, Player **player, uint64 *player_guid=NULL, std::string *player_name=NULL)
virtual bool needReportToTarget(Player *chr) const
virtual void SendSysMessage(const char *str)
virtual const char * GetSkyFireString(int32 entry) const
bool GetPlayerGroupAndGUIDByName(const char *cname, Player *&player, Group *&group, uint64 &guid, bool offline=false)
std::string extractPlayerNameFromLink(char *text)
bool ShowHelpForCommand(std::vector< ChatCommand > const &table, const char *cmd)
GameObject * GetNearbyGameObject()
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
static std::vector< ChatCommand > const & getCommandTable()
void SendSysMessage(const char *str)
bool needReportToTarget(Player *chr) const
const char * GetSkyFireString(int32 entry) const
LocaleConstant GetSessionDbcLocale() const
int GetSessionDbLocaleIndex() const
std::string GetNameLink() const
bool isAvailable(ChatCommand const &cmd) const
std::string GetString() const
GameObject * GetGameObject(uint64 guid)
const char * GetMapName() const
static Creature * GetCreatureOrPetOrVehicle(WorldObject const &, uint64)
static Unit * GetUnit(WorldObject const &, uint64 guid)
static Player * FindPlayer(uint64)
uint32 GetGuildId() const
WorldSession * GetSession() const
bool IsVisibleGloballyFor(Player const *player) const
Unit * GetSelectedUnit() const
float GetGridActivationRange() const
std::string const & GetName() const
virtual std::string const & GetNameForLocaleIdx(LocaleConstant) const
void VisitNearbyGridObject(float const &radius, NOTIFIER ¬ifier) const
void Initialize(Opcodes opcode, size_t newres=200)
Player session in the World.
AccountTypes GetSecurity() const
uint32 GetVirtualRealmID() const
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
@ CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY
@ CONFIG_GM_LOWER_SECURITY
CellCoord ComputeCellCoord(float x, float y)
@ RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR
@ RBAC_PERM_COMMAND_GM_CHAT
@ RBAC_PERM_CHECK_FOR_LOWER_SECURITY
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
float GetPositionZ() const
float GetPositionX() const
float GetPositionY() const