diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/battle.c | 35 | ||||
-rw-r--r-- | src/map/map.h | 10 | ||||
-rw-r--r-- | src/map/mob.c | 28 | ||||
-rw-r--r-- | src/map/pc.c | 64 |
4 files changed, 87 insertions, 50 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 52aee5c69..4ae6ea545 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -27,7 +27,7 @@ #define is_boss(bl) status_get_mexp(bl) // Can refine later [Aru] -int attr_fix_table[4][10][10]; +int attr_fix_table[4][ELE_MAX][ELE_MAX]; struct Battle_Config battle_config; static struct eri *delay_damage_ers; //For battle delay damage structures. @@ -189,39 +189,6 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag def_lv < 1 || def_lv > 4) { if (battle_config.error_log) ShowError("battle_attr_fix: unknown attr type: atk=%d def_type=%d def_lv=%d\n",atk_elem,def_type,def_lv); - //TODO: Remove this debug case once the cause is resolved. [Skotlex] - if (src) switch (src->type) { - case BL_MOB: - ShowDebug("src: Mob %s-%d\n", ((struct mob_data*)src)->name, ((struct mob_data*)src)->class_); - break; - case BL_PC: - ShowDebug("src: Player %s-%d\n", ((struct map_session_data*)src)->status.name, ((struct map_session_data*)src)->bl.id); - break; - case BL_PET: - ShowDebug("src: Pet %s-%d\n", ((struct pet_data*)src)->name, ((struct pet_data*)src)->bl.id); - break; - case BL_SKILL: - ShowDebug("src: Ground Skill id: %d\n", ((struct skill_unit*)src)->group->skill_id); - break; - default: - ShowDebug("unknown source type %d.\n", src->type); - } - if (target) switch (target->type) { - case BL_MOB: - ShowDebug("target: Mob %s-%d\n", ((struct mob_data*)target)->name, ((struct mob_data*)target)->class_); - break; - case BL_PC: - ShowDebug("target: Player %s-%d\n", ((struct map_session_data*)target)->status.name, ((struct map_session_data*)target)->bl.id); - break; - case BL_PET: - ShowDebug("target: Pet %s-%d\n", ((struct pet_data*)target)->name, ((struct pet_data*)target)->bl.id); - break; - case BL_SKILL: - ShowDebug("target: Ground Skill id: %d\n", ((struct skill_unit*)target)->group->skill_id); - break; - default: - ShowDebug("unknown target type %d.\n", target->type); - } return damage; } diff --git a/src/map/map.h b/src/map/map.h index b323b1a7e..5e986fa01 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -463,7 +463,7 @@ struct weapon_data { int ignore_def_race;
int def_ratio_atk_ele;
int def_ratio_atk_race;
- int addele[10];
+ int addele[ELE_MAX];
int addrace[RC_MAX];
int addrace2[RC_MAX];
int addsize[3];
@@ -622,23 +622,23 @@ struct map_session_data { // here start arrays to be globally zeroed at the beginning of status_calc_pc()
int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
- int subele[10];
+ int subele[ELE_MAX];
int subrace[RC_MAX];
int subrace2[RC_MAX];
int subsize[3];
int addeff[SC_COMMON_MAX-SC_COMMON_MIN+1];
int addeff2[SC_COMMON_MAX-SC_COMMON_MIN+1];
int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
- int weapon_coma_ele[10];
+ int weapon_coma_ele[ELE_MAX];
int weapon_coma_race[RC_MAX];
int weapon_atk[16];
int weapon_atk_rate[16];
- int arrow_addele[10];
+ int arrow_addele[ELE_MAX];
int arrow_addrace[RC_MAX];
int arrow_addsize[3];
int arrow_addeff[SC_COMMON_MAX-SC_COMMON_MIN+1];
int arrow_addeff2[SC_COMMON_MAX-SC_COMMON_MIN+1];
- int magic_addele[10];
+ int magic_addele[ELE_MAX];
int magic_addrace[RC_MAX];
int magic_addsize[3];
int critaddrace[RC_MAX];
diff --git a/src/map/mob.c b/src/map/mob.c index 929565511..087d05546 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -793,10 +793,10 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) !(status_get_mode(&md->bl)&MD_BOSS)) return 0; //Gangster paradise protection. case BL_MOB: - if((dist=distance_bl(&md->bl, bl)) < md->db->range2 - && (md->status.rhw.range > 6 || mob_can_reach(md,bl,dist+1, MSS_FOLLOW)) - && ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) //New target closer than previous one. - ) { + if((dist=distance_bl(&md->bl, bl)) < md->db->range2 && + ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) && + battle_check_range(&md->bl,bl,md->db->range2) + ) { //Pick closest target? (*target) = bl; md->target_id=bl->id; md->min_chase= dist + md->db->range3; @@ -3157,6 +3157,16 @@ static int mob_readdb(void) i = atoi(str[24]); //Element status->def_ele = i%10; status->ele_lv = i/20; + if (status->def_ele >= ELE_MAX) + { + ShowWarning("Mob with ID: %d has invalid element type %d (max element is %d)\n", class_, status->def_ele, ELE_MAX-1); + status->def_ele = ELE_NEUTRAL; + } + if (status->ele_lv < 1 || status->ele_lv > 4) + { + ShowWarning("Mob with ID: %d has invalid element level %d (max is 4)\n", class_, status->ele_lv); + status->ele_lv = 1; + } status->mode=atoi(str[25]); status->speed=atoi(str[26]); status->aspd_rate = 100; @@ -3826,6 +3836,16 @@ static int mob_read_sqldb(void) i = TO_INT(24); //Element status->def_ele = i%10; status->ele_lv = i/20; + if (status->def_ele >= ELE_MAX) + { + ShowWarning("Mob with ID: %d has invalid element type %d (max element is %d)\n", status->def_ele, ELE_MAX-1); + status->def_ele = ELE_NEUTRAL; + } + if (status->ele_lv < 1 || status->ele_lv > 4) + { + ShowWarning("Mob with ID: %d has invalid elemnt level %d (max is 4)\n", status->ele_lv); + status->ele_lv = 1; + } status->mode = TO_INT(25); status->speed = TO_INT(26); status->aspd_rate = 100; diff --git a/src/map/pc.c b/src/map/pc.c index 8f8e6749c..8cf18635a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1233,6 +1233,11 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->arrow_cri += val*10;
break;
case SP_ATKELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_ATKELE: Invalid element %d\n", val);
+ break;
+ }
if(!sd->state.lr_flag)
status->rhw.ele=val;
else if(sd->state.lr_flag == 1)
@@ -1241,6 +1246,11 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->arrow_ele=val;
break;
case SP_DEFELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_DEFELE: Invalid element %d\n", val);
+ break;
+ }
if(sd->state.lr_flag != 2)
status->def_ele=val;
break;
@@ -1342,6 +1352,11 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->matk_rate += val;
break;
case SP_IGNORE_DEF_ELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_IGNORE_DEF_ELE: Invalid element %d\n", val);
+ break;
+ }
if(!sd->state.lr_flag)
sd->right_weapon.ignore_def_ele |= 1<<val;
else if(sd->state.lr_flag == 1)
@@ -1366,6 +1381,11 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->misc_def_rate += val;
break;
case SP_IGNORE_MDEF_ELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_IGNORE_MDEF_ELE: Invalid element %d\n", val);
+ break;
+ }
if(sd->state.lr_flag != 2)
sd->ignore_mdef_ele |= 1<<val;
break;
@@ -1386,12 +1406,22 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->critical_rate+=val;
break;
case SP_DEF_RATIO_ATK_ELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_DEF_RATIO_ATK_ELE: Invalid element %d\n", val);
+ break;
+ }
if(!sd->state.lr_flag)
sd->right_weapon.def_ratio_atk_ele |= 1<<val;
else if(sd->state.lr_flag == 1)
sd->left_weapon.def_ratio_atk_ele |= 1<<val;
break;
case SP_DEF_RATIO_ATK_RACE:
+ if(val >= RC_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus: SP_DEF_RATIO_ATK_RACE: Invalid race %d\n", val);
+ break;
+ }
if(!sd->state.lr_flag)
sd->right_weapon.def_ratio_atk_race |= 1<<val;
else if(sd->state.lr_flag == 1)
@@ -1629,6 +1659,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) switch(type){
case SP_ADDELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus2: SP_ADDELE: Invalid element %d\n", val);
+ break;
+ }
if(!sd->state.lr_flag)
sd->right_weapon.addele[type2]+=val;
else if(sd->state.lr_flag == 1)
@@ -1653,6 +1688,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->arrow_addsize[type2]+=val;
break;
case SP_SUBELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus2: SP_SUBELE: Invalid element %d\n", val);
+ break;
+ }
if(sd->state.lr_flag != 2)
sd->subele[type2]+=val;
break;
@@ -1689,6 +1729,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->reseff[type2-SC_COMMON_MIN]+=val;
break;
case SP_MAGIC_ADDELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus2: SP_MAGIC_ADDELE: Invalid element %d\n", val);
+ break;
+ }
if(sd->state.lr_flag != 2)
sd->magic_addele[type2]+=val;
break;
@@ -1850,6 +1895,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) }
break;
case SP_WEAPON_COMA_ELE:
+ if(val >= ELE_MAX) {
+ if(battle_config.error_log)
+ ShowError("pc_bonus2: SP_WEAPON_COMA_ELE: Invalid element %d\n", val);
+ break;
+ }
if(sd->state.lr_flag != 2)
sd->weapon_coma_ele[type2] += val;
break;
@@ -1978,11 +2028,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<<10)|(1<<11), val);
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 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<<10)|(1<<11), val);
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
break;
case SP_SP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
@@ -2125,7 +2175,7 @@ int pc_skill(struct map_session_data *sd,int id,int level,int flag) if(level>MAX_SKILL_LEVEL){
if(battle_config.error_log)
- ShowError("support card skill only!\n");
+ ShowError("pc_skill: Skill level %d too high. Max lv supported is MAX_SKILL_LEVEL (%d)\n", level, MAX_SKILL_LEVEL);
return 0;
}
if(!flag && (sd->status.skill[id].id == id || level == 0)){ // クエスト所得ならここで?件を確認して送信する
@@ -7118,8 +7168,8 @@ int pc_readdb(void) // ?性修正テ?ブル
for(i=0;i<4;i++)
- for(j=0;j<10;j++)
- for(k=0;k<10;k++)
+ for(j=0;j<ELE_MAX;j++)
+ for(k=0;k<ELE_MAX;k++)
attr_fix_table[i][j][k]=100;
sprintf(line, "%s/attr_fix.txt", db_path);
@@ -7141,13 +7191,13 @@ int pc_readdb(void) lv=atoi(split[0]);
n=atoi(split[1]);
- for(i=0;i<n;){
+ for(i=0;i<n && i<ELE_MAX;){
if( !fgets(line, sizeof(line)-1, fp) )
break;
if(line[0]=='/' && line[1]=='/')
continue;
- for(j=0,p=line;j<n && p;j++){
+ for(j=0,p=line;j<n && j<ELE_MAX && p;j++){
while(*p==32 && *p>0)
p++;
attr_fix_table[lv-1][i][j]=atoi(p);
|