From 6828b6014a0c4f510351a6c6828c7702549dcdb1 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 5 Jan 2024 21:38:56 +0000 Subject: [PATCH] Codechange: Use company group statistics to test for vehicles for drop down list state. This avoids iterating full the vehicle pool to find out if a company has any vehicles of a particular type. --- src/toolbar_gui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 0ff9cfe7eb..7a187103cd 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -728,10 +728,10 @@ static CallBackFunction MenuClickIndustry(int index) static void ToolbarVehicleClick(Window *w, VehicleType veh) { - int dis = ~0; + int dis = 0; - for (const Vehicle *v : Vehicle::Iterate()) { - if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner); + for (const Company *c : Company::Iterate()) { + if (c->group_all[veh].num_vehicle == 0) SetBit(dis, c->index); } PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis); }