Skip to content

Commit

Permalink
Eliminate last get_vehicle call when vehicles are idle. (#31903)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade authored and ZhilkinSerg committed Jun 27, 2019
1 parent 3118778 commit 91022b0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91022b0

Please sign in to comment.