From ee964386078f572ca29ece3432a089c6e9a6a043 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 8 Feb 2020 16:35:02 +0100 Subject: [PATCH] Fixed a map-server crash Fixes #4614 Thanks to @reunite-ro --- src/map/battle.cpp | 2 +- src/map/skill.cpp | 19 +++++++++++-------- src/map/skill.hpp | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/map/battle.cpp b/src/map/battle.cpp index d5dedb1787..6a8965b530 100644 --- a/src/map/battle.cpp +++ b/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) ) 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 ) return 0; diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 2b0aa4e6b8..99515c142f 100755 --- a/src/map/skill.cpp +++ b/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_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)) - return CAST_GROUND; - if (inf&INF_SUPPORT_SKILL) - return CAST_NODAMAGE; - +e_cast_type skill_get_casttype (uint16 skill_id) { std::shared_ptr skill = skill_db.find(skill_id); - if (inf&INF_SELF_SKILL) { + if( skill == nullptr ){ + return CAST_DAMAGE; + } + + if (skill->inf&(INF_GROUND_SKILL)) + return CAST_GROUND; + if (skill->inf&INF_SUPPORT_SKILL) + return CAST_NODAMAGE; + + if (skill->inf&INF_SELF_SKILL) { if(skill->inf2[INF2_NOTARGETSELF]) return CAST_DAMAGE; //Combo skill. return CAST_NODAMAGE; diff --git a/src/map/skill.hpp b/src/map/skill.hpp index a2ca51fd15..73f09c8cc4 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -452,9 +452,9 @@ void do_init_skill(void); void do_final_skill(void); /// 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 -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_desc( uint16 skill_id ); // [Skotlex] int skill_tree_get_max( uint16 skill_id, int b_class ); // Celest