Skip to content

Commit

Permalink
Fix procedural mine mapgen overwriting exit location (#1808)
Browse files Browse the repository at this point in the history
* Fix off-by-one ladder to manhole exit in mine shaft

* Prevent old mine overmapgen from overwriting exit location
  • Loading branch information
olanti-p authored Aug 28, 2022
1 parent 56d1f1d commit b5088e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/json/mapgen/mine/mine_shaft.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"object": {
"fill_ter": "t_rock",
"rows": [
" ",
" <# ",
" # ",
" # ",
Expand All @@ -17,7 +18,6 @@
" # ",
" # ",
" # ",
" # ",
" #># ",
" ....###.. ",
" .... .. ",
Expand Down
8 changes: 8 additions & 0 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,14 @@ void overmap::build_mine( const tripoint_om_omt &origin, int s )
s = 2;
}
tripoint_om_omt p = origin;
// Don't overwrite existing mapgen
while( ter( p ) != empty_rock ) {
if( one_in( 2 ) ) {
p.x() += rng( 0, 1 ) * 2 - 1;
} else {
p.y() += rng( 0, 1 ) * 2 - 1;
}
}
while( built < s ) {
ter_set( p, mine );
std::vector<tripoint_om_omt> next;
Expand Down

0 comments on commit b5088e4

Please sign in to comment.