From 56c16fc06e40151c3f5498122a1182fb04c33689 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 22 Feb 2024 20:00:54 -0600 Subject: [PATCH] Resource Merchant --- src/engine/net/client/ClientMessagePump.java | 7 ------ src/engine/objects/CharacterItemManager.java | 23 +++++++++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index d4fbe7b3..2df894ef 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1376,20 +1376,17 @@ public class ClientMessagePump implements NetMsgHandler { CharacterItemManager itemMan = sourcePlayer.getCharItemManager(); if (itemMan == null) { - ChatManager.chatSystemError(sourcePlayer,"Item Man Null"); return; } NPC npc = NPC.getFromCache(msg.getNPCID()); if (npc == null) { - ChatManager.chatSystemError(sourcePlayer,"NPC Null"); return; } Item gold = itemMan.getGoldInventory(); if (gold == null) { - ChatManager.chatSystemError(sourcePlayer,"Gold Null"); return; } Item buy = null; @@ -1397,19 +1394,16 @@ public class ClientMessagePump implements NetMsgHandler { if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) { ArrayList sellInventory = npc.getContract().getSellInventory(); if (sellInventory == null) { - ChatManager.chatSystemError(sourcePlayer,"Sell Inventory Null"); return; } for (MobEquipment me : sellInventory) { if (me.getObjectUUID() == msg.getItemID()) { ItemBase ib = me.getItemBase(); if (ib == null) { - ChatManager.chatSystemError(sourcePlayer,"Item Base Null"); return; } //test room available for item if (!itemMan.hasRoomInventory(ib.getWeight())) { - ChatManager.chatSystemError(sourcePlayer,"No Room In Inventory"); return; } int cost = me.getMagicValue(); @@ -1428,7 +1422,6 @@ public class ClientMessagePump implements NetMsgHandler { if (gold.getNumOfItems() - cost < 0) { //dont' have enough goldItem exit! // chatMan.chatSystemInfo(pc, "" + "You dont have enough gold."); - ChatManager.chatSystemError(sourcePlayer,"Not Enough Gold"); return; } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 8e80fabd..9d97e8ba 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1347,8 +1347,10 @@ public class CharacterItemManager { Item gold = this.getGoldInventory(); - if (cost <= 0 || (gold.getNumOfItems() - cost) < 0) + if (cost <= 0 || (gold.getNumOfItems() - cost) < 0){ + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Not Enough Gold"); return false; + } if (this.getOwner() != null && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { @@ -1362,7 +1364,7 @@ public class CharacterItemManager { // if the NPC is not slotted. if (vendorBuilding == null) { - + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Failed To Modify Gold"); return this.modifyInventoryGold(-cost); } @@ -1374,31 +1376,36 @@ public class CharacterItemManager { if (pc.getClientConnection() != null) ErrorPopupMsg.sendErrorPopup(pc, 206); } - + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Strongbox Full"); return false; } // Update strongbox and inventory gold - if (!this.modifyInventoryGold(-cost)) + if (!this.modifyInventoryGold(-cost)) { + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Modify Gold Fail 2"); return false; - + } City buildingCity = vendorBuilding.getCity(); if (buildingCity != null) { buildingCity.transactionLock.writeLock().lock(); try { - if (!vendorBuilding.transferGold(buildingDeposit, true)) + if (!vendorBuilding.transferGold(buildingDeposit, true)) { + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Failed Transfer Gold"); return false; + } } catch (Exception e) { Logger.error(e); + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Catch Fail"); return false; } finally { buildingCity.transactionLock.writeLock().unlock(); } - } else if (!vendorBuilding.transferGold(buildingDeposit, true)) + } else if (!vendorBuilding.transferGold(buildingDeposit, true)) { + ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Vendor Building Transfer Gold"); return false; - + } return true; }