diff options
author | panikon <panikon@zoho.com> | 2014-03-31 17:26:34 -0300 |
---|---|---|
committer | panikon <panikon@zoho.com> | 2014-03-31 17:26:34 -0300 |
commit | a3fecfc4e984f3f734f5f5481f1b756ad3b93caf (patch) | |
tree | ee1cb32de0492191fdd5353d7d9c09b247544d60 /src | |
parent | d9f4084d50057f1103cbdae03dea3b4abddaa209 (diff) | |
download | hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.gz hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.bz2 hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.xz hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.zip |
Updated documentation for pc_statusup2 and pc_statusup
(fixed issue: 7916 http://hercules.ws/board/tracker/issue-7916-wrong-comment-in-pc-statusup2/)
Now pc_statusup2 returns stat increase amount as stated in previous documentation
Updated *statusup documentation it was wrong
Added last update in upgrade index
@console.c/.h
Documented partially
Now two different parsing categories can have functions with same name
e.g.
- server exit
- sql exit
Diffstat (limited to 'src')
-rw-r--r-- | src/common/console.c | 83 | ||||
-rw-r--r-- | src/common/console.h | 12 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/pc.c | 22 |
4 files changed, 108 insertions, 19 deletions
diff --git a/src/common/console.c b/src/common/console.c index 94824dc25..ec228b563 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -82,15 +82,35 @@ int console_parse_key_pressed(void) { return FD_ISSET(STDIN_FILENO, &fds); } #endif /* _WIN32 */ -CPCMD(exit) { + +/*====================================== + * CORE: Console commands + *--------------------------------------*/ + +/** + * Stops server + **/ +CPCMD_C(exit,server) { runflag = 0; } -CPCMD(ers_report) { + +/** + * Displays ERS-related statistics (Entry Reusage System) + **/ +CPCMD_C(ers_report,server) { ers_report(); } -CPCMD(mem_report) { + +/** + * Displays memory usage + **/ +CPCMD_C(mem_report,server) { memmgr_report(line?atoi(line):0); } + +/** + * Displays command list + **/ CPCMD(help) { unsigned int i = 0; for ( i = 0; i < console->cmd_list_count; i++ ) { @@ -102,22 +122,61 @@ CPCMD(help) { } } } -/* [Ind/Hercules] */ -CPCMD(malloc_usage) { + +/** + * [Ind/Hercules] + * Displays current malloc usage + */ +CPCMD_C(malloc_usage,server) { unsigned int val = (unsigned int)iMalloc->usage(); ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024); } -CPCMD(skip) { + +/** + * Skips an sql update + * Usage: sql update skip UPDATE-FILE.sql + **/ +CPCMD_C(skip,update) { if( !line ) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } Sql_HerculesUpdateSkip(console->SQL, line); } + +/** + * Defines a main category + * Categories can't be used as commands! + * E.G. + * sql update skip + * 'sql' is the main category + * CP_DEF_C(category) + **/ #define CP_DEF_C(x) { #x , NULL , NULL, NULL } +/** + * Defines a sub-category + * Sub-categories can't be used as commands! + * E.G. + * sql update skip + * 'update' is a sub-category + * CP_DEF_C2(command, category) + **/ #define CP_DEF_C2(x,y) { #x , NULL , #y, NULL } -#define CP_DEF_S(x,y) { #x , console_parse_ ## x , #y, NULL } -#define CP_DEF(x) { #x , console_parse_ ## x , NULL, NULL } +/** + * Defines a command that is inside a category or sub-category + * CP_DEF_S(command, category/sub-category) + **/ +#define CP_DEF_S(x,y) { #x, CPCMD_C_A(x,y), #y, NULL } +/** + * Defines a command that is _not_ inside any category + * CP_DEF_S(command) + **/ +#define CP_DEF(x) { #x , CPCMD_A(x), NULL, NULL } + +/** + * Loads console commands list + * See CP_DEF_C, CP_DEF_C2, CP_DEF_S, CP_DEF + **/ void console_load_defaults(void) { struct { char *name; @@ -126,11 +185,17 @@ void console_load_defaults(void) { struct CParseEntry *self; } default_list[] = { CP_DEF(help), + /** + * Server related commands + **/ CP_DEF_C(server), CP_DEF_S(ers_report,server), CP_DEF_S(mem_report,server), CP_DEF_S(malloc_usage,server), CP_DEF_S(exit,server), + /** + * Sql related commands + **/ CP_DEF_C(sql), CP_DEF_C2(update,sql), CP_DEF_S(skip,update), @@ -305,7 +370,7 @@ void console_parse_sub(char *line) { cmd = cmd->u.next[i]; len += snprintf(sublist + len,CP_CMD_LENGTH * 5,":%s", cmd->cmd); } - ShowError("it is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist); + ShowError("Is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist); } } void console_parse(char* line) { diff --git a/src/common/console.h b/src/common/console.h index 513c769ff..bd1de4cbf 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -16,9 +16,21 @@ **/ #define CONSOLE_PARSE_SIZE 10 +/** + * Default parsing function abstract prototype + **/ typedef void (*CParseFunc)(char *line); + +/** + * Console parsing function prototypes + * CPCMD: Console Parsing CoMmand + * x - command + * y - category + **/ #define CPCMD(x) void console_parse_ ##x (char *line) #define CPCMD_A(x) console_parse_ ##x +#define CPCMD_C(x,y) void console_parse_ ##y ##x (char *line) +#define CPCMD_C_A(x,y) console_parse_ ##y ##x #define CP_CMD_LENGTH 20 struct CParseEntry { diff --git a/src/map/clif.c b/src/map/clif.c index e78c034cb..2dbe7cb96 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11177,7 +11177,15 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) /// Old clients send always 1 for this, even when using /str+ and the like. /// Newer clients (2013-12-23 and newer) send the correct amount. void clif_parse_StatusUp(int fd,struct map_session_data *sd) { - pc->statusup(sd,RFIFOW(fd,2), RFIFOB(fd, 4)); + int increase_amount; + + increase_amount = RFIFOB(fd,4); + if( increase_amount < 0 ) + { + ShowDebug("clif_parse_StatusUp: Negative 'increase' value sent by client! (fd: %d, value: %d)\n", + fd, increase_amount); + } + pc->statusup(sd, RFIFOW(fd,2), increase_amount); } diff --git a/src/map/pc.c b/src/map/pc.c index 268125ae1..249b5f0b1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6220,7 +6220,7 @@ int pc_maxparameterincrease(struct map_session_data* sd, int type) { /** * Raises a stat by the specified amount. * Obeys max_parameter limits. - * Subtracts stat points. + * Does not subtract stat points. * * @param sd The target character. * @param type The stat to change (see enum _sp) @@ -6275,12 +6275,16 @@ bool pc_statusup(struct map_session_data* sd, int type, int increase) { return true; } -/// Raises a stat by the specified amount. -/// Obeys max_parameter limits. -/// Does not subtract stat points. -/// -/// @param type The stat to change (see enum _sp) -/// @param val The stat increase amount. +/** + * Raises a stat by the specified amount. + * Obeys max_parameter limits. + * Subtracts stat points. + * + * @param sd The target character. + * @param type The stat to change (see enum _sp) + * @param increase The stat increase amount. + * @return zero if no changes were made, otherwise returns stat increase amount + */ int pc_statusup2(struct map_session_data* sd, int type, int val) { int max, need; @@ -6289,7 +6293,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) if( type < SP_STR || type > SP_LUK ) { clif->statusupack(sd,type,0,0); - return 1; + return 0; } need = pc->need_status_point(sd,type,1); @@ -6309,7 +6313,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) if( val > 255 ) clif->updatestatus(sd,type); // send after the 'ack' to override the truncated value - return 0; + return val; } /*========================================== |