From 8de325f2567bd47ed6546a15c084449d4f585f3e Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 16 Jan 2021 17:38:43 +0100 Subject: [PATCH] Codechange: [SDL2] Only prepare "caption" if you are going to us it --- src/video/sdl2_v.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index ce1917ccc6..33c2b96b18 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -282,7 +282,6 @@ static uint FindStartupDisplay(uint startup_display) bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize) { SDL_Surface *newscreen; - char caption[50]; int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); GetAvailableVideoMode(&w, &h); @@ -292,8 +291,6 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize) /* Free any previously allocated shadow surface */ if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface); - seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision); - if (_sdl_window == nullptr) { Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; @@ -307,6 +304,9 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize) x = r.x + std::max(0, r.w - static_cast(w)) / 2; y = r.y + std::max(0, r.h - static_cast(h)) / 4; // decent desktops have taskbars at the bottom } + + char caption[50]; + seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision); _sdl_window = SDL_CreateWindow( caption, x, y,