Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5984 - Prevent 0 CF bridges in generated maps #6026

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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