From 526c078978fc37a93ae91466c57c1c1fc97b9655 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Jan 2023 08:31:56 -0500 Subject: [PATCH] Collision check extracted to method. --- .../client/handlers/PlaceAssetMsgHandler.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 218ceea1..71701c61 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -380,6 +380,13 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (validateSiegeLimits(player, origin, serverCity.getBane()) == false) return false; + // Collision check (Removes rubble side effect) + + if (placementCollisionCheck(serverZone, origin, buildingList)){ + PlaceAssetMsg.sendPlaceAssetError(origin, 3, ""); // Conflict between proposed assets + return false; + } + // Create the siege Building siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); @@ -1311,6 +1318,15 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } + if (placementCollisionCheck(serverZone, origin, placementInfo)){ + PlaceAssetMsg.sendPlaceAssetError(origin, 3, ""); // Conflict between proposed assets + return false; + } + + return true; + } + + private static boolean placementCollisionCheck(Zone serverZone, ClientConnection origin, PlacementInfo placementInfo) { // Overlap check for (Building building : serverZone.zoneBuildingSet) { @@ -1338,11 +1354,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { PlaceAssetMsg.sendPlaceAssetError(origin, 3, ""); // Conflict between proposed assets - return false; + return true; } } - - return true; + return false; } private static boolean validateCityBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo buildingInfo) {