From e6af752c6d3bdcd041b0baa81ae3b352c87786bb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 27 Jul 2022 08:56:45 -0400 Subject: [PATCH] Hotfix: bane null check order. --- .../handlers/DestroyBuildingHandler.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/engine/net/client/handlers/DestroyBuildingHandler.java b/src/engine/net/client/handlers/DestroyBuildingHandler.java index d26723ee..1789c453 100644 --- a/src/engine/net/client/handlers/DestroyBuildingHandler.java +++ b/src/engine/net/client/handlers/DestroyBuildingHandler.java @@ -30,6 +30,8 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { DestroyBuildingMsg msg; msg = (DestroyBuildingMsg) baseMsg; + Bane bane = null; + Blueprint blueprint; int buildingUUID = msg.getUUID(); @@ -38,10 +40,9 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { if (pc == null || building == null) return true; - Blueprint blueprint; - blueprint = building.getBlueprint(); City city = building.getCity(); + // Can't destroy buildings without a blueprint. if (blueprint == null) @@ -55,11 +56,17 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { if (!BuildingManager.PlayerCanControlNotOwner(building, pc)) return true; -Bane bane = city.getBane(); -if(bane.getSiegePhase() == Enum.SiegePhase.WAR && bane != null) { - ErrorPopupMsg.sendErrorPopup(pc, 171); - return true; -} + + // Can't delete siege assets during an active bane. + + if (city != null) + bane = city.getBane(); + + if ( bane != null && bane.getSiegePhase() == Enum.SiegePhase.WAR) { + ErrorPopupMsg.sendErrorPopup(pc, 171); + return true; + } + // Can't destroy a tree of life if (blueprint.getBuildingGroup() == BuildingGroup.TOL) return true; @@ -68,12 +75,17 @@ if(bane.getSiegePhase() == Enum.SiegePhase.WAR && bane != null) { if (blueprint.getBuildingGroup() == BuildingGroup.SHRINE) return true; + // Cannot destroy mines outside of normal mine mechanics + if (blueprint.getBuildingGroup() == BuildingGroup.MINE) return true; + // Cannot delete rungates + if (blueprint.getBuildingGroup() == BuildingGroup.RUNEGATE) return true; -//stop if active siege + + // Turn off spire if destoying if (blueprint.getBuildingGroup() == BuildingGroup.SPIRE) building.disableSpire(true);