From 2643be456ed14de07d68350a16458ee1a77ffac0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 14 Jan 2023 15:34:23 -0500 Subject: [PATCH] Moved validation check to before asset creation. --- .../client/handlers/PlaceAssetMsgHandler.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index a3b2e789..132d2198 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -371,7 +371,13 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { } // cant place siege equipment off city zone. - + + // If there is a bane placed, we limit placement to 2x the stone rank's worth of attacker assets + // and 1x the tree rank for defenders + + if (validateSiegeLimits(player, origin, serverCity.getBane()) == false) + return true; + // Create the siege Building siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); @@ -380,20 +386,9 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (siegeBuilding == null) return false; - - // If there is a bane placed, we limit placement to 2x the stone rank's worth of attacker assets - // and 1x the tree rank for defenders - - if (validateSiegeLimits(player, origin, serverCity.getBane()) == false) - return true; // passes validation: can assign auto-protection to war asset - if (serverCity.getBane() != null) - if (serverCity.isLocationOnCityGrid(siegeBuilding.getBounds())) - if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) - return true; - siegeBuilding.setProtectionState(ProtectionState.PROTECTED); // No bane placed. We're done! @@ -434,10 +429,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) continue; - // Only count auto protected buildings - if (building.getProtectionState() != ProtectionState.PROTECTED) - continue; - if (building.getGuild().equals(serverCity.getGuild())) defenderBuildings.add(building);