Fix asserts due to main window not existing yet

Partial revert of https://github.com/OpenTTD/OpenTTD/pull/10327
This commit is contained in:
Jonathan G Rennison
2023-01-27 17:56:17 +00:00
parent 32fe84cfdd
commit 4761750eae
4 changed files with 15 additions and 9 deletions

View File

@@ -36,11 +36,13 @@ ZoomLevel _saved_scrollpos_zoom;
void SaveViewportBeforeSaveGame()
{
const Window *w = GetMainWindow();
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
_saved_scrollpos_x = w->viewport->scrollpos_x;
_saved_scrollpos_y = w->viewport->scrollpos_y;
_saved_scrollpos_zoom = w->viewport->zoom;
if (w != nullptr) {
_saved_scrollpos_x = w->viewport->scrollpos_x;
_saved_scrollpos_y = w->viewport->scrollpos_y;
_saved_scrollpos_zoom = w->viewport->zoom;
}
}
void ResetViewportAfterLoadGame()