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

4
src/engine/objects/CharacterItemManager.java

@ -70,6 +70,8 @@ public class CharacterItemManager { @@ -70,6 +70,8 @@ public class CharacterItemManager {
*/
private byte equipVer = (byte) 0;
public boolean updateLock = false;
public CharacterItemManager(AbstractCharacter ac) {
super();
this.absCharacter = ac;
@ -2286,6 +2288,8 @@ public class CharacterItemManager { @@ -2286,6 +2288,8 @@ public class CharacterItemManager {
if (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) == false)
return;
if(this.updateLock)
return;
PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
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 { @@ -178,6 +178,9 @@ public class PlayerCharacter extends AbstractCharacter {
public float ZergMultiplier = 1.0f;
public int mineAppliedID = 0;
public boolean depositingWarehouse = false;
public Building warehouseBuilding;
/**
* No Id Constructor
*/
@ -4885,6 +4888,20 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4885,6 +4888,20 @@ public class PlayerCharacter extends AbstractCharacter {
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){

56
src/engine/objects/Warehouse.java

@ -128,42 +128,44 @@ public class Warehouse extends AbstractWorldObject { @@ -128,42 +128,44 @@ public class Warehouse extends AbstractWorldObject {
}
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;
}
int depositAmount = msg.getAmount();
CharacterItemManager itemMan = player.getCharItemManager();
player.getTimestamps().put("lastDepositWarehouse", System.currentTimeMillis());
player.depositingWarehouse = true;
player.warehouseBuilding = warehouseBuilding;
player.getCharItemManager().updateLock = true;
Item resource = Item.getFromCache(msg.getItemID());
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) {
return;
}
if (resource == null) {
return;
}
Building warehouseBuilding = npc.getBuilding();
if (warehouseBuilding == null) {
return;
}
int depositAmount = msg.getAmount();
CharacterItemManager itemMan = player.getCharItemManager();
Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID());
if (warehouse == null) {
return;
}
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) {
return;
}
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;
}
Warehouse warehouse = warehouseByBuildingUUID.get(warehouseBuilding.getObjectUUID());
if (warehouse == null) {
return;
}
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
vrm.setGuild(player.getGuild());
vrm.setWarehouseBuilding(warehouseBuilding);
vrm.configure();
Dispatch dispatch = Dispatch.borrow(player, vrm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
if (!warehouse.deposit(player, resource, depositAmount, true, true)) {
return;
}
//ViewResourcesMessage vrm = new ViewResourcesMessage(player);
//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) {

Loading…
Cancel
Save