From b439ef3168c8453d02461cb298a8515f59a07ede Mon Sep 17 00:00:00 2001 From: aleos89 Date: Tue, 12 Jan 2016 14:34:50 -0500 Subject: [PATCH] Follow up to 8a730cd * Fixes pc_delitem checking for an invalid index. * Adjusted to not count Magnifiers if other checks fail. --- src/map/clif.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 9d1d129868..e93b3fe7eb 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18648,17 +18648,22 @@ void clif_dressing_room(struct map_session_data *sd, int flag) { /// 0A35 .W void clif_parse_Oneclick_Itemidentify(int fd, struct map_session_data *sd) { #if PACKETVER >= 20150513 - short idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 2, magnifier_idx = pc_search_inventory(sd, ITEMID_MAGNIFIER); + short idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 2, magnifier_idx; // Ignore the request // - Invalid item index // - Invalid item ID or item doesn't exist // - Item is already identified - // - No magnifiers in inventory - if (idx < 0 || idx >= MAX_INVENTORY || sd->status.inventory[idx].nameid <= 0 || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].identify || magnifier_idx == -1) + if (idx < 0 || idx >= MAX_INVENTORY || + sd->status.inventory[idx].nameid <= 0 || sd->inventory_data[idx] == NULL || + sd->status.inventory[idx].identify) + return; + + // Ignore the request - No magnifiers in inventory + if ((magnifier_idx = pc_search_inventory(sd, ITEMID_MAGNIFIER)) == -1) return; - if (pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER) != 0) // Deleting of magnifier failed, for whatever reason... + if (pc_delitem(sd, magnifier_idx, 1, 0, 0, LOG_TYPE_OTHER) != 0) // Deleting of magnifier failed, for whatever reason... return; skill_identify(sd, idx);