Some minor code cleanup (gepard's idea from some time ago)
- Removed a dozen #REMODE checks. - Added a typedef for the def type var git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15776 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
7ddb5fa88a
commit
878c8cfe07
@ -2381,11 +2381,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
|
|||||||
if (!flag.idef || !flag.idef2)
|
if (!flag.idef || !flag.idef2)
|
||||||
{ //Defense reduction
|
{ //Defense reduction
|
||||||
short vit_def;
|
short vit_def;
|
||||||
#if REMODE
|
defType def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
|
||||||
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
|
|
||||||
short def2 = (short)tstatus->def2;
|
short def2 = (short)tstatus->def2;
|
||||||
|
|
||||||
if( sd )
|
if( sd )
|
||||||
@ -3358,11 +3354,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!flag.imdef){
|
if(!flag.imdef){
|
||||||
#if REMODE
|
defType mdef = tstatus->mdef;
|
||||||
short mdef = tstatus->mdef;
|
|
||||||
#else
|
|
||||||
char mdef = tstatus->mdef;
|
|
||||||
#endif
|
|
||||||
int mdef2= tstatus->mdef2;
|
int mdef2= tstatus->mdef2;
|
||||||
if(sd) {
|
if(sd) {
|
||||||
i = sd->ignore_mdef[is_boss(target)?RC_BOSS:RC_NONBOSS];
|
i = sd->ignore_mdef[is_boss(target)?RC_BOSS:RC_NONBOSS];
|
||||||
|
@ -42,9 +42,22 @@
|
|||||||
* Path within the /db folder to (non-)renewal specific db files
|
* Path within the /db folder to (non-)renewal specific db files
|
||||||
**/
|
**/
|
||||||
#if REMODE
|
#if REMODE
|
||||||
#define DBPATH "re/"
|
#define DBPATH "re/"
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2738,11 +2738,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
|
|||||||
sd->def_rate = 0;
|
sd->def_rate = 0;
|
||||||
if(sd->def_rate != 100) {
|
if(sd->def_rate != 100) {
|
||||||
i = status->def * sd->def_rate/100;
|
i = status->def * sd->def_rate/100;
|
||||||
#if REMODE
|
status->def = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX);
|
||||||
status->def = cap_value(i, SHRT_MIN, SHRT_MAX);
|
|
||||||
#else
|
|
||||||
status->def = cap_value(i, CHAR_MIN, CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if isOFF(REMODE)
|
#if isOFF(REMODE)
|
||||||
/**
|
/**
|
||||||
@ -2761,11 +2757,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
|
|||||||
sd->mdef_rate = 0;
|
sd->mdef_rate = 0;
|
||||||
if(sd->mdef_rate != 100) {
|
if(sd->mdef_rate != 100) {
|
||||||
i = status->mdef * sd->mdef_rate/100;
|
i = status->mdef * sd->mdef_rate/100;
|
||||||
#if REMODE
|
status->mdef = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX);
|
||||||
status->mdef = cap_value(i, SHRT_MIN, SHRT_MAX);
|
|
||||||
#else
|
|
||||||
status->mdef = cap_value(i, CHAR_MIN, CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if isOFF(REMODE)
|
#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_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_flee(struct block_list *,struct status_change *,int);
|
||||||
static signed short status_calc_flee2(struct block_list *,struct status_change *,int);
|
static signed short status_calc_flee2(struct block_list *,struct status_change *,int);
|
||||||
#if REMODE
|
static defType status_calc_def(struct block_list *bl, struct status_change *sc, int);
|
||||||
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 signed short status_calc_def2(struct block_list *,struct status_change *,int);
|
static signed short status_calc_def2(struct block_list *,struct status_change *,int);
|
||||||
#if REMODE
|
static defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int);
|
||||||
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 signed short status_calc_mdef2(struct block_list *,struct status_change *,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 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);
|
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);
|
return (short)cap_value(flee2,10,SHRT_MAX);
|
||||||
}
|
}
|
||||||
#if REMODE
|
static defType status_calc_def(struct block_list *bl, struct status_change *sc, int def) {
|
||||||
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
|
|
||||||
{
|
|
||||||
if(!sc || !sc->count)
|
if(!sc || !sc->count)
|
||||||
#if REMODE
|
return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
|
||||||
return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
|
|
||||||
#else
|
|
||||||
return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
if(sc->data[SC_BERSERK])
|
if(sc->data[SC_BERSERK])
|
||||||
return 0;
|
return 0;
|
||||||
if(sc->data[SC_SKA])
|
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;
|
def += def * sc->data[SC_PRESTIGE]->val1 / 100;
|
||||||
if(sc->data[SC_ODINS_POWER])
|
if(sc->data[SC_ODINS_POWER])
|
||||||
def -= 20;
|
def -= 20;
|
||||||
#if REMODE
|
|
||||||
return (short)cap_value(def,SHRT_MIN,SHRT_MAX);
|
return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);;
|
||||||
#else
|
|
||||||
return (signed char)cap_value(def,CHAR_MIN,CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static signed short status_calc_def2(struct block_list *bl, struct status_change *sc, int def2)
|
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);
|
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)
|
static defType 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
|
|
||||||
{
|
|
||||||
if(!sc || !sc->count)
|
if(!sc || !sc->count)
|
||||||
#if REMODE
|
return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
|
||||||
return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
|
|
||||||
#else
|
|
||||||
return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(sc->data[SC_BERSERK])
|
if(sc->data[SC_BERSERK])
|
||||||
return 0;
|
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])
|
if(sc->data[SC_ODINS_POWER])
|
||||||
mdef -= 20;
|
mdef -= 20;
|
||||||
|
|
||||||
|
return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
|
||||||
#if REMODE
|
|
||||||
return (short)cap_value(mdef,SHRT_MIN,SHRT_MAX);
|
|
||||||
#else
|
|
||||||
return (signed char)cap_value(mdef,CHAR_MIN,CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, int mdef2)
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if REMODE
|
defType status_get_def(struct block_list *bl) {
|
||||||
short status_get_def(struct block_list *bl)
|
|
||||||
#else
|
|
||||||
signed char status_get_def(struct block_list *bl)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
struct unit_data *ud;
|
struct unit_data *ud;
|
||||||
struct status_data *status = status_get_status_data(bl);
|
struct status_data *status = status_get_status_data(bl);
|
||||||
int def = status?status->def:0;
|
int def = status?status->def:0;
|
||||||
ud = unit_bl2ud(bl);
|
ud = unit_bl2ud(bl);
|
||||||
if (ud && ud->skilltimer != INVALID_TIMER)
|
if (ud && ud->skilltimer != INVALID_TIMER)
|
||||||
def -= def * skill_get_castdef(ud->skillid)/100;
|
def -= def * skill_get_castdef(ud->skillid)/100;
|
||||||
#if REMODE
|
|
||||||
return cap_value(def, SHRT_MIN, SHRT_MAX);
|
return cap_value(def, DEFTYPE_MIN, DEFTYPE_MAX);
|
||||||
#else
|
|
||||||
return cap_value(def, CHAR_MIN, CHAR_MAX);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short status_get_speed(struct block_list *bl)
|
unsigned short status_get_speed(struct block_list *bl)
|
||||||
|
@ -1384,13 +1384,12 @@ struct status_data {
|
|||||||
short
|
short
|
||||||
hit, flee, cri, flee2,
|
hit, flee, cri, flee2,
|
||||||
def2, mdef2,
|
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;
|
aspd_rate;
|
||||||
|
/**
|
||||||
|
* defType is REMODE dependent and defined in src/map/config/data/const.h
|
||||||
|
**/
|
||||||
|
defType def,mdef;
|
||||||
|
|
||||||
unsigned char
|
unsigned char
|
||||||
def_ele, ele_lv,
|
def_ele, ele_lv,
|
||||||
#if REMODE
|
#if REMODE
|
||||||
@ -1400,13 +1399,7 @@ struct status_data {
|
|||||||
wlv,
|
wlv,
|
||||||
#endif
|
#endif
|
||||||
size, race;
|
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.
|
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_luk(bl) status_get_status_data(bl)->luk
|
||||||
#define status_get_hit(bl) status_get_status_data(bl)->hit
|
#define status_get_hit(bl) status_get_status_data(bl)->hit
|
||||||
#define status_get_flee(bl) status_get_status_data(bl)->flee
|
#define status_get_flee(bl) status_get_status_data(bl)->flee
|
||||||
#if REMODE
|
defType status_get_def(struct block_list *bl);
|
||||||
short status_get_def(struct block_list *bl);
|
|
||||||
#else
|
|
||||||
signed char status_get_def(struct block_list *bl);
|
|
||||||
#endif
|
|
||||||
#define status_get_mdef(bl) status_get_status_data(bl)->mdef
|
#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_flee2(bl) status_get_status_data(bl)->flee2
|
||||||
#define status_get_def2(bl) status_get_status_data(bl)->def2
|
#define status_get_def2(bl) status_get_status_data(bl)->def2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user