From c11c8452e1015c64082bad1f95a0963c08299baa Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Tue, 2 Jan 2018 20:28:36 +0000 Subject: [PATCH 30/31] VehicleSet ~> std::vector --- src/vehicle.cpp | 4 ++-- src/vehicle_cmd.cpp | 2 +- src/vehicle_func.h | 2 +- src/vehicle_gui.cpp | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e4a8c7bf1..9f7e14a1e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2845,10 +2845,10 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles) for (; u != NULL && num_vehicles > 0; num_vehicles--) { do { /* Include current vehicle in the selection. */ - set.Include(u->index); + Include(set, u->index); /* If the vehicle is multiheaded, add the other part too. */ - if (u->IsMultiheaded()) set.Include(u->other_multiheaded_part->index); + if (u->IsMultiheaded()) Include(set, u->other_multiheaded_part->index); u = u->Next(); } while (u != NULL && u->IsArticulatedPart()); diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 9670fa05d..87b9172fd 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -321,7 +321,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, /* Reset actual_subtype for every new vehicle */ if (!v->IsArticulatedPart()) actual_subtype = new_subtype; - if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue; + if (v->type == VEH_TRAIN && !Contains(vehicles_to_refit, v->index) && !only_this) continue; const Engine *e = v->GetEngine(); if (!e->CanCarryCargo()) continue; diff --git a/src/vehicle_func.h b/src/vehicle_func.h index 9eb6b9121..2fbb88a9d 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -175,7 +175,7 @@ bool CanVehicleUseStation(const Vehicle *v, const struct Station *st); void ReleaseDisastersTargetingVehicle(VehicleID vehicle); -typedef SmallVector VehicleSet; +using VehicleSet = std::vector; void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles); void CheckCargoCapacity(Vehicle *v); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 205b8561a..f932c4ce5 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -414,7 +414,7 @@ struct RefitWindow : public Window { GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles); do { - if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index)) continue; + if (v->type == VEH_TRAIN && !Contains(vehicles_to_refit, v->index)) continue; const Engine *e = v->GetEngine(); uint32 cmask = e->info.refit_mask; byte callback_mask = e->info.callback_mask; @@ -747,14 +747,14 @@ struct RefitWindow : public Window { for (Train *u = Train::From(v); u != NULL; u = u->Next()) { /* Start checking. */ - if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) { + if (Contains(vehicles_to_refit, u->index) && left == INT32_MIN) { left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin; width = 0; } /* Draw a selection. */ - if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) { - if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) { + if ((!Contains(vehicles_to_refit, u->index) || u->Next() == NULL) && left != INT32_MIN) { + if (u->Next() == NULL && Contains(vehicles_to_refit, u->index)) { int current_width = u->GetDisplayImageWidth(); width += current_width; x += current_width; -- 2.14.1