From 75aef6a5440711c0fcfeb785cd43673ac26e77c8 Mon Sep 17 00:00:00 2001 From: Aleos Date: Wed, 19 Dec 2018 18:09:24 -0500 Subject: [PATCH] Corrected AutospellOnSkill (#3770) * Fixes #3769. * Added a missing reference call. * Defaulted item bonus entries to 0/nullptr. Thanks to @laziem! --- src/map/pc.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 222ebd2cee..a0780f27d7 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -2110,7 +2110,7 @@ static void pc_bonus_autospell(std::vector &spell, short id, short } } - struct s_autospell entry; + struct s_autospell entry = {}; entry.id = id; entry.lv = lv; @@ -2130,7 +2130,7 @@ static void pc_bonus_autospell(std::vector &spell, short id, short * @param rate: Success chance * @param card_id: Used to prevent card stacking */ -static void pc_bonus_autospell_onskill(std::vector spell, short src_skill, short id, short lv, short rate, unsigned short card_id) +static void pc_bonus_autospell_onskill(std::vector &spell, short src_skill, short id, short lv, short rate, unsigned short card_id) { if (spell.size() == MAX_PC_BONUS) { ShowWarning("pc_bonus_autospell_onskill: Reached max (%d) number of autospells per character!\n", MAX_PC_BONUS); @@ -2140,7 +2140,7 @@ static void pc_bonus_autospell_onskill(std::vector spell, short src if (!rate) return; - struct s_autospell entry; + struct s_autospell entry = {}; entry.flag = src_skill; entry.id = id; @@ -2186,7 +2186,7 @@ static void pc_bonus_addeff(std::vector &effect, enum sc_type sc, s } } - struct s_addeffect entry; + struct s_addeffect entry = {}; entry.sc = sc; entry.rate = rate; @@ -2224,7 +2224,7 @@ static void pc_bonus_addeff_onskill(std::vector &effect, enu } } - struct s_addeffectonskill entry; + struct s_addeffectonskill entry = {}; entry.sc = sc; entry.rate = rate; @@ -2287,7 +2287,7 @@ static void pc_bonus_item_drop(std::vector &drop, unsigned short nam } } - struct s_add_drop entry; + struct s_add_drop entry = {}; entry.nameid = nameid; entry.group = group; @@ -2330,7 +2330,7 @@ bool pc_addautobonus(std::vector &bonus, const char *script, short } } - struct s_autobonus entry; + struct s_autobonus entry = {}; entry.rate = rate; entry.duration = dur; @@ -2485,8 +2485,6 @@ static void pc_bonus_addele(struct map_session_data* sd, unsigned char ele, shor */ static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, short flag) { - struct s_addele2 entry; - if (sd->subele2.size() == MAX_PC_BONUS) { ShowWarning("pc_bonus_subele: Reached max (%d) number of resist element damage bonuses per character!\n", MAX_PC_BONUS); return; @@ -2511,6 +2509,8 @@ static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, shor } } + struct s_addele2 entry = {}; + entry.ele = ele; entry.rate = rate; entry.flag = flag; @@ -2526,8 +2526,6 @@ static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, shor */ static void pc_bonus_itembonus(std::vector &bonus, uint16 id, int val) { - struct s_item_bonus entry; - for (auto &it : bonus) { if (it.id == id) { it.val += val; @@ -2535,6 +2533,8 @@ static void pc_bonus_itembonus(std::vector &bonus, uint16 id, int } } + struct s_item_bonus entry = {}; + entry.id = id; entry.val = val;