Autoreplace window: Don't scroll to selected engine if it isn't listed

See: https://github.com/OpenTTD/OpenTTD/issues/10554
This commit is contained in:
Jonathan G Rennison
2023-03-08 18:01:27 +00:00
parent 0fc9223724
commit 8002f023cb

View File

@@ -239,10 +239,12 @@ class ReplaceVehicleWindow : public Window {
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
int position = 0;
for (const auto &item : this->engines[1]) {
if (item.engine_id == this->sel_engine[1]) break;
if (item.engine_id == this->sel_engine[1]) {
this->vscroll[1]->ScrollTowards(position);
break;
}
++position;
}
this->vscroll[1]->ScrollTowards(position);
}
}
}