Browse Source

attempted warehouse delay issue resolution

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
023057668a
  1. 4
      src/engine/db/handlers/dbWarehouseHandler.java
  2. 4
      src/engine/objects/CharacterItemManager.java
  3. 17
      src/engine/objects/PlayerCharacter.java
  4. 56
      src/engine/objects/Warehouse.java

4
src/engine/db/handlers/dbWarehouseHandler.java

@ -45,7 +45,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
list.add(building); list.add(building);
break; break;
case "warehouse": case "warehouse":
Warehouse warehouse = new Warehouse(rs); Warehouse warehouse = new Warehouse(rs, depositQueItem);
DbManager.addToCache(warehouse); DbManager.addToCache(warehouse);
list.add(warehouse); list.add(warehouse);
break; break;
@ -543,7 +543,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) { while (rs.next()) {
warehouse = new Warehouse(rs); warehouse = new Warehouse(rs, depositQueItem);
warehouse.runAfterLoad(); warehouse.runAfterLoad();
warehouse.loadAllTransactions(); warehouse.loadAllTransactions();
} }

4
src/engine/objects/CharacterItemManager.java

@ -70,6 +70,8 @@ public class CharacterItemManager {
*/ */
private byte equipVer = (byte) 0; private byte equipVer = (byte) 0;
public boolean updateLock = false;
public CharacterItemManager(AbstractCharacter ac) { public CharacterItemManager(AbstractCharacter ac) {
super(); super();
this.absCharacter = ac; this.absCharacter = ac;
@ -2286,6 +2288,8 @@ public class CharacterItemManager {
if (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) == false) if (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) == false)
return; return;
if(this.updateLock)
return;
PlayerCharacter pc = (PlayerCharacter) this.absCharacter; PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
UpdateInventoryMsg updateInventoryMsg = new UpdateInventoryMsg(inventory, this.getBank(), this.getGoldInventory(), add); UpdateInventoryMsg updateInventoryMsg = new UpdateInventoryMsg(inventory, this.getBank(), this.getGoldInventory(), add);

17
src/engine/objects/PlayerCharacter.java

@ -178,6 +178,9 @@ public class PlayerCharacter extends AbstractCharacter {
public float ZergMultiplier = 1.0f; public float ZergMultiplier = 1.0f;
public int mineAppliedID = 0; public int mineAppliedID = 0;
public boolean depositingWarehouse = false;
public Building warehouseBuilding;
/** /**
* No Id Constructor * No Id Constructor
*/ */
@ -4885,6 +4888,20 @@ public class PlayerCharacter extends AbstractCharacter {
this.updateLock.writeLock().unlock(); this.updateLock.writeLock().unlock();
} }
} }
if(this.depositingWarehouse){
long sinceLast = System.currentTimeMillis() - this.getTimestamps().get("lastDepositWarehouse");
if(sinceLast > 1000) {
this.depositingWarehouse = false;
ViewResourcesMessage vrm = new ViewResourcesMessage(this);
vrm.setGuild(this.getGuild());
vrm.setWarehouseBuilding(this.warehouseBuilding);
vrm.configure();
Dispatch dispatch = Dispatch.borrow(this, vrm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
this.charItemManager.updateLock = false;
this.charItemManager.updateInventory();
}
}
} }
public static boolean checkIfBoxed(PlayerCharacter player){ public static boolean checkIfBoxed(PlayerCharacter player){

56
src/engine/objects/Warehouse.java

@ -128,42 +128,44 @@ public class Warehouse extends AbstractWorldObject {
} }
public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) { public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) {
Item resource = Item.getFromCache(msg.getItemID());
if (resource == null) { Building warehouseBuilding = npc.getBuilding();
if (warehouseBuilding == null) {
return; return;
} }
int depositAmount = msg.getAmount(); player.getTimestamps().put("lastDepositWarehouse", System.currentTimeMillis());
CharacterItemManager itemMan = player.getCharItemManager(); player.depositingWarehouse = true;
player.warehouseBuilding = warehouseBuilding;
player.getCharItemManager().updateLock = true;
Item resource = Item.getFromCache(msg.getItemID());
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) { if (resource == null) {
return; return;
} }
Building warehouseBuilding = npc.getBuilding(); int depositAmount = msg.getAmount();
if (warehouseBuilding == null) { CharacterItemManager itemMan = player.getCharItemManager();
return;
}
Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID()); if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) {
if (warehouse == null) { return;
return; }
}
if (!warehouse.deposit(player, resource, depositAmount, true, true)) { Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID());
// Optional: Uncomment these lines for debugging/logging purposes. if (warehouse == null) {
// ChatManager.chatGuildError(player, "Failed to deposit " + resource.getItemBase().getName() + "."); return;
// Logger.debug("OpenWindow", player.getName() + " Failed to deposit Item with ID " + resource.getObjectUUID() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); }
return;
}
ViewResourcesMessage vrm = new ViewResourcesMessage(player); if (!warehouse.deposit(player, resource, depositAmount, true, true)) {
vrm.setGuild(player.getGuild()); return;
vrm.setWarehouseBuilding(warehouseBuilding); }
vrm.configure();
Dispatch dispatch = Dispatch.borrow(player, vrm); //ViewResourcesMessage vrm = new ViewResourcesMessage(player);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); //vrm.setGuild(player.getGuild());
//vrm.setWarehouseBuilding(warehouseBuilding);
//vrm.configure();
//Dispatch dispatch = Dispatch.borrow(player, vrm);
//DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
} }
public static void warehouseWithdraw(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) { public static void warehouseWithdraw(MerchantMsg msg, PlayerCharacter player, NPC npc, ClientConnection origin) {

Loading…
Cancel
Save