From 4981f26566e9d98ef813b5f2944dac86f1856421 Mon Sep 17 00:00:00 2001 From: sketchyphoenix Date: Mon, 5 Jan 2009 19:10:03 +0000 Subject: Added @charcommands to return a list of available charcommands (bugreport:2630) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13435 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + conf/Changelog.txt | 2 ++ conf/atcommand_athena.conf | 3 +++ src/map/atcommand.c | 42 +++++++----------------------------------- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7706c47ed..696d4a028 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -7,6 +7,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. * Fixed @mobsearch and @showmobs (bugreport:2481) [ultramage] - now only search for mobs on the same map as the caller - now properly distinguish between dead and alive mobs + * Added @charcommands to return a list of available charcommands (bugreport:2630) [SketchyPhoenix] 2008/12/31 * Changes to the script engine: [FlavioJS] - new stack datatype script_retinfo for C_RETINFO to hold all the return state info diff --git a/conf/Changelog.txt b/conf/Changelog.txt index 2e5abc674..543d6dc47 100644 --- a/conf/Changelog.txt +++ b/conf/Changelog.txt @@ -1,4 +1,6 @@ Date Added +2009/1/5 + * Added @charcommands to return a list of available # commands [SketchyPhoenix] 2008/12/26 * Rev. 13444 Marked new Morroc fields as nomemo. [L0ne_W0lf] * Rev. 13415 Commented out maps no longer accessable with 12.1. [L0ne_W0lf] diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index 49526631c..04dbec4f2 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -52,6 +52,9 @@ char_symbol: # // Displays a list of @ commands available to the player. commands: 1,1 +// Displays a list of # commands available to the player. +charcommands: 1,1 + // Displays the server rates. rates: 1,1 diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bf052f5ba..a8d139dc1 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8916,6 +8916,7 @@ AtCommandInfo atcommand_info[] = { { "itemlist", 40,40, atcommand_itemlist }, { "stats", 40,40, atcommand_stats }, { "delitem", 60,60, atcommand_delitem }, + { "charcommands", 1,1, atcommand_commands }, }; @@ -9002,8 +9003,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message char cmd[100]; char param[100]; char output[200]; - char output2[200]; - const char* message2; + char message2[200]; int gmlvl = pc_isGM(sd); @@ -9051,16 +9051,12 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if (sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param) == 2 || sscanf(message, "%99s %23s %99[^\n]", cmd, charname, param) == 2) { - sprintf(output, "%s", cmd); - memcpy(output2, output, sizeof(output2)); - message2 = output2; + 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(output, "%s %s", cmd, param); - memcpy(output2, output, sizeof(output2)); - message2 = output2; + sprintf(message2, "%s %s", cmd, param); return is_atcommand_sub(fd,pl_sd,message2,gmlvl); } } @@ -9169,31 +9165,9 @@ int atcommand_commands(const int fd, struct map_session_data* sd, const char* co { unsigned int slen; - if( gm_lvl < atcommand_info[i].level ) + if( gm_lvl < atcommand_info[i].level && stristr(command,"commands") ) continue; - - slen = (unsigned int)strlen(atcommand_info[i].command); - - // flush the text buffer if this command won't fit into it - if( slen + cur - line_buff >= CHATBOX_SIZE ) - { - clif_displaymessage(fd,line_buff); - cur = line_buff; - memset(line_buff,' ',CHATBOX_SIZE); - line_buff[CHATBOX_SIZE-1] = 0; - } - - memcpy(cur,atcommand_info[i].command,slen); - cur += slen+(10-slen%10); - - count++; - } - - for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ ) - { - unsigned int slen; - - if( gm_lvl < atcommand_info[i].level2 ) + if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") ) continue; slen = (unsigned int)strlen(atcommand_info[i].command); @@ -9210,15 +9184,13 @@ int atcommand_commands(const int fd, struct map_session_data* sd, const char* co memcpy(cur,atcommand_info[i].command,slen); cur += slen+(10-slen%10); - count2++; + count++; } clif_displaymessage(fd,line_buff); sprintf(atcmd_output, msg_txt(274), count); // "%d commands found." clif_displaymessage(fd, atcmd_output); - sprintf(atcmd_output, "%d charcommands found.", count2); - clif_displaymessage(fd, atcmd_output); return 0; } \ No newline at end of file -- cgit v1.2.3-70-g09d2