Skip to content

Commit

Permalink
Merge pull request #27489 from ralreegorganon/mission-start-find-spec…
Browse files Browse the repository at this point in the history
…ial-improvement

Greater search range for refugee camp bandit missions
  • Loading branch information
ZhilkinSerg committed Jan 8, 2019
2 parents f146951 + dbc48ea commit 4a1ab34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mission_start.cpp
Expand Up @@ -391,6 +391,7 @@ void mission_start::place_bandit_cabin( mission *miss )
t.overmap_terrain_subtype = "bandit_cabin";
t.overmap_special = overmap_special_id( "bandit_cabin" );
t.mission_pointer = miss;
t.search_range = OMAPX * 5;
t.reveal_radius = 1;

const cata::optional<tripoint> target_pos = assign_mission_target( t );
Expand Down Expand Up @@ -445,6 +446,7 @@ void mission_start::place_bandit_camp( mission *miss )
t.overmap_terrain_subtype = "bandit_camp_1";
t.overmap_special = overmap_special_id( "bandit_camp" );
t.mission_pointer = miss;
t.search_range = OMAPX * 5;
t.reveal_radius = 1;

const cata::optional<tripoint> target_pos = assign_mission_target( t );
Expand Down
9 changes: 9 additions & 0 deletions src/overmapbuffer.cpp
Expand Up @@ -910,6 +910,15 @@ std::vector<overmap *> overmapbuffer::get_overmaps_near( const tripoint &locatio
}
}

// Sort the resulting overmaps so that the closest ones are first.
const tripoint center = sm_to_om_copy( location );
std::sort( result.begin(), result.end(), [&center]( const overmap * lhs,
const overmap * rhs ) {
const tripoint lhs_pos( lhs->pos(), 0 );
const tripoint rhs_pos( rhs->pos(), 0 );
return trig_dist( center, lhs_pos ) < trig_dist( center, rhs_pos );
} );

return result;
}

Expand Down
1 change: 1 addition & 0 deletions src/overmapbuffer.h
Expand Up @@ -497,6 +497,7 @@ class overmapbuffer
/**
* Retrieve overmaps that overlap the bounding box defined by the location and radius.
* The location is in absolute submap coordinates, the radius is in the same system.
* The overmaps are returned sorted by distance from the provided location (closest first).
*/
std::vector<overmap *> get_overmaps_near( const point &location, int radius );
std::vector<overmap *> get_overmaps_near( const tripoint &location, int radius );
Expand Down

0 comments on commit 4a1ab34

Please sign in to comment.