Browse Source

Resource Merchant

lakebane-master
FatBoy-DOTC 10 months ago
parent
commit
56c16fc06e
  1. 7
      src/engine/net/client/ClientMessagePump.java
  2. 23
      src/engine/objects/CharacterItemManager.java

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

@ -1376,20 +1376,17 @@ public class ClientMessagePump implements NetMsgHandler {
CharacterItemManager itemMan = sourcePlayer.getCharItemManager(); CharacterItemManager itemMan = sourcePlayer.getCharItemManager();
if (itemMan == null) { if (itemMan == null) {
ChatManager.chatSystemError(sourcePlayer,"Item Man Null");
return; return;
} }
NPC npc = NPC.getFromCache(msg.getNPCID()); NPC npc = NPC.getFromCache(msg.getNPCID());
if (npc == null) { if (npc == null) {
ChatManager.chatSystemError(sourcePlayer,"NPC Null");
return; return;
} }
Item gold = itemMan.getGoldInventory(); Item gold = itemMan.getGoldInventory();
if (gold == null) { if (gold == null) {
ChatManager.chatSystemError(sourcePlayer,"Gold Null");
return; return;
} }
Item buy = null; Item buy = null;
@ -1397,19 +1394,16 @@ public class ClientMessagePump implements NetMsgHandler {
if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) { if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) {
ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory(); ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory();
if (sellInventory == null) { if (sellInventory == null) {
ChatManager.chatSystemError(sourcePlayer,"Sell Inventory Null");
return; return;
} }
for (MobEquipment me : sellInventory) { for (MobEquipment me : sellInventory) {
if (me.getObjectUUID() == msg.getItemID()) { if (me.getObjectUUID() == msg.getItemID()) {
ItemBase ib = me.getItemBase(); ItemBase ib = me.getItemBase();
if (ib == null) { if (ib == null) {
ChatManager.chatSystemError(sourcePlayer,"Item Base Null");
return; return;
} }
//test room available for item //test room available for item
if (!itemMan.hasRoomInventory(ib.getWeight())) { if (!itemMan.hasRoomInventory(ib.getWeight())) {
ChatManager.chatSystemError(sourcePlayer,"No Room In Inventory");
return; return;
} }
int cost = me.getMagicValue(); int cost = me.getMagicValue();
@ -1428,7 +1422,6 @@ public class ClientMessagePump implements NetMsgHandler {
if (gold.getNumOfItems() - cost < 0) { if (gold.getNumOfItems() - cost < 0) {
//dont' have enough goldItem exit! //dont' have enough goldItem exit!
// chatMan.chatSystemInfo(pc, "" + "You dont have enough gold."); // chatMan.chatSystemInfo(pc, "" + "You dont have enough gold.");
ChatManager.chatSystemError(sourcePlayer,"Not Enough Gold");
return; return;
} }

23
src/engine/objects/CharacterItemManager.java

@ -1347,8 +1347,10 @@ public class CharacterItemManager {
Item gold = this.getGoldInventory(); 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; return false;
}
if (this.getOwner() != null && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { if (this.getOwner() != null && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) {
@ -1362,7 +1364,7 @@ public class CharacterItemManager {
// if the NPC is not slotted. // if the NPC is not slotted.
if (vendorBuilding == null) { if (vendorBuilding == null) {
ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Failed To Modify Gold");
return this.modifyInventoryGold(-cost); return this.modifyInventoryGold(-cost);
} }
@ -1374,31 +1376,36 @@ public class CharacterItemManager {
if (pc.getClientConnection() != null) if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 206); ErrorPopupMsg.sendErrorPopup(pc, 206);
} }
ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Strongbox Full");
return false; return false;
} }
// Update strongbox and inventory gold // Update strongbox and inventory gold
if (!this.modifyInventoryGold(-cost)) if (!this.modifyInventoryGold(-cost)) {
ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Modify Gold Fail 2");
return false; return false;
}
City buildingCity = vendorBuilding.getCity(); City buildingCity = vendorBuilding.getCity();
if (buildingCity != null) { if (buildingCity != null) {
buildingCity.transactionLock.writeLock().lock(); buildingCity.transactionLock.writeLock().lock();
try { try {
if (!vendorBuilding.transferGold(buildingDeposit, true)) if (!vendorBuilding.transferGold(buildingDeposit, true)) {
ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Failed Transfer Gold");
return false; return false;
}
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
ChatManager.chatSystemError((PlayerCharacter)this.getOwner(),"Catch Fail");
return false; return false;
} finally { } finally {
buildingCity.transactionLock.writeLock().unlock(); 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 false;
}
return true; return true;
} }

Loading…
Cancel
Save