diff --git a/src/map.cpp b/src/map.cpp index c1803e727977a..d3bcef74a9a2b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -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( tmp ), p ); + if( placed == nullptr ) { + return; + } if( !i.data.patrol_points_rel_ms.empty() ) { placed->set_patrol_route( i.data.patrol_points_rel_ms ); } @@ -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 pos = random_point( points, valid_location ) ) { - place_it( *pos ); + // } else if( const std::optional pos = random_point( points, valid_location ) ) { + } else { + const std::optional pos = random_point( points, valid_location ); + if( pos.has_value() ) { + place_it( *pos ); + } } } }