summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-11-18 08:53:22 +0100
committerHaru <haru@dotalux.com>2013-11-19 03:41:30 +0100
commit12dce46d611d6ea7c772174ebbd555fa10fead99 (patch)
tree8f953e4166750c2ec1cbd1df89717b8d5dc8f455 /src/map/status.c
parent51cbaf27c96e874850588ddcfa13b656db45bb2e (diff)
downloadhercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.gz
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.bz2
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.xz
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.zip
Sanitized and improved several macros through the code
- Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/map/status.c b/src/map/status.c
index a8389691f..d64986eca 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -102,10 +102,6 @@ int status_type2relevant_bl_types(int type)
return status->RelevantBLTypes[type];
}
-#define add_sc(skill,sc) set_sc(skill,sc,SI_BLANK,SCB_NONE)
-// indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units
-#define set_sc_with_vfx(skill, sc, icon, flag) set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT
-
static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) {
uint16 idx;
if( (idx = skill->get_index(skill_id)) == 0 ) {
@@ -128,6 +124,10 @@ static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) {
}
void initChangeTables(void) {
+#define add_sc(skill,sc) set_sc((skill),(sc),SI_BLANK,SCB_NONE)
+// indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units
+#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0)
+
int i;
for (i = 0; i < SC_MAX; i++)
@@ -1034,6 +1034,8 @@ void initChangeTables(void) {
if( !battle_config.display_hallucination ) //Disable Hallucination.
status->IconChangeTable[SC_ILLUSION] = SI_BLANK;
+#undef add_sc
+#undef set_sc_with_vfx
}
void initDummyData(void)
@@ -8559,12 +8561,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_GENSOU:
- #define PER( a ) do { \
- if( a <= 15 ) lv = 1; \
- else if( a <= 30 ) lv = 2; \
- else if( a <= 50 ) lv = 3; \
- else if( a <= 75 ) lv = 4; \
- } while(0)
+#define PER( a, lvl ) do { \
+ int temp__ = (a); \
+ if( temp__ <= 15 ) (lvl) = 1; \
+ else if( temp__ <= 30 ) (lvl) = 2; \
+ else if( temp__ <= 50 ) (lvl) = 3; \
+ else if( temp__ <= 75 ) (lvl) = 4; \
+ else (lvl) = 5; \
+} while(0)
{
int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5;
@@ -8572,13 +8576,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if( rand()%100 > (25 + 10 * val1) - status_get_int(bl) / 2)
return 0;
- PER( 100 / (status_get_max_hp(bl) / hp) );
+ PER( 100 / (status_get_max_hp(bl) / hp), lv );
status->heal(bl, (!(hp%2) ? (6-lv) *4 / 100 : -(lv*4) / 100), 0, 1);
- PER( 100 / (status_get_max_sp(bl) / sp) );
+ PER( 100 / (status_get_max_sp(bl) / sp), lv );
status->heal(bl, 0,(!(sp%2) ? (6-lv) *3 / 100 : -(lv*3) / 100), 1);
}
- #undef PER
+#undef PER
break;
case SC_ANGRIFFS_MODUS:
val2 = 50 + 20 * val1; //atk bonus
@@ -10022,7 +10026,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
// set the next timer of the sce (don't assume the status still exists)
#define sc_timer_next(t,f,i,d) do { \
if( (sce=sc->data[type]) ) \
- sce->timer = timer->add(t,f,i,d); \
+ sce->timer = timer->add((t),(f),(i),(d)); \
else \
ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data); \
} while(0)