Extern gameScreen, remove screenbuffer

I know earlier I removed the gameScreen extern in favor of using
screenbuffer, but that was only to be consistent. After further
consideration, I have found that it's actually really stupid.

There's no reason to be accessing it through screenbuffer, and it's
probably an artifact of 2.0-2.2 passing stack-allocated otherwise-global
classes everywhere through function arguments. Also, it leads to stupid
bugs where screenbuffer could potentially be NULL, which has already
resulted in various annoying crashes in the past. Although those could
be fixed by simply initializing screenbuffer at the very top of main(),
but, why not just scrap the whole thing anyway?

So that's what I'm doing.

As a nice side effect, I've removed the transitive include of Screen.h
from Graphics.h. This could've been done already since it only includes
it for the pointer anyway, but it's still good to do it now.
This commit is contained in:
Misa
2021-12-24 23:56:47 -08:00
parent b7cbdfe8f9
commit d0ffafe117
10 changed files with 37 additions and 64 deletions

View File

@@ -14,6 +14,7 @@
#include "Map.h"
#include "Maths.h"
#include "Music.h"
#include "Screen.h"
#include "Script.h"
#include "UtilityClass.h"
#include "Version.h"
@@ -288,19 +289,13 @@ static void menurender(void)
}
break;
case Menu::graphicoptions:
if (graphics.screenbuffer == NULL)
{
SDL_assert(0 && "Screenbuffer is NULL!");
break;
}
switch (game.currentmenuoption)
{
case 0:
graphics.bigprint( -1, 30, "Toggle Fullscreen", tr, tg, tb, true);
graphics.Print( -1, 65, "Change to fullscreen/windowed mode.", tr, tg, tb, true);
if (graphics.screenbuffer->isWindowed)
if (gameScreen.isWindowed)
{
graphics.Print( -1, 85, "Current mode: WINDOWED", tr, tg, tb, true);
}
@@ -314,7 +309,7 @@ static void menurender(void)
graphics.bigprint( -1, 30, "Scaling Mode", tr, tg, tb, true);
graphics.Print( -1, 65, "Choose letterbox/stretch/integer mode.", tr, tg, tb, true);
switch (graphics.screenbuffer->scalingMode)
switch (gameScreen.scalingMode)
{
case 2:
graphics.Print( -1, 85, "Current mode: INTEGER", tr, tg, tb, true);
@@ -331,7 +326,7 @@ static void menurender(void)
graphics.bigprint(-1, 30, "Resize to Nearest", tr, tg, tb, true);
graphics.Print(-1, 65, "Resize to the nearest window size", tr, tg, tb, true);
graphics.Print(-1, 75, "that is of an integer multiple.", tr, tg, tb, true);
if (!graphics.screenbuffer->isWindowed)
if (!gameScreen.isWindowed)
{
graphics.Print(-1, 95, "You must be in windowed mode", tr, tg, tb, true);
graphics.Print(-1, 105, "to use this option.", tr, tg, tb, true);
@@ -341,7 +336,7 @@ static void menurender(void)
graphics.bigprint( -1, 30, "Toggle Filter", tr, tg, tb, true);
graphics.Print( -1, 65, "Change to nearest/linear filter.", tr, tg, tb, true);
if (graphics.screenbuffer->isFiltered)
if (gameScreen.isFiltered)
{
graphics.Print( -1, 85, "Current mode: LINEAR", tr, tg, tb, true);
}
@@ -367,7 +362,7 @@ static void menurender(void)
graphics.Print(-1, 75, "Edit the config file.", tr, tg, tb, true);
#endif
if (!graphics.screenbuffer->vsync)
if (!gameScreen.vsync)
{
graphics.Print(-1, 85, "Current mode: VSYNC OFF", tr/2, tg/2, tb/2, true);
}