Skip to content

Commit

Permalink
prevent 0 CF bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Sep 21, 2024
1 parent 59948bf commit f4de423
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions megamek/src/megamek/common/util/CityBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Coords> e = hexes.elements(); e.hasMoreElements();) {
Coords c = e.nextElement();
addBridge(board.getHex(c), exits, elev1, cf);
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit f4de423

Please sign in to comment.