瀏覽代碼

Fixed a map-server crash

Fixes #4614

Thanks to @reunite-ro
Lemongrass3110 5 年之前
父節點
當前提交
ee96438607
共有 3 個文件被更改,包括 13 次插入10 次删除
  1. 1 1
      src/map/battle.cpp
  2. 10 7
      src/map/skill.cpp
  3. 2 2
      src/map/skill.hpp

+ 1 - 1
src/map/battle.cpp

@@ -1063,7 +1063,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
 	if( battle_config.ksprotection && mob_ksprotected(src, bl) )
 	if( battle_config.ksprotection && mob_ksprotected(src, bl) )
 		return 0;
 		return 0;
 
 
-	if( map_getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill_get_type(skill_id) != BF_MISC
+	if( map_getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill_id && skill_get_type(skill_id) != BF_MISC
 		&& skill_get_casttype(skill_id) == CAST_GROUND )
 		&& skill_get_casttype(skill_id) == CAST_GROUND )
 		return 0;
 		return 0;
 
 

+ 10 - 7
src/map/skill.cpp

@@ -344,16 +344,19 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl,t_tick tick);
 static int skill_unit_effect(struct block_list *bl,va_list ap);
 static int skill_unit_effect(struct block_list *bl,va_list ap);
 static int skill_bind_trap(struct block_list *bl, va_list ap);
 static int skill_bind_trap(struct block_list *bl, va_list ap);
 
 
-int skill_get_casttype (uint16 skill_id) {
-	int inf = skill_get_inf(skill_id);
-	if (inf&(INF_GROUND_SKILL))
+e_cast_type skill_get_casttype (uint16 skill_id) {
+	std::shared_ptr<s_skill_db> skill = skill_db.find(skill_id);
+
+	if( skill == nullptr ){
+		return CAST_DAMAGE;
+	}
+
+	if (skill->inf&(INF_GROUND_SKILL))
 		return CAST_GROUND;
 		return CAST_GROUND;
-	if (inf&INF_SUPPORT_SKILL)
+	if (skill->inf&INF_SUPPORT_SKILL)
 		return CAST_NODAMAGE;
 		return CAST_NODAMAGE;
 
 
-	std::shared_ptr<s_skill_db> skill = skill_db.find(skill_id);
-
-	if (inf&INF_SELF_SKILL) {
+	if (skill->inf&INF_SELF_SKILL) {
 		if(skill->inf2[INF2_NOTARGETSELF])
 		if(skill->inf2[INF2_NOTARGETSELF])
 			return CAST_DAMAGE; //Combo skill.
 			return CAST_DAMAGE; //Combo skill.
 		return CAST_NODAMAGE;
 		return CAST_NODAMAGE;

+ 2 - 2
src/map/skill.hpp

@@ -452,9 +452,9 @@ void do_init_skill(void);
 void do_final_skill(void);
 void do_final_skill(void);
 
 
 /// Cast type
 /// Cast type
-enum { CAST_GROUND, CAST_DAMAGE, CAST_NODAMAGE };
+enum e_cast_type { CAST_GROUND, CAST_DAMAGE, CAST_NODAMAGE };
 /// Returns the cast type of the skill: ground cast, castend damage, castend no damage
 /// Returns the cast type of the skill: ground cast, castend damage, castend no damage
-int skill_get_casttype(uint16 skill_id); //[Skotlex]
+e_cast_type skill_get_casttype(uint16 skill_id); //[Skotlex]
 const char*	skill_get_name( uint16 skill_id ); 	// [Skotlex]
 const char*	skill_get_name( uint16 skill_id ); 	// [Skotlex]
 const char*	skill_get_desc( uint16 skill_id ); 	// [Skotlex]
 const char*	skill_get_desc( uint16 skill_id ); 	// [Skotlex]
 int skill_tree_get_max( uint16 skill_id, int b_class );	// Celest
 int skill_tree_get_max( uint16 skill_id, int b_class );	// Celest