From f4de423ca8cecdb4ff27d577b4a8101ab9231c34 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 21 Sep 2024 14:17:42 +0200 Subject: [PATCH] prevent 0 CF bridges --- megamek/src/megamek/common/util/CityBuilder.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/common/util/CityBuilder.java b/megamek/src/megamek/common/util/CityBuilder.java index e61536c5632..270f3e75ffb 100644 --- a/megamek/src/megamek/common/util/CityBuilder.java +++ b/megamek/src/megamek/common/util/CityBuilder.java @@ -51,7 +51,7 @@ public CityBuilder(MapSettings mapSettings, Board board) { /** * This function will generate a city with a grid lay out. 4 rounds running * North and South and 4 roads running east west - * + * * @author Torren (Jason Tighe) * @return */ @@ -383,7 +383,7 @@ private void connectHexes(Coords src, Coords dest, int roadStyle) { /** * Build a bridge across an obstacle - * + * * @todo: use a bridge not a road when bridges are working * @param start * @param direction @@ -436,6 +436,11 @@ private void connectHexes(Coords src, Coords dest, int roadStyle) { + Compute.randomInt(1 + mapSettings.getCityMaxCF() - mapSettings.getCityMinCF()); + if (cf == 0) { + // some city settings can lead to 0 CF bridges; use a default CF in this case + cf = 40; + } + for (Enumeration e = hexes.elements(); e.hasMoreElements();) { Coords c = e.nextElement(); addBridge(board.getHex(c), exits, elev1, cf); @@ -484,7 +489,7 @@ private void buildStraightRoad(Coords start, int direction, int roadStyle) { /** * Utility function for setting building type from CF table - * + * * @param cf * @return building type */