diff options
author | Haru <haru@dotalux.com> | 2013-09-25 00:29:15 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-25 00:29:15 +0200 |
commit | 44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7 (patch) | |
tree | 1c1e300503d99ecbe8b41355daa716858aaece5d /src/config/const.h | |
parent | b9c8f57b92d2935db971a38e144529682712dc82 (diff) | |
download | hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.gz hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.bz2 hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.tar.xz hercules-44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7.zip |
Renamed more forgotten variables during interface conversions
(related: b9c8f57)
Most renames are trivial (just to avoid shadowing global variables, even
if they currently did no harm), but there were some cases of partly
renamed variables that caused some NULL checks to always pass and who
knows what could have been happened when they were too subtle to make
the application crash.
Also corrected some potentially unsafe macro definitions
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/config/const.h')
-rw-r--r-- | src/config/const.h | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/config/const.h b/src/config/const.h index f0902759d..7badb1071 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -53,39 +53,42 @@ /* pointer size fix which fixes several gcc warnings */ #ifdef __64BIT__ - #define __64BPTRSIZE(y) (intptr)y + #define __64BPTRSIZE(y) ((intptr)(y)) #else - #define __64BPTRSIZE(y) y + #define __64BPTRSIZE(y) (y) #endif /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL - #define MOB_FLEE(mob) ( mob->lv + mob->status.agi + 100 ) - #define MOB_HIT(mob) ( mob->lv + mob->status.dex + 150 ) - #define RE_SKILL_REDUCTION(){ \ - wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag), nk, n_ele, s_ele, s_ele_, false, flag.arrow); \ - if( flag.lh ) \ - wd.damage2 = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 1, wd.flag), nk, n_ele, s_ele, s_ele_, true, flag.arrow); \ - } + #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) + #define MOB_HIT(mobdata) ( (mobdata)->lv + (mobdata)->status.dex + 150 ) + #define RE_SKILL_REDUCTION() do { \ + wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag), nk, n_ele, s_ele, s_ele_, false, flag.arrow); \ + if( flag.lh ) \ + wd.damage2 = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 1, wd.flag), nk, n_ele, s_ele, s_ele_, true, flag.arrow); \ + } while(0) #else - #define MOB_FLEE(mob) ( mob->lv + mob->status.agi ) - #define MOB_HIT(mob) ( mob->lv + mob->status.dex ) + #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi ) + #define MOB_HIT(mobdata) ( (mobdata)->lv + (mobdata)->status.dex ) #endif /* Renewal's dmg level modifier, used as a macro for a easy way to turn off. */ #ifdef RENEWAL_LVDMG - #define RE_LVL_DMOD(val) \ - if( iStatus->get_lv(src) > 100 && val > 0 ) \ - skillratio = skillratio * iStatus->get_lv(src) / val; - #define RE_LVL_MDMOD(val) \ - if( iStatus->get_lv(src) > 100 && val > 0) \ - md.damage = md.damage * iStatus->get_lv(src) / val; + #define RE_LVL_DMOD(val) do { \ + if( iStatus->get_lv(src) > 100 && (val) > 0 ) \ + skillratio = skillratio * iStatus->get_lv(src) / (val); \ + } while(0) + #define RE_LVL_MDMOD(val) do { \ + if( iStatus->get_lv(src) > 100 && (val) > 0) \ + md.damage = md.damage * iStatus->get_lv(src) / (val); \ + } while(0) /* ranger traps special */ - #define RE_LVL_TMDMOD() \ + #define RE_LVL_TMDMOD() do { \ if( iStatus->get_lv(src) > 100 ) \ - md.damage = md.damage * 150 / 100 + md.damage * iStatus->get_lv(src) / 100; + md.damage = md.damage * 150 / 100 + md.damage * iStatus->get_lv(src) / 100; \ + } while(0) #else - #define RE_LVL_DMOD(val) + #define RE_LVL_DMOD(val) #define RE_LVL_MDMOD(val) #define RE_LVL_TMDMOD() #endif @@ -100,10 +103,10 @@ // Renewal variable cast time reduction #ifdef RENEWAL_CAST - #define VARCAST_REDUCTION(val){ \ - if( (varcast_r += val) != 0 && varcast_r >= 0 ) \ - time = time * (1 - (float)min(val, 100) / 100); \ - } + #define VARCAST_REDUCTION(val) do { \ + if( (varcast_r += (val)) != 0 && varcast_r >= 0 ) \ + time = time * (1 - (float)min((val), 100) / 100); \ + } while(0) #endif /* console_input doesn't go well with minicore */ |