Fix refreshing of vehicle panel from vehicle updates
Regression from vehicle grouping changes
This commit is contained in:
@@ -2540,13 +2540,31 @@ void DirtyVehicleListWindowForVehicle(const Vehicle *v)
|
||||
FOR_ALL_WINDOWS_FROM_BACK(w) {
|
||||
if (w->window_class == cls || w->window_class == cls2) {
|
||||
BaseVehicleListWindow *listwin = static_cast<BaseVehicleListWindow *>(w);
|
||||
uint max = std::min<uint>(listwin->vscroll->GetPosition() + listwin->vscroll->GetCapacity(), (uint)listwin->vehicles.size());
|
||||
uint max = std::min<uint>(listwin->vscroll->GetPosition() + listwin->vscroll->GetCapacity(), (uint)listwin->vehgroups.size());
|
||||
switch (listwin->grouping) {
|
||||
case BaseVehicleListWindow::GB_NONE:
|
||||
for (uint i = listwin->vscroll->GetPosition(); i < max; ++i) {
|
||||
if (v == listwin->vehicles[i]) {
|
||||
if (v == listwin->vehgroups[i].vehicles_begin[0]) {
|
||||
listwin->SetWidgetDirty(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseVehicleListWindow::GB_SHARED_ORDERS: {
|
||||
const Vehicle *v_first_shared = v->FirstShared();
|
||||
for (uint i = listwin->vscroll->GetPosition(); i < max; ++i) {
|
||||
if (v_first_shared == listwin->vehgroups[i].vehicles_begin[0]->FirstShared()) {
|
||||
listwin->SetWidgetDirty(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,9 @@ struct BaseVehicleListWindow : public Window {
|
||||
};
|
||||
|
||||
GroupBy grouping; ///< How we want to group the list.
|
||||
protected:
|
||||
VehicleList vehicles; ///< List of vehicles. This is the buffer for `vehgroups` to point into; if this is structurally modified, `vehgroups` must be rebuilt.
|
||||
public:
|
||||
uint own_vehicles = 0; ///< Count of vehicles of the local company
|
||||
CompanyID own_company; ///< Company ID used for own_vehicles
|
||||
GUIVehicleGroupList vehgroups; ///< List of (groups of) vehicles. This stores iterators of `vehicles`, and should be rebuilt if `vehicles` is structurally changed.
|
||||
|
Reference in New Issue
Block a user