mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10334] Update shift-link related functions for chat command parsing.
Also * Better single | detection as non-link case (doubled by client) * Commands .pdump now allow quoted filename (usefull if filename path include whitespaces)
This commit is contained in:
parent
e36a4a5d01
commit
344dff303e
7 changed files with 1016 additions and 1044 deletions
|
|
@ -56,7 +56,7 @@
|
||||||
// |color|Hquest:quest_id:quest_level|h[name]|h|r - client, quest list name shift-click
|
// |color|Hquest:quest_id:quest_level|h[name]|h|r - client, quest list name shift-click
|
||||||
// |color|Hskill:skill_id|h[name]|h|r
|
// |color|Hskill:skill_id|h[name]|h|r
|
||||||
// |color|Hspell:spell_id|h[name]|h|r - client, spellbook spell icon shift-click
|
// |color|Hspell:spell_id|h[name]|h|r - client, spellbook spell icon shift-click
|
||||||
// |color|Htalent:talent_id,rank|h[name]|h|r - client, talent icon shift-click
|
// |color|Htalent:talent_id,rank|h[name]|h|r - client, talent icon shift-click rank==-1 if shift-copy unlearned talent
|
||||||
// |color|Htaxinode:id|h[name]|h|r
|
// |color|Htaxinode:id|h[name]|h|r
|
||||||
// |color|Htele:id|h[name]|h|r
|
// |color|Htele:id|h[name]|h|r
|
||||||
// |color|Htitle:id|h[name]|h|r
|
// |color|Htitle:id|h[name]|h|r
|
||||||
|
|
@ -2096,6 +2096,8 @@ bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base)
|
||||||
// value successfully extracted
|
// value successfully extracted
|
||||||
val = uint32(valRaw);
|
val = uint32(valRaw);
|
||||||
*args = tail;
|
*args = tail;
|
||||||
|
|
||||||
|
SkipWhiteSpaces(args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2142,6 +2144,8 @@ bool ChatHandler::ExtractFloat(char** args, float& val)
|
||||||
// value successfully extracted
|
// value successfully extracted
|
||||||
val = float(valRaw);
|
val = float(valRaw);
|
||||||
*args = tail;
|
*args = tail;
|
||||||
|
|
||||||
|
SkipWhiteSpaces(args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2218,6 +2222,7 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/)
|
||||||
else
|
else
|
||||||
*args = NULL;
|
*args = NULL;
|
||||||
|
|
||||||
|
SkipWhiteSpaces(args);
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2297,41 +2302,142 @@ bool ChatHandler::ExtractOnOff(char** args, bool& value)
|
||||||
* Function extract shift-link-like string (any characters guarded by | and |h|r with some additional internal structure check)
|
* Function extract shift-link-like string (any characters guarded by | and |h|r with some additional internal structure check)
|
||||||
*
|
*
|
||||||
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
||||||
|
*
|
||||||
|
* @param linkTypes optional NULL-terminated array of link types, shift-link must fit one from link type from array if provided or extraction fail
|
||||||
|
*
|
||||||
|
* @param found_idx if not NULL then at return index in linkTypes that fit shift-link type, if extraction fail then non modified
|
||||||
|
*
|
||||||
|
* @param keyPair if not NULL then pointer to 2-elements array for return start and end pointer for found key
|
||||||
|
* if extraction fail then non modified
|
||||||
|
*
|
||||||
|
* @param somethingPair then pointer to 2-elements array for return start and end pointer if found.
|
||||||
|
* if not NULL then shift-link must have data field, if extraction fail then non modified
|
||||||
|
*
|
||||||
* @return shift-link-like string, or NULL if args empty or not appropriate content.
|
* @return shift-link-like string, or NULL if args empty or not appropriate content.
|
||||||
*/
|
*/
|
||||||
char* ChatHandler::ExtractLinkArg( char** args )
|
char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= NULL*/, int* foundIdx /*= NULL*/, char** keyPair /*= NULL*/, char** somethingPair /*= NULL*/)
|
||||||
{
|
{
|
||||||
if (!*args || !**args)
|
if (!*args || !**args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (**args != '|')
|
// skip if not linked started or encoded single | (doubled by client)
|
||||||
|
if ((*args)[0] != '|' || (*args)[1] == '|')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// |color|Hkey:data|h[name]|h|r
|
// |color|Hlinktype:key:data...|h[name]|h|r
|
||||||
|
|
||||||
char* head = *args;
|
char* head = *args;
|
||||||
|
|
||||||
|
// [name] Shift-click form |color|linkType:key|h[name]|h|r
|
||||||
|
// or
|
||||||
|
// [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
|
||||||
|
// or
|
||||||
|
// [name] Shift-click form |linkType:key|h[name]|h|r
|
||||||
|
|
||||||
|
// |color|Hlinktype:key:data...|h[name]|h|r
|
||||||
|
|
||||||
char* tail = (*args)+1; // skip |
|
char* tail = (*args)+1; // skip |
|
||||||
|
|
||||||
while (*tail && *tail != '|') // skip color part
|
if (*tail != 'H') // skip color part, some links can not have color part
|
||||||
|
{
|
||||||
|
while (*tail && *tail != '|')
|
||||||
++tail;
|
++tail;
|
||||||
|
|
||||||
if (!*tail)
|
if (!*tail)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// |Hkey:data|h[name]|h|r
|
// |Hlinktype:key:data...|h[name]|h|r
|
||||||
|
|
||||||
++tail; // skip |
|
++tail; // skip |
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hlinktype:key:data...|h[name]|h|r
|
||||||
|
|
||||||
if (*tail != 'H')
|
if (*tail != 'H')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (*tail && (*tail != '|' || *(tail+1) != 'h')) // skip key/data part
|
int linktype_idx = 0;
|
||||||
|
|
||||||
|
if (linkTypes) // check link type if provided
|
||||||
|
{
|
||||||
|
// check linktypes (its include H in name)
|
||||||
|
for (; linkTypes[linktype_idx]; ++linktype_idx)
|
||||||
|
{
|
||||||
|
// exactly string with follow : or |
|
||||||
|
int l = strlen(linkTypes[linktype_idx]);
|
||||||
|
if (strncmp(tail, linkTypes[linktype_idx], l) == 0 &&
|
||||||
|
(tail[l] == ':' || tail[l] == '|'))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is search fail?
|
||||||
|
if (!linkTypes[linktype_idx]) // NULL terminator in last element
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
tail += strlen(linkTypes[linktype_idx]); // skip linktype string
|
||||||
|
|
||||||
|
// :key:data...|h[name]|h|r
|
||||||
|
|
||||||
|
if (*tail != ':')
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (*tail && *tail != ':') // skip linktype string
|
||||||
|
++tail;
|
||||||
|
|
||||||
|
if (!*tail)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
++tail;
|
||||||
|
|
||||||
|
// key:data...|h[name]|h|r
|
||||||
|
char* keyStart = tail; // remember key start for return
|
||||||
|
char* keyEnd = tail; // key end for truncate, will updated
|
||||||
|
|
||||||
|
while (*tail && *tail != '|' && *tail != ':')
|
||||||
++tail;
|
++tail;
|
||||||
|
|
||||||
if (!*tail)
|
if (!*tail)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tail += 2;
|
keyEnd = tail; // remember key end for truncate
|
||||||
|
|
||||||
|
// |h[name]|h|r or :something...|h[name]|h|r
|
||||||
|
|
||||||
|
char* somethingStart = tail+1;
|
||||||
|
char* somethingEnd = tail+1; // will updated later if need
|
||||||
|
|
||||||
|
if (*tail == ':' && somethingPair) // optional data extraction
|
||||||
|
{
|
||||||
|
// :something...|h[name]|h|r
|
||||||
|
|
||||||
|
if (*tail == ':')
|
||||||
|
++tail;
|
||||||
|
|
||||||
|
// something|h[name]|h|r or something:something2...|h[name]|h|r
|
||||||
|
|
||||||
|
while (*tail && *tail != '|' && *tail != ':')
|
||||||
|
++tail;
|
||||||
|
|
||||||
|
if (!*tail)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
somethingEnd = tail; // remember data end for truncate
|
||||||
|
}
|
||||||
|
|
||||||
|
// |h[name]|h|r or :something2...|h[name]|h|r
|
||||||
|
|
||||||
|
while (*tail && (*tail != '|' || *(tail+1) != 'h')) // skip ... part if exist
|
||||||
|
++tail;
|
||||||
|
|
||||||
|
if (!*tail)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// |h[name]|h|r
|
||||||
|
|
||||||
|
tail += 2; // skip |h
|
||||||
|
|
||||||
// [name]|h|r
|
// [name]|h|r
|
||||||
if (!*tail || *tail != '[')
|
if (!*tail || *tail != '[')
|
||||||
|
|
@ -2340,23 +2446,38 @@ char* ChatHandler::ExtractLinkArg( char** args )
|
||||||
while (*tail && (*tail != ']' || *(tail+1) != '|')) // skip name part
|
while (*tail && (*tail != ']' || *(tail+1) != '|')) // skip name part
|
||||||
++tail;
|
++tail;
|
||||||
|
|
||||||
tail += 2;
|
tail += 2; // skip ]|
|
||||||
|
|
||||||
// h|r
|
// h|r
|
||||||
if (!*tail || *tail != 'h' || *(tail+1) != '|')
|
if (!*tail || *tail != 'h' || *(tail+1) != '|')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tail += 2;
|
tail += 2; // skip h|
|
||||||
|
|
||||||
// r
|
// r
|
||||||
if (!*tail || *tail != 'r' || *(tail+1) && !isWhiteSpace(*(tail+1)))
|
if (!*tail || *tail != 'r' || *(tail+1) && !isWhiteSpace(*(tail+1)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
++tail;
|
++tail; // skip r
|
||||||
|
|
||||||
if (*tail)
|
// success
|
||||||
{
|
|
||||||
|
if (*tail) // truncate all link string
|
||||||
*(tail++) = '\0';
|
*(tail++) = '\0';
|
||||||
|
|
||||||
|
if (foundIdx)
|
||||||
|
*foundIdx = linktype_idx;
|
||||||
|
|
||||||
|
if (keyPair)
|
||||||
|
{
|
||||||
|
keyPair[0] = keyStart;
|
||||||
|
keyPair[1] = keyEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (somethingPair)
|
||||||
|
{
|
||||||
|
somethingPair[0] = somethingStart;
|
||||||
|
somethingPair[1] = somethingEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
*args = tail;
|
*args = tail;
|
||||||
|
|
@ -2377,21 +2498,11 @@ char* ChatHandler::ExtractArg( char** args )
|
||||||
if (!*args || !**args)
|
if (!*args || !**args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (**args)
|
char* arg = ExtractQuotedOrLiteralArg(args);
|
||||||
{
|
if (!arg)
|
||||||
case '|' :
|
arg = ExtractLinkArg(args);
|
||||||
return ExtractLinkArg(args);
|
|
||||||
case '\'' : case '"' : case '[' :
|
|
||||||
return ExtractQuotedArg(args);
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
char* name = strtok(*args, " ");
|
|
||||||
|
|
||||||
*args = strtok(NULL, "");
|
return arg;
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2415,116 +2526,102 @@ char* ChatHandler::ExtractOptNotLastArg(char** args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
|
/**
|
||||||
|
* Function extract data from shift-link "|color|LINKTYPE:RETURN:SOMETHING1|h[name]|h|r if linkType == LINKTYPE
|
||||||
|
* It also extract literal/quote if not shift-link in args
|
||||||
|
*
|
||||||
|
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
||||||
|
* if args have sift link with linkType != LINKTYPE then args still pointing to this arg (unmodified pointer)
|
||||||
|
*
|
||||||
|
* @param linkType shift-link must fit by link type to this arg value or extraction fail
|
||||||
|
*
|
||||||
|
* @param something1 if not NULL then shift-link must have data field and it returned into this arg
|
||||||
|
* if extraction fail then non modified
|
||||||
|
*
|
||||||
|
* @return extracted key, or NULL if args empty or not appropriate content or not fit to linkType.
|
||||||
|
*/
|
||||||
|
char* ChatHandler::ExtractKeyFromLink(char** text, char const* linkType, char** something1 /*= NULL*/)
|
||||||
{
|
{
|
||||||
// skip empty
|
char const* linkTypes[2];
|
||||||
if(!text)
|
linkTypes[0] = linkType;
|
||||||
return NULL;
|
linkTypes[1] = NULL;
|
||||||
|
|
||||||
// skip speces
|
int foundIdx;
|
||||||
while(*text==' '||*text=='\t'||*text=='\b')
|
|
||||||
++text;
|
|
||||||
|
|
||||||
if(!*text)
|
return ExtractKeyFromLink(text, linkTypes, &foundIdx, something1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// return non link case
|
|
||||||
if(text[0]!='|')
|
|
||||||
return strtok(text, " ");
|
|
||||||
|
|
||||||
// [name] Shift-click form |color|linkType:key|h[name]|h|r
|
|
||||||
// or
|
|
||||||
// [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
|
|
||||||
|
|
||||||
char* check = strtok(text, "|"); // skip color
|
|
||||||
if(!check)
|
|
||||||
return NULL; // end of data
|
|
||||||
|
|
||||||
char* cLinkType = strtok(NULL, ":"); // linktype
|
|
||||||
if(!cLinkType)
|
|
||||||
return NULL; // end of data
|
|
||||||
|
|
||||||
if(strcmp(cLinkType,linkType) != 0)
|
|
||||||
{
|
|
||||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after retturn from function
|
|
||||||
SendSysMessage(LANG_WRONG_LINK_TYPE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* cKeys = strtok(NULL, "|"); // extract keys and values
|
|
||||||
char* cKeysTail = strtok(NULL, "");
|
|
||||||
|
|
||||||
char* cKey = strtok(cKeys, ":|"); // extract key
|
|
||||||
if(something1)
|
|
||||||
*something1 = strtok(NULL, ":|"); // extract something
|
|
||||||
|
|
||||||
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
|
|
||||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function
|
|
||||||
return cKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1)
|
/**
|
||||||
|
* Function extract data from shift-link "|color|LINKTYPE:RETURN:SOMETHING1|h[name]|h|r if LINKTYPE in linkTypes array
|
||||||
|
* It also extract literal/quote if not shift-link in args
|
||||||
|
*
|
||||||
|
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
||||||
|
* if args have sift link with linkType != LINKTYPE then args still pointing to this arg (unmodified pointer)
|
||||||
|
*
|
||||||
|
* @param linkTypes NULL-terminated array of link types, shift-link must fit one from link type from array or extraction fail
|
||||||
|
*
|
||||||
|
* @param found_idx if not NULL then at return index in linkTypes that fit shift-link type, for non-link case return -1
|
||||||
|
* if extraction fail then non modified
|
||||||
|
*
|
||||||
|
* @param something1 if not NULL then shift-link must have data field and it returned into this arg
|
||||||
|
* if extraction fail then non modified
|
||||||
|
*
|
||||||
|
* @return extracted key, or NULL if args empty or not appropriate content or not fit to linkType.
|
||||||
|
*/
|
||||||
|
char* ChatHandler::ExtractKeyFromLink(char** text, char const* const* linkTypes, int* found_idx, char** something1 /*= NULL*/)
|
||||||
{
|
{
|
||||||
// skip empty
|
// skip empty
|
||||||
if(!text)
|
if (!*text || !**text)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// skip speces
|
|
||||||
while(*text==' '||*text=='\t'||*text=='\b')
|
|
||||||
++text;
|
|
||||||
|
|
||||||
if(!*text)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// return non link case
|
// return non link case
|
||||||
if(text[0]!='|')
|
char* arg = ExtractQuotedOrLiteralArg(text);
|
||||||
return strtok(text, " ");
|
if (arg)
|
||||||
|
|
||||||
// [name] Shift-click form |color|linkType:key|h[name]|h|r
|
|
||||||
// or
|
|
||||||
// [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r
|
|
||||||
// or
|
|
||||||
// [name] Shift-click form |linkType:key|h[name]|h|r
|
|
||||||
|
|
||||||
char* tail;
|
|
||||||
|
|
||||||
if(text[1]=='c')
|
|
||||||
{
|
{
|
||||||
char* check = strtok(text, "|"); // skip color
|
if (found_idx)
|
||||||
if(!check)
|
*found_idx = -1; // special index case
|
||||||
return NULL; // end of data
|
|
||||||
|
|
||||||
tail = strtok(NULL, ""); // tail
|
return arg;
|
||||||
}
|
|
||||||
else
|
|
||||||
tail = text+1; // skip first |
|
|
||||||
|
|
||||||
char* cLinkType = strtok(tail, ":"); // linktype
|
|
||||||
if(!cLinkType)
|
|
||||||
return NULL; // end of data
|
|
||||||
|
|
||||||
for(int i = 0; linkTypes[i]; ++i)
|
|
||||||
{
|
|
||||||
if(strcmp(cLinkType,linkTypes[i]) == 0)
|
|
||||||
{
|
|
||||||
char* cKeys = strtok(NULL, "|"); // extract keys and values
|
|
||||||
char* cKeysTail = strtok(NULL, "");
|
|
||||||
|
|
||||||
char* cKey = strtok(cKeys, ":|"); // extract key
|
|
||||||
if(something1)
|
|
||||||
*something1 = strtok(NULL, ":|"); // extract something
|
|
||||||
|
|
||||||
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
|
|
||||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function
|
|
||||||
if(found_idx)
|
|
||||||
*found_idx = i;
|
|
||||||
return cKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function
|
char* keyPair[2];
|
||||||
SendSysMessage(LANG_WRONG_LINK_TYPE);
|
char* somethingPair[2];
|
||||||
|
|
||||||
|
arg = ExtractLinkArg(text, linkTypes, found_idx, keyPair, something1 ? somethingPair : NULL);
|
||||||
|
if (!arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
*keyPair[1] = '\0'; // truncate key string
|
||||||
|
|
||||||
|
if (something1)
|
||||||
|
{
|
||||||
|
*somethingPair[1] = '\0'; // truncate data string
|
||||||
|
*something1 = somethingPair[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyPair[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function extract uint32 key from shift-link "|color|LINKTYPE:RETURN|h[name]|h|r if linkType == LINKTYPE
|
||||||
|
* It also extract direct number if not shift-link in args
|
||||||
|
*
|
||||||
|
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
||||||
|
* if args have sift link with linkType != LINKTYPE then args still pointing to this arg (unmodified pointer)
|
||||||
|
*
|
||||||
|
* @param linkType shift-link must fit by link type to this arg value or extraction fail
|
||||||
|
*
|
||||||
|
* @param value store result value at success return, not modified at fail
|
||||||
|
*
|
||||||
|
* @return true if extraction succesful
|
||||||
|
*/
|
||||||
|
bool ChatHandler::ExtractUint32KeyFromLink(char** text, char const* linkType, uint32& value)
|
||||||
|
{
|
||||||
|
char* arg = ExtractKeyFromLink(text, linkType);
|
||||||
|
if (!arg)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ExtractUInt32(&arg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry)
|
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry)
|
||||||
|
|
@ -2548,11 +2645,12 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
|
||||||
|
|
||||||
enum SpellLinkType
|
enum SpellLinkType
|
||||||
{
|
{
|
||||||
|
SPELL_LINK_RAW =-1, // non-link case
|
||||||
SPELL_LINK_SPELL = 0,
|
SPELL_LINK_SPELL = 0,
|
||||||
SPELL_LINK_TALENT = 1,
|
SPELL_LINK_TALENT = 1,
|
||||||
SPELL_LINK_ENCHANT = 2,
|
SPELL_LINK_ENCHANT = 2,
|
||||||
SPELL_LINK_TRADE = 3,
|
SPELL_LINK_TRADE = 3,
|
||||||
SPELL_LINK_GLYPH = 4
|
SPELL_LINK_GLYPH = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char const* const spellKeys[] =
|
static char const* const spellKeys[] =
|
||||||
|
|
@ -2562,27 +2660,32 @@ static char const* const spellKeys[] =
|
||||||
"Henchant", // enchanting recipe spell
|
"Henchant", // enchanting recipe spell
|
||||||
"Htrade", // profession/skill spell
|
"Htrade", // profession/skill spell
|
||||||
"Hglyph", // glyph
|
"Hglyph", // glyph
|
||||||
0
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
uint32 ChatHandler::ExtractSpellIdFromLink(char** text)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r
|
// number or [name] Shift-click form |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r
|
||||||
// number or [name] Shift-click form |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r
|
// number or [name] Shift-click form |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r
|
||||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
|
||||||
// number or [name] Shift-click form |color|Htalent:talent_id,rank|h[name]|h|r
|
// number or [name] Shift-click form |color|Htalent:talent_id,rank|h[name]|h|r
|
||||||
// number or [name] Shift-click form |color|Htrade:spell_id,skill_id,max_value,cur_value|h[name]|h|r
|
// number or [name] Shift-click form |color|Htrade:spell_id,skill_id,max_value,cur_value|h[name]|h|r
|
||||||
int type = 0;
|
int type;
|
||||||
char* param1_str = NULL;
|
char* param1_str = NULL;
|
||||||
char* idS = extractKeyFromLink(text,spellKeys,&type,¶m1_str);
|
char* idS = ExtractKeyFromLink(text, spellKeys, &type, ¶m1_str);
|
||||||
if(!idS)
|
if (!idS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return 0;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
case SPELL_LINK_RAW:
|
||||||
case SPELL_LINK_SPELL:
|
case SPELL_LINK_SPELL:
|
||||||
|
case SPELL_LINK_ENCHANT:
|
||||||
|
case SPELL_LINK_TRADE:
|
||||||
return id;
|
return id;
|
||||||
case SPELL_LINK_TALENT:
|
case SPELL_LINK_TALENT:
|
||||||
{
|
{
|
||||||
|
|
@ -2591,27 +2694,21 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||||
if(!talentEntry)
|
if(!talentEntry)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 rank = param1_str ? (uint32)atol(param1_str) : 0;
|
uint32 rank;
|
||||||
if(rank >= MAX_TALENT_RANK)
|
if (!ExtractUInt32(¶m1_str, rank))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(rank < 0)
|
return rank < MAX_TALENT_RANK ? talentEntry->RankID[rank] : 0;
|
||||||
rank = 0;
|
|
||||||
|
|
||||||
return talentEntry->RankID[rank];
|
|
||||||
}
|
}
|
||||||
case SPELL_LINK_ENCHANT:
|
|
||||||
case SPELL_LINK_TRADE:
|
|
||||||
return id;
|
|
||||||
case SPELL_LINK_GLYPH:
|
case SPELL_LINK_GLYPH:
|
||||||
{
|
{
|
||||||
uint32 glyph_prop_id = param1_str ? (uint32)atol(param1_str) : 0;
|
uint32 glyph_prop_id;
|
||||||
|
|
||||||
GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id);
|
if (!ExtractUInt32(¶m1_str, glyph_prop_id))
|
||||||
if(!glyphPropEntry)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return glyphPropEntry->SpellId;
|
GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id);
|
||||||
|
return glyphPropEntry ? glyphPropEntry->SpellId : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2619,26 +2716,27 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
|
GameTele const* ChatHandler::ExtractGameTeleFromLink(char** text)
|
||||||
{
|
{
|
||||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(text,"Htele");
|
char* cId = ExtractKeyFromLink(text,"Htele");
|
||||||
if(!cId)
|
if (!cId)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// id case (explicit or from shift link)
|
// id case (explicit or from shift link)
|
||||||
if(cId[0] >= '0' || cId[0] >= '9')
|
uint32 id;
|
||||||
if(uint32 id = atoi(cId))
|
if (ExtractUInt32(&cId, id))
|
||||||
return sObjectMgr.GetGameTele(id);
|
return sObjectMgr.GetGameTele(id);
|
||||||
|
else
|
||||||
return sObjectMgr.GetGameTele(cId);
|
return sObjectMgr.GetGameTele(cId);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GuidLinkType
|
enum GuidLinkType
|
||||||
{
|
{
|
||||||
SPELL_LINK_PLAYER = 0, // must be first for selection in not link case
|
GUID_LINK_RAW =-1, // non-link case
|
||||||
SPELL_LINK_CREATURE = 1,
|
GUID_LINK_PLAYER = 0,
|
||||||
SPELL_LINK_GAMEOBJECT = 2
|
GUID_LINK_CREATURE = 1,
|
||||||
|
GUID_LINK_GAMEOBJECT = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char const* const guidKeys[] =
|
static char const* const guidKeys[] =
|
||||||
|
|
@ -2649,60 +2747,66 @@ static char const* const guidKeys[] =
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64 ChatHandler::extractGuidFromLink(char* text)
|
ObjectGuid ChatHandler::ExtractGuidFromLink(char** text)
|
||||||
{
|
{
|
||||||
int type = 0;
|
int type = 0;
|
||||||
|
|
||||||
// |color|Hcreature:creature_guid|h[name]|h|r
|
// |color|Hcreature:creature_guid|h[name]|h|r
|
||||||
// |color|Hgameobject:go_guid|h[name]|h|r
|
// |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
// |color|Hplayer:name|h[name]|h|r
|
// |color|Hplayer:name|h[name]|h|r
|
||||||
char* idS = extractKeyFromLink(text,guidKeys,&type);
|
char* idS = ExtractKeyFromLink(text, guidKeys, &type);
|
||||||
if(!idS)
|
if (!idS)
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SPELL_LINK_PLAYER:
|
case GUID_LINK_RAW:
|
||||||
|
case GUID_LINK_PLAYER:
|
||||||
{
|
{
|
||||||
std::string name = idS;
|
std::string name = idS;
|
||||||
if(!normalizePlayerName(name))
|
if (!normalizePlayerName(name))
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
|
|
||||||
if(Player* player = sObjectMgr.GetPlayer(name.c_str()))
|
if (Player* player = sObjectMgr.GetPlayer(name.c_str()))
|
||||||
return player->GetGUID();
|
return player->GetObjectGuid();
|
||||||
|
|
||||||
if(uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
|
if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
|
||||||
return guid;
|
return ObjectGuid(guid);
|
||||||
|
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
}
|
}
|
||||||
case SPELL_LINK_CREATURE:
|
case GUID_LINK_CREATURE:
|
||||||
{
|
{
|
||||||
uint32 lowguid = (uint32)atol(idS);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&idS, lowguid))
|
||||||
|
return ObjectGuid();
|
||||||
|
|
||||||
if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) )
|
if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid))
|
||||||
return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT);
|
return ObjectGuid(HIGHGUID_UNIT, data->id, lowguid);
|
||||||
else
|
else
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
}
|
}
|
||||||
case SPELL_LINK_GAMEOBJECT:
|
case GUID_LINK_GAMEOBJECT:
|
||||||
{
|
{
|
||||||
uint32 lowguid = (uint32)atol(idS);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&idS, lowguid))
|
||||||
|
return ObjectGuid();
|
||||||
|
|
||||||
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
|
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
|
||||||
return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_GAMEOBJECT);
|
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
|
||||||
else
|
else
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown type?
|
// unknown type?
|
||||||
return 0;
|
return ObjectGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum LocationLinkType
|
enum LocationLinkType
|
||||||
{
|
{
|
||||||
LOCATION_LINK_PLAYER = 0, // must be first for selection in not link case
|
LOCATION_LINK_RAW =-1, // non-link case
|
||||||
|
LOCATION_LINK_PLAYER = 0,
|
||||||
LOCATION_LINK_TELE = 1,
|
LOCATION_LINK_TELE = 1,
|
||||||
LOCATION_LINK_TAXINODE = 2,
|
LOCATION_LINK_TAXINODE = 2,
|
||||||
LOCATION_LINK_CREATURE = 3,
|
LOCATION_LINK_CREATURE = 3,
|
||||||
|
|
@ -2727,7 +2831,7 @@ static char const* const locationKeys[] =
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, float& y, float& z)
|
bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, float& y, float& z)
|
||||||
{
|
{
|
||||||
int type = 0;
|
int type = 0;
|
||||||
|
|
||||||
|
|
@ -2740,24 +2844,20 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
// |color|Hgameobject_entry:go_id|h[name]|h|r
|
// |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||||
// |color|Hareatrigger:id|h[name]|h|r
|
// |color|Hareatrigger:id|h[name]|h|r
|
||||||
// |color|Hareatrigger_target:id|h[name]|h|r
|
// |color|Hareatrigger_target:id|h[name]|h|r
|
||||||
char* idS = extractKeyFromLink(text,locationKeys,&type);
|
char* idS = ExtractKeyFromLink(text, locationKeys, &type);
|
||||||
if(!idS)
|
if (!idS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
// it also fail case
|
case LOCATION_LINK_RAW:
|
||||||
case LOCATION_LINK_PLAYER:
|
case LOCATION_LINK_PLAYER:
|
||||||
{
|
{
|
||||||
// not link and not name, possible coordinates/etc
|
|
||||||
if (isNumeric(idS[0]))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::string name = idS;
|
std::string name = idS;
|
||||||
if(!normalizePlayerName(name))
|
if (!normalizePlayerName(name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(Player* player = sObjectMgr.GetPlayer(name.c_str()))
|
if (Player* player = sObjectMgr.GetPlayer(name.c_str()))
|
||||||
{
|
{
|
||||||
mapid = player->GetMapId();
|
mapid = player->GetMapId();
|
||||||
x = player->GetPositionX();
|
x = player->GetPositionX();
|
||||||
|
|
@ -2766,7 +2866,7 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
|
if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
|
||||||
{
|
{
|
||||||
// to point where player stay (if loaded)
|
// to point where player stay (if loaded)
|
||||||
float o;
|
float o;
|
||||||
|
|
@ -2778,7 +2878,10 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_TELE:
|
case LOCATION_LINK_TELE:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
GameTele const* tele = sObjectMgr.GetGameTele(id);
|
GameTele const* tele = sObjectMgr.GetGameTele(id);
|
||||||
if (!tele)
|
if (!tele)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2790,7 +2893,10 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_TAXINODE:
|
case LOCATION_LINK_TAXINODE:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
|
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2802,7 +2908,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_CREATURE:
|
case LOCATION_LINK_CREATURE:
|
||||||
{
|
{
|
||||||
uint32 lowguid = (uint32)atol(idS);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&idS, lowguid))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) )
|
if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) )
|
||||||
{
|
{
|
||||||
|
|
@ -2817,7 +2925,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_GAMEOBJECT:
|
case LOCATION_LINK_GAMEOBJECT:
|
||||||
{
|
{
|
||||||
uint32 lowguid = (uint32)atol(idS);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&idS, lowguid))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
|
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
|
||||||
{
|
{
|
||||||
|
|
@ -2832,7 +2942,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_CREATURE_ENTRY:
|
case LOCATION_LINK_CREATURE_ENTRY:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (sObjectMgr.GetCreatureTemplate(id))
|
if (sObjectMgr.GetCreatureTemplate(id))
|
||||||
{
|
{
|
||||||
|
|
@ -2856,7 +2968,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_GAMEOBJECT_ENTRY:
|
case LOCATION_LINK_GAMEOBJECT_ENTRY:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (sObjectMgr.GetGameObjectInfo(id))
|
if (sObjectMgr.GetGameObjectInfo(id))
|
||||||
{
|
{
|
||||||
|
|
@ -2880,7 +2994,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_AREATRIGGER:
|
case LOCATION_LINK_AREATRIGGER:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id);
|
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id);
|
||||||
if (!atEntry)
|
if (!atEntry)
|
||||||
|
|
@ -2898,7 +3014,9 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
}
|
}
|
||||||
case LOCATION_LINK_AREATRIGGER_TARGET:
|
case LOCATION_LINK_AREATRIGGER_TARGET:
|
||||||
{
|
{
|
||||||
uint32 id = (uint32)atol(idS);
|
uint32 id;
|
||||||
|
if (!ExtractUInt32(&idS, id))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!sAreaTriggerStore.LookupEntry(id))
|
if (!sAreaTriggerStore.LookupEntry(id))
|
||||||
{
|
{
|
||||||
|
|
@ -2927,10 +3045,10 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ChatHandler::extractPlayerNameFromLink(char* text)
|
std::string ChatHandler::ExtractPlayerNameFromLink(char** text)
|
||||||
{
|
{
|
||||||
// |color|Hplayer:name|h[name]|h|r
|
// |color|Hplayer:name|h[name]|h|r
|
||||||
char* name_str = extractKeyFromLink(text,"Hplayer");
|
char* name_str = ExtractKeyFromLink(text, "Hplayer");
|
||||||
if(!name_str)
|
if(!name_str)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|
@ -2941,11 +3059,24 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=NULL*/,std::string* player_name /*= NULL*/)
|
/**
|
||||||
|
* Function extract at least one from request player data (pointer/guid/name) from args name/shift-link or selected player if no args
|
||||||
|
*
|
||||||
|
* @param args variable pointer to non parsed args string, updated at function call to new position (with skipped white spaces)
|
||||||
|
*
|
||||||
|
* @param player optional arg One from 3 optional args must be provided at least (or more).
|
||||||
|
* @param player_guid optional arg For function success only one from provided args need get result
|
||||||
|
* @param player_name optional arg But if early arg get value then all later args will have its (if requested)
|
||||||
|
* if player_guid requested and not found then name also will not found
|
||||||
|
* So at success can be returned 2 cases: (player/guid/name) or (guid/name)
|
||||||
|
*
|
||||||
|
* @return true if extraction successful
|
||||||
|
*/
|
||||||
|
bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, uint64* player_guid /*= NULL*/,std::string* player_name /*= NULL*/)
|
||||||
{
|
{
|
||||||
if (args && *args)
|
if (*args && **args)
|
||||||
{
|
{
|
||||||
std::string name = extractPlayerNameFromLink(args);
|
std::string name = ExtractPlayerNameFromLink(args);
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
|
|
@ -2994,12 +3125,12 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ChatHandler::extractAccountId(char* args, std::string* accountName /*= NULL*/, Player** targetIfNullArg /*= NULL*/)
|
uint32 ChatHandler::ExtractAccountId(char** args, std::string* accountName /*= NULL*/, Player** targetIfNullArg /*= NULL*/)
|
||||||
{
|
{
|
||||||
uint32 account_id = 0;
|
uint32 account_id = 0;
|
||||||
|
|
||||||
///- Get the account name from the command line
|
///- Get the account name from the command line
|
||||||
char* account_str = args ? strtok (args," ") : NULL;
|
char* account_str = ExtractLiteralArg(args);
|
||||||
|
|
||||||
if (!account_str)
|
if (!account_str)
|
||||||
{
|
{
|
||||||
|
|
@ -3024,18 +3155,8 @@ uint32 ChatHandler::extractAccountId(char* args, std::string* accountName /*= NU
|
||||||
|
|
||||||
std::string account_name;
|
std::string account_name;
|
||||||
|
|
||||||
if (isNumeric(account_str))
|
if (ExtractUInt32(&account_str, account_id))
|
||||||
{
|
{
|
||||||
long id = atol(account_str);
|
|
||||||
if (id <= 0 || ((unsigned long)id) >= std::numeric_limits<uint32>::max())
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
account_id = uint32(id);
|
|
||||||
|
|
||||||
if (!sAccountMgr.GetName(account_id, account_name))
|
if (!sAccountMgr.GetName(account_id, account_name))
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str);
|
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@
|
||||||
#ifndef MANGOSSERVER_CHAT_H
|
#ifndef MANGOSSERVER_CHAT_H
|
||||||
#define MANGOSSERVER_CHAT_H
|
#define MANGOSSERVER_CHAT_H
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
struct AchievementEntry;
|
struct AchievementEntry;
|
||||||
struct AreaTrigger;
|
struct AreaTrigger;
|
||||||
|
|
@ -563,30 +565,31 @@ class ChatHandler
|
||||||
bool ExtractFloat(char** args, float& val);
|
bool ExtractFloat(char** args, float& val);
|
||||||
bool ExtractOptFloat(char** args, float& val, float defVal);
|
bool ExtractOptFloat(char** args, float& val, float defVal);
|
||||||
char* ExtractQuotedArg(char** args); // string with " or [] or ' around
|
char* ExtractQuotedArg(char** args); // string with " or [] or ' around
|
||||||
char* ExtractLinkArg(char** args); // shift-link like arg
|
|
||||||
char* ExtractLiteralArg(char** args, char const* lit = NULL);
|
char* ExtractLiteralArg(char** args, char const* lit = NULL);
|
||||||
// literal string (until whitespace and not started from "['|), any or 'lit' if provided
|
// literal string (until whitespace and not started from "['|), any or 'lit' if provided
|
||||||
char* ExtractQuotedOrLiteralArg(char** args);
|
char* ExtractQuotedOrLiteralArg(char** args);
|
||||||
bool ExtractOnOff(char** args, bool& value);
|
bool ExtractOnOff(char** args, bool& value);
|
||||||
|
char* ExtractLinkArg(char** args, char const* const* linkTypes = NULL, int* foundIdx = NULL, char** keyPair = NULL, char** somethingPair = NULL);
|
||||||
|
// shift-link like arg (with aditional info if need)
|
||||||
char* ExtractArg(char** args); // any name/number/quote/shift-link strings
|
char* ExtractArg(char** args); // any name/number/quote/shift-link strings
|
||||||
char* ExtractOptNotLastArg(char** args); // extract name/number/quote/shift-link arg only if more data in args for parse
|
char* ExtractOptNotLastArg(char** args); // extract name/number/quote/shift-link arg only if more data in args for parse
|
||||||
|
|
||||||
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL);
|
char* ExtractKeyFromLink(char** text, char const* linkType, char** something1 = NULL);
|
||||||
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL);
|
char* ExtractKeyFromLink(char** text, char const* const* linkTypes, int* found_idx = NULL, char** something1 = NULL);
|
||||||
|
bool ExtractUint32KeyFromLink(char** text, char const* linkType, uint32& value);
|
||||||
|
|
||||||
uint32 extractSpellIdFromLink(char* text);
|
uint32 ExtractAccountId(char** args, std::string* accountName = NULL, Player** targetIfNullArg = NULL);
|
||||||
uint64 extractGuidFromLink(char* text);
|
uint32 ExtractSpellIdFromLink(char** text);
|
||||||
GameTele const* extractGameTeleFromLink(char* text);
|
ObjectGuid ExtractGuidFromLink(char** text);
|
||||||
bool extractLocationFromLink(char* text, uint32& mapid, float& x, float& y, float& z);
|
GameTele const* ExtractGameTeleFromLink(char** text);
|
||||||
std::string extractPlayerNameFromLink(char* text);
|
bool ExtractLocationFromLink(char** text, uint32& mapid, float& x, float& y, float& z);
|
||||||
|
std::string ExtractPlayerNameFromLink(char** text);
|
||||||
|
bool ExtractPlayerTarget(char** args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
|
||||||
// select by arg (name/link) or in-game selection online/offline player
|
// select by arg (name/link) or in-game selection online/offline player
|
||||||
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
|
|
||||||
|
|
||||||
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
|
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
|
||||||
std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
|
std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
|
||||||
|
|
||||||
uint32 extractAccountId(char* args, std::string* accountName = NULL, Player** targetIfNullArg = NULL);
|
|
||||||
|
|
||||||
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
|
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
|
||||||
|
|
||||||
// Utility methods for commands
|
// Utility methods for commands
|
||||||
|
|
|
||||||
|
|
@ -97,27 +97,24 @@ bool ChatHandler::HandleNpcTextEmoteCommand(char* args)
|
||||||
// make npc whisper to player
|
// make npc whisper to player
|
||||||
bool ChatHandler::HandleNpcWhisperCommand(char* args)
|
bool ChatHandler::HandleNpcWhisperCommand(char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
Player* target;
|
||||||
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* receiver_str = strtok(args, " ");
|
|
||||||
char* text = strtok(NULL, "");
|
|
||||||
|
|
||||||
uint64 guid = m_session->GetPlayer()->GetSelection();
|
uint64 guid = m_session->GetPlayer()->GetSelection();
|
||||||
|
if (!guid)
|
||||||
|
return false;
|
||||||
|
|
||||||
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid);
|
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid);
|
||||||
|
|
||||||
if(!pCreature || !receiver_str || !text)
|
if(!pCreature || !target || !*args)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
uint64 receiver_guid= atol(receiver_str);
|
|
||||||
|
|
||||||
// check online security
|
// check online security
|
||||||
if (HasLowerSecurity(sObjectMgr.GetPlayer(receiver_guid), 0))
|
if (HasLowerSecurity(target, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pCreature->MonsterWhisper(text,receiver_guid);
|
pCreature->MonsterWhisper(args, target->GetGUID());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -255,8 +252,8 @@ bool ChatHandler::HandleGPSCommand(char* args)
|
||||||
WorldObject *obj = NULL;
|
WorldObject *obj = NULL;
|
||||||
if (*args)
|
if (*args)
|
||||||
{
|
{
|
||||||
uint64 guid = extractGuidFromLink(args);
|
ObjectGuid guid = ExtractGuidFromLink(&args);
|
||||||
if(guid)
|
if (!guid.IsEmpty())
|
||||||
obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
|
obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
|
||||||
|
|
||||||
if(!obj)
|
if(!obj)
|
||||||
|
|
@ -355,7 +352,7 @@ bool ChatHandler::HandleNamegoCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args,&target,&target_guid,&target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
@ -476,7 +473,7 @@ bool ChatHandler::HandleGonameCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args,&target,&target_guid,&target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
@ -613,7 +610,7 @@ bool ChatHandler::HandleGonameCommand(char* args)
|
||||||
bool ChatHandler::HandleRecallCommand(char* args)
|
bool ChatHandler::HandleRecallCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if(!extractPlayerTarget(args,&target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check online security
|
// check online security
|
||||||
|
|
@ -821,11 +818,6 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args)
|
||||||
//Edit Player Faction
|
//Edit Player Faction
|
||||||
bool ChatHandler::HandleModifyFactionCommand(char* args)
|
bool ChatHandler::HandleModifyFactionCommand(char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char* pfactionid = extractKeyFromLink(args,"Hfaction");
|
|
||||||
|
|
||||||
Creature* chr = getSelectedCreature();
|
Creature* chr = getSelectedCreature();
|
||||||
if(!chr)
|
if(!chr)
|
||||||
{
|
{
|
||||||
|
|
@ -834,7 +826,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pfactionid)
|
if (!*args)
|
||||||
{
|
{
|
||||||
if(chr)
|
if(chr)
|
||||||
{
|
{
|
||||||
|
|
@ -854,30 +846,9 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 factionid = atoi(pfactionid);
|
uint32 factionid;
|
||||||
uint32 flag;
|
if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionid))
|
||||||
|
return false;
|
||||||
char *pflag = strtok(NULL, " ");
|
|
||||||
if (!pflag)
|
|
||||||
flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
|
|
||||||
else
|
|
||||||
flag = atoi(pflag);
|
|
||||||
|
|
||||||
char* pnpcflag = strtok(NULL, " ");
|
|
||||||
|
|
||||||
uint32 npcflag;
|
|
||||||
if(!pnpcflag)
|
|
||||||
npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
|
|
||||||
else
|
|
||||||
npcflag = atoi(pnpcflag);
|
|
||||||
|
|
||||||
char* pdyflag = strtok(NULL, " ");
|
|
||||||
|
|
||||||
uint32 dyflag;
|
|
||||||
if(!pdyflag)
|
|
||||||
dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
|
|
||||||
else
|
|
||||||
dyflag = atoi(pdyflag);
|
|
||||||
|
|
||||||
if(!sFactionTemplateStore.LookupEntry(factionid))
|
if(!sFactionTemplateStore.LookupEntry(factionid))
|
||||||
{
|
{
|
||||||
|
|
@ -886,7 +857,19 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
|
uint32 flag;
|
||||||
|
if (!ExtractOptUInt32(&args, flag, chr->GetUInt32Value(UNIT_FIELD_FLAGS)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 npcflag;
|
||||||
|
if (!ExtractOptUInt32(&args, npcflag, chr->GetUInt32Value(UNIT_NPC_FLAGS)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 dyflag;
|
||||||
|
if (!ExtractOptUInt32(&args, dyflag, chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag);
|
||||||
|
|
||||||
chr->setFaction(factionid);
|
chr->setFaction(factionid);
|
||||||
chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
|
chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
|
||||||
|
|
@ -1593,7 +1576,7 @@ bool ChatHandler::HandleTeleCommand(char* args)
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
GameTele const* tele = extractGameTeleFromLink(args);
|
GameTele const* tele = ExtractGameTeleFromLink(&args);
|
||||||
|
|
||||||
if (!tele)
|
if (!tele)
|
||||||
{
|
{
|
||||||
|
|
@ -1762,18 +1745,14 @@ bool ChatHandler::HandleSendMailCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* tail = strtok(NULL, "");
|
char* msgSubject = ExtractQuotedArg(&args);
|
||||||
if(!tail)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char* msgSubject = ExtractQuotedArg(&tail);
|
|
||||||
if (!msgSubject)
|
if (!msgSubject)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* msgText = ExtractQuotedArg(&tail);
|
char* msgText = ExtractQuotedArg(&args);
|
||||||
if (!msgText)
|
if (!msgText)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -1800,11 +1779,11 @@ bool ChatHandler::HandleTeleNameCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
|
if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
GameTele const* tele = extractGameTeleFromLink(args);
|
GameTele const* tele = ExtractGameTeleFromLink(&args);
|
||||||
if (!tele)
|
if (!tele)
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
||||||
|
|
@ -1868,7 +1847,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
GameTele const* tele = extractGameTeleFromLink(args);
|
GameTele const* tele = ExtractGameTeleFromLink(&args);
|
||||||
if(!tele)
|
if(!tele)
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
||||||
|
|
@ -1929,7 +1908,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
|
||||||
bool ChatHandler::HandleGroupgoCommand(char* args)
|
bool ChatHandler::HandleGroupgoCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check online security
|
// check online security
|
||||||
|
|
@ -2070,21 +2049,14 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
if (!*args)
|
uint32 nodeId;
|
||||||
|
if (!ExtractUint32KeyFromLink(&args, "Htaxinode", nodeId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* cNodeId = extractKeyFromLink(args, "Htaxinode");
|
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
|
||||||
if (!cNodeId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32 i_nodeId = atoi(cNodeId);
|
|
||||||
if (!i_nodeId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId);
|
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND,i_nodeId);
|
PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, nodeId);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -2110,27 +2082,19 @@ bool ChatHandler::HandleGoCommand(char* args)
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
|
|
||||||
// raw coordinates case
|
// raw coordinates case
|
||||||
if (isNumeric(args[0]) || args[0] == '-')
|
if (ExtractFloat(&args, x))
|
||||||
{
|
{
|
||||||
char* px = strtok(args, " ");
|
if (!ExtractFloat(&args, y))
|
||||||
char* py = strtok(NULL, " ");
|
|
||||||
char* pz = strtok(NULL, " ");
|
|
||||||
char* pmapid = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (!px || !py || !pz)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
x = (float)atof(px);
|
if (!ExtractFloat(&args, z))
|
||||||
y = (float)atof(py);
|
return false;
|
||||||
z = (float)atof(pz);
|
|
||||||
if (pmapid)
|
|
||||||
mapid = (uint32)atoi(pmapid);
|
|
||||||
else
|
|
||||||
mapid = _player->GetMapId();
|
|
||||||
|
|
||||||
|
if (!ExtractOptUInt32(&args, mapid, _player->GetMapId()))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// link case
|
// link case
|
||||||
else if (!extractLocationFromLink(args, mapid, x, y, z))
|
else if (!ExtractLocationFromLink(&args, mapid, x, y, z))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return HandleGoHelper(_player, mapid, x, y, &z);
|
return HandleGoHelper(_player, mapid, x, y, &z);
|
||||||
|
|
@ -2185,34 +2149,30 @@ bool ChatHandler::HandleGoXYZCommand(char* args)
|
||||||
//teleport at coordinates
|
//teleport at coordinates
|
||||||
bool ChatHandler::HandleGoZoneXYCommand(char* args)
|
bool ChatHandler::HandleGoZoneXYCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
char* px = strtok(args, " ");
|
float x;
|
||||||
char* py = strtok(NULL, " ");
|
if (!ExtractFloat(&args, x))
|
||||||
char* tail = strtok(NULL,"");
|
|
||||||
|
|
||||||
char* cAreaId = extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
|
|
||||||
|
|
||||||
if (!px || !py)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float x = (float)atof(px);
|
float y;
|
||||||
float y = (float)atof(py);
|
if (!ExtractFloat(&args, y))
|
||||||
|
|
||||||
// prevent accept wrong numeric args
|
|
||||||
if ((x==0.0f && *px!='0') || (y==0.0f && *py!='0'))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
|
uint32 areaid;
|
||||||
|
if (*args)
|
||||||
|
{
|
||||||
|
if (!ExtractUint32KeyFromLink(&args, "Harea", areaid))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
areaid = _player->GetZoneId();
|
||||||
|
|
||||||
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
|
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
|
||||||
|
|
||||||
if( x<0 || x>100 || y<0 || y>100 || !areaEntry )
|
if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid);
|
PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaid);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ bool ChatHandler::HandleMuteCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 notspeaktime;
|
uint32 notspeaktime;
|
||||||
|
|
@ -100,7 +100,7 @@ bool ChatHandler::HandleUnmuteCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
|
uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
|
||||||
|
|
@ -192,20 +192,18 @@ bool ChatHandler::HandleTriggerCommand(char* args)
|
||||||
// select by args
|
// select by args
|
||||||
if (*args)
|
if (*args)
|
||||||
{
|
{
|
||||||
char *atId = extractKeyFromLink(args, "Hareatrigger");
|
uint32 atId;
|
||||||
|
if (!ExtractUint32KeyFromLink(&args, "Hareatrigger", atId))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!atId)
|
if (!atId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 i_atId = atoi(atId);
|
atEntry = sAreaTriggerStore.LookupEntry(atId);
|
||||||
|
|
||||||
if (!i_atId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
atEntry = sAreaTriggerStore.LookupEntry(i_atId);
|
|
||||||
|
|
||||||
if (!atEntry)
|
if (!atEntry)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId);
|
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, atId);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -403,39 +401,35 @@ bool ChatHandler::HandleGoTriggerCommand(char* args)
|
||||||
if (!*args)
|
if (!*args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int keyIdx; // not index
|
char *atIdStr = ExtractKeyFromLink(&args, areatriggerKeys);
|
||||||
|
if (!atIdStr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 atId;
|
||||||
|
if (!ExtractUInt32(&atIdStr, atId))
|
||||||
|
return false;
|
||||||
|
|
||||||
char *atId = extractKeyFromLink(args, areatriggerKeys, &keyIdx);
|
|
||||||
if (!atId)
|
if (!atId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 i_atId = atoi(atId);
|
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(atId);
|
||||||
|
|
||||||
if (!i_atId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(i_atId);
|
|
||||||
if (!atEntry)
|
if (!atEntry)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId);
|
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, atId);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* target_str = strtok(NULL, " ");
|
bool to_target = ExtractLiteralArg(&args, "target");
|
||||||
if (target_str)
|
if (!to_target && *args) // can be fail also at syntax error
|
||||||
{
|
|
||||||
int l = strlen(target_str);
|
|
||||||
if (strncmp(target_str, "target", l) != 0)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (target_str != NULL)
|
if (to_target)
|
||||||
{
|
{
|
||||||
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(i_atId);
|
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atId);
|
||||||
if (!at)
|
if (!at)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_AREATRIGER_NOT_HAS_TARGET, i_atId);
|
PSendSysMessage(LANG_AREATRIGER_NOT_HAS_TARGET, atId);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -465,6 +459,20 @@ bool ChatHandler::HandleGoGraveyardCommand(char* args)
|
||||||
return HandleGoHelper(_player, gy->map_id, gy->x, gy->y, &gy->z);
|
return HandleGoHelper(_player, gy->map_id, gy->x, gy->y, &gy->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CreatureLinkType
|
||||||
|
{
|
||||||
|
CREATURE_LINK_RAW =-1, // non-link case
|
||||||
|
CREATURE_LINK_GUID = 0,
|
||||||
|
CREATURE_LINK_ENTRY = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static char const* const creatureKeys[] =
|
||||||
|
{
|
||||||
|
"Hcreature",
|
||||||
|
"Hcreature_entry",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
/** \brief Teleport the GM to the specified creature
|
/** \brief Teleport the GM to the specified creature
|
||||||
*
|
*
|
||||||
* .go creature <GUID> --> TP using creature.guid
|
* .go creature <GUID> --> TP using creature.guid
|
||||||
|
|
@ -484,25 +492,32 @@ bool ChatHandler::HandleGoCreatureCommand(char* args)
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
// "id" or number or [name] Shift-click form |color|Hcreature:creature_id|h[name]|h|r
|
// "id" or number or [name] Shift-click form |color|Hcreature:creature_id|h[name]|h|r
|
||||||
char* pParam1 = extractKeyFromLink(args, "Hcreature");
|
int crType;
|
||||||
|
char* pParam1 = ExtractKeyFromLink(&args, creatureKeys, &crType);
|
||||||
if (!pParam1)
|
if (!pParam1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CreatureData const* data = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
// User wants to teleport to the NPC's template entry
|
// User wants to teleport to the NPC's template entry
|
||||||
if (strcmp(pParam1, "id") == 0)
|
if (crType == CREATURE_LINK_RAW && strcmp(pParam1, "id") == 0)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
|
||||||
char* tail = strtok(NULL,"");
|
pParam1 = ExtractKeyFromLink(&args, "Hcreature_entry");
|
||||||
if (!tail)
|
if (!pParam1)
|
||||||
return false;
|
return false;
|
||||||
char* cId = extractKeyFromLink(tail,"Hcreature_entry");
|
|
||||||
if (!cId)
|
crType = CREATURE_LINK_ENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureData const* data = NULL;
|
||||||
|
|
||||||
|
switch(crType)
|
||||||
|
{
|
||||||
|
case CREATURE_LINK_ENTRY:
|
||||||
|
{
|
||||||
|
uint32 tEntry;
|
||||||
|
if (!ExtractUInt32(&pParam1, tEntry))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 tEntry = atoi(cId);
|
|
||||||
if (!tEntry)
|
if (!tEntry)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -526,13 +541,27 @@ bool ChatHandler::HandleGoCreatureCommand(char* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
data = &dataPair->second;
|
data = &dataPair->second;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
case CREATURE_LINK_GUID:
|
||||||
{
|
{
|
||||||
int32 lowguid = atoi(pParam1);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&pParam1, lowguid))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Number is invalid - maybe the user specified the mob's name
|
data = sObjectMgr.GetCreatureData(lowguid);
|
||||||
if (lowguid)
|
if (!data)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CREATURE_LINK_RAW:
|
||||||
|
{
|
||||||
|
uint32 lowguid;
|
||||||
|
if (ExtractUInt32(&pParam1, lowguid))
|
||||||
{
|
{
|
||||||
data = sObjectMgr.GetCreatureData(lowguid);
|
data = sObjectMgr.GetCreatureData(lowguid);
|
||||||
if (!data)
|
if (!data)
|
||||||
|
|
@ -542,6 +571,7 @@ bool ChatHandler::HandleGoCreatureCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Number is invalid - maybe the user specified the mob's name
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string name = pParam1;
|
std::string name = pParam1;
|
||||||
|
|
@ -580,38 +610,59 @@ bool ChatHandler::HandleGoCreatureCommand(char* args)
|
||||||
|
|
||||||
data = &dataPair->second;
|
data = &dataPair->second;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HandleGoHelper(_player, data->mapid, data->posX, data->posY, &data->posZ);
|
return HandleGoHelper(_player, data->mapid, data->posX, data->posY, &data->posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum GameobjectLinkType
|
||||||
|
{
|
||||||
|
GAMEOBJECT_LINK_RAW =-1, // non-link case
|
||||||
|
GAMEOBJECT_LINK_GUID = 0,
|
||||||
|
GAMEOBJECT_LINK_ENTRY = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static char const* const gameobjectKeys[] =
|
||||||
|
{
|
||||||
|
"Hgameobject",
|
||||||
|
"Hgameobject_entry",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
//teleport to gameobject
|
//teleport to gameobject
|
||||||
bool ChatHandler::HandleGoObjectCommand(char* args)
|
bool ChatHandler::HandleGoObjectCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
char* pParam1 = extractKeyFromLink(args, "Hgameobject");
|
int goType;
|
||||||
|
char* pParam1 = ExtractKeyFromLink(&args, gameobjectKeys, &goType);
|
||||||
if (!pParam1)
|
if (!pParam1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GameObjectData const* data = NULL;
|
// User wants to teleport to the GO's template entry
|
||||||
|
if (goType == GAMEOBJECT_LINK_RAW && strcmp(pParam1, "id") == 0)
|
||||||
// User wants to teleport to the NPC's template entry
|
|
||||||
if (strcmp(pParam1, "id") == 0)
|
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject_entry:creature_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject_entry:creature_id|h[name]|h|r
|
||||||
char* tail = strtok(NULL,"");
|
pParam1 = ExtractKeyFromLink(&args, "Hgameobject_entry");
|
||||||
if (!tail)
|
if (!pParam1)
|
||||||
return false;
|
return false;
|
||||||
char* cId = extractKeyFromLink(tail,"Hgameobject_entry");
|
|
||||||
if (!cId)
|
goType = GAMEOBJECT_LINK_ENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObjectData const* data = NULL;
|
||||||
|
|
||||||
|
switch(goType)
|
||||||
|
{
|
||||||
|
case CREATURE_LINK_ENTRY:
|
||||||
|
{
|
||||||
|
uint32 tEntry;
|
||||||
|
if (!ExtractUInt32(&pParam1, tEntry))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 tEntry = atoi(cId);
|
|
||||||
if (!tEntry)
|
if (!tEntry)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -636,15 +687,31 @@ bool ChatHandler::HandleGoObjectCommand(char* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
data = &dataPair->second;
|
data = &dataPair->second;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
case GAMEOBJECT_LINK_GUID:
|
||||||
{
|
{
|
||||||
int32 guid = atoi(pParam1);
|
uint32 lowguid;
|
||||||
|
if (!ExtractUInt32(&pParam1, lowguid))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (guid)
|
// by DB guid
|
||||||
|
data = sObjectMgr.GetGOData(lowguid);
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GAMEOBJECT_LINK_RAW:
|
||||||
|
{
|
||||||
|
uint32 lowguid;
|
||||||
|
if (ExtractUInt32(&pParam1, lowguid))
|
||||||
{
|
{
|
||||||
// by DB guid
|
// by DB guid
|
||||||
data = sObjectMgr.GetGOData(guid);
|
data = sObjectMgr.GetGOData(lowguid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||||
|
|
@ -690,6 +757,8 @@ bool ChatHandler::HandleGoObjectCommand(char* args)
|
||||||
|
|
||||||
data = &dataPair->second;
|
data = &dataPair->second;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HandleGoHelper(_player, data->mapid, data->posX, data->posY, &data->posZ);
|
return HandleGoHelper(_player, data->mapid, data->posX, data->posY, &data->posZ);
|
||||||
|
|
@ -703,15 +772,16 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args)
|
||||||
if (*args)
|
if (*args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameobject_entry");
|
char* cId = ExtractKeyFromLink(&args, "Hgameobject_entry");
|
||||||
if (!cId)
|
if (!cId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 id = atol(cId);
|
uint32 id;
|
||||||
|
if (ExtractUInt32(&cId, id))
|
||||||
if (id)
|
{
|
||||||
result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
|
result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
|
||||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
|
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string name = cId;
|
std::string name = cId;
|
||||||
|
|
@ -816,11 +886,10 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args)
|
||||||
bool ChatHandler::HandleGameObjectDeleteCommand(char* args)
|
bool ChatHandler::HandleGameObjectDeleteCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameobject");
|
uint32 lowguid;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -864,11 +933,10 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args)
|
||||||
bool ChatHandler::HandleGameObjectTurnCommand(char* args)
|
bool ChatHandler::HandleGameObjectTurnCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameobject");
|
uint32 lowguid;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -885,18 +953,9 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* po = strtok(NULL, " ");
|
|
||||||
float o;
|
float o;
|
||||||
|
if (!ExtractOptFloat(&args, o, m_session->GetPlayer()->GetOrientation()))
|
||||||
if (po)
|
return false;
|
||||||
{
|
|
||||||
o = (float)atof(po);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Player *chr = m_session->GetPlayer();
|
|
||||||
o = chr->GetOrientation();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map* map = obj->GetMap();
|
Map* map = obj->GetMap();
|
||||||
map->Remove(obj,false);
|
map->Remove(obj,false);
|
||||||
|
|
@ -918,11 +977,10 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args)
|
||||||
bool ChatHandler::HandleGameObjectMoveCommand(char* args)
|
bool ChatHandler::HandleGameObjectMoveCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args,"Hgameobject");
|
uint32 lowguid;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -939,11 +997,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* px = strtok(NULL, " ");
|
if (!args)
|
||||||
char* py = strtok(NULL, " ");
|
|
||||||
char* pz = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (!px)
|
|
||||||
{
|
{
|
||||||
Player *chr = m_session->GetPlayer();
|
Player *chr = m_session->GetPlayer();
|
||||||
|
|
||||||
|
|
@ -956,16 +1010,21 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!py || !pz)
|
float x;
|
||||||
|
if (!ExtractFloat(&args, x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float x = (float)atof(px);
|
float y;
|
||||||
float y = (float)atof(py);
|
if (!ExtractFloat(&args, y))
|
||||||
float z = (float)atof(pz);
|
return false;
|
||||||
|
|
||||||
if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z))
|
float z;
|
||||||
|
if (!ExtractFloat(&args, z))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!MapManager::IsValidMapCoord(obj->GetMapId(), x, y, z))
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId());
|
PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, obj->GetMapId());
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -989,19 +1048,17 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args)
|
||||||
//spawn go
|
//spawn go
|
||||||
bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameobject_entry");
|
uint32 id;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameobject_entry", id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 id = atol(cId);
|
|
||||||
if (!id)
|
if (!id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* spawntimeSecs = strtok(NULL, " ");
|
int32 spawntimeSecs;
|
||||||
|
if (!ExtractInt32(&args, spawntimeSecs))
|
||||||
|
return false;
|
||||||
|
|
||||||
const GameObjectInfo *gInfo = ObjectMgr::GetGameObjectInfo(id);
|
const GameObjectInfo *gInfo = ObjectMgr::GetGameObjectInfo(id);
|
||||||
|
|
||||||
|
|
@ -1038,11 +1095,7 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawntimeSecs)
|
if (spawntimeSecs)
|
||||||
{
|
pGameObj->SetRespawnTime(spawntimeSecs);
|
||||||
uint32 value = atoi((char*)spawntimeSecs);
|
|
||||||
pGameObj->SetRespawnTime(value);
|
|
||||||
//DEBUG_LOG("*** spawntimeSecs: %d", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill the gameobject data and save to the db
|
// fill the gameobject data and save to the db
|
||||||
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
||||||
|
|
@ -1069,11 +1122,10 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
bool ChatHandler::HandleGameObjectPhaseCommand(char* args)
|
bool ChatHandler::HandleGameObjectPhaseCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameobject");
|
uint32 lowguid;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -1090,9 +1142,8 @@ bool ChatHandler::HandleGameObjectPhaseCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* phaseStr = strtok (NULL, " ");
|
uint32 phasemask;
|
||||||
uint32 phasemask = phaseStr? atoi(phaseStr) : 0;
|
if (!ExtractUInt32(&args, phasemask) || !phasemask)
|
||||||
if (phasemask == 0)
|
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_BAD_VALUE);
|
SendSysMessage(LANG_BAD_VALUE);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -1280,7 +1331,7 @@ bool ChatHandler::HandleLookupAchievementCommand(char* args)
|
||||||
bool ChatHandler::HandleCharacterAchievementsCommand(char* args)
|
bool ChatHandler::HandleCharacterAchievementsCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LocaleConstant loc = GetSessionDbcLocale();
|
LocaleConstant loc = GetSessionDbcLocale();
|
||||||
|
|
@ -1411,20 +1462,20 @@ bool ChatHandler::HandleModifyRepCommand(char* args)
|
||||||
if (HasLowerSecurity(target, 0))
|
if (HasLowerSecurity(target, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* factionTxt = extractKeyFromLink(args, "Hfaction");
|
uint32 factionId;
|
||||||
if (!factionTxt)
|
if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 factionId = atoi(factionTxt);
|
if (!factionId)
|
||||||
|
return false;
|
||||||
|
|
||||||
int32 amount = 0;
|
int32 amount = 0;
|
||||||
char *rankTxt = strtok(NULL, " ");
|
if (!ExtractInt32(&args, amount))
|
||||||
if (!factionTxt || !rankTxt)
|
{
|
||||||
|
char *rankTxt = ExtractLiteralArg(&args);
|
||||||
|
if (!rankTxt)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
amount = atoi(rankTxt);
|
|
||||||
if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0]))
|
|
||||||
{
|
|
||||||
std::string rankStr = rankTxt;
|
std::string rankStr = rankTxt;
|
||||||
std::wstring wrankStr;
|
std::wstring wrankStr;
|
||||||
if (!Utf8toWStr(rankStr, wrankStr))
|
if (!Utf8toWStr(rankStr, wrankStr))
|
||||||
|
|
@ -1447,18 +1498,14 @@ bool ChatHandler::HandleModifyRepCommand(char* args)
|
||||||
|
|
||||||
if (wrank.substr(0, wrankStr.size()) == wrankStr)
|
if (wrank.substr(0, wrankStr.size()) == wrankStr)
|
||||||
{
|
{
|
||||||
char *deltaTxt = strtok(NULL, " ");
|
int32 delta;
|
||||||
if (deltaTxt)
|
if (!ExtractInt32(&args, delta) || (delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1))
|
||||||
{
|
|
||||||
int32 delta = atoi(deltaTxt);
|
|
||||||
if ((delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1))
|
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1));
|
PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1));
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
amount += delta;
|
amount += delta;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
amount += ReputationMgr::PointsInRank[r];
|
amount += ReputationMgr::PointsInRank[r];
|
||||||
|
|
@ -1499,16 +1546,14 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
if (!*args)
|
||||||
return false;
|
return false;
|
||||||
char* charID = extractKeyFromLink(args, "Hcreature_entry");
|
|
||||||
if (!charID)
|
uint32 id;
|
||||||
|
if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* team = strtok(NULL, " ");
|
uint32 team;
|
||||||
int32 teamval = 0;
|
if (!ExtractOptUInt32(&args, team, 0))
|
||||||
if (team) { teamval = atoi(team); }
|
return false;
|
||||||
if (teamval < 0) { teamval = 0; }
|
|
||||||
|
|
||||||
uint32 id = atoi(charID);
|
|
||||||
|
|
||||||
Player *chr = m_session->GetPlayer();
|
Player *chr = m_session->GetPlayer();
|
||||||
float x = chr->GetPositionX();
|
float x = chr->GetPositionX();
|
||||||
|
|
@ -1518,7 +1563,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
|
||||||
Map *map = chr->GetMap();
|
Map *map = chr->GetMap();
|
||||||
|
|
||||||
Creature* pCreature = new Creature;
|
Creature* pCreature = new Creature;
|
||||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, (uint32)teamval))
|
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, team))
|
||||||
{
|
{
|
||||||
delete pCreature;
|
delete pCreature;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1548,31 +1593,25 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
|
||||||
//add item in vendorlist
|
//add item in vendorlist
|
||||||
bool ChatHandler::HandleNpcAddVendorItemCommand(char* args)
|
bool ChatHandler::HandleNpcAddVendorItemCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
uint32 itemId;
|
||||||
return false;
|
if (!ExtractUint32KeyFromLink(&args, "Hitem", itemId))
|
||||||
|
|
||||||
char* pitem = extractKeyFromLink(args, "Hitem");
|
|
||||||
if (!pitem)
|
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_COMMAND_NEEDITEMSEND);
|
SendSysMessage(LANG_COMMAND_NEEDITEMSEND);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 itemId = atol(pitem);
|
uint32 maxcount;
|
||||||
|
if (!ExtractOptUInt32(&args, maxcount, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0
|
uint32 incrtime;
|
||||||
uint32 maxcount = 0;
|
if (!ExtractOptUInt32(&args, incrtime, 0))
|
||||||
if (fmaxcount)
|
return false;
|
||||||
maxcount = atol(fmaxcount);
|
|
||||||
|
|
||||||
char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0
|
uint32 extendedcost;
|
||||||
uint32 incrtime = 0;
|
if (!ExtractOptUInt32(&args, extendedcost, 0))
|
||||||
if (fincrtime)
|
return false;
|
||||||
incrtime = atol(fincrtime);
|
|
||||||
|
|
||||||
char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
|
|
||||||
uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
|
|
||||||
|
|
||||||
Creature* vendor = getSelectedCreature();
|
Creature* vendor = getSelectedCreature();
|
||||||
|
|
||||||
|
|
@ -1606,14 +1645,13 @@ bool ChatHandler::HandleNpcDelVendorItemCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* pitem = extractKeyFromLink(args, "Hitem");
|
uint32 itemId;
|
||||||
if (!pitem)
|
if (!ExtractUint32KeyFromLink(&args, "Hitem", itemId))
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_COMMAND_NEEDITEMSEND);
|
SendSysMessage(LANG_COMMAND_NEEDITEMSEND);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint32 itemId = atol(pitem);
|
|
||||||
|
|
||||||
if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(), itemId))
|
if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(), itemId))
|
||||||
{
|
{
|
||||||
|
|
@ -1631,24 +1669,14 @@ bool ChatHandler::HandleNpcDelVendorItemCommand(char* args)
|
||||||
//add move for creature
|
//add move for creature
|
||||||
bool ChatHandler::HandleNpcAddMoveCommand(char* args)
|
bool ChatHandler::HandleNpcAddMoveCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
uint32 lowguid;
|
||||||
|
if (!ExtractUint32KeyFromLink(&args, "Hcreature", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* guid_str = strtok(args, " ");
|
uint32 wait;
|
||||||
char* wait_str = strtok(NULL, " ");
|
if (!ExtractOptUInt32(&args, wait, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(guid_str);
|
|
||||||
|
|
||||||
Creature* pCreature = NULL;
|
|
||||||
|
|
||||||
/* FIXME: impossible without entry
|
|
||||||
if (lowguid)
|
|
||||||
pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// attempt check creature existence by DB data
|
|
||||||
if (!pCreature)
|
|
||||||
{
|
|
||||||
CreatureData const* data = sObjectMgr.GetCreatureData(lowguid);
|
CreatureData const* data = sObjectMgr.GetCreatureData(lowguid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
|
|
@ -1656,20 +1684,18 @@ bool ChatHandler::HandleNpcAddMoveCommand(char* args)
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// obtain real GUID for DB operations
|
|
||||||
lowguid = pCreature->GetDBTableGUIDLow();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wait = wait_str ? atoi(wait_str) : 0;
|
|
||||||
|
|
||||||
if (wait < 0)
|
|
||||||
wait = 0;
|
|
||||||
|
|
||||||
Player* player = m_session->GetPlayer();
|
Player* player = m_session->GetPlayer();
|
||||||
|
|
||||||
|
if (player->GetMapId() != data->mapid)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Creature* pCreature = player->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
|
||||||
|
|
||||||
sWaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0);
|
sWaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0);
|
||||||
|
|
||||||
// update movement type
|
// update movement type
|
||||||
|
|
@ -1766,11 +1792,10 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args)
|
||||||
if (*args)
|
if (*args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
|
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hcreature");
|
uint32 lowguid;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hcreature", lowguid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -1807,20 +1832,9 @@ bool ChatHandler::HandleNpcMoveCommand(char* args)
|
||||||
if (!pCreature)
|
if (!pCreature)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
|
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hcreature");
|
if (!ExtractUint32KeyFromLink(&args, "Hcreature", lowguid))
|
||||||
if (!cId)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
lowguid = atoi(cId);
|
|
||||||
|
|
||||||
/* FIXME: impossibel without entry
|
|
||||||
if (lowguid)
|
|
||||||
pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Attempting creature load from DB data
|
|
||||||
if (!pCreature)
|
|
||||||
{
|
|
||||||
CreatureData const* data = sObjectMgr.GetCreatureData(lowguid);
|
CreatureData const* data = sObjectMgr.GetCreatureData(lowguid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
|
|
@ -1829,24 +1843,19 @@ bool ChatHandler::HandleNpcMoveCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 map_id = data->mapid;
|
Player* player = m_session->GetPlayer();
|
||||||
|
|
||||||
if (m_session->GetPlayer()->GetMapId() != map_id)
|
if (player->GetMapId() != data->mapid)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
|
PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pCreature = player->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
lowguid = pCreature->GetDBTableGUIDLow();
|
lowguid = pCreature->GetDBTableGUIDLow();
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lowguid = pCreature->GetDBTableGUIDLow();
|
|
||||||
}
|
|
||||||
|
|
||||||
float x = m_session->GetPlayer()->GetPositionX();
|
float x = m_session->GetPlayer()->GetPositionX();
|
||||||
float y = m_session->GetPlayer()->GetPositionY();
|
float y = m_session->GetPlayer()->GetPositionY();
|
||||||
|
|
@ -2451,7 +2460,7 @@ bool ChatHandler::HandleModifyMorphCommand(char* args)
|
||||||
bool ChatHandler::HandleKickPlayerCommand(char *args)
|
bool ChatHandler::HandleKickPlayerCommand(char *args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_session && target == m_session->GetPlayer())
|
if (m_session && target == m_session->GetPlayer())
|
||||||
|
|
@ -2498,7 +2507,7 @@ bool ChatHandler::HandlePInfoCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args, &target, &target_guid,& target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 accId = 0;
|
uint32 accId = 0;
|
||||||
|
|
@ -2594,7 +2603,7 @@ void ChatHandler::ShowTicket(uint64 guid, char const* text, char const* time)
|
||||||
//ticket commands
|
//ticket commands
|
||||||
bool ChatHandler::HandleTicketCommand(char* args)
|
bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
{
|
{
|
||||||
char* px = strtok(args, " ");
|
char* px = ExtractLiteralArg(&args);
|
||||||
|
|
||||||
// ticket<end>
|
// ticket<end>
|
||||||
if (!px)
|
if (!px)
|
||||||
|
|
@ -2647,16 +2656,14 @@ bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
// ticket respond
|
// ticket respond
|
||||||
if (strncmp(px, "respond", 8) == 0)
|
if (strncmp(px, "respond", 8) == 0)
|
||||||
{
|
{
|
||||||
char *name = strtok(NULL, " ");
|
std::string plName = ExtractPlayerNameFromLink(&args);
|
||||||
|
if (plName.empty())
|
||||||
if (!name)
|
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_CMD_SYNTAX);
|
SendSysMessage(LANG_CMD_SYNTAX);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string plName = name;
|
|
||||||
uint64 guid = sObjectMgr.GetPlayerGUIDByName(plName);
|
uint64 guid = sObjectMgr.GetPlayerGUIDByName(plName);
|
||||||
|
|
||||||
if (!guid)
|
if (!guid)
|
||||||
|
|
@ -2675,16 +2682,14 @@ bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* response = strtok(NULL, "");
|
if (!*args)
|
||||||
|
|
||||||
if (!response)
|
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_CMD_SYNTAX);
|
SendSysMessage(LANG_CMD_SYNTAX);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket->SetResponseText(response);
|
ticket->SetResponseText(args);
|
||||||
|
|
||||||
if (Player* pl = sObjectMgr.GetPlayer(guid))
|
if (Player* pl = sObjectMgr.GetPlayer(guid))
|
||||||
pl->GetSession()->SendGMResponse(ticket);
|
pl->GetSession()->SendGMResponse(ticket);
|
||||||
|
|
@ -2693,9 +2698,12 @@ bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ticket #num
|
// ticket #num
|
||||||
int num = atoi(px);
|
uint32 num;
|
||||||
if (num > 0)
|
if (!ExtractUInt32(&px, num))
|
||||||
{
|
{
|
||||||
|
if (num == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_, num-1);
|
QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_, num-1);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
@ -2717,7 +2725,7 @@ bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
if (!extractPlayerTarget(px, NULL, &target_guid))
|
if (!ExtractPlayerTarget(&px, NULL, &target_guid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// ticket $char_name
|
// ticket $char_name
|
||||||
|
|
@ -2735,7 +2743,7 @@ bool ChatHandler::HandleTicketCommand(char* args)
|
||||||
//dell all tickets
|
//dell all tickets
|
||||||
bool ChatHandler::HandleDelTicketCommand(char *args)
|
bool ChatHandler::HandleDelTicketCommand(char *args)
|
||||||
{
|
{
|
||||||
char* px = strtok(args, " ");
|
char* px = ExtractLiteralArg(&args);
|
||||||
if (!px)
|
if (!px)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -2747,11 +2755,14 @@ bool ChatHandler::HandleDelTicketCommand(char *args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = (uint32)atoi(px);
|
uint32 num;
|
||||||
|
|
||||||
// delticket #num
|
// delticket #num
|
||||||
if (num > 0)
|
if (ExtractUInt32(&px, num))
|
||||||
{
|
{
|
||||||
|
if (num ==0)
|
||||||
|
return false;
|
||||||
|
|
||||||
QueryResult* result = CharacterDatabase.PQuery("SELECT guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1);
|
QueryResult* result = CharacterDatabase.PQuery("SELECT guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|
@ -2780,7 +2791,7 @@ bool ChatHandler::HandleDelTicketCommand(char *args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(px, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&px, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// delticket $char_name
|
// delticket $char_name
|
||||||
|
|
@ -3940,7 +3951,7 @@ bool ChatHandler::HandleCharacterRenameCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
|
|
@ -3974,7 +3985,7 @@ bool ChatHandler::HandleCharacterCustomizeCommand(char* args)
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 target_guid;
|
||||||
std::string target_name;
|
std::string target_name;
|
||||||
if (!extractPlayerTarget(args, &target, &target_guid, &target_name))
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
|
|
@ -3997,7 +4008,7 @@ bool ChatHandler::HandleCharacterCustomizeCommand(char* args)
|
||||||
bool ChatHandler::HandleCharacterReputationCommand(char* args)
|
bool ChatHandler::HandleCharacterReputationCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LocaleConstant loc = GetSessionDbcLocale();
|
LocaleConstant loc = GetSessionDbcLocale();
|
||||||
|
|
@ -4179,12 +4190,10 @@ bool ChatHandler::HandleEventInfoCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameevent");
|
uint32 event_id;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 event_id = atoi(cId);
|
|
||||||
|
|
||||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||||
|
|
||||||
if (event_id >=events.size())
|
if (event_id >=events.size())
|
||||||
|
|
@ -4228,12 +4237,10 @@ bool ChatHandler::HandleEventStartCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameevent");
|
uint32 event_id;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 event_id = atoi(cId);
|
|
||||||
|
|
||||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||||
|
|
||||||
if (event_id < 1 || event_id >=(int32)events.size())
|
if (event_id < 1 || event_id >=(int32)events.size())
|
||||||
|
|
@ -4270,12 +4277,10 @@ bool ChatHandler::HandleEventStopCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||||
char* cId = extractKeyFromLink(args, "Hgameevent");
|
uint32 event_id;
|
||||||
if (!cId)
|
if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 event_id = atoi(cId);
|
|
||||||
|
|
||||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||||
|
|
||||||
if (event_id < 1 || event_id >=(int32)events.size())
|
if (event_id < 1 || event_id >=(int32)events.size())
|
||||||
|
|
@ -4310,7 +4315,7 @@ bool ChatHandler::HandleEventStopCommand(char* args)
|
||||||
bool ChatHandler::HandleCombatStopCommand(char* args)
|
bool ChatHandler::HandleCombatStopCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check online security
|
// check online security
|
||||||
|
|
@ -4669,7 +4674,7 @@ bool ChatHandler::HandleServerCorpsesCommand(char* /*args*/)
|
||||||
bool ChatHandler::HandleRepairitemsCommand(char* args)
|
bool ChatHandler::HandleRepairitemsCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check online security
|
// check online security
|
||||||
|
|
@ -4798,11 +4803,10 @@ bool ChatHandler::HandleLookupTitleCommand(char* args)
|
||||||
bool ChatHandler::HandleTitlesAddCommand(char* args)
|
bool ChatHandler::HandleTitlesAddCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||||
char* id_p = extractKeyFromLink(args, "Htitle");
|
uint32 id;
|
||||||
if (!id_p)
|
if (!ExtractUint32KeyFromLink(&args, "Htitle", id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 id = atoi(id_p);
|
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||||
|
|
@ -4845,11 +4849,10 @@ bool ChatHandler::HandleTitlesAddCommand(char* args)
|
||||||
bool ChatHandler::HandleTitlesRemoveCommand(char* args)
|
bool ChatHandler::HandleTitlesRemoveCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||||
char* id_p = extractKeyFromLink(args, "Htitle");
|
uint32 id;
|
||||||
if (!id_p)
|
if (!ExtractUint32KeyFromLink(&args, "Htitle", id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 id = atoi(id_p);
|
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||||
|
|
@ -4941,7 +4944,7 @@ bool ChatHandler::HandleTitlesSetMaskCommand(char* args)
|
||||||
bool ChatHandler::HandleCharacterTitlesCommand(char* args)
|
bool ChatHandler::HandleCharacterTitlesCommand(char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
if (!extractPlayerTarget(args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LocaleConstant loc = GetSessionDbcLocale();
|
LocaleConstant loc = GetSessionDbcLocale();
|
||||||
|
|
@ -4978,11 +4981,10 @@ bool ChatHandler::HandleCharacterTitlesCommand(char* args)
|
||||||
bool ChatHandler::HandleTitlesCurrentCommand(char* args)
|
bool ChatHandler::HandleTitlesCurrentCommand(char* args)
|
||||||
{
|
{
|
||||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||||
char* id_p = extractKeyFromLink(args, "Htitle");
|
uint32 id;
|
||||||
if (!id_p)
|
if (!ExtractUint32KeyFromLink(&args, "Htitle", id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 id = atoi(id_p);
|
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -65,7 +65,7 @@ bool ChatHandler::HandleAccountDeleteCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string account_name;
|
std::string account_name;
|
||||||
uint32 account_id = extractAccountId(args, &account_name);
|
uint32 account_id = ExtractAccountId(&args, &account_name);
|
||||||
if (!account_id)
|
if (!account_id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -409,44 +409,31 @@ bool ChatHandler::HandleCharacterDeletedOldCommand(char* args)
|
||||||
|
|
||||||
bool ChatHandler::HandleCharacterEraseCommand(char* args)
|
bool ChatHandler::HandleCharacterEraseCommand(char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
char* nameStr = ExtractLiteralArg(&args);
|
||||||
|
if (!*nameStr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char *character_name_str = strtok(args," ");
|
Player* target;
|
||||||
if(!character_name_str)
|
uint64 target_guid;
|
||||||
|
std::string target_name;
|
||||||
|
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string character_name = character_name_str;
|
|
||||||
if(!normalizePlayerName(character_name))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint64 character_guid;
|
|
||||||
uint32 account_id;
|
uint32 account_id;
|
||||||
|
|
||||||
if (Player *player = sObjectMgr.GetPlayer(character_name.c_str()))
|
if (target)
|
||||||
{
|
{
|
||||||
character_guid = player->GetGUID();
|
account_id = target->GetSession()->GetAccountId();
|
||||||
account_id = player->GetSession()->GetAccountId();
|
target->GetSession()->KickPlayer();
|
||||||
player->GetSession()->KickPlayer();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
|
||||||
character_guid = sObjectMgr.GetPlayerGUIDByName(character_name);
|
|
||||||
if(!character_guid)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_NO_PLAYER,character_name.c_str());
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
account_id = sObjectMgr.GetPlayerAccountIdByGUID(character_guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string account_name;
|
std::string account_name;
|
||||||
sAccountMgr.GetName (account_id,account_name);
|
sAccountMgr.GetName (account_id,account_name);
|
||||||
|
|
||||||
Player::DeleteFromDB(character_guid, account_id, true, true);
|
Player::DeleteFromDB(target_guid, account_id, true, true);
|
||||||
PSendSysMessage(LANG_CHARACTER_DELETED,character_name.c_str(),GUID_LOPART(character_guid),account_name.c_str(), account_id);
|
PSendSysMessage(LANG_CHARACTER_DELETED, target_name.c_str(), GUID_LOPART(target_guid), account_name.c_str(), account_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10333"
|
#define REVISION_NR "10334"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue