Changeset - r28408:bbda8868bcc8
[Not reviewed]
master
0 1 0
Peter Nelson - 4 months ago 2024-01-05 21:38:56
peter1138@openttd.org
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.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/toolbar_gui.cpp
Show inline comments
 
@@ -728,10 +728,10 @@ static CallBackFunction MenuClickIndustr
 

	
 
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);
 
}
0 comments (0 inline, 0 general)