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. 30
      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){

30
src/engine/objects/Warehouse.java

@ -128,6 +128,16 @@ 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) {
Building warehouseBuilding = npc.getBuilding();
if (warehouseBuilding == null) {
return;
}
player.getTimestamps().put("lastDepositWarehouse", System.currentTimeMillis());
player.depositingWarehouse = true;
player.warehouseBuilding = warehouseBuilding;
player.getCharItemManager().updateLock = true;
Item resource = Item.getFromCache(msg.getItemID()); Item resource = Item.getFromCache(msg.getItemID());
if (resource == null) { if (resource == null) {
@ -141,29 +151,21 @@ public class Warehouse extends AbstractWorldObject {
return; return;
} }
Building warehouseBuilding = npc.getBuilding();
if (warehouseBuilding == null) {
return;
}
Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID()); Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID());
if (warehouse == null) { if (warehouse == null) {
return; return;
} }
if (!warehouse.deposit(player, resource, depositAmount, true, true)) { if (!warehouse.deposit(player, resource, depositAmount, true, true)) {
// Optional: Uncomment these lines for debugging/logging purposes.
// ChatManager.chatGuildError(player, "Failed to deposit " + resource.getItemBase().getName() + ".");
// Logger.debug("OpenWindow", player.getName() + " Failed to deposit Item with ID " + resource.getObjectUUID() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID());
return; return;
} }
ViewResourcesMessage vrm = new ViewResourcesMessage(player); //ViewResourcesMessage vrm = new ViewResourcesMessage(player);
vrm.setGuild(player.getGuild()); //vrm.setGuild(player.getGuild());
vrm.setWarehouseBuilding(warehouseBuilding); //vrm.setWarehouseBuilding(warehouseBuilding);
vrm.configure(); //vrm.configure();
Dispatch dispatch = Dispatch.borrow(player, vrm); //Dispatch dispatch = Dispatch.borrow(player, vrm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); //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