mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-14 10:09:11 +00:00
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.
This commit is contained in:
@@ -728,10 +728,10 @@ static CallBackFunction MenuClickIndustry(int index)
|
|||||||
|
|
||||||
static void ToolbarVehicleClick(Window *w, VehicleType veh)
|
static void ToolbarVehicleClick(Window *w, VehicleType veh)
|
||||||
{
|
{
|
||||||
int dis = ~0;
|
int dis = 0;
|
||||||
|
|
||||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
|
if (c->group_all[veh].num_vehicle == 0) SetBit(dis, c->index);
|
||||||
}
|
}
|
||||||
PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis);
|
PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user