Browse Source

optimized deleting items

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
0ac7a1a7fa
  1. 64
      src/engine/net/client/ClientMessagePump.java

64
src/engine/net/client/ClientMessagePump.java

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

Loading…
Cancel
Save