From fb357c0bc03d68914385e7deae28ebd0b568cb59 Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Mon, 7 Jan 2019 22:40:43 -0900 Subject: [PATCH 1/2] get_overmaps_near returns closest overmaps first --- src/overmapbuffer.cpp | 9 +++++++++ src/overmapbuffer.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/overmapbuffer.cpp b/src/overmapbuffer.cpp index 37f6ea3312c39..be68a97114cd5 100644 --- a/src/overmapbuffer.cpp +++ b/src/overmapbuffer.cpp @@ -910,6 +910,15 @@ std::vector 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(), [¢er]( 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; } diff --git a/src/overmapbuffer.h b/src/overmapbuffer.h index f6a267110872b..05509839240c8 100644 --- a/src/overmapbuffer.h +++ b/src/overmapbuffer.h @@ -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 get_overmaps_near( const point &location, int radius ); std::vector get_overmaps_near( const tripoint &location, int radius ); From dbc48eace0d5b41d7422a9b31198345e953992eb Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Mon, 7 Jan 2019 22:42:05 -0900 Subject: [PATCH 2/2] Extend search range for bandit_cabin/camp missions --- src/mission_start.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 1b1e141fe12a8..10e1ebf2dcc45 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -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 target_pos = assign_mission_target( t ); @@ -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 target_pos = assign_mission_target( t );