Skip to content

Commit

Permalink
Codechange: Use company group statistics to test for vehicles for dro…
Browse files Browse the repository at this point in the history
…p down list state.

This avoids iterating full the vehicle pool to find out if a company has any vehicles of a particular type.
  • Loading branch information
PeterN committed Jan 5, 2024
1 parent 847f3f6 commit 6828b60
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/toolbar_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6828b60

Please sign in to comment.