summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c12
-rw-r--r--src/map/config/Data/Const.h17
-rw-r--r--src/map/status.c82
-rw-r--r--src/map/status.h25
4 files changed, 42 insertions, 94 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 95756c2f7..5addc4955 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2381,11 +2381,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if (!flag.idef || !flag.idef2)
{ //Defense reduction
short vit_def;
-#if REMODE
- short def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
-#else
- signed char def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
-#endif
+ defType def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
short def2 = (short)tstatus->def2;
if( sd )
@@ -3358,11 +3354,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
}
if(!flag.imdef){
-#if REMODE
- short mdef = tstatus->mdef;
-#else
- char mdef = tstatus->mdef;
-#endif
+ defType mdef = tstatus->mdef;
int mdef2= tstatus->mdef2;
if(sd) {
i = sd->ignore_mdef[is_boss(target)?RC_BOSS:RC_NONBOSS];
diff --git a/src/map/config/Data/Const.h b/src/map/config/Data/Const.h
index 88b00ea21..b4984f9c2 100644
--- a/src/map/config/Data/Const.h
+++ b/src/map/config/Data/Const.h
@@ -42,9 +42,22 @@
* Path within the /db folder to (non-)renewal specific db files
**/
#if REMODE
-#define DBPATH "re/"
+ #define DBPATH "re/"
#else
-#define DBPATH "pre-re/"
+ #define DBPATH "pre-re/"
+#endif
+
+/**
+ * DefType
+ **/
+#if REMODE
+ typedef short defType;
+ #define DEFTYPE_MIN SHRT_MIN
+ #define DEFTYPE_MAX SHRT_MAX
+#else
+ typedef signed char defType;
+ #define DEFTYPE_MIN CHAR_MIN
+ #define DEFTYPE_MAX CHAR_MAX
#endif
/**
diff --git a/src/map/status.c b/src/map/status.c
index 464207060..37d4fe4f1 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2738,11 +2738,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->def_rate = 0;
if(sd->def_rate != 100) {
i = status->def * sd->def_rate/100;
-#if REMODE
- status->def = cap_value(i, SHRT_MIN, SHRT_MAX);
-#else
- status->def = cap_value(i, CHAR_MIN, CHAR_MAX);
-#endif
+ status->def = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX);
}
#if isOFF(REMODE)
/**
@@ -2761,11 +2757,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->mdef_rate = 0;
if(sd->mdef_rate != 100) {
i = status->mdef * sd->mdef_rate/100;
-#if REMODE
- status->mdef = cap_value(i, SHRT_MIN, SHRT_MAX);
-#else
- status->mdef = cap_value(i, CHAR_MIN, CHAR_MAX);
-#endif
+ status->mdef = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX);
}
#if isOFF(REMODE)
/**
@@ -3035,17 +3027,9 @@ static signed short status_calc_hit(struct block_list *,struct status_change *,i
static signed short status_calc_critical(struct block_list *,struct status_change *,int);
static signed short status_calc_flee(struct block_list *,struct status_change *,int);
static signed short status_calc_flee2(struct block_list *,struct status_change *,int);
-#if REMODE
- static short status_calc_def(struct block_list *bl, struct status_change *sc, int);
-#else
- static signed char status_calc_def(struct block_list *,struct status_change *,int);
-#endif
+static defType status_calc_def(struct block_list *bl, struct status_change *sc, int);
static signed short status_calc_def2(struct block_list *,struct status_change *,int);
-#if REMODE
- static short status_calc_mdef(struct block_list *bl, struct status_change *sc, int);
-#else
- static signed char status_calc_mdef(struct block_list *,struct status_change *,int);
-#endif
+static defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int);
static signed short status_calc_mdef2(struct block_list *,struct status_change *,int);
static unsigned short status_calc_speed(struct block_list *,struct status_change *,int);
static short status_calc_aspd_rate(struct block_list *,struct status_change *,int);
@@ -4360,18 +4344,11 @@ static signed short status_calc_flee2(struct block_list *bl, struct status_chang
return (short)cap_value(flee2,10,SHRT_MAX);
}
-#if REMODE
- static short status_calc_def(struct block_list *bl, struct status_change *sc, int def)
-#else
- static signed char status_calc_def(struct block_list *bl, struct status_change *sc, int def)
-#endif
-{
+static defType status_calc_def(struct block_list *bl, struct status_change *sc, int def) {
+
if(!sc || !sc->count)
-#if REMODE
- return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
-#else
- return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
-#endif
+ return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
+
if(sc->data[SC_BERSERK])
return 0;
if(sc->data[SC_SKA])
@@ -4437,11 +4414,8 @@ static signed short status_calc_flee2(struct block_list *bl, struct status_chang
def += def * sc->data[SC_PRESTIGE]->val1 / 100;
if(sc->data[SC_ODINS_POWER])
def -= 20;
-#if REMODE
- return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
-#else
- return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
-#endif
+
+ return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);;
}
static signed short status_calc_def2(struct block_list *bl, struct status_change *sc, int def2)
@@ -4488,18 +4462,11 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
return (short)cap_value(def2,1,SHRT_MAX);
}
-#if REMODE
- static short status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef)
-#else
- static signed char status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef)
-#endif
-{
+
+static defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef) {
+
if(!sc || !sc->count)
-#if REMODE
- return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
-#else
- return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
-#endif
+ return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
if(sc->data[SC_BERSERK])
return 0;
@@ -4537,12 +4504,7 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
if(sc->data[SC_ODINS_POWER])
mdef -= 20;
-
-#if REMODE
- return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
-#else
- return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
-#endif
+ return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
}
static signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, int mdef2)
@@ -5150,23 +5112,15 @@ struct status_data *status_get_base_status(struct block_list *bl)
return NULL;
}
}
-#if REMODE
- short status_get_def(struct block_list *bl)
-#else
- signed char status_get_def(struct block_list *bl)
-#endif
-{
+defType status_get_def(struct block_list *bl) {
struct unit_data *ud;
struct status_data *status = status_get_status_data(bl);
int def = status?status->def:0;
ud = unit_bl2ud(bl);
if (ud && ud->skilltimer != INVALID_TIMER)
def -= def * skill_get_castdef(ud->skillid)/100;
-#if REMODE
- return cap_value(def, SHRT_MIN, SHRT_MAX);
-#else
- return cap_value(def, CHAR_MIN, CHAR_MAX);
-#endif
+
+ return cap_value(def, DEFTYPE_MIN, DEFTYPE_MAX);
}
unsigned short status_get_speed(struct block_list *bl)
diff --git a/src/map/status.h b/src/map/status.h
index e46f0b4a0..7ebe9627b 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -1384,13 +1384,12 @@ struct status_data {
short
hit, flee, cri, flee2,
def2, mdef2,
-#if REMODE
- /**
- * In RE def and mdef can go over 127 (signed char) limit, so in RE mode we use short
- **/
- def,mdef,
-#endif
aspd_rate;
+ /**
+ * defType is REMODE dependent and defined in src/map/config/data/const.h
+ **/
+ defType def,mdef;
+
unsigned char
def_ele, ele_lv,
#if REMODE
@@ -1400,13 +1399,7 @@ struct status_data {
wlv,
#endif
size, race;
-#if REMODE == 0
- /**
- * In NON-RE def and mdef are not required to be short, so we keep it signed char (ancient-default)
- **/
- signed char
- def, mdef;
-#endif
+
struct weapon_atk rhw, lhw; //Right Hand/Left Hand Weapon.
};
@@ -1522,11 +1515,7 @@ int status_get_lv(struct block_list *bl);
#define status_get_luk(bl) status_get_status_data(bl)->luk
#define status_get_hit(bl) status_get_status_data(bl)->hit
#define status_get_flee(bl) status_get_status_data(bl)->flee
-#if REMODE
- short status_get_def(struct block_list *bl);
-#else
- signed char status_get_def(struct block_list *bl);
-#endif
+defType status_get_def(struct block_list *bl);
#define status_get_mdef(bl) status_get_status_data(bl)->mdef
#define status_get_flee2(bl) status_get_status_data(bl)->flee2
#define status_get_def2(bl) status_get_status_data(bl)->def2