From 4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45 Mon Sep 17 00:00:00 2001 From: glighta Date: Wed, 14 Nov 2012 02:26:00 +0000 Subject: Following r16914 -fix @zeny for negative amout bugreport:6886, bugreport:6895 bugreport:6888 -fix @cash,@points command display result -enforce bound chk for both git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16924 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 27329ae4a..891fb1a79 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2522,7 +2522,7 @@ ACMD_FUNC(skillpoint) } /*========================================== - * @zeny (Rewritten by [Yor]) + * @zeny *------------------------------------------*/ ACMD_FUNC(zeny) { @@ -2533,10 +2533,14 @@ ACMD_FUNC(zeny) clif_displaymessage(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny ). return -1; } - if(zeny > 0) - pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL); - else - pc_payzeny(sd,zeny,LOG_TYPE_COMMAND,NULL); + + if(zeny > 0){ + if(pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL) == 1) + clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value. + } + else if(pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL) == 1){ + clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value. + } return 0; } @@ -7858,6 +7862,7 @@ ACMD_FUNC(cash) { char output[128]; int value; + int ret=0; nullpo_retr(-1, sd); if( !message || !*message || (value = atoi(message)) == 0 ) { @@ -7868,25 +7873,33 @@ ACMD_FUNC(cash) if( !strcmpi(command+1,"cash") ) { if( value > 0 ) { - pc_getcash(sd, value, 0); - sprintf(output, msg_txt(505), value, sd->cashPoints); - clif_disp_onlyself(sd, output, strlen(output)); + if( (ret=pc_getcash(sd, value, 0)) >= 0){ + sprintf(output, msg_txt(505), ret, sd->cashPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value. } else { - pc_paycash(sd, -value, 0); - sprintf(output, msg_txt(410), value, sd->cashPoints); - clif_disp_onlyself(sd, output, strlen(output)); + if( (ret=pc_paycash(sd, -value, 0)) >= 0){ + sprintf(output, msg_txt(410), ret, sd->cashPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value. } } else { // @points if( value > 0 ) { - pc_getcash(sd, 0, value); - sprintf(output, msg_txt(506), value, sd->kafraPoints); - clif_disp_onlyself(sd, output, strlen(output)); + if( (ret=pc_getcash(sd, 0, value)) >= 0){ + sprintf(output, msg_txt(506), ret, sd->kafraPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value. } else { - pc_paycash(sd, -value, -value); - sprintf(output, msg_txt(411), -value, sd->kafraPoints); - clif_disp_onlyself(sd, output, strlen(output)); + if( (ret=pc_paycash(sd, -value, -value)) >= 0){ + sprintf(output, msg_txt(411), ret, sd->kafraPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value. } } -- cgit v1.2.3-70-g09d2