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

Removes all hardcoded overmap_connection_id references #72725

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions data/json/regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest", "special_forest" ],
Expand Down
8 changes: 8 additions & 0 deletions data/mods/Backrooms/regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
"river_floodplain_buffer_distance_min": 0,
"river_floodplain_buffer_distance_max": 0
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"sparseness_adjacency_factor": 3,
Expand Down
8 changes: 8 additions & 0 deletions data/mods/No_Hope/regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest", "special_forest" ],
Expand Down
8 changes: 8 additions & 0 deletions data/mods/TEST_DATA/regions.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
"river_floodplain_buffer_distance_min": 1,
"river_floodplain_buffer_distance_max": 6
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"sparseness_adjacency_factor": 3,
Expand Down
8 changes: 8 additions & 0 deletions data/mods/TropiCataclysm/tropical_regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest", "special_forest" ],
Expand Down
8 changes: 8 additions & 0 deletions data/mods/aftershock_exoplanet/region_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"sparseness_adjacency_factor": 9,
Expand Down
8 changes: 8 additions & 0 deletions data/mods/classic_zombies/alberta_regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest", "special_forest" ],
Expand Down
8 changes: 8 additions & 0 deletions data/mods/desert_region/desert_regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest" ],
Expand Down
8 changes: 8 additions & 0 deletions data/mods/rural_biome/rural_regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@
"river_floodplain_buffer_distance_min": 3,
"river_floodplain_buffer_distance_max": 15
},
"overmap_connection_settings": {
"intra_city_road_connection": "local_road",
"inter_city_road_connection": "local_road",
"trail_connection": "forest_trail",
"sewer_connection": "sewer_tunnel",
"subway_connection": "subway_tunnel",
"rail_connection": "local_railroad"
},
"forest_mapgen_settings": {
"forest": {
"terrains": [ "forest" ],
Expand Down
26 changes: 26 additions & 0 deletions doc/REGION_SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,32 @@ trailheads, and some general tuning of the actual trail width/position in mapgen
}
```

## Forest Trail Settings

The **overmap_connection_settings** section defines the `overmap_connection_id`s used in hardcoded placement.

### Fields

| Identifier | Description |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `intra_city_road_connection` | overmap_connection id used within cities. Should include locations for road, city_center and road_nesw_manhole. |
| `inter_city_road_connection` | overmap_connection id used between cities. Should include locations for the intra city terrains. |
| `trail_connection` | overmap_connection id used for forest trails. |
| `sewer_connection` | overmap_connection id used for sewer connections. |
| `subway_connection` | overmap_connection id used for for both z-2 and z-4 subway connections. |
| `rail_connection` | overmap_connection id used for rail connections. ( Unused in vanilla as of 0.H ) |

### Example

```json
{
"overmap_connection_settings": {
"intra_city_road_connection": "cobbled_road",
"inter_city_road_connection": "rural_road"
}
}
```

## City

The **city** section defines the possible overmap terrains and specials that may be used as
Expand Down
27 changes: 17 additions & 10 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ static const oter_type_str_id oter_type_slimepit_down( "slimepit_down" );
static const oter_type_str_id oter_type_solid_earth( "solid_earth" );
static const oter_type_str_id oter_type_sub_station( "sub_station" );

static const overmap_connection_id overmap_connection_forest_trail( "forest_trail" );
static const overmap_connection_id overmap_connection_local_railroad( "local_railroad" );
static const overmap_connection_id overmap_connection_local_road( "local_road" );
static const overmap_connection_id overmap_connection_sewer_tunnel( "sewer_tunnel" );
static const overmap_connection_id overmap_connection_subway_tunnel( "subway_tunnel" );

static const overmap_location_id overmap_location_land( "land" );
static const overmap_location_id overmap_location_swamp( "swamp" );

Expand Down Expand Up @@ -3616,6 +3610,8 @@ bool overmap::generate_sub( const int z )
for( city &i : goo_points ) {
requires_sub |= build_slimepit( tripoint_om_omt( i.pos, z ), i.size );
}
const overmap_connection_id &overmap_connection_sewer_tunnel =
settings->overmap_connection.sewer_connection;
connect_closest_points( sewer_points, z, *overmap_connection_sewer_tunnel );

// A third of overmaps have labs with a 1-in-2 chance of being subway connected.
Expand Down Expand Up @@ -3696,6 +3692,8 @@ bool overmap::generate_sub( const int z )

subway_points.insert( subway_points.end(), subway_lab_train_points.begin(),
subway_lab_train_points.end() );
const overmap_connection_id &overmap_connection_subway_tunnel =
settings->overmap_connection.subway_connection;
connect_closest_points( subway_points, z, *overmap_connection_subway_tunnel );

for( auto &i : subway_points ) {
Expand All @@ -3705,7 +3703,8 @@ bool overmap::generate_sub( const int z )
}

// The first lab point is adjacent to a lab, set it a depot (as long as track was actually laid).
const auto create_train_depots = [this, z]( const oter_id & train_type,
const auto create_train_depots = [this, z,
overmap_connection_subway_tunnel]( const oter_id & train_type,
const std::vector<point_om_omt> &train_points ) {
bool is_first_in_pair = true;
std::vector<point_om_omt> extra_route;
Expand Down Expand Up @@ -4482,6 +4481,8 @@ void overmap::place_forest_trails()
}

// Finally, connect all the points and make a forest trail out of them.
const overmap_connection_id &overmap_connection_forest_trail =
settings->overmap_connection.trail_connection;
connect_closest_points( chosen_points, 0, *overmap_connection_forest_trail );
}
}
Expand Down Expand Up @@ -5096,7 +5097,9 @@ void overmap::place_roads( const overmap *north, const overmap *east, const over
if( op_city_size <= 0 ) {
return;
}
std::vector<tripoint_om_omt> &roads_out = connections_out[overmap_connection_local_road];
const overmap_connection_id &overmap_connection_inter_city_road =
settings->overmap_connection.inter_city_road_connection;
std::vector<tripoint_om_omt> &roads_out = connections_out[overmap_connection_inter_city_road];

// At least 3 exit points, to guarantee road continuity across overmaps
if( roads_out.size() < 3 ) {
Expand Down Expand Up @@ -5158,7 +5161,7 @@ void overmap::place_roads( const overmap *north, const overmap *east, const over
}

// And finally connect them via roads.
connect_closest_points( road_points, 0, *overmap_connection_local_road );
connect_closest_points( road_points, 0, *overmap_connection_inter_city_road );
}

void overmap::place_railroads( const overmap *north, const overmap *east, const overmap *south,
Expand All @@ -5169,6 +5172,8 @@ void overmap::place_railroads( const overmap *north, const overmap *east, const
if( op_city_size <= 0 ) {
return;
}
const overmap_connection_id &overmap_connection_local_railroad =
settings->overmap_connection.rail_connection;
std::vector<tripoint_om_omt> &railroads_out = connections_out[overmap_connection_local_railroad];

// At least 3 exit points, to guarantee railroad continuity across overmaps
Expand Down Expand Up @@ -5476,7 +5481,9 @@ void overmap::place_cities()
omts_per_city );
}

const overmap_connection &local_road( *overmap_connection_local_road );
const overmap_connection_id &overmap_connection_intra_city_road =
settings->overmap_connection.intra_city_road_connection;
const overmap_connection &local_road( *overmap_connection_intra_city_road );

// if there is only a single free tile, the probability of NOT finding it after MAX_PLACEMENT_ATTEMPTS attempts
// is (1 - 1/(OMAPX * OMAPY))^MAX_PLACEMENT_ATTEMPTS ≈ 36% for the OMAPX=OMAPY=180 and MAX_PLACEMENT_ATTEMPTS=OMAPX * OMAPY
Expand Down
33 changes: 33 additions & 0 deletions src/regional_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,33 @@ static void load_overmap_ravine_settings(
}
}

static void load_overmap_connection_settings(
const JsonObject &jo, overmap_connection_settings &overmap_connection_settings, const bool strict,
const bool overlay )
{
if( !jo.has_object( "overmap_connection_settings" ) ) {
if( strict ) {
jo.throw_error( "\"overmap_connection_settings\": { … } required for default" );
}
} else {
JsonObject overmap_connection_settings_jo = jo.get_object( "overmap_connection_settings" );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo, "trail_connection",
overmap_connection_settings.trail_connection, !overlay );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo, "sewer_connection",
overmap_connection_settings.sewer_connection, !overlay );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo, "subway_connection",
overmap_connection_settings.subway_connection, !overlay );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo, "rail_connection",
overmap_connection_settings.rail_connection, !overlay );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo,
"intra_city_road_connection",
overmap_connection_settings.intra_city_road_connection, !overlay );
read_and_set_or_throw<overmap_connection_id>( overmap_connection_settings_jo,
"inter_city_road_connection",
overmap_connection_settings.inter_city_road_connection, !overlay );
}
}

static void load_overmap_lake_settings( const JsonObject &jo,
overmap_lake_settings &overmap_lake_settings,
const bool strict, const bool overlay )
Expand Down Expand Up @@ -568,6 +595,8 @@ void load_region_settings( const JsonObject &jo )

load_overmap_ravine_settings( jo, new_region.overmap_ravine, strict, false );

load_overmap_connection_settings( jo, new_region.overmap_connection, strict, false );

load_region_terrain_and_furniture_settings( jo, new_region.region_terrain_and_furniture, strict,
false );

Expand Down Expand Up @@ -713,8 +742,12 @@ void apply_region_overlay( const JsonObject &jo, regional_settings &region )

load_overmap_lake_settings( jo, region.overmap_lake, false, true );

load_overmap_ocean_settings( jo, region.overmap_ocean, false, true );

load_overmap_ravine_settings( jo, region.overmap_ravine, false, true );

load_overmap_connection_settings( jo, region.overmap_connection, false, true );

load_region_terrain_and_furniture_settings( jo, region.region_terrain_and_furniture, false, true );
}

Expand Down
13 changes: 13 additions & 0 deletions src/regional_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ struct overmap_ravine_settings {
overmap_ravine_settings() = default;
};

struct overmap_connection_settings {
overmap_connection_id trail_connection;
overmap_connection_id sewer_connection;
overmap_connection_id subway_connection;
overmap_connection_id rail_connection;
overmap_connection_id intra_city_road_connection;
overmap_connection_id inter_city_road_connection;

void finalize();
overmap_connection_settings() = default;
};

struct map_extras {
unsigned int chance;
weighted_int_list<map_extra_id> values;
Expand Down Expand Up @@ -275,6 +287,7 @@ struct regional_settings {
overmap_lake_settings overmap_lake;
overmap_ocean_settings overmap_ocean;
overmap_ravine_settings overmap_ravine;
overmap_connection_settings overmap_connection;
region_terrain_and_furniture_settings region_terrain_and_furniture;

std::unordered_map<std::string, map_extras> region_extras;
Expand Down
Loading