Просмотр исходного кода

Follow up to 8a730cd
* Fixes pc_delitem checking for an invalid index.
* Adjusted to not count Magnifiers if other checks fail.

aleos89 9 лет назад
Родитель
Сommit
b439ef3168
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      src/map/clif.c

+ 9 - 4
src/map/clif.c

@@ -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);