Skip to content

Commit

Permalink
Fixed special optional overmap field (CleverRaven#70677)
Browse files Browse the repository at this point in the history
* Initial Commit

* Test special

* Revert test special

* Astyle

* Update OVERMAP.md

* Astyle better
  • Loading branch information
Procyonae authored Jan 6, 2024
1 parent ab85743 commit 69cddfe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions doc/OVERMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
32 changes: 16 additions & 16 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}
}
Expand Down Expand Up @@ -2755,7 +2755,7 @@ void overmap_special::load( const JsonObject &jo, const std::string &src )
case overmap_special_subtype::fixed: {
shared_ptr_fast<fixed_overmap_special_data> fixed_data =
make_shared_fast<fixed_overmap_special_data>();
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 );
}
Expand Down

0 comments on commit 69cddfe

Please sign in to comment.