Skip to content

Commit

Permalink
Merge pull request #6026 from SJuliez/prevent-0-cf-bridges
Browse files Browse the repository at this point in the history
#5984 - Prevent 0 CF bridges in generated maps
  • Loading branch information
SJuliez authored Sep 22, 2024
2 parents 5b011f9 + f4de423 commit 7beb861
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 7beb861

Please sign in to comment.