Skip to content

Commit

Permalink
Avoid overflow in get_overmaps_near
Browse files Browse the repository at this point in the history
In some cases a call to get_overmaps_near was passing a tripoint with z
value INT_MIN.  This led to an overflow when computing the distance
between points.

Instead, just pass the x,y part of the tripoint.
  • Loading branch information
jbytheway committed Jan 25, 2020
1 parent 31e9af9 commit 698fde7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/overmapbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ std::vector<shared_ptr_fast<npc>> overmapbuffer::get_npcs_near( const tripoint &
int radius )
{
std::vector<shared_ptr_fast<npc>> result;
for( auto &it : get_overmaps_near( p, radius ) ) {
for( auto &it : get_overmaps_near( p.xy(), radius ) ) {
auto temp = it->get_npcs( [&]( const npc & guy ) {
// Global position of NPC, in submap coordinates
const tripoint pos = guy.global_sm_location();
Expand Down

0 comments on commit 698fde7

Please sign in to comment.