Follow up to 8a730cd

* Fixes pc_delitem checking for an invalid index.
* Adjusted to not count Magnifiers if other checks fail.
This commit is contained in:
aleos89 2016-01-12 14:34:50 -05:00
parent e4a3811b92
commit b439ef3168

View File

@ -18648,17 +18648,22 @@ void clif_dressing_room(struct map_session_data *sd, int flag) {
/// 0A35 <result>.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);