summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-29 00:05:45 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-29 00:05:45 +0000
commit98bc5a50c724236000263526a0539caeb11a3200 (patch)
tree789284c63cfae64eb896c2b838d5da9ff57480bb /src/map/pc.c
parent96c726976d259ff9a56be04f67bcd46cf3a5b4fc (diff)
downloadhercules-98bc5a50c724236000263526a0539caeb11a3200.tar.gz
hercules-98bc5a50c724236000263526a0539caeb11a3200.tar.bz2
hercules-98bc5a50c724236000263526a0539caeb11a3200.tar.xz
hercules-98bc5a50c724236000263526a0539caeb11a3200.zip
- Added @cash and @points command to manage your cash/kafra points.
- Optimized code. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12266 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 551fa9c55..3f1128e2a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -2708,21 +2708,25 @@ void pc_paycash(struct map_session_data *sd, int prize, int points)
int cash = prize - points;
nullpo_retv(sd);
- sd->cashPoints -= cash;
- sd->kafraPoints -= points;
+ if( cash > 0 )
+ {
+ if( (sd->cashPoints -= cash) < 0 )
+ sd->cashPoints = 0;
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- if( points )
- {
- sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
+ sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
- if( cash )
+ if( points > 0 )
{
- sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
+ if( (sd->kafraPoints -= points) < 0 )
+ sd->kafraPoints = 0;
+
+ pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+
+ sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
}
@@ -2732,27 +2736,26 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
char output[128];
nullpo_retv(sd);
- if( cash > MAX_ZENY - sd->cashPoints )
- cash = MAX_ZENY - sd->cashPoints;
-
- sd->cashPoints += cash;
-
- if( points > MAX_ZENY - sd->kafraPoints )
- points = MAX_ZENY - sd->kafraPoints;
-
- sd->kafraPoints += points;
-
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
-
if( cash > 0 )
{
+ if( cash > MAX_ZENY - sd->cashPoints )
+ cash = MAX_ZENY - sd->cashPoints;
+
+ sd->cashPoints += cash;
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
+
sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
if( points > 0 )
{
+ if( points > MAX_ZENY - sd->kafraPoints )
+ points = MAX_ZENY - sd->kafraPoints;
+
+ sd->kafraPoints += points;
+ pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+
sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
}