summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c27
-rw-r--r--src/map/map.h15
-rw-r--r--src/map/mob.c4
-rw-r--r--src/map/pc.c185
-rw-r--r--src/map/skill.c8
-rw-r--r--src/map/status.c6
6 files changed, 108 insertions, 137 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 4ec4e652d..93bc5e1d0 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -817,7 +817,7 @@ static int battle_blewcount_bonus(struct map_session_data *sd, int skill_num)
if (!sd->skillblown[0].id)
return 0;
//Apply the bonus blewcount. [Skotlex]
- for (i = 0; i < MAX_PC_BONUS && sd->skillblown[i].id; i++) {
+ for (i = 0; i < ARRAYLENGTH(sd->skillblown) && sd->skillblown[i].id; i++) {
if (sd->skillblown[i].id == skill_num)
return sd->skillblown[i].val;
}
@@ -1871,18 +1871,18 @@ static struct Damage battle_calc_weapon_attack(
}
}
- for(i=0;i<sd->right_weapon.add_damage_class_count;i++) {
- if(sd->right_weapon.add_damage_classid[i] == t_class) {
- cardfix=cardfix*(100+sd->right_weapon.add_damage_classrate[i])/100;
+ for(i=0;i<ARRAYLENGTH(sd->right_weapon.add_dmg) && sd->right_weapon.add_dmg[i].rate;i++) {
+ if(sd->right_weapon.add_dmg[i].class_ == t_class) {
+ cardfix=cardfix*(100+sd->right_weapon.add_dmg[i].rate)/100;
break;
}
}
if (flag.lh)
{
- for(i=0;i<sd->left_weapon.add_damage_class_count;i++) {
- if(sd->left_weapon.add_damage_classid[i] == t_class) {
- cardfix_=cardfix_*(100+sd->left_weapon.add_damage_classrate[i])/100;
+ for(i=0;i<ARRAYLENGTH(sd->left_weapon.add_dmg) && sd->left_weapon.add_dmg[i].rate;i++) {
+ if(sd->left_weapon.add_dmg[i].class_ == t_class) {
+ cardfix_=cardfix_*(100+sd->left_weapon.add_dmg[i].rate)/100;
break;
}
}
@@ -1923,10 +1923,9 @@ static struct Damage battle_calc_weapon_attack(
cardfix=cardfix*(100-tsd->subrace2[s_race2])/100;
cardfix=cardfix*(100-tsd->subrace[sstatus->race])/100;
cardfix=cardfix*(100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS])/100;
-
- for(i=0;i<tsd->add_dmg_count;i++) {
- if(tsd->add_dmg[i].class_ == s_class) {
- cardfix=cardfix*(100+tsd->add_dmg[i].rate)/100;
+ for(i=0; i < ARRAYLENGTH(tsd->add_def) && tsd->add_def[i].rate;i++) {
+ if(tsd->add_def[i].class_ == s_class) {
+ cardfix=cardfix*(100-tsd->add_def[i].rate)/100;
break;
}
}
@@ -2379,7 +2378,7 @@ struct Damage battle_calc_magic_attack(
cardfix=cardfix*(100+sd->magic_addele[tstatus->def_ele])/100;
cardfix=cardfix*(100+sd->magic_addsize[tstatus->size])/100;
cardfix=cardfix*(100+sd->magic_addrace[is_boss(target)?RC_BOSS:RC_NONBOSS])/100;
- for(i=0;i<sd->add_mdmg_count;i++) {
+ for(i=0; i< ARRAYLENGTH(sd->add_mdmg) && sd->add_mdmg[i].rate;i++) {
if(sd->add_mdmg[i].class_ == t_class) {
cardfix=cardfix*(100+sd->add_mdmg[i].rate)/100;
continue;
@@ -2401,10 +2400,10 @@ struct Damage battle_calc_magic_attack(
cardfix=cardfix*(100-tsd->subrace2[s_race2])/100;
cardfix=cardfix*(100-tsd->subrace[sstatus->race])/100;
cardfix=cardfix*(100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS])/100;
- for(i=0;i<tsd->add_mdef_count;i++) {
+ for(i=0; i < ARRAYLENGTH(tsd->add_mdef) && tsd->add_mdef[i].rate;i++) {
if(tsd->add_mdef[i].class_ == s_class) {
cardfix=cardfix*(100-tsd->add_mdef[i].rate)/100;
- continue;
+ break;
}
}
//It was discovered that ranged defense also counts vs magic! [Skotlex]
diff --git a/src/map/map.h b/src/map/map.h
index 8dc60b7cf..05a157dc0 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -425,9 +425,9 @@ struct weapon_data {
unsigned type:1;
} hp_drain[RC_MAX], sp_drain[RC_MAX];
- short add_damage_classid[MAX_PC_BONUS];
- int add_damage_classrate[MAX_PC_BONUS];
- int add_damage_class_count;
+ struct {
+ short class_, rate;
+ } add_dmg[MAX_PC_BONUS];
};
struct view_data {
@@ -683,7 +683,7 @@ struct map_session_data {
struct {
short class_, rate;
} add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS],
- add_dmg[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
+ add_mdmg[MAX_PC_BONUS];
struct s_add_drop {
short id, group;
int race, rate;
@@ -720,12 +720,9 @@ struct map_session_data {
short sp_gain_value, hp_gain_value;
short sp_vanish_rate;
short sp_vanish_per;
- short add_drop_count;
unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
unsigned short unbreakable_equip; //100% break resistance on certain equipment
unsigned short unstripable_equip;
- short add_def_count,add_mdef_count;
- short add_dmg_count,add_mdmg_count;
// zeroed vars end here.
@@ -1193,13 +1190,15 @@ enum _sp {
SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012
SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
- SP_SKILL_ATK, SP_UNSTRIPABLE, SP_ADD_DAMAGE_BY_CLASS, // 2018-2020
+ SP_SKILL_ATK, SP_UNSTRIPABLE, SP_FREE, // 2018-2020
SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
SP_SP_GAIN_RACE, SP_SUBRACE2, SP_ADDEFF_WHENHIT_SHORT, // 2031-2033
SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
SP_INTRAVISION, SP_ADD_MONSTER_DROP_ITEMGROUP, SP_SP_LOSS_RATE, // 2038-2040
SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE //2041
+ //Before adding new bonuses, reuse the currently free slots:
+ //2020 (SP_FREE) (previously SP_ADD_DAMAGE_BY_CLASS)
};
enum _look {
diff --git a/src/map/mob.c b/src/map/mob.c
index 1802500cc..cd1fe1cc7 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2007,10 +2007,8 @@ 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 < sd->add_drop_count; i++)
+ for (i = 0; i < ARRAYLENGTH(sd->add_drop) && (sd->add_drop[i].id || sd->add_drop[i].group); i++)
{
- if (sd->add_drop[i].id < 0)
- continue;
if (sd->add_drop[i].race & (1<<status->race) ||
sd->add_drop[i].race & 1<<(status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS))
{
diff --git a/src/map/pc.c b/src/map/pc.c
index 8fcac8826..3eabde647 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1308,7 +1308,7 @@ static int pc_bonus_addeff(struct s_addeffect* effect, int max, short id, short
return 1;
}
-static int pc_bonus_item_drop(struct s_add_drop *drop, short *count, short id, short group, int race, int rate)
+static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate)
{
int i;
//Apply config rate adjustment settings.
@@ -1325,7 +1325,7 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, short *count, short id, s
if (rate > -1)
rate = -1;
}
- for(i = 0; i < *count; i++) {
+ for(i = 0; i < max && (drop[i].id || drop[i].group); i++) {
if(
(id && drop[i].id == id) ||
(group && drop[i].group == group)
@@ -1345,16 +1345,15 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, short *count, short id, s
return 1;
}
}
- if(*count >= MAX_PC_BONUS) {
+ if(i == max) {
if (battle_config.error_log)
- ShowWarning("pc_bonus: Reached max (%d) number of added drops per character!\n", MAX_PC_BONUS);
+ ShowWarning("pc_bonus: Reached max (%d) number of added drops per character!\n", max);
return 0;
}
- drop[*count].id = id;
- drop[*count].group = group;
- drop[*count].race |= race;
- drop[*count].rate = rate;
- (*count)++;
+ drop[i].id = id;
+ drop[i].group = group;
+ drop[i].race |= race;
+ drop[i].rate = rate;
return 1;
}
@@ -1970,7 +1969,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0,
ATF_SHORT|ATF_LONG|ATF_TARGET);
break;
@@ -1979,7 +1978,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0,
ATF_SHORT|ATF_LONG|ATF_SELF);
break;
@@ -2011,77 +2010,74 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->magic_addsize[type2]+=val;
break;
case SP_ADD_DAMAGE_CLASS:
- if(!sd->state.lr_flag) {
- for(i=0;i<sd->right_weapon.add_damage_class_count;i++) {
- if(sd->right_weapon.add_damage_classid[i] == type2) {
- sd->right_weapon.add_damage_classrate[i] += val;
- break;
- }
- }
- if(i >= sd->right_weapon.add_damage_class_count && sd->right_weapon.add_damage_class_count < 10) {
- sd->right_weapon.add_damage_classid[sd->right_weapon.add_damage_class_count] = type2;
- sd->right_weapon.add_damage_classrate[sd->right_weapon.add_damage_class_count] += val;
- sd->right_weapon.add_damage_class_count++;
- }
- }
- else if(sd->state.lr_flag == 1) {
- for(i=0;i<sd->left_weapon.add_damage_class_count;i++) {
- if(sd->left_weapon.add_damage_classid[i] == type2) {
- sd->left_weapon.add_damage_classrate[i] += val;
- break;
- }
+ switch (sd->state.lr_flag) {
+ case 0: //Right hand
+ ARR_FIND(0, ARRAYLENGTH(sd->right_weapon.add_dmg), i, sd->right_weapon.add_dmg[i].rate == 0 || sd->right_weapon.add_dmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->right_weapon.add_dmg))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->right_weapon.add_dmg));
+ break;
}
- if(i >= sd->left_weapon.add_damage_class_count && sd->left_weapon.add_damage_class_count < 10) {
- sd->left_weapon.add_damage_classid[sd->left_weapon.add_damage_class_count] = type2;
- sd->left_weapon.add_damage_classrate[sd->left_weapon.add_damage_class_count] += val;
- sd->left_weapon.add_damage_class_count++;
+ sd->right_weapon.add_dmg[i].class_ = type2;
+ sd->right_weapon.add_dmg[i].rate += val;
+ if (!sd->right_weapon.add_dmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->right_weapon.add_dmg[i], &sd->right_weapon.add_dmg[i+1], sizeof(sd->right_weapon.add_dmg) - (i+1)*sizeof(sd->right_weapon.add_dmg[0]));
+ break;
+ case 1: //Left hand
+ ARR_FIND(0, ARRAYLENGTH(sd->left_weapon.add_dmg), i, sd->left_weapon.add_dmg[i].rate == 0 || sd->left_weapon.add_dmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->left_weapon.add_dmg))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->left_weapon.add_dmg));
+ break;
}
+ sd->left_weapon.add_dmg[i].class_ = type2;
+ sd->left_weapon.add_dmg[i].rate += val;
+ if (!sd->left_weapon.add_dmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->left_weapon.add_dmg[i], &sd->left_weapon.add_dmg[i+1], sizeof(sd->left_weapon.add_dmg) - (i+1)*sizeof(sd->left_weapon.add_dmg[0]));
+ break;
}
break;
case SP_ADD_MAGIC_DAMAGE_CLASS:
- if(sd->state.lr_flag != 2) {
- for(i=0;i<sd->add_mdmg_count;i++) {
- if(sd->add_mdmg[i].class_ == type2) {
- sd->add_mdmg[i].rate += val;
- break;
- }
- }
- if(i >= sd->add_mdmg_count && sd->add_mdmg_count < MAX_PC_BONUS) {
- sd->add_mdmg[sd->add_mdmg_count].class_ = type2;
- sd->add_mdmg[sd->add_mdmg_count].rate += val;
- sd->add_mdmg_count++;
- }
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_mdmg), i, sd->add_mdmg[i].rate == 0 || sd->add_mdmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_mdmg))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg));
+ break;
}
+ sd->add_mdmg[i].class_ = type2;
+ sd->add_mdmg[i].rate += val;
+ if (!sd->add_mdmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_mdmg[i], &sd->add_mdmg[i+1], sizeof(sd->add_mdmg) - (i+1)*sizeof(sd->add_mdmg[0]));
break;
case SP_ADD_DEF_CLASS:
- if(sd->state.lr_flag != 2) {
- for(i=0;i<sd->add_def_count;i++) {
- if(sd->add_def[i].class_ == type2) {
- sd->add_def[i].rate += val;
- break;
- }
- }
- if(i >= sd->add_def_count && sd->add_def_count < MAX_PC_BONUS) {
- sd->add_def[sd->add_def_count].class_ = type2;
- sd->add_def[sd->add_def_count].rate += val;
- sd->add_def_count++;
- }
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_def), i, sd->add_def[i].rate == 0 || sd->add_def[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_def))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def));
+ break;
}
+ sd->add_def[i].class_ = type2;
+ sd->add_def[i].rate += val;
+ if (!sd->add_def[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_def[i], &sd->add_def[i+1], sizeof(sd->add_def) - (i+1)*sizeof(sd->add_def[0]));
break;
case SP_ADD_MDEF_CLASS:
- if(sd->state.lr_flag != 2) {
- for(i=0;i<sd->add_mdef_count;i++) {
- if(sd->add_mdef[i].class_ == type2) {
- sd->add_mdef[i].rate += val;
- break;
- }
- }
- if(i >= sd->add_mdef_count && sd->add_mdef_count < MAX_PC_BONUS) {
- sd->add_mdef[sd->add_mdef_count].class_ = type2;
- sd->add_mdef[sd->add_mdef_count].rate += val;
- sd->add_mdef_count++;
- }
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_mdef), i, sd->add_mdef[i].rate == 0 || sd->add_mdef[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_mdef))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef));
+ break;
}
+ sd->add_mdef[i].class_ = type2;
+ sd->add_mdef[i].rate += val;
+ if (!sd->add_mdef[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_mdef[i], &sd->add_mdef[i+1], sizeof(sd->add_mdef) - (i+1)*sizeof(sd->add_mdef[0]));
break;
case SP_HP_DRAIN_RATE:
if(!sd->state.lr_flag) {
@@ -2200,7 +2196,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, val, 0,
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, val, 0,
ATF_SHORT|ATF_LONG|ATF_TARGET);
break;
case SP_ADDEFF_WHENHIT_SHORT:
@@ -2278,21 +2274,6 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
}
break;
- case SP_ADD_DAMAGE_BY_CLASS:
- if(sd->state.lr_flag != 2) {
- for(i=0;i<sd->add_dmg_count;i++) {
- if(sd->add_dmg[i].class_ == type2) {
- sd->add_dmg[i].rate += val;
- break;
- }
- }
- if(i >= sd->add_dmg_count && sd->add_dmg_count < MAX_PC_BONUS) {
- sd->add_dmg[sd->add_dmg_count].class_ = type2;
- sd->add_dmg[sd->add_dmg_count].rate += val;
- sd->add_dmg_count++;
- }
- }
- break;
case SP_HP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
sd->hp_loss.value = type2;
@@ -2329,9 +2310,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
}
//Standard item bonus.
- for(i=0; i < MAX_PC_BONUS && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
- if(i == MAX_PC_BONUS) {
- ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", MAX_PC_BONUS);
+ for(i=0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
+ if(i == ARRAYLENGTH(sd->itemhealrate)) {
+ ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate));
break;
}
sd->itemhealrate[i].nameid = type2;
@@ -2347,11 +2328,11 @@ 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, &sd->add_drop_count, type2, 0, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
break;
case SP_ADD_MONSTER_DROP_ITEMGROUP:
if (sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, type2, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
break;
case SP_SP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
@@ -2401,15 +2382,15 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
switch(type){
case SP_ADD_MONSTER_DROP_ITEM:
if(sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, type2, 0, 1<<type3, val);
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, 1<<type3, val);
break;
case SP_AUTOSPELL:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, skill_get_inf(type2)&INF_SELF_SKILL?-type2:type2, type3, val, 0, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), skill_get_inf(type2)&INF_SELF_SKILL?-type2:type2, type3, val, 0, current_equip_card_id);
break;
case SP_AUTOSPELL_WHENHIT:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, skill_get_inf(type2)&INF_SELF_SKILL?-type2:type2, type3, val, 0, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), skill_get_inf(type2)&INF_SELF_SKILL?-type2:type2, type3, val, 0, current_equip_card_id);
break;
case SP_SP_DRAIN_RATE:
if(!sd->state.lr_flag) {
@@ -2452,7 +2433,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
case SP_ADD_MONSTER_DROP_ITEMGROUP:
if (sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, 1<<type3, val);
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, type2, 1<<type3, val);
break;
case SP_ADDEFF:
@@ -2460,7 +2441,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2);
break;
}
- pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2,
sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0,
ATF_SHORT|ATF_LONG|(val?ATF_TARGET:ATF_SELF)|(val==2?ATF_SELF:0));
break;
@@ -2471,7 +2452,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
break;
}
if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, type3, 0,
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, type3, 0,
ATF_SHORT|ATF_LONG|(val?ATF_TARGET:ATF_SELF)|(val==2?ATF_SELF:0));
break;
@@ -2491,12 +2472,12 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4
switch(type){
case SP_AUTOSPELL:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, current_equip_card_id);
break;
case SP_AUTOSPELL_WHENHIT:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, current_equip_card_id);
break;
default:
if(battle_config.error_log)
@@ -2514,12 +2495,12 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4
switch(type){
case SP_AUTOSPELL:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
break;
case SP_AUTOSPELL_WHENHIT:
if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
+ pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
break;
default:
if(battle_config.error_log)
@@ -5453,7 +5434,7 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
//Item Group bonuses
bonus += bonus*itemdb_group_bonus(sd, itemid)/100;
//Individual item bonuses.
- for(i = 0; i < MAX_PC_BONUS && sd->itemhealrate[i].nameid; i++)
+ for(i = 0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid; i++)
{
if (sd->itemhealrate[i].nameid == itemid) {
bonus += bonus*sd->itemhealrate[i].rate/100;
diff --git a/src/map/skill.c b/src/map/skill.c
index 02d41c671..679753f2f 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1433,7 +1433,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
skillid != CR_REFLECTSHIELD
){ //Trigger status effects
int i, type;
- for(i=0; i < MAX_PC_BONUS && sd->addeff[i].flag; i++)
+ for(i=0; i < ARRAYLENGTH(sd->addeff) && sd->addeff[i].flag; i++)
{
rate = sd->addeff[i].rate;
if (attack_type&BF_LONG) // Any ranged physical attack takes status arrows into account (Grimtooth...) [DracoRPG]
@@ -1469,7 +1469,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int
struct unit_data *ud;
int i, skilllv;
- for (i = 0; i < MAX_PC_BONUS && sd->autospell[i].id; i++) {
+ for (i = 0; i < ARRAYLENGTH(sd->autospell) && sd->autospell[i].id; i++) {
if(!(sd->autospell[i].flag&attack_type&BF_WEAPONMASK &&
sd->autospell[i].flag&attack_type&BF_RANGEMASK &&
@@ -1609,7 +1609,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
if(dstsd && attack_type&BF_WEAPON)
{ //Counter effects.
int i, type, time;
- for(i=0; i < MAX_PC_BONUS && dstsd->addeff2[i].flag; i++)
+ for(i=0; i < ARRAYLENGTH(dstsd->addeff2) && dstsd->addeff2[i].flag; i++)
{
rate = dstsd->addeff2[i].rate;
if (attack_type&BF_LONG)
@@ -1641,7 +1641,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
struct unit_data *ud;
int i, skillid, skilllv, rate;
- for (i = 0; i < MAX_PC_BONUS && dstsd->autospell2[i].id; i++) {
+ for (i = 0; i < ARRAYLENGTH(dstsd->autospell2) && dstsd->autospell2[i].id; i++) {
if(!(dstsd->autospell2[i].flag&attack_type&BF_WEAPONMASK &&
dstsd->autospell2[i].flag&attack_type&BF_RANGEMASK &&
diff --git a/src/map/status.c b/src/map/status.c
index 226cad91e..d97a887e3 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1701,7 +1701,6 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->skillcast)
+ sizeof(sd->add_def)
+ sizeof(sd->add_mdef)
- + sizeof(sd->add_dmg)
+ sizeof(sd->add_mdmg)
+ sizeof(sd->add_drop)
+ sizeof(sd->itemhealrate)
@@ -1749,14 +1748,9 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->sp_gain_value)
+ sizeof(sd->sp_vanish_rate)
+ sizeof(sd->sp_vanish_per)
- + sizeof(sd->add_drop_count)
+ sizeof(sd->unbreakable)
+ sizeof(sd->unbreakable_equip)
+ sizeof(sd->unstripable_equip)
- + sizeof(sd->add_def_count)
- + sizeof(sd->add_mdef_count)
- + sizeof(sd->add_dmg_count)
- + sizeof(sd->add_mdmg_count)
);
// Parse equipment.