diff --git a/src/sounds.cpp b/src/sounds.cpp index 712749875614a..a232ad1539cb7 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -192,8 +192,12 @@ static std::vector cluster_sounds( std::vector sound_clusters; - const int num_seed_clusters = std::max( std::min( recent_sounds.size(), static_cast( 10 ) ), - static_cast( log( recent_sounds.size() ) ) ); + if( recent_sounds.empty() ) { + return sound_clusters; + } + const int num_seed_clusters = + std::max( std::min( recent_sounds.size(), static_cast( 10 ) ), + static_cast( log( recent_sounds.size() ) ) ); const size_t stopping_point = recent_sounds.size() - num_seed_clusters; const size_t max_map_distance = rl_dist( point_zero, point( MAPSIZE_X, MAPSIZE_Y ) ); // Randomly choose cluster seeds.