diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-05 00:19:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-05 00:19:58 +0300 |
commit | 88a6bbe81cdac8392af63d9732b582fa02b04261 (patch) | |
tree | b3ff5d684c24990a1540bee398b59656c066089c /src/map/script.c | |
parent | a59d2cf735c961d86050ae51d345a5a81cfeb77c (diff) | |
parent | dcc9ee43a4b33ace1501864415f5a856b18f8201 (diff) | |
download | hercules-88a6bbe81cdac8392af63d9732b582fa02b04261.tar.gz hercules-88a6bbe81cdac8392af63d9732b582fa02b04261.tar.bz2 hercules-88a6bbe81cdac8392af63d9732b582fa02b04261.tar.xz hercules-88a6bbe81cdac8392af63d9732b582fa02b04261.zip |
Merge pull request #993 from HerculesWS/mobdb2sql
Mob DB support for the db2sql plugin
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/map/script.c b/src/map/script.c index 64bdba592..f3c839555 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3845,7 +3845,7 @@ void op_2str(struct script_state* st, int op, const char* s1, const char* s2) void op_2num(struct script_state* st, int op, int i1, int i2) { int ret; - double ret_double; + int64 ret64; switch( op ) { case C_AND: ret = i1 & i2; break; @@ -3877,25 +3877,21 @@ void op_2num(struct script_state* st, int op, int i1, int i2) ret = i1 % i2; break; default: - switch( op ) - {// operators that can overflow/underflow - case C_ADD: ret = i1 + i2; ret_double = (double)i1 + (double)i2; break; - case C_SUB: ret = i1 - i2; ret_double = (double)i1 - (double)i2; break; - case C_MUL: ret = i1 * i2; ret_double = (double)i1 * (double)i2; break; + switch (op) { // operators that can overflow/underflow + case C_ADD: ret = i1 + i2; ret64 = (int64)i1 + i2; break; + case C_SUB: ret = i1 - i2; ret64 = (int64)i1 - i2; break; + case C_MUL: ret = i1 * i2; ret64 = (int64)i1 * i2; break; default: ShowError("script:op_2num: unexpected number operator %s i1=%d i2=%d\n", script->op2name(op), i1, i2); script->reportsrc(st); script_pushnil(st); return; } - if( ret_double < (double)INT_MIN ) - { + if (ret64 < INT_MIN) { ShowWarning("script:op_2num: underflow detected op=%s i1=%d i2=%d\n", script->op2name(op), i1, i2); script->reportsrc(st); ret = INT_MIN; - } - else if( ret_double > (double)INT_MAX ) - { + } else if (ret64 > INT_MAX) { ShowWarning("script:op_2num: overflow detected op=%s i1=%d i2=%d\n", script->op2name(op), i1, i2); script->reportsrc(st); ret = INT_MAX; @@ -9702,20 +9698,18 @@ BUILDIN(makepet) BUILDIN(getexp) { int base=0,job=0; - double bonus; struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; - base=script_getnum(st,2); - job =script_getnum(st,3); - if(base<0 || job<0) + base = script_getnum(st,2); + job = script_getnum(st,3); + if (base < 0 || job < 0) return true; // bonus for npc-given exp - bonus = battle_config.quest_exp_rate / 100.; - base = (int) cap_value(base * bonus, 0, INT_MAX); - job = (int) cap_value(job * bonus, 0, INT_MAX); + base = cap_value(apply_percentrate(base, battle_config.quest_exp_rate, 100), 0, INT_MAX); + job = cap_value(apply_percentrate(job, battle_config.quest_exp_rate, 100), 0, INT_MAX); pc->gainexp(sd, &sd->bl, base, job, true); |