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

@@ -13,6 +13,7 @@
#include "MakeAndPlay.h"
#include "Map.h"
#include "Music.h"
#include "Screen.h"
#include "Script.h"
#include "UtilityClass.h"
#include "Vlogging.h"
@@ -559,7 +560,7 @@ static void menuactionpress(void)
&& FILESYSTEM_openDirectory(FILESYSTEM_getUserLevelDirectory()))
{
music.playef(11);
SDL_MinimizeWindow(graphics.screenbuffer->m_window);
SDL_MinimizeWindow(gameScreen.m_window);
}
else
{
@@ -604,30 +605,24 @@ static void menuactionpress(void)
map.nexttowercolour();
break;
case Menu::graphicoptions:
if (graphics.screenbuffer == NULL)
{
SDL_assert(0 && "Screenbuffer is NULL!");
break;
}
switch (game.currentmenuoption)
{
case 0:
music.playef(11);
graphics.screenbuffer->toggleFullScreen();
gameScreen.toggleFullScreen();
game.savestatsandsettings_menu();
break;
case 1:
music.playef(11);
graphics.screenbuffer->toggleScalingMode();
gameScreen.toggleScalingMode();
game.savestatsandsettings_menu();
break;
case 2:
// resize to nearest multiple
if (graphics.screenbuffer->isWindowed)
if (gameScreen.isWindowed)
{
music.playef(11);
graphics.screenbuffer->ResizeToNearestMultiple();
gameScreen.ResizeToNearestMultiple();
game.savestatsandsettings_menu();
}
else
@@ -637,13 +632,13 @@ static void menuactionpress(void)
break;
case 3:
music.playef(11);
graphics.screenbuffer->toggleLinearFilter();
gameScreen.toggleLinearFilter();
game.savestatsandsettings_menu();
break;
case 4:
//change smoothing
music.playef(11);
graphics.screenbuffer->badSignalEffect= !graphics.screenbuffer->badSignalEffect;
gameScreen.badSignalEffect= !gameScreen.badSignalEffect;
game.savestatsandsettings_menu();
break;
case 5:
@@ -651,7 +646,7 @@ static void menuactionpress(void)
#if SDL_VERSION_ATLEAST(2, 0, 17)
//toggle vsync
music.playef(11);
graphics.screenbuffer->toggleVSync();
gameScreen.toggleVSync();
game.savestatsandsettings_menu();
#endif
break;