Fix asserts due to main window not existing yet
Partial revert of https://github.com/OpenTTD/OpenTTD/pull/10327
This commit is contained in:
@@ -4185,8 +4185,8 @@ bool VehicleClicked(const GUIVehicleGroup &vehgroup)
|
||||
|
||||
void StopGlobalFollowVehicle(const Vehicle *v)
|
||||
{
|
||||
Window *w = GetMainWindow();
|
||||
if (w->viewport->follow_vehicle == v->index) {
|
||||
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||
if (w != nullptr && w->viewport->follow_vehicle == v->index) {
|
||||
ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos, true); // lock the main view on the vehicle's last position
|
||||
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user