Skip to content

Commit d4c78e3

Browse files
committed
Allow swapping lake terrains
For custom lake generations
1 parent fb19487 commit d4c78e3

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

doc/JSON/REGION_SETTINGS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ are interpreted.
242242
| `shore_extendable_overmap_terrain` | List of overmap terrains that can be extended to the shore if adjacent. |
243243
| `shore_extendable_overmap_terrain_aliases` | Overmap terrains to treat as different overmap terrain for extending shore. |
244244
| `invert_lakes` | Invert drawing of lakes. What would be a lake is land, what would be land is a lake. |
245+
| `shore_ter` | Overmap terrain id of shore terrain place on boundary with land. |
246+
| `surface_ter` | Overmap terrain id of surface terrain, placed on z = 0. |
247+
| `interior_ter` | Overmap terrain id of interior terrain, placed between surface terrain and bed terrain. |
248+
| `bed_ter` | Overmap terrain id of bed terrain, placed on bottom of the lake. |
245249

246250
### Example
247251

src/overmap_water.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,6 @@ void overmap::place_lakes( const std::vector<const overmap *> &neighbor_overmaps
271271
settings_lake.invert_lakes ^ omt_lake_noise_threshold( origin, p, noise_threshold );
272272
};
273273

274-
const oter_id lake_surface( "lake_surface" );
275-
const oter_id lake_shore( "lake_shore" );
276-
const oter_id lake_water_cube( "lake_water_cube" );
277-
const oter_id lake_bed( "lake_bed" );
278-
279274
// We'll keep track of our visited lake points so we don't repeat the work.
280275
std::unordered_set<point_om_omt> visited;
281276

@@ -356,14 +351,14 @@ void overmap::place_lakes( const std::vector<const overmap *> &neighbor_overmaps
356351
}
357352
}
358353

359-
ter_set( tripoint_om_omt( p, 0 ), shore ? lake_shore : lake_surface );
354+
ter_set( tripoint_om_omt( p, 0 ), shore ? settings_lake.shore : settings_lake.surface );
360355

361356
// If this is not a shore, we'll make our subsurface lake cubes and beds.
362357
if( !shore ) {
363358
for( int z = -1; z > lake_depth; z-- ) {
364-
ter_set( tripoint_om_omt( p, z ), lake_water_cube );
359+
ter_set( tripoint_om_omt( p, z ), settings_lake.interior );
365360
}
366-
ter_set( tripoint_om_omt( p, lake_depth ), lake_bed );
361+
ter_set( tripoint_om_omt( p, lake_depth ), settings_lake.bed );
367362
}
368363
}
369364
}

src/regional_settings.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
class mapgendata;
2323

24+
static const oter_str_id oter_lake_surface( "lake_surface" );
25+
static const oter_str_id oter_lake_shore( "lake_shore" );
26+
static const oter_str_id oter_lake_water_cube( "lake_water_cube" );
27+
static const oter_str_id oter_lake_bed( "lake_bed" );
28+
2429
static const weighted_string_id_reader<overmap_special_id, int> building_bin_reader( 1 );
2530
static const weighted_string_id_reader<furn_id, int> furn_reader( 1 );
2631
static const weighted_string_id_reader<ter_id, int> ter_reader( 1 );
@@ -527,6 +532,10 @@ void region_settings_lake::load( const JsonObject &jo, std::string_view )
527532
optional( jo, was_loaded, "shore_extendable_overmap_terrain_aliases",
528533
shore_extendable_overmap_terrain_aliases );
529534
optional( jo, was_loaded, "invert_lakes", invert_lakes, false );
535+
optional( jo, was_loaded, "surface_ter", surface, oter_lake_surface );
536+
optional( jo, was_loaded, "shore_ter", surface, oter_lake_shore );
537+
optional( jo, was_loaded, "interior_ter", surface, oter_lake_water_cube );
538+
optional( jo, was_loaded, "bed_ter", surface, oter_lake_bed );
530539
}
531540

532541
void shore_extendable_overmap_terrain_alias::deserialize( const JsonObject &jo )

src/regional_settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ struct region_settings_lake {
324324
double noise_threshold_lake = 0.25;
325325
int lake_size_min = 20;
326326
int lake_depth = -5;
327+
oter_str_id surface;
328+
oter_str_id shore;
329+
oter_str_id interior;
330+
oter_str_id bed;
327331
std::vector<oter_str_id> shore_extendable_overmap_terrain;
328332
std::vector<shore_extendable_overmap_terrain_alias> shore_extendable_overmap_terrain_aliases;
329333
bool invert_lakes = false;

0 commit comments

Comments
 (0)