diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 4cfb8ad6..d674c05b 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -542,53 +542,43 @@ public class ClientMessagePump implements NetMsgHandler { } - private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) { - - CharacterItemManager itemManager = origin.getPlayerCharacter().getCharItemManager(); - int uuid = msg.getUUID(); - - + private static void deleteItem(DeleteItemMsg msg, ClientConnection origin) { PlayerCharacter sourcePlayer = origin.getPlayerCharacter(); - - if (sourcePlayer == null) + if (sourcePlayer == null || !sourcePlayer.isAlive()) { return; + } - if (!sourcePlayer.isAlive()) - return; - - Item i = Item.getFromCache(msg.getUUID()); - - if (i == null) - return; - - if(i.getItemBaseID() == 7) - return; //cant delete gold - - if (!itemManager.doesCharOwnThisItem(i.getObjectUUID())) + CharacterItemManager itemManager = sourcePlayer.getCharItemManager(); + Item item = Item.getFromCache(msg.getUUID()); + if (item == null || !canDeleteItem(item, itemManager)) { return; + } - if (!itemManager.inventoryContains(i)) - return; + int value = item.getItemBase().value; + if (item.getItemBase().isRune()) { + value = 500000; + } - if(i.getItemBaseID() == 980066) + if (sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value > 10000000) { return; + } - if (i.canDestroy) { - int value = i.getItemBase().value; - if(i.getItemBase().isRune()) - value = 500000; - if(sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value > 10000000){ - return; - } - if (itemManager.delete(i) == true) { - sourcePlayer.getCharItemManager().addGoldToInventory(value,false); - sourcePlayer.getCharItemManager().updateInventory(); - Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - } + if (itemManager.delete(item)) { + itemManager.addGoldToInventory(value, false); + itemManager.updateInventory(); + Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); } } + private static boolean canDeleteItem(Item item, CharacterItemManager itemManager) { + return item.getItemBaseID() != 7 && // Can't delete gold + item.getItemBaseID() != 980066 && // Can't delete conc pots + item.canDestroy && + itemManager.doesCharOwnThisItem(item.getObjectUUID()) && + itemManager.inventoryContains(item); + } + private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) { // According to the Wiki, the client should not send this message. // Log the instance to investigate, and modify Wiki accordingly. @@ -1750,7 +1740,7 @@ public class ClientMessagePump implements NetMsgHandler { TransferItemFromInventoryToEquip((TransferItemFromInventoryToEquipMsg) msg, origin); break; case DELETEOBJECT: - DeleteItem((DeleteItemMsg) msg, origin); + deleteItem((DeleteItemMsg) msg, origin); break; case VIEWRESOURCES: ViewResourcesMessage((ViewResourcesMessage) msg, origin);