Fixed int64 support for some exp commands (#5942)

Fixes #5941

Thanks to @Angelic234 and @aleos89
This commit is contained in:
Lemongrass3110 2021-05-18 17:15:21 +02:00 committed by GitHub
parent 58f2d2173f
commit 7b39ee2f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 30 deletions

View File

@ -10489,26 +10489,39 @@ BUILDIN_FUNC(makepet)
* Give player exp base,job * quest_exp_rate/100 * Give player exp base,job * quest_exp_rate/100
* getexp <base xp>,<job xp>{,<char_id>}; * getexp <base xp>,<job xp>{,<char_id>};
**/ **/
BUILDIN_FUNC(getexp) BUILDIN_FUNC(getexp){
{ struct map_session_data* sd;
TBL_PC* sd;
int base=0,job=0;
double bonus;
if (!script_charid2sd(4,sd)) if( !script_charid2sd( 4, sd ) ){
return SCRIPT_CMD_FAILURE; return SCRIPT_CMD_FAILURE;
}
base=script_getnum(st,2); int64 base = script_getnum64( st, 2 );
job =script_getnum(st,3);
if(base<0 || job<0) if( base < 0 ){
return SCRIPT_CMD_SUCCESS; ShowError( "buildin_getexp: Called with negative base exp.\n" );
return SCRIPT_CMD_FAILURE;
}
int64 job = script_getnum64( st, 3 );
if( job < 0 ){
ShowError( "buildin_getexp: Called with negative job exp.\n" );
return SCRIPT_CMD_FAILURE;
}
if( base == 0 && job == 0 ){
ShowError( "buildin_getexp: Called with base and job exp 0.\n" );
return SCRIPT_CMD_FAILURE;
}
// bonus for npc-given exp // bonus for npc-given exp
bonus = battle_config.quest_exp_rate / 100.; double bonus = battle_config.quest_exp_rate / 100.;
if (base) if (base)
base = (int) cap_value(base * bonus, 0, INT_MAX); base = (int64) cap_value(base * bonus, 0, MAX_EXP);
if (job) if (job)
job = (int) cap_value(job * bonus, 0, INT_MAX); job = (int64) cap_value(job * bonus, 0, MAX_EXP);
pc_gainexp(sd, NULL, base, job, 1); pc_gainexp(sd, NULL, base, job, 1);
#ifdef RENEWAL #ifdef RENEWAL
@ -10522,19 +10535,26 @@ BUILDIN_FUNC(getexp)
/*========================================== /*==========================================
* Gain guild exp [Celest] * Gain guild exp [Celest]
*------------------------------------------*/ *------------------------------------------*/
BUILDIN_FUNC(guildgetexp) BUILDIN_FUNC(guildgetexp){
{ struct map_session_data* sd;
TBL_PC* sd;
int exp;
if( !script_rid2sd(sd) ) if( !script_rid2sd( sd ) ){
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_FAILURE;
}
exp = script_getnum(st,2); int64 exp = script_getnum64( st, 2 );
if(exp < 0)
return SCRIPT_CMD_SUCCESS; if( exp <= 0 ){
if(sd && sd->status.guild_id > 0) ShowError( "buildin_guildgetexp: Called with exp <= 0.\n" );
guild_getexp (sd, exp); return SCRIPT_CMD_FAILURE;
}
if( sd->status.guild_id <= 0 ){
ShowError( "buildin_guildgetexp: Called for player %s (AID: %u, CID: %u) without a guild.\n", sd->status.name, sd->status.account_id, sd->status.char_id );
return SCRIPT_CMD_FAILURE;
}
guild_getexp( sd, exp );
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
} }
@ -23296,14 +23316,16 @@ BUILDIN_FUNC(minmax){
**/ **/
BUILDIN_FUNC(getexp2) { BUILDIN_FUNC(getexp2) {
TBL_PC *sd = NULL; TBL_PC *sd = NULL;
int base_exp = script_getnum(st, 2); int64 base_exp = script_getnum64(st, 2);
int job_exp = script_getnum(st, 3); int64 job_exp = script_getnum64(st, 3);
if (!script_charid2sd(4, sd)) if (!script_charid2sd(4, sd))
return SCRIPT_CMD_FAILURE; return SCRIPT_CMD_FAILURE;
if (base_exp == 0 && job_exp == 0) if( base_exp == 0 && job_exp == 0 ){
return SCRIPT_CMD_SUCCESS; ShowError( "buildin_getexp2: Called with base and job exp 0.\n" );
return SCRIPT_CMD_FAILURE;
}
if (base_exp > 0) if (base_exp > 0)
pc_gainexp(sd, NULL, base_exp, 0, 2); pc_gainexp(sd, NULL, base_exp, 0, 2);

View File

@ -6520,7 +6520,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AB_HIGHNESSHEAL: case AB_HIGHNESSHEAL:
{ {
int heal = skill_calc_heal(src, bl, skill_id, skill_lv, true); int heal = skill_calc_heal(src, bl, skill_id, skill_lv, true);
int heal_get_jobexp;
if (status_isimmune(bl) || (dstmd && (status_get_class(bl) == MOBID_EMPERIUM || status_get_class_(bl) == CLASS_BATTLEFIELD))) if (status_isimmune(bl) || (dstmd && (status_get_class(bl) == MOBID_EMPERIUM || status_get_class_(bl) == CLASS_BATTLEFIELD)))
heal = 0; heal = 0;
@ -6544,7 +6543,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_nodamage (src, bl, skill_id, heal, 1); clif_skill_nodamage (src, bl, skill_id, heal, 1);
if( tsc && tsc->data[SC_AKAITSUKI] && heal && skill_id != HLIF_HEAL ) if( tsc && tsc->data[SC_AKAITSUKI] && heal && skill_id != HLIF_HEAL )
heal = ~heal + 1; heal = ~heal + 1;
heal_get_jobexp = status_heal(bl,heal,0,0); t_exp heal_get_jobexp = status_heal(bl,heal,0,0);
if(sd && dstsd && heal > 0 && sd != dstsd && battle_config.heal_exp > 0){ if(sd && dstsd && heal > 0 && sd != dstsd && battle_config.heal_exp > 0){
heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100; heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100;