Jelajahi Sumber

Count check should be synchronized too

_DS_ 16 tahun lalu
induk
melakukan
5a092e3839

+ 9 - 9
L2_GameServer/java/net/sf/l2j/gameserver/model/itemcontainer/Inventory.java

@@ -777,26 +777,26 @@ public abstract class Inventory extends ItemContainer
 		if (item == null)
 			return null;
 
-		// Adjust item quantity and create new instance to drop
-		if (item.getCount() > count)
+		synchronized (item)
 		{
-			synchronized (item)
-			{
-				if (!_items.contains(item))
-					return null;
+			if (!_items.contains(item))
+				return null;
 
+			// Adjust item quantity and create new instance to drop
+			// Directly drop entire item
+			if (item.getCount() > count)
+			{
 				item.changeCount(process, -count, actor, reference);
 				item.setLastChange(L2ItemInstance.MODIFIED);
 				item.updateDatabase();
-				
+
 				item = ItemTable.getInstance().createItem(process, item.getItemId(), count, actor, reference);
 				item.updateDatabase();
 				refreshWeight();
 				return item;
 			}
 		}
-		// Directly drop entire item
-		else return dropItem(process, item, actor, reference);
+		return dropItem(process, item, actor, reference);
 	}
 
 	/**