1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-10 13:09:43 +01:00

GetWindowSize: Initialize out values if GetRendererOutput fails

Issue #870 showed one of the problems that this game has, namely that it
only sometimes checks SDL return values, and did not do so in this case.
Part of the cause of #870 is that Screen::GetWindowSize does not check
the return value of SDL_GetRendererOutputSize, so when that function
fails (as in the case where m_renderer is NULL and does not exist), it
does not initialize the out values, so it ends up writing uninitialized
values to the save files.

We need to make sure every function's return value is checked, not just
SDL functions, but that will have to be done later.
This commit is contained in:
Misa 2022-03-12 16:47:23 -08:00
parent 726b149fbb
commit 997363ce56

View file

@ -253,7 +253,13 @@ void Screen::ResizeToNearestMultiple(void)
void Screen::GetWindowSize(int* x, int* y) void Screen::GetWindowSize(int* x, int* y)
{ {
SDL_GetRendererOutputSize(m_renderer, x, y); if (SDL_GetRendererOutputSize(m_renderer, x, y) != 0)
{
vlog_error("Could not get window size: %s", SDL_GetError());
/* Initialize to safe defaults */
*x = SCREEN_WIDTH_PIXELS;
*y = SCREEN_HEIGHT_PIXELS;
}
} }
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect ) void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )