* #command parsing cleaned up.

- Fixed charname reading problems from r13441 
- Corrected agitend typo to agitend2 (bugreport:2654)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13444 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
sketchyphoenix 2009-01-12 17:49:10 +00:00
parent b80a8cdc87
commit 753620d68c
4 changed files with 38 additions and 29 deletions

View File

@ -5,6 +5,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2009/01/12
* Added regen_db to reduce hp/sp processing delays (bugreport:2256) [ultramage]
* #command parsing cleaned up. [SketchyPhoenix]
- Fixed charname reading problems from r13441
- Corrected agitend typo to agitend2 (bugreport:2654)
2009/01/05
* Fixed @mobsearch and @showmobs (bugreport:2481) [ultramage]
- now only search for mobs on the same map as the caller

View File

@ -1,4 +1,6 @@
Date Added
2009/1/12
* Second agitend corrected to agitend2 [SketchyPhoenix]
2009/1/5
* Added @charcommands to return a list of available # commands [SketchyPhoenix]
2008/12/26

View File

@ -643,7 +643,7 @@ homshuffle: 60,60
// WoE 2 start/stop commands
agitstart2: 60,60
agitend: 60,60
agitend2: 60,60
// Resets player stats
streset: 60,60

View File

@ -8984,6 +8984,7 @@ bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str
if( log_config.gm && info->level >= log_config.gm && *str == atcommand_symbol )
log_atcommand(sd, str);
//
if( log_config.gm && info->level2 >= log_config.gm && *str == charcommand_symbol
&& (ssd = (struct map_session_data *)session[fd]->session_data) != NULL )
log_atcommand(ssd, str);
@ -9003,13 +9004,13 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
{
struct map_session_data* pl_sd;
char charname[NAME_LENGTH];
char charname[NAME_LENGTH], charname2[NAME_LENGTH];
char cmd[100];
char param[100];
char param[100], param2[100];
char output[200];
char message2[200];
int gmlvl = pc_isGM(sd);
int x, y, z, gmlvl = pc_isGM(sd);
nullpo_retr(false, sd);
@ -9035,35 +9036,38 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if (*message == charcommand_symbol)
{
//Checks to see if #command has a name or a name + parameters.
if (sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param) >= 2
|| sscanf(message, "%99s %23s %99[^\n]", cmd, charname, param) >= 2)
x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param);
y = sscanf(message, "%99s %23s %99[^\n]", cmd, charname2, param2);
//x being > 1 is unique to its proper syntax
z = ( x > 1 ) ? x : y;
if ( (pl_sd = map_nick2sd(charname)) == NULL && ( (pl_sd = map_nick2sd(charname2)) == NULL ) )
{
if ( (pl_sd = map_nick2sd(charname)) == NULL )
{
sprintf(output, "%s failed. Player %s not found.", cmd, charname);
clif_displaymessage(fd, output);
return true;
}
else {
//If it's just a name and no params, send the command with no name. Otherwise, send it with the parameters.
if (sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param) == 2
|| sscanf(message, "%99s %23s %99[^\n]", cmd, charname, param) == 2)
{
sprintf(message2, "%s", cmd);
//NOTE: fd is passed to is_atcommand_sub instead of pl_sd->fd because we want output sent to the user of the command, not the target.
return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
}
else {
sprintf(message2, "%s %s", cmd, param);
return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
}
}
}
else {
sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
sprintf(output, "%s failed. Player not found.", cmd);
clif_displaymessage(fd, output);
return true;
}
if ( x == 3 && x > y ) {
sprintf(message2, "%s %s", cmd, param);
return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
}
else if ( y > 2 ) {
sprintf(message2, "%s %s", cmd, param2);
return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
}
//Regardless of what style the #command is used, if it's correct, it will always have
//this value if there is no parameter.
if ( z == 2 ) {
sprintf(message2, "%s", cmd);
return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
}
sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
clif_displaymessage(fd, output);
return true;
}
return is_atcommand_sub(fd,sd,message,gmlvl);