|
|
@ -24,10 +24,7 @@ import engine.net.client.msg.ClientNetMsg; |
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
|
import engine.net.client.msg.ItemProductionMsg; |
|
|
|
import engine.net.client.msg.ItemProductionMsg; |
|
|
|
import engine.net.client.msg.ManageNPCMsg; |
|
|
|
import engine.net.client.msg.ManageNPCMsg; |
|
|
|
import engine.objects.CharacterItemManager; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.Item; |
|
|
|
|
|
|
|
import engine.objects.NPC; |
|
|
|
|
|
|
|
import engine.objects.PlayerCharacter; |
|
|
|
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -132,6 +129,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
Item virtualItem = Item.getFromCache(itemUUID); |
|
|
|
Item virtualItem = Item.getFromCache(itemUUID); |
|
|
|
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); |
|
|
|
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
City city = workOrder.vendor.building.getCity(); |
|
|
|
|
|
|
|
city.transactionLock.writeLock().lock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
// Refresh the window. SetPrice is used only to force a window refresh.
|
|
|
|
// Refresh the window. SetPrice is used only to force a window refresh.
|
|
|
|
// What controls items displayed are the contents of the workOrders. (ManageNPCMsg)
|
|
|
|
// What controls items displayed are the contents of the workOrders. (ManageNPCMsg)
|
|
|
|
|
|
|
|
|
|
|
@ -170,6 +172,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); |
|
|
|
ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
city.transactionLock.writeLock().unlock(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { |
|
|
|
private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { |
|
|
@ -312,7 +319,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) |
|
|
|
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (vendor.charItemManager.inventoryContains(targetItem) == false) |
|
|
|
if (!vendor.charItemManager.inventoryContains(targetItem)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
itemValue = targetItem.template.item_value; |
|
|
|
itemValue = targetItem.template.item_value; |
|
|
@ -361,10 +368,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
ManageNPCMsg outMsg; |
|
|
|
ManageNPCMsg outMsg; |
|
|
|
Dispatch dispatch; |
|
|
|
Dispatch dispatch; |
|
|
|
|
|
|
|
|
|
|
|
if (origin.sellLock.tryLock()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targetItem = Item.getFromCache(itemUUID); |
|
|
|
targetItem = Item.getFromCache(itemUUID); |
|
|
|
|
|
|
|
|
|
|
|
PlayerCharacter player = origin.getPlayerCharacter(); |
|
|
|
PlayerCharacter player = origin.getPlayerCharacter(); |
|
|
@ -383,6 +386,12 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); |
|
|
|
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
City city = workOrder.vendor.building.getCity(); |
|
|
|
|
|
|
|
city.transactionLock.writeLock().lock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
workOrder.cooking.remove(targetItem); |
|
|
|
workOrder.cooking.remove(targetItem); |
|
|
|
DbManager.removeFromCache(targetItem); |
|
|
|
DbManager.removeFromCache(targetItem); |
|
|
|
|
|
|
|
|
|
|
@ -400,9 +409,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
outMsg.setMessageType(1); |
|
|
|
outMsg.setMessageType(1); |
|
|
|
dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
origin.sellLock.unlock(); |
|
|
|
city.transactionLock.writeLock().unlock(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -425,10 +435,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { |
|
|
|
if (targetItem.template.item_type.equals(ItemType.GOLD)) |
|
|
|
if (targetItem.template.item_type.equals(ItemType.GOLD)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (vendor.charItemManager.inventoryContains(targetItem) == false) |
|
|
|
if (!vendor.charItemManager.inventoryContains(targetItem)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (player.charItemManager.hasRoomInventory(targetItem.template.item_wt) == false) |
|
|
|
if (!player.charItemManager.hasRoomInventory(targetItem.template.item_wt)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
player.charItemManager.buyFromNPC(targetItem, vendor); |
|
|
|
player.charItemManager.buyFromNPC(targetItem, vendor); |
|
|
|