- Optimized the code to handle #KAFRAPOINTS and #CASHPOINTS. Now you can really edit those vars on scripts.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12304 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
zephyrus 2008-03-05 17:43:46 +00:00
parent 284334b4f0
commit e742a17822

View File

@ -2715,10 +2715,7 @@ void pc_paycash(struct map_session_data *sd, int price, int points)
if( cash > 0 ) if( cash > 0 )
{ {
if( (sd->cashPoints -= cash) < 0 ) pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints - cash);
sd->cashPoints = 0;
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints); sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output)); 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( points > 0 )
{ {
if( (sd->kafraPoints -= points) < 0 ) pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints - points);
sd->kafraPoints = 0;
pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints); sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output)); 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 > 0 )
{ {
if( cash > MAX_ZENY - sd->cashPoints ) pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints + cash);
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); sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output)); 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 > 0 )
{ {
if( points > MAX_ZENY - sd->kafraPoints ) pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints + points);
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); sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output)); 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; int i,*max, regmax;
nullpo_retr(0, sd); 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); i = (!sd->die_counter && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE);
sd->die_counter = val; 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; sd_reg = sd->save_reg.global;
max = &sd->save_reg.global_num; max = &sd->save_reg.global_num;
regmax = GLOBAL_REG_NUM; regmax = GLOBAL_REG_NUM;
break; break;
case 2: //Account reg 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; sd_reg = sd->save_reg.account;
max = &sd->save_reg.account_num; max = &sd->save_reg.account_num;
regmax = ACCOUNT_REG_NUM; regmax = ACCOUNT_REG_NUM;