diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mob.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 24 | ||||
-rw-r--r-- | src/map/pc.h | 4 |
3 files changed, 15 insertions, 17 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 765acafe7..d82e49bcc 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2546,7 +2546,7 @@ static int mob_dead(struct mob_data *md, struct block_list *src, int type) if(sd) { // process script-granted extra drop bonuses int itemid = 0; - for (i = 0; i < ARRAYLENGTH(sd->add_drop) && (sd->add_drop[i].id || sd->add_drop[i].group); i++) + for (i = 0; i < ARRAYLENGTH(sd->add_drop) && (sd->add_drop[i].id != 0 || sd->add_drop[i].is_group); i++) { if ( sd->add_drop[i].race == -md->class_ || ( sd->add_drop[i].race > 0 && ( @@ -2568,7 +2568,7 @@ static int mob_dead(struct mob_data *md, struct block_list *src, int type) if (rnd()%10000 >= drop_rate) continue; - itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb->chain_item(sd->add_drop[i].group,&drop_rate); + itemid = (!sd->add_drop[i].is_group) ? sd->add_drop[i].id : itemdb->chain_item(sd->add_drop[i].id, &drop_rate); if( itemid ) mob->item_drop(md, dlist, mob->setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly); } diff --git a/src/map/pc.c b/src/map/pc.c index 94d8cd0c6..95c10cbe7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2221,11 +2221,12 @@ static int pc_bonus_addeff_onskill(struct s_addeffectonskill *effect, int max, e return 1; } -static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race_mask, int rate) +static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, int id, bool is_group, int race_mask, int rate) { int i; nullpo_ret(drop); + Assert_ret(is_group || id > 0); //Apply config rate adjustment settings. if (rate >= 0) { //Absolute drop. if (battle_config.item_rate_adddrop != 100) @@ -2240,17 +2241,14 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id if (rate > -1) rate = -1; } - for(i = 0; i < max && (drop[i].id || drop[i].group); i++) { - if (((id && drop[i].id == id) || (group && drop[i].group == group)) - && race_mask != RCMASK_NONE - ) { + for (i = 0; i < max && (drop[i].id != 0 || drop[i].is_group); i++) { + if (drop[i].id == id && race_mask != RCMASK_NONE) { drop[i].race |= race_mask; if (drop[i].rate > 0 && rate > 0) { //Both are absolute rates. if (drop[i].rate < rate) drop[i].rate = rate; - } else - if(drop[i].rate < 0 && rate < 0) { + } else if (drop[i].rate < 0 && rate < 0) { //Both are relative rates. if (drop[i].rate > rate) drop[i].rate = rate; @@ -2264,7 +2262,7 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id return 0; } drop[i].id = id; - drop[i].group = group; + drop[i].is_group = is_group; drop[i].race |= race_mask; drop[i].rate = rate; return 1; @@ -3111,7 +3109,7 @@ static int pc_bonus(struct map_session_data *sd, int type, int val) #endif case SP_ADD_MONSTER_DROP_CHAINITEM: if (sd->state.lr_flag != 2) - pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, val, map->race_id2mask(RC_ALL), 10000); + pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), val, true, map->race_id2mask(RC_ALL), 10000); break; case SP_ADDMAXWEIGHT: if (sd->state.lr_flag != 2) @@ -3686,7 +3684,7 @@ static int pc_bonus2(struct map_session_data *sd, int type, int type2, int val) break; case SP_ADD_MONSTER_DROP_ITEM: if (sd->state.lr_flag != 2) - pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, map->race_id2mask(RC_ALL), val); + pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, false, map->race_id2mask(RC_ALL), val); break; case SP_SP_LOSS_RATE: if(sd->state.lr_flag != 2) { @@ -3892,7 +3890,7 @@ static int pc_bonus2(struct map_session_data *sd, int type, int type2, int val) break; } if (sd->state.lr_flag != 2) - pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, type2, race_mask, 10000); + pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, true, race_mask, 10000); } break; #ifdef RENEWAL @@ -3932,12 +3930,12 @@ static int pc_bonus3(struct map_session_data *sd, int type, int type2, int type3 break; } if (sd->state.lr_flag != 2) - pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, race_mask, val); + pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, false, race_mask, val); } break; case SP_ADD_CLASS_DROP_ITEM: if(sd->state.lr_flag != 2) - pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, -type3, val); + pc->bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, false, -type3, val); break; case SP_AUTOSPELL: if(sd->state.lr_flag != 2) diff --git a/src/map/pc.h b/src/map/pc.h index bc2fd5a62..90e59edb2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -151,8 +151,8 @@ struct s_addeffectonskill { unsigned char target; }; struct s_add_drop { + bool is_group; int id; - short group; int race, rate; }; struct s_autobonus { @@ -1124,7 +1124,7 @@ END_ZEROED_BLOCK; /* End */ int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, int card_id); int (*bonus_addeff) (struct s_addeffect* effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration); int (*bonus_addeff_onskill) (struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target); - int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate); + int (*bonus_item_drop) (struct s_add_drop *drop, const short max, int id, bool is_group, int race, int rate); void (*calcexp) (struct map_session_data *sd, uint64 *base_exp, uint64 *job_exp, struct block_list *src); int (*respawn_timer) (int tid, int64 tick, int id, intptr_t data); int (*jobchange_killclone) (struct block_list *bl, va_list ap); |