Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid casting -inf to an integer type in the sound code #39349

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/sounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ static std::vector<centroid> cluster_sounds( std::vector<std::pair<tripoint, int
// so we cluster sounds and apply the centroids of the sounds to the monster AI
// to fight the combinatorial explosion.
std::vector<centroid> sound_clusters;
const int num_seed_clusters = std::max( std::min( recent_sounds.size(), static_cast<size_t>( 10 ) ),
static_cast<size_t>( 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<size_t>( 10 ) ),
static_cast<size_t>( 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.
Expand Down