Skip to content

Commit

Permalink
Adds support for <account id> param for getcharid(). Deprecates chari…
Browse files Browse the repository at this point in the history
…d2rid(), its functionality now merged into getcharid().
  • Loading branch information
bWolfie committed Jan 13, 2019
1 parent 406ae36 commit a4595d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 14 additions & 1 deletion doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2435,10 +2435,18 @@ if any, or else return an empty string.

*charid2rid(<char id>)

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ /!\ This command is deprecated @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

This function returns the RID of the character with the given character ID.

If the character is offline or doesn't exist, 0 is returned.

This command is deprecated and it should not be used in new scripts, as it is
likely to be removed at a later time. Please use getcharid instead,
ie: getcharid(CHAR_ID_ACCOUNT, <char id>)

---------------------------------------

*getarraysize(<array name>)
Expand Down Expand Up @@ -2549,9 +2557,10 @@ bStr, bInt, bLuk
---------------------------------------

*getcharid(<type>{, "<character name>"})
*getcharid(<type>{, <account id>})

This function will return a unique ID number of the invoking character,
or, if a character name is specified, of that player.
or, if a character name or account id is specified, of that player.

Type is the kind of associated ID number required:

Expand All @@ -2562,6 +2571,10 @@ Type is the kind of associated ID number required:
(4) CHAR_ID_BG - Battle ground ID
(5) CHAR_ID_CLAN - Clan ID number.

If type is (3) CHAR_ID_ACCOUNT, the optional parameter will check
char id instead of account id.
I.e. getcharid(CHAR_ID_ACCOUNT{, <char id>})

For most purposes other than printing it, a number is better to have than
a name (people do horrifying things to their character names).

Expand Down
12 changes: 8 additions & 4 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -8660,10 +8660,14 @@ static BUILDIN(getcharid)
int num = script_getnum(st, 2);
struct map_session_data *sd;

if (script_hasdata(st, 3))
sd = map->nick2sd(script_getstr(st, 3));
else
if (script_hasdata(st, 3)) {
if (num == 3 && script_isinttype(st, 3))
sd = script->charid2sd(st, script_getnum(st, 3));
else
sd = script_isstringtype(st, 3) ? script->nick2sd(st, script_getstr(st, 3)) : script->id2sd(st, script_getnum(st, 3));
} else {
sd = script->rid2sd(st);
}

if (sd == NULL) {
script_pushint(st, 0); //return 0, according docs
Expand Down Expand Up @@ -25150,7 +25154,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(getguildmember,"i?"),
BUILDIN_DEF(strcharinfo,"i??"),
BUILDIN_DEF(strnpcinfo,"i??"),
BUILDIN_DEF(charid2rid,"i"),
BUILDIN_DEF_DEPRECATED(charid2rid, "i"),
BUILDIN_DEF(getequipid,"i"),
BUILDIN_DEF(getequipname,"i"),
BUILDIN_DEF(getbrokenid,"i"), // [Valaris]
Expand Down

0 comments on commit a4595d7

Please sign in to comment.