diff options
author | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-05 17:43:46 +0000 |
---|---|---|
committer | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-05 17:43:46 +0000 |
commit | 7f3d829d17818d0ec7f1eb277a144133e3b53ad7 (patch) | |
tree | 9228bde12fe0b2942e05ab1a49959f1f7ede323f /src/map | |
parent | b81ff1c3772fddc5885042a29d8b8ece39a4629a (diff) | |
download | hercules-7f3d829d17818d0ec7f1eb277a144133e3b53ad7.tar.gz hercules-7f3d829d17818d0ec7f1eb277a144133e3b53ad7.tar.bz2 hercules-7f3d829d17818d0ec7f1eb277a144133e3b53ad7.tar.xz hercules-7f3d829d17818d0ec7f1eb277a144133e3b53ad7.zip |
- Optimized the code to handle #KAFRAPOINTS and #CASHPOINTS. Now you can really edit those vars on scripts.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12304 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/pc.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 7a863ad1b..1a88acf02 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2715,10 +2715,7 @@ void pc_paycash(struct map_session_data *sd, int price, int points) if( cash > 0 ) { - if( (sd->cashPoints -= cash) < 0 ) - sd->cashPoints = 0; - - pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints); + pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints - cash); sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints); clif_disp_onlyself(sd, output, strlen(output)); @@ -2726,10 +2723,7 @@ void pc_paycash(struct map_session_data *sd, int price, int points) if( points > 0 ) { - if( (sd->kafraPoints -= points) < 0 ) - sd->kafraPoints = 0; - - pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints); + pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints - points); sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints); clif_disp_onlyself(sd, output, strlen(output)); @@ -2743,11 +2737,7 @@ void pc_getcash(struct map_session_data *sd, int cash, int points) if( cash > 0 ) { - if( cash > MAX_ZENY - sd->cashPoints ) - cash = MAX_ZENY - sd->cashPoints; - - sd->cashPoints += cash; - pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints); + pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints + cash); sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints); clif_disp_onlyself(sd, output, strlen(output)); @@ -2755,11 +2745,7 @@ void pc_getcash(struct map_session_data *sd, int cash, int points) if( points > 0 ) { - if( points > MAX_ZENY - sd->kafraPoints ) - points = MAX_ZENY - sd->kafraPoints; - - sd->kafraPoints += points; - pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints); + pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints + points); sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints); clif_disp_onlyself(sd, output, strlen(output)); @@ -6000,20 +5986,32 @@ int pc_setregistry(struct map_session_data *sd,const char *reg,int val,int type) int i,*max, regmax; nullpo_retr(0, sd); - if (type == 3) { //Some special character reg values... - if(strcmp(reg,"PC_DIE_COUNTER") == 0 && sd->die_counter != val){ + + switch( type ) + { + case 3: //Char reg + if( !strcmp(reg,"PC_DIE_COUNTER") && sd->die_counter != val ) + { i = (!sd->die_counter && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE); sd->die_counter = val; - if (i) status_calc_pc(sd,0); //Lost the bonus. + if( i ) + status_calc_pc(sd,0); // Lost the bonus. } - } - switch (type) { - case 3: //Char reg sd_reg = sd->save_reg.global; max = &sd->save_reg.global_num; regmax = GLOBAL_REG_NUM; break; case 2: //Account reg + if( !strcmp(reg,"#CASHPOINTS") && sd->cashPoints != val ) + { + val = cap_value(val, 0, MAX_ZENY); + sd->cashPoints = val; + } + else if( !strcmp(reg,"#KAFRAPOINTS") && sd->kafraPoints != val ) + { + val = cap_value(val, 0, MAX_ZENY); + sd->kafraPoints = val; + } sd_reg = sd->save_reg.account; max = &sd->save_reg.account_num; regmax = ACCOUNT_REG_NUM; |