Browse Source

Moved validation check to before asset creation.

master
MagicBot 2 years ago
parent
commit
2643be456e
  1. 21
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java

21
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -372,6 +372,12 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// cant place siege equipment off city zone. // 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 // Create the siege Building
siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone);
@ -381,19 +387,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (siegeBuilding == null) if (siegeBuilding == null)
return false; 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 // 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); siegeBuilding.setProtectionState(ProtectionState.PROTECTED);
// No bane placed. We're done! // 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())) if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
continue; continue;
// Only count auto protected buildings
if (building.getProtectionState() != ProtectionState.PROTECTED)
continue;
if (building.getGuild().equals(serverCity.getGuild())) if (building.getGuild().equals(serverCity.getGuild()))
defenderBuildings.add(building); defenderBuildings.add(building);

Loading…
Cancel
Save