Skip to content

Commit

Permalink
Fix floor disappearing with z-levels off (#35651)
Browse files Browse the repository at this point in the history
The collapse code was performing a lot of operations on neighboring
z-levels, without first checking if experimental z-levels were enabled.
This was causing bugs due to these operations being performed on the
current z-level instead.
Fixes #35266
  • Loading branch information
Davi-DeGanne authored and kevingranade committed Nov 23, 2019
1 parent dba86fe commit 35f6557
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/map.cpp
Original file line number Diff line number Diff line change
@@ -2965,14 +2965,15 @@ void map::collapse_at( const tripoint &p, const bool silent, const bool was_supp
// If something supporting the roof collapsed, see what else collapses
if( supports && !still_supports ) {
for( const tripoint &t : points_in_radius( p, 1 ) ) {
// If z-levels are off, tz == t, so we end up skipping a lot of stuff to avoid bugs.
const tripoint &tz = tripoint( t.xy(), t.z + 1 );
// if nothing above us had the chance of collapsing, move on
if( !one_in( collapse_check( tz ) ) ) {
continue;
}
// if a wall collapses, walls without support from below risk collapsing and
//propogate the collapse upwards
if( wall && p == t && has_flag( "WALL", tz ) ) {
if( zlevels && wall && p == t && has_flag( "WALL", tz ) ) {
collapse_at( tz, silent );
}
// floors without support from below risk collapsing into open air and can propogate
@@ -2982,8 +2983,10 @@ void map::collapse_at( const tripoint &p, const bool silent, const bool was_supp
}
// this tile used to support a roof, now it doesn't, which means there is only
// open air above us
ter_set( tz, t_open_air );
furn_set( tz, f_null );
if( zlevels ) {
ter_set( tz, t_open_air );
furn_set( tz, f_null );
}
}
}
// it would be great to check if collapsing ceilings smashed through the floor, but

0 comments on commit 35f6557

Please sign in to comment.