Skip to content

Commit

Permalink
Introduce EMPTY_SPACE terrain flag (CleverRaven#73116)
Browse files Browse the repository at this point in the history
* Introduce EMPTY_SPACE terrain flag

* Additional conversion to use of EMPTY_SPACE terrain flag

* Update data/json/furniture_and_terrain/terrain-liquids.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/construction.cpp

Co-authored-by: anothersimulacrum <[email protected]>

* Update src/map.cpp

Co-authored-by: anothersimulacrum <[email protected]>

* Update src/map.cpp

Co-authored-by: anothersimulacrum <[email protected]>

* Update src/construction.cpp

Co-authored-by: anothersimulacrum <[email protected]>

* A hole empty space is empty space.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: anothersimulacrum <[email protected]>
  • Loading branch information
3 people authored May 3, 2024
1 parent 8b64122 commit d2fd8af
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
32 changes: 21 additions & 11 deletions data/json/furniture_and_terrain/terrain-liquids.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"looks_like": "t_water_sh",
"color": "blue",
"move_cost": 8,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "NO_FLOOR_WATER" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "NO_FLOOR_WATER", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand All @@ -53,7 +53,7 @@
"color": "blue",
"move_cost": 8,
"roof": "t_rock_roof",
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "INDOORS" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "INDOORS", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -127,7 +127,7 @@
"symbol": "~",
"color": "blue",
"move_cost": 10,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "CURRENT" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "CURRENT", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand All @@ -143,7 +143,7 @@
"color": "blue",
"move_cost": 10,
"roof": "t_rock_roof",
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "CURRENT", "INDOORS" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "FISHABLE", "CURRENT", "INDOORS", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -187,7 +187,7 @@
"looks_like": "t_water_dp",
"color": "blue",
"move_cost": 8,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "SALT_WATER", "DEEP_WATER", "FISHABLE" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "SALT_WATER", "DEEP_WATER", "FISHABLE", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand All @@ -203,7 +203,7 @@
"looks_like": "t_swater_dp",
"move_cost": 8,
"roof": "t_rock_roof",
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "SALT_WATER", "DEEP_WATER", "FISHABLE", "INDOORS" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "SALT_WATER", "DEEP_WATER", "FISHABLE", "INDOORS", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -231,7 +231,7 @@
"looks_like": "t_water_dp",
"color": "light_blue",
"move_cost": 5,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "INDOORS", "DEEP_WATER" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "INDOORS", "DEEP_WATER", "EMPTY_SPACE" ],
"connect_groups": "POOLWATER",
"connects_to": "POOLWATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -259,7 +259,7 @@
"looks_like": "t_water_pool",
"color": "light_blue",
"move_cost": 5,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "EMPTY_SPACE" ],
"connect_groups": "POOLWATER",
"connects_to": "POOLWATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -313,7 +313,7 @@
"symbol": "~",
"color": "blue",
"move_cost": 8,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "WATER_CUBE", "NO_FLOOR_WATER" ],
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "WATER_CUBE", "NO_FLOOR_WATER", "EMPTY_SPACE" ],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand All @@ -326,7 +326,17 @@
"symbol": "~",
"color": "blue",
"move_cost": 8,
"flags": [ "TRANSPARENT", "LIQUID", "NO_SCENT", "SWIMMABLE", "DEEP_WATER", "SALT_WATER", "WATER_CUBE", "NO_FLOOR_WATER" ],
"flags": [
"TRANSPARENT",
"LIQUID",
"NO_SCENT",
"SWIMMABLE",
"DEEP_WATER",
"SALT_WATER",
"WATER_CUBE",
"NO_FLOOR_WATER",
"EMPTY_SPACE"
],
"connect_groups": "WATER",
"connects_to": "WATER",
"examine_action": "water_source"
Expand Down Expand Up @@ -379,7 +389,7 @@
{
"type": "terrain",
"id": "t_bulkhead_floor",
"//": "for eventual use with water z levels. Currently non-functional. Roof for submerged structures.",
"//": "for eventual use with water z levels. Currently non-functional. Floor for submerged structures.",
"name": "bulkhead",
"description": "The bottom of a submerged structure.",
"symbol": "#",
Expand Down
6 changes: 3 additions & 3 deletions data/json/furniture_and_terrain/terrain-roofs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"move_cost": 2,
"roof": "t_flat_roof",
"trap": "tr_ledge",
"flags": [ "TRANSPARENT", "NO_FLOOR" ],
"flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ],
"examine_action": "ledge"
},
{
Expand All @@ -23,7 +23,7 @@
"trap": "tr_ledge",
"roof": "t_flat_roof",
"examine_action": "ledge",
"flags": [ "TRANSPARENT", "NO_FLOOR", "INDOORS" ]
"flags": [ "TRANSPARENT", "NO_FLOOR", "INDOORS", "EMPTY_SPACE" ]
},
{
"type": "terrain",
Expand All @@ -34,7 +34,7 @@
"color": "i_cyan",
"move_cost": 2,
"trap": "tr_ledge",
"flags": [ "TRANSPARENT", "NO_FLOOR" ],
"flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ],
"examine_action": "ledge"
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/json/furniture_and_terrain/terrain-traps.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"color": "black",
"move_cost": 2,
"trap": "tr_ledge",
"flags": [ "TRANSPARENT", "NO_FLOOR" ],
"flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ],
"examine_action": "ledge"
},
{
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ List of known flags, used in both `furniture` and `terrain`. Some work for both
- ```DOOR``` Can be opened (used for NPC path-finding).
- ```EASY_DECONSTRUCT``` Player can deconstruct this without tools.
- ```ELEVATOR``` Terrain with this flag will move player, NPCs, monsters, and items up and down when player activates nearby `elevator controls`.
- ```EMPTY_SPACE``` Terrain without anything solid in it, including a floor, implying there should be no roof supporting terrain beneath it. It also should imply containment is broken (releasing air out, water etc. in, but that's currently not implemented).
- ```EXAMINE_FROM_ABOVE``` Furniture can be <kbd>e</kbd> examined from a ledge above. If deployed furniture is taken down it will be placed on the ledge.
- ```FIRE_CONTAINER``` Stops fire from spreading (brazier, wood stove, etc).
- ```FISHABLE``` You can try to catch fish here.
Expand Down
7 changes: 3 additions & 4 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_hole( "t_hole" );
static const ter_str_id ter_t_ladder_up( "t_ladder_up" );
static const ter_str_id ter_t_lava( "t_lava" );
static const ter_str_id ter_t_open_air( "t_open_air" );
static const ter_str_id ter_t_pit( "t_pit" );
static const ter_str_id ter_t_ramp_down_high( "t_ramp_down_high" );
static const ter_str_id ter_t_ramp_down_low( "t_ramp_down_low" );
Expand Down Expand Up @@ -1151,18 +1150,18 @@ void complete_construction( Character *you )
here.furn_set( terp, furn_str_id( built.post_terrain ) );
} else {
here.ter_set( terp, ter_str_id( built.post_terrain ) );
// Make a roof if constructed terrain should have it and it's an open air
// Make a roof if constructed terrain should have it and it's an open space
if( construct::check_up_OK( terp ) ) {
const int_id<ter_t> post_terrain = ter_id( built.post_terrain );
if( post_terrain->roof ) {
const tripoint_bub_ms top = terp + tripoint_above;
if( here.ter( top ) == ter_t_open_air ) {
if( here.ter( top )->has_flag( "EMPTY_SPACE" ) ) {
here.ter_set( top, ter_id( post_terrain->roof ) );
}
}
}

if( ter_id( built.post_terrain ).id() == ter_t_open_air ) {
if( ter_id( built.post_terrain )->has_flag( "EMPTY_SPACE" ) ) {
const tripoint_bub_ms below = terp + tripoint_below;
if( below.z() > -OVERMAP_DEPTH && here.ter( below ).obj().has_flag( "SUPPORTS_ROOF" ) ) {
const map_bash_info bash_info = here.ter( below ).obj().bash;
Expand Down
4 changes: 2 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4250,7 +4250,7 @@ void map::bash_ter_furn( const tripoint &p, bash_params &params )
spawn_items( p, item_group::items_from( bash->drop_group, calendar::turn ) );
}

if( smash_ter && ter( p ) == ter_t_open_air && zlevels ) {
if( smash_ter && ter( p )->has_flag( "EMPTY_SPACE" ) && zlevels ) {
tripoint below( p.xy(), p.z - 1 );
const ter_str_id roof = get_roof( below, params.bash_floor && ter( below ).obj().movecost != 0 );
ter_set( p, roof );
Expand Down Expand Up @@ -8728,7 +8728,7 @@ void map::add_roofs( const tripoint &grid )
for( int x = 0; x < SEEX; x++ ) {
for( int y = 0; y < SEEY; y++ ) {
const ter_id ter_here = sub_here->get_ter( { x, y } );
if( ter_here != ter_t_open_air ) {
if( !ter_here->has_flag( "EMPTY_SPACE" ) ) {
continue;
}

Expand Down

0 comments on commit d2fd8af

Please sign in to comment.