summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-10 00:37:24 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-10 00:37:24 +0000
commitecbca44f124c5e379c9a1ef5433c2c3c0ed07c4f (patch)
tree91a260e1db952e349a2aab182cb3b02607440be2 /src
parent03a0930bca1ecd78e36d7fe26d57b98bb3619dff (diff)
downloadhercules-ecbca44f124c5e379c9a1ef5433c2c3c0ed07c4f.tar.gz
hercules-ecbca44f124c5e379c9a1ef5433c2c3c0ed07c4f.tar.bz2
hercules-ecbca44f124c5e379c9a1ef5433c2c3c0ed07c4f.tar.xz
hercules-ecbca44f124c5e379c9a1ef5433c2c3c0ed07c4f.zip
- Modified @commands to use Meruru's code which is faster and does a fair attempt at tabulating the commands presented.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6541 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index c2bbfda12..1e6f76516 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1162,37 +1162,49 @@ int duel_reject(
*/
/*==========================================
- * @commands Lists available @ commands to you.
+ * @commands Lists available @ commands to you (code 98% from Meruru)
*------------------------------------------
*/
-int atcommand_commands(const int fd, struct map_session_data* sd,
+int atcommand_commands(
+ const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- int i,count=0,level;
- nullpo_retr(-1, sd);
- level = pc_isGM(sd);
-
+ char cz_line_buff[MESSAGE_SIZE+1];
+
+ register char *lpcz_cur = cz_line_buff;
+ register unsigned int ui_slen;
+
+ int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
+
+ memset(cz_line_buff,' ',MESSAGE_SIZE);
+ cz_line_buff[MESSAGE_SIZE] = 0;
+
clif_displaymessage(fd, msg_txt(273));
- memset(atcmd_output, 0, sizeof atcmd_output);
- for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
- if (atcommand_info[i].level <= level && atcommand_info[i].command) {
- count++;
- strcat(atcmd_output, atcommand_info[i].command);
- strcat(atcmd_output, " ");
- if (!(count%10)) {
- clif_displaymessage(fd, atcmd_output);
- memset(atcmd_output, 0, sizeof atcmd_output);
- }
+
+ for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
+ {
+ if(gm_lvl < atcommand_info[i_cur_cmd].level)
+ continue;
+
+ count++;
+ ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
+
+ //rember not <= bc we need null terminator
+ if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
+ {
+ clif_displaymessage(fd,(char*)cz_line_buff);
+ lpcz_cur = cz_line_buff;
+ memset(cz_line_buff,' ',MESSAGE_SIZE);
+ cz_line_buff[MESSAGE_SIZE] = 0;
}
- if (count%10)
- clif_displaymessage(fd, atcmd_output);
- if (count) {
- sprintf(atcmd_output, msg_txt(274), count);
- clif_displaymessage(fd, atcmd_output);
- } else
- clif_displaymessage(fd, msg_txt(275));
-
+ memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
+ lpcz_cur += ui_slen+(10-ui_slen%10);
+ }
+
+ clif_displaymessage(fd,(char*)cz_line_buff);
+ sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
+ clif_displaymessage(fd, atcmd_output);
return 0;
}