summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c96
1 files changed, 42 insertions, 54 deletions
diff --git a/src/map/status.c b/src/map/status.c
index 4f1813af6..25c7e13dc 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1080,7 +1080,6 @@ void initDummyData(void)
status->dummy.mode = MD_CANMOVE;
}
-
//For copying a status_data structure from b to a, without overwriting current Hp and Sp
static inline void status_cpy(struct status_data* a, const struct status_data* b)
{
@@ -1193,7 +1192,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
struct status_change_entry *sce;
#ifdef DEVOTION_REFLECT_DAMAGE
- if(src && (sce = sc->data[SC_DEVOTION])) {
+ if (src && (sce = sc->data[SC_DEVOTION]) != NULL) {
struct block_list *d_bl = map->id2bl(sce->val1);
if(d_bl &&((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id)
@@ -1589,7 +1588,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
//on dead characters, said checks are left to skill.c [Skotlex]
if (target && status->isdead(target))
return 0;
- if( src && (sc = status->get_sc(src)) && sc->data[SC_COLD] && src->type != BL_MOB)
+ if( src && (sc = status->get_sc(src)) != NULL && sc->data[SC_COLD] && src->type != BL_MOB)
return 0;
}
@@ -1631,7 +1630,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
break;
case AL_TELEPORT:
//Should fail when used on top of Land Protector [Skotlex]
- if (src && map->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR)
+ if (src && map->getcell(src->m, src, src->x, src->y, CELL_CHKLANDPROTECTOR)
&& !(st->mode&MD_BOSS)
&& (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id))
return 0;
@@ -1876,8 +1875,8 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
if (md->special_state.size)
flag|=2;
- if( md->guardian_data && md->guardian_data->g
- && (guardup_lv = guild->checkskill(md->guardian_data->g,GD_GUARDUP)) )
+ if (md->guardian_data && md->guardian_data->g
+ && (guardup_lv = guild->checkskill(md->guardian_data->g,GD_GUARDUP)) > 0)
flag|=4;
if (battle_config.slaves_inherit_speed && md->master_id)
@@ -1953,7 +1952,6 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
mstatus->speed -= cap_value(diff, 0, mstatus->speed - 10);
}
-
if (flag&2 && battle_config.mob_size_influence) {
// change for sized monsters [Valaris]
if (md->special_state.size==SZ_MEDIUM) {
@@ -2456,7 +2454,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if( data && data->script )
script->run_use_script(sd, data, 0);
}
-
+
status->calc_pc_additional(sd, opt);
if( sd->pd ) { // Pet Bonus
@@ -2603,7 +2601,6 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
if( (skill_lv = pc->checkskill(sd,WM_LESSON)) > 0 )
bstatus->max_sp += 30 * skill_lv;
-
// Apply relative modifiers from equipment
if(sd->sprate < 0)
sd->sprate = 0;
@@ -2705,7 +2702,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
}
if( (sd->status.weapon == W_1HAXE || sd->status.weapon == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0 )
bstatus->hit += 3*skill_lv;
- if((sd->status.weapon == W_MACE || sd->status.weapon == W_2HMACE) && ((skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0))
+ if((sd->status.weapon == W_MACE || sd->status.weapon == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
bstatus->hit += 2*skill_lv;
// ----- FLEE CALCULATION -----
@@ -2782,7 +2779,6 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
#endif
bstatus->adelay = 2*bstatus->amotion;
-
// ----- DMOTION -----
//
i = 800-bstatus->agi*4;
@@ -3540,12 +3536,6 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) {
st->cri = status->calc_critical(bl, sc, bst->cri, true);
else
st->cri = status->calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true);
- /**
- * after status_calc_critical so the bonus is applied despite if you have or not a sc bugreport:5240
- **/
- if( bl->type == BL_PC && ((TBL_PC*)bl)->status.weapon == W_KATAR )
- st->cri <<= 1;
-
}
if(flag&SCB_FLEE2 && bst->flee2) {
@@ -5087,7 +5077,6 @@ signed short status_calc_def2(struct block_list *bl, struct status_change *sc, i
#endif
}
-
defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef, bool viewable) {
if(!sc || !sc->count)
@@ -5801,7 +5790,6 @@ unsigned char status_calc_element_lv(struct block_list *bl, struct status_change
return (unsigned char)cap_value(lv,1,4);
}
-
unsigned char status_calc_attack_element(struct block_list *bl, struct status_change *sc, int element)
{
if(!sc || !sc->count)
@@ -7553,11 +7541,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( sd ) {
int i;
for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
- if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
+ if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) != NULL)
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL);
}
- } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
+ } else if (bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) != NULL) {
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL);
+ }
}
//val4 signals infinite endure (if val4 == 2 it is infinite endure from Berserk)
if( val4 )
@@ -7652,11 +7641,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( sd ) {
int i;
for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
- if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
+ if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) != NULL)
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
- } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
+ } else if (bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) != NULL) {
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
+ }
}
break;
case SC_NOEQUIPWEAPON:
@@ -7910,12 +7900,13 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
if( bl->type&(BL_PC|BL_MER) ) {
if( sd ) {
for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
- if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) )
+ if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) != NULL)
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
}
}
- else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) )
+ else if (bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) != NULL) {
status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL);
+ }
}
}
break;
@@ -7931,7 +7922,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
int i;
for (i = 0; i < MAX_PC_DEVOTION; i++) {
//See if there are devoted characters, and pass the status to them. [Skotlex]
- if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])))
+ if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) != NULL)
status->change_start(bl, &tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,SCFLAG_NOAVOID);
}
}
@@ -8068,7 +8059,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
struct block_list *d_bl;
struct status_change *d_sc;
- if ((d_bl = map->id2bl(val1)) && (d_sc = status->get_sc(d_bl)) && d_sc->count) {
+ if ((d_bl = map->id2bl(val1)) && (d_sc = status->get_sc(d_bl)) != NULL && d_sc->count) {
// Inherits Status From Source
const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE };
int i = (map_flag_gvg(bl->m) || map->list[bl->m].flag.battleground)?2:3;
@@ -8970,6 +8961,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
{
int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5;
+ if (sp < 1) sp = 1;
+ if (hp < 1) hp = 1;
+
if( rnd()%100 > (25 + 10 * val1) - status_get_int(bl) / 2)
return 0;
@@ -9531,12 +9525,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
++(sc->count);
sce = sc->data[type] = ers_alloc(status->data_ers, struct status_change_entry);
}
-
+
sce->val1 = val1;
sce->val2 = val2;
sce->val3 = val3;
sce->val4 = val4;
-
+
if (tick >= 0) {
sce->timer = timer->add(timer->gettick() + tick, status->change_timer, bl->id, type);
sce->infinite_duration = false;
@@ -9727,7 +9721,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
return 0;
st = status->get_status_data(bl);
-
+
if( sd && sce->infinite_duration && !sd->state.loggingout )
chrif->del_scdata_single(sd->status.account_id,sd->status.char_id,type);
@@ -9823,7 +9817,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
// Clear Status from others
int i;
for( i = 0; i < MAX_PC_DEVOTION; i++ ) {
- if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) && tsd->sc.data[type] )
+ if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) != NULL && tsd->sc.data[type])
status_change_end(&tsd->bl, type, INVALID_TIMER);
}
} else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag ) {
@@ -9884,7 +9878,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
sd->delunit_prevline = line;
}
- if (sce->val4 && sce->val4 != BCT_SELF && (dsd=map->id2sd(sce->val4))) {
+ if (sce->val4 && sce->val4 != BCT_SELF && (dsd=map->id2sd(sce->val4)) != NULL) {
// end status on partner as well
dsc = dsd->sc.data[SC_DANCING];
if (dsc) {
@@ -9909,7 +9903,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
sce->val2 = 0;
-
+
if( group )
skill->del_unitgroup(group,ALC_MARK);
}
@@ -10073,7 +10067,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
struct block_list *tbl = map->id2bl(sce->val2);
struct status_change *tsc = NULL;
sce->val2 = 0;
- if( tbl && (tsc = status->get_sc(tbl)) && tsc->data[SC_STOP] && tsc->data[SC_STOP]->val2 == bl->id )
+ if (tbl && (tsc = status->get_sc(tbl)) != NULL && tsc->data[SC_STOP] && tsc->data[SC_STOP]->val2 == bl->id)
status_change_end(tbl, SC_STOP, INVALID_TIMER);
}
break;
@@ -10438,7 +10432,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
skill->unit_move(bl,timer->gettick(),1);
if (opt_flag & 2 && sd) {
- if (map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
+ if (map->getcell(bl->m, bl, bl->x, bl->y, CELL_CHKNPC))
npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
else
npc->untouch_areanpc(sd, bl->m, bl->x, bl->y);
@@ -10455,10 +10449,7 @@ int kaahi_heal_timer(int tid, int64 tick, int id, intptr_t data) {
struct status_data *st;
int hp;
- if(!( (bl=map->id2bl(id))
- && (sc=status->get_sc(bl))
- && (sce=sc->data[SC_KAAHI])
- ))
+ if ((bl=map->id2bl(id)) == NULL || (sc=status->get_sc(bl)) == NULL || (sce=sc->data[SC_KAAHI]) == NULL)
return 0;
if(sce->val4 != tid) {
@@ -10502,7 +10493,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
sc = status->get_sc(bl);
st = status->get_status_data(bl);
- if (!(sc && (sce = sc->data[type]))) {
+ if (!sc || (sce = sc->data[type]) == NULL) {
ShowDebug("status_change_timer: Null pointer id: %d data: %"PRIdPTR" bl-type: %d\n", id, data, bl->type);
return 0;
}
@@ -10511,7 +10502,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id);
return 0;
}
-
+
sce->timer = INVALID_TIMER;
sd = BL_CAST(BL_PC, bl);
@@ -10949,15 +10940,14 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
int heal = st->max_hp * 3 / 100;
if (sc->count && sc->data[SC_AKAITSUKI] && heal)
heal = ~heal + 1;
-
+
map->freeblock_lock();
-
status->heal(bl, heal, 0, 2);
if( sc->data[type] ) {
sc_timer_next(5000 + tick, status->change_timer, bl->id, data);
}
map->freeblock_unlock();
-
+
return 0;
}
break;
@@ -11116,7 +11106,6 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
}
break;
-
case SC_SATURDAY_NIGHT_FEVER:
if( --(sce->val3) >= 0 ) {
if( !status->charge(bl, st->max_hp * 1 / 100, st->max_sp * 1 / 100) )
@@ -11657,7 +11646,7 @@ int status_change_clear_buffs (struct block_list* bl, int type) {
return 0;
map->freeblock_lock();
-
+
if (type&6) //Debuffs
for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++)
status_change_end(bl, (sc_type)i, INVALID_TIMER);
@@ -11704,9 +11693,9 @@ int status_change_clear_buffs (struct block_list* bl, int type) {
}
status_change_end(bl, (sc_type)i, INVALID_TIMER);
}
-
+
map->freeblock_unlock();
-
+
return 0;
}
@@ -11839,7 +11828,7 @@ int status_natural_heal(struct block_list* bl, va_list args) {
if (flag&(RGN_SHP|RGN_SSP)
&& regen->ssregen
- && (vd = status->get_viewdata(bl))
+ && (vd = status->get_viewdata(bl)) != NULL
&& vd->dead_sit == 2
) {
//Apply sitting regen bonus.
@@ -12172,7 +12161,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
if ((temp = libconfig->setting_get_member(jdb, "HPTable"))) {
int level = 0, avg_increment, base;
config_setting_t *hp = NULL;
- while (level <= MAX_LEVEL && (hp = libconfig->setting_get_elem(temp, level))) {
+ while (level <= MAX_LEVEL && (hp = libconfig->setting_get_elem(temp, level)) != NULL) {
i32 = libconfig->setting_get_int(hp);
status->dbs->HP_table[idx][++level] = min(i32, battle_config.max_hp);
}
@@ -12192,7 +12181,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
if ((temp = libconfig->setting_get_member(jdb, "SPTable"))) {
int level = 0, avg_increment, base;
config_setting_t *sp = NULL;
- while (level <= MAX_LEVEL && (sp = libconfig->setting_get_elem(temp, level))) {
+ while (level <= MAX_LEVEL && (sp = libconfig->setting_get_elem(temp, level)) != NULL) {
i32 = libconfig->setting_get_int(sp);
status->dbs->SP_table[idx][++level] = min(i32, battle_config.max_sp);
}
@@ -12221,11 +12210,10 @@ void status_read_job_db(void) { /* [malufett/Hercules] */
int i = 0;
config_t job_db_conf;
config_setting_t *jdb = NULL;
- const char *config_filename =
#ifdef RENEWAL_ASPD
- "db/re/job_db.conf";
+ const char *config_filename = "db/re/job_db.conf";
#else
- "db/pre-re/job_db.conf";
+ const char *config_filename = "db/pre-re/job_db.conf";
#endif
if ( libconfig->read_file(&job_db_conf, config_filename) ) {