From 91022b0750f051aebe537371a10a70f78b9205eb Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Thu, 27 Jun 2019 01:13:59 -0700 Subject: [PATCH] Eliminate last get_vehicle call when vehicles are idle. (#31903) --- src/map.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index cc93f93170a7b..d374537ecbdf5 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -356,11 +356,18 @@ void map::on_vehicle_moved( const int smz ) void map::vehmove() { // give vehicles movement points - VehicleList vehicle_list = get_vehicles(); - for( auto &vehs_v : vehicle_list ) { - vehicle *veh = vehs_v.v; - veh->gain_moves(); - veh->slow_leak(); + VehicleList vehicle_list; + int minz = zlevels ? -OVERMAP_DEPTH : abs_sub.z; + int maxz = zlevels ? OVERMAP_HEIGHT : abs_sub.z; + for( int zlev = minz; zlev < maxz; ++zlev ) { + level_cache &cache = get_cache( zlev ); + for( vehicle *veh : cache.vehicle_list ) { + veh->gain_moves(); + veh->slow_leak(); + wrapped_vehicle w; + w.v = veh; + vehicle_list.push_back( w ); + } } // 15 equals 3 >50mph vehicles, or up to 15 slow (1 square move) ones