From 77d59bad5d27a528fb503e19807bfc07cf2077b1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:06:12 +0200 Subject: Add pc_autocast_remove() function --- src/map/pc.c | 23 +++++++++++++++++++++++ src/map/pc.h | 1 + 2 files changed, 24 insertions(+) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 6985ecff8..9c1342836 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5383,6 +5383,28 @@ static void pc_autocast_set_current(struct map_session_data *sd, int skill_id) } } +/** + * Removes a specific entry from a character's auto-cast vector. + * + * @param sd The character. + * @param type The entry's auto-cast type. + * @param skill_id The entry's skill ID. + * @param skill_lv The entry's skill level. + * + **/ +static void pc_autocast_remove(struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv) +{ + nullpo_retv(sd); + + for (int i = 0; i < VECTOR_LENGTH(sd->auto_cast); i++) { + if (VECTOR_INDEX(sd->auto_cast, i).type == type && VECTOR_INDEX(sd->auto_cast, i).skill_id == skill_id + && VECTOR_INDEX(sd->auto_cast, i).skill_lv == skill_lv) { + VECTOR_ERASE(sd->auto_cast, i); + break; + } + } +} + /*========================================== * Add item on cart for given index. * Return: @@ -12915,6 +12937,7 @@ void pc_defaults(void) pc->useitem = pc_useitem; pc->autocast_clear = pc_autocast_clear; pc->autocast_set_current = pc_autocast_set_current; + pc->autocast_remove = pc_autocast_remove; pc->skillatk_bonus = pc_skillatk_bonus; pc->skillheal_bonus = pc_skillheal_bonus; diff --git a/src/map/pc.h b/src/map/pc.h index 010de1e9d..9012a67cb 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1035,6 +1035,7 @@ END_ZEROED_BLOCK; /* End */ int (*useitem) (struct map_session_data *sd,int n); int (*autocast_clear) (struct map_session_data *sd); void (*autocast_set_current) (struct map_session_data *sd, int skill_id); + void (*autocast_remove) (struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv); int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id); -- cgit v1.2.3-60-g2f50