Skip to content

Commit

Permalink
Don't place null monsters or on null positions
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikLundell committed Jan 10, 2025
1 parent 0df6e42 commit 75d64f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9263,6 +9263,9 @@ void map::spawn_monsters_submap( const tripoint_rel_sm &gp, bool ignore_sight, b

const auto place_it = [&]( const tripoint_bub_ms & p ) {
monster *const placed = g->place_critter_at( make_shared_fast<monster>( tmp ), p );
if( placed == nullptr ) {
return;
}
if( !i.data.patrol_points_rel_ms.empty() ) {
placed->set_patrol_route( i.data.patrol_points_rel_ms );
}
Expand All @@ -9275,8 +9278,12 @@ void map::spawn_monsters_submap( const tripoint_rel_sm &gp, bool ignore_sight, b
// then fall back to picking a random point that is a valid location.
if( valid_location( center ) ) {
place_it( center );
} else if( const std::optional<tripoint_bub_ms> pos = random_point( points, valid_location ) ) {
place_it( *pos );
// } else if( const std::optional<tripoint_bub_ms> pos = random_point( points, valid_location ) ) {
} else {
const std::optional<tripoint_bub_ms> pos = random_point( points, valid_location );
if( pos.has_value() ) {
place_it( *pos );
}
}
}
}
Expand Down

0 comments on commit 75d64f5

Please sign in to comment.