summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorglighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-14 02:26:00 +0000
committerglighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-14 02:26:00 +0000
commit4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45 (patch)
treeae5f4769d161f5693f94e95b1623909a3d75eaf9 /src/map/atcommand.c
parentdc88ae10c96b5d5d9d40fccbb102f1ec80058063 (diff)
downloadhercules-4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45.tar.gz
hercules-4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45.tar.bz2
hercules-4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45.tar.xz
hercules-4e406f3ed6e6f8b2b8434a366a5e54c8f7186f45.zip
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
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c47
1 files changed, 30 insertions, 17 deletions
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 <amount>).
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.
}
}