Skip to content

Commit

Permalink
Merge pull request #36876 from hexagonrecursion/patch-4
Browse files Browse the repository at this point in the history
Fix floating point divide by zero in game::update_overmap_seen
  • Loading branch information
ZhilkinSerg committed Jan 10, 2020
2 parents 4452534 + aa5dfdf commit 9543261
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10690,6 +10690,11 @@ void game::update_overmap_seen()
if( trigdist && h_squared > dist_squared ) {
continue;
}
if( delta == point_zero ) {
// 1. This case is already handled outside of the loop
// 2. Calculating multiplier would cause division by zero
continue;
}
// If circular distances are enabled, scale overmap distances by the diagonality of the sight line.
const float multiplier = trigdist ? std::sqrt( h_squared ) / std::max( std::abs( delta.x ),
std::abs( delta.y ) ) : 1;
Expand Down

0 comments on commit 9543261

Please sign in to comment.