From b151b29cf072ed336214c2d0ca43e6db34a773ad Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 22:07:36 +0100 Subject: Add skill_validate_autocast_data() function calls --- src/map/clif.c | 24 ++++++++++++++++++++++++ src/map/unit.c | 12 ++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index 6c693297d..66533a6fc 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12706,6 +12706,14 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill { int64 tick = timer->gettick(); + /** + * According to Skotlex' comment below, the client sometimes passes 0 for the skill level. + * Even though this seems to only affect guild skills, sd->autocast.skill_lv is used + * for the auto-cast data validation if skill_lv is 0. + * + **/ + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->autocast.skill_lv : skill_lv); + if (skill_lv < 1) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex] @@ -12847,6 +12855,16 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin int64 tick = timer->gettick(); nullpo_retv(sd); + + /** + * When using clif_item_skill() to initiate the execution of ground skills, + * the client sometimes passes 0 for the skill level in packet 0x0af4. + * In that case sd->autocast.skill_lv is used for the auto-cast data validation, + * since clif_item_skill() is only used for auto-cast skills. + * + **/ + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->autocast.skill_lv : skill_lv); + if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -12985,6 +13003,12 @@ static void clif_parse_UseSkillMap(int fd, struct map_session_data *sd) return; } + /** + * Since no skill level was passed use 0 to notify skill_validate_autocast_data() of this special case. + * + **/ + skill->validate_autocast_data(sd, skill_id, 0); + pc->delinvincibletimer(sd); skill->castend_map(sd,skill_id,map_name); pc->autocast_clear(sd); diff --git a/src/map/unit.c b/src/map/unit.c index 984cc6802..c1da2c72b 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1145,8 +1145,10 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_ int ret = unit->skilluse_id2(src, target_id, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->autocast_clear(sd); + if (sd != NULL && ret == 0) + pc->autocast_clear(sd); // Error in unit_skilluse_id2(). + else if (sd != NULL && ret != 0 && skill_id != SA_ABRACADABRA && skill_id != WM_RANDOMIZESPELL) + skill->validate_autocast_data(sd, skill_id, skill_lv); return ret; } @@ -1782,8 +1784,10 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_ int ret = unit->skilluse_pos2(src, skill_x, skill_y, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->autocast_clear(sd); + if (sd != NULL && ret == 0) + pc->autocast_clear(sd); // Error in unit_skilluse_pos2(). + else if (sd != NULL && ret != 0 && skill_id != SA_ABRACADABRA && skill_id != WM_RANDOMIZESPELL) + skill->validate_autocast_data(sd, skill_id, skill_lv); return ret; } -- cgit v1.2.3-70-g09d2