From 69cddfe538bcfd173c8fd315e9fd38b668146413 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 6 Jan 2024 04:50:03 +0000 Subject: [PATCH] Fixed special optional overmap field (#70677) * Initial Commit * Test special * Revert test special * Astyle * Update OVERMAP.md * Astyle better --- doc/OVERMAP.md | 12 ++++++------ src/overmap.cpp | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/OVERMAP.md b/doc/OVERMAP.md index 9f097617d5947..308b6cb11dd45 100644 --- a/doc/OVERMAP.md +++ b/doc/OVERMAP.md @@ -439,11 +439,11 @@ Depending on the subtype, there are further relevant fields: ### Fixed special overmaps -| Identifier | Description | -| ----------- | -------------------------------------------------------------------------- | -| `point` | `[ x, y, z]` of the overmap terrain within the special. | -| `overmap` | Id of the `overmap_terrain` to place at the location. | -| `locations` | List of `overmap_location` ids that this overmap terrain may be placed on. | +| Identifier | Description | +| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `point` | `[ x, y, z]` of the overmap terrain within the special. | +| `overmap` | Id of the `overmap_terrain` to place at the location. If ommited no overmap_terrain is placed but the point will still be checked for valid locations when deciding if placement is valid. | +| `locations` | List of `overmap_location` ids that this overmap terrain may be placed on. Overrides the specials overall `locations` field. | ### Connections @@ -453,7 +453,7 @@ Depending on the subtype, there are further relevant fields: | `terrain` | Will go away in favor of `connection` eventually. Use `road`, `subway`, `sewer`, etc. | | `connection` | Id of the `overmap_connection` to build. Optional for now, but you should specify it explicitly. | | `from` | Optional point `[ x, y, z]` within the special to treat as the origin of the connection. | -| `existing` | Boolean, default false. If the special requires a preexisting terrain to spawn. | +| `existing` | Boolean, default false. If the special requires a preexisting terrain to spawn. | ### Example mutable special diff --git a/src/overmap.cpp b/src/overmap.cpp index 5fccb9a7aee63..29336229ace4e 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1422,21 +1422,21 @@ struct fixed_overmap_special_data : overmap_special_data { for( const overmap_special_terrain &elem : terrains ) { const tripoint_om_omt location = origin + om_direction::rotate( elem.p, dir ); - result.omts_used.push_back( location ); - const oter_id tid = elem.terrain->get_rotated( dir ); - - om.ter_set( location, tid ); - - if( blob ) { - for( int x = -2; x <= 2; x++ ) { - for( int y = -2; y <= 2; y++ ) { - const tripoint_om_omt nearby_pos = location + point( x, y ); - if( !overmap::inbounds( nearby_pos ) ) { - continue; - } - if( one_in( 1 + std::abs( x ) + std::abs( y ) ) && - elem.can_be_placed_on( om.ter( nearby_pos ) ) ) { - om.ter_set( nearby_pos, tid ); + if( !( elem.terrain == oter_str_id::NULL_ID() ) ) { + result.omts_used.push_back( location ); + const oter_id tid = elem.terrain->get_rotated( dir ); + om.ter_set( location, tid ); + if( blob ) { + for( int x = -2; x <= 2; x++ ) { + for( int y = -2; y <= 2; y++ ) { + const tripoint_om_omt nearby_pos = location + point( x, y ); + if( !overmap::inbounds( nearby_pos ) ) { + continue; + } + if( one_in( 1 + std::abs( x ) + std::abs( y ) ) && + elem.can_be_placed_on( om.ter( nearby_pos ) ) ) { + om.ter_set( nearby_pos, tid ); + } } } } @@ -2755,7 +2755,7 @@ void overmap_special::load( const JsonObject &jo, const std::string &src ) case overmap_special_subtype::fixed: { shared_ptr_fast fixed_data = make_shared_fast(); - mandatory( jo, was_loaded, "overmaps", fixed_data->terrains ); + optional( jo, was_loaded, "overmaps", fixed_data->terrains ); if( is_special ) { optional( jo, was_loaded, "connections", fixed_data->connections ); }