Skip to content

Commit

Permalink
Fix infinite loop in mine gen (cataclysmbnteam#3379)
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p authored Oct 6, 2023
1 parent 42d0b2f commit 2c31bfa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3696,12 +3696,17 @@ void overmap::build_mine( const tripoint_om_omt &origin, int s )
}
tripoint_om_omt p = origin;
// Don't overwrite existing mapgen
while( ter( p ) != empty_rock ) {
int attempts_left = 100;
while( ter( p ) != empty_rock && attempts_left > 0 ) {
if( one_in( 2 ) ) {
p.x() += rng( 0, 1 ) * 2 - 1;
} else {
p.y() += rng( 0, 1 ) * 2 - 1;
}
attempts_left -= 1;
}
if( !inbounds( p ) ) {
return;
}
while( built < s ) {
ter_set( p, mine );
Expand Down

0 comments on commit 2c31bfa

Please sign in to comment.