Remove global args from Game

I've decided to call dwgfx/game/map/obj/key/help/music the "global args".
Because they're essentially global variables that are being passed
around in args.

This commit removes global args from all functions on the Game class,
and deals with updating the callsites of said functions accordingly. It
also renames all usages of 'dwgfx' in Game.cpp to 'graphics', since the
global variable is called 'graphics' now.

Interesting to note, I was removing the class defines from Game.h, but
it turns out that Graphics.h depends on the mapclass and entityclass
defines from Game.h. And also Graphics.h spelled mapclass wrong (it
forgot the "class") so I just decided to use that existing line instead.
This is only temporary and after all is said and done, at the end of
this pull request those class defines will be gone.
This commit is contained in:
Misa
2020-03-30 17:16:02 -07:00
committed by Ethan Lee
parent 1be398319c
commit 0e561f23f8
8 changed files with 586 additions and 593 deletions

View File

@@ -511,7 +511,7 @@ SDL_assert(0 && "Remove open level dir");
dwgfx.screenbuffer->toggleFullScreen();
game.fullscreen = !game.fullscreen;
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 0;
}else if (game.currentmenuoption == 1){
@@ -519,7 +519,7 @@ SDL_assert(0 && "Remove open level dir");
dwgfx.screenbuffer->toggleStretchMode();
game.stretchMode = (game.stretchMode + 1) % 3;
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 1;
}else if (game.currentmenuoption == 2){
@@ -527,7 +527,7 @@ SDL_assert(0 && "Remove open level dir");
dwgfx.screenbuffer->toggleLinearFilter();
game.useLinearFilter = !game.useLinearFilter;
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 2;
}else if (game.currentmenuoption == 3){
@@ -537,7 +537,7 @@ SDL_assert(0 && "Remove open level dir");
//Hook the analogue thing in here: ABCDEFG
updategraphicsmode(game, dwgfx);
dwgfx.screenbuffer->badSignalEffect= !dwgfx.screenbuffer->badSignalEffect;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 3;
}else if (game.currentmenuoption == 4) {
@@ -577,7 +577,7 @@ SDL_assert(0 && "Remove open level dir");
game.fullscreen = true;
}
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
}
else if (game.currentmenuoption == 1)
@@ -593,7 +593,7 @@ SDL_assert(0 && "Remove open level dir");
}
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 1;
}
@@ -606,7 +606,7 @@ SDL_assert(0 && "Remove open level dir");
dwgfx.screenbuffer->SetScale(game.advanced_scaling);
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 2;
}
@@ -617,7 +617,7 @@ SDL_assert(0 && "Remove open level dir");
game.advanced_smoothing = !game.advanced_smoothing;
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 3;
}
@@ -646,7 +646,7 @@ SDL_assert(0 && "Remove open level dir");
}
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
}
else if (game.currentmenuoption == 1)
@@ -662,7 +662,7 @@ SDL_assert(0 && "Remove open level dir");
}
updategraphicsmode(game, dwgfx);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("graphicoptions");
game.currentmenuoption = 1;
}
@@ -707,7 +707,7 @@ SDL_assert(0 && "Remove open level dir");
map.invincibility = !map.invincibility;
//game.deletequick();
//game.deletetele();
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
game.createmenu("accessibility");
game.currentmenuoption = 3;
@@ -741,7 +741,7 @@ SDL_assert(0 && "Remove open level dir");
//back
game.gameframerate=34;
game.slowdown = 30;
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
game.createmenu("accessibility");
game.currentmenuoption = 4;
@@ -751,7 +751,7 @@ SDL_assert(0 && "Remove open level dir");
{
game.gameframerate=41;
game.slowdown = 24;
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
game.createmenu("accessibility");
game.currentmenuoption = 4;
@@ -761,7 +761,7 @@ SDL_assert(0 && "Remove open level dir");
{
game.gameframerate=55;
game.slowdown = 18;
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
game.createmenu("accessibility");
game.currentmenuoption = 4;
@@ -771,7 +771,7 @@ SDL_assert(0 && "Remove open level dir");
{
game.gameframerate=83;
game.slowdown = 12;
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
game.createmenu("accessibility");
game.currentmenuoption = 4;
@@ -784,7 +784,7 @@ SDL_assert(0 && "Remove open level dir");
{
//disable animated backgrounds
game.colourblindmode = !game.colourblindmode;
game.savestats(map, dwgfx);
game.savestats();
map.tdrawback = true;
music.playef(11, 10);
}
@@ -792,7 +792,7 @@ SDL_assert(0 && "Remove open level dir");
{
//disable screeneffects
game.noflashingmode = !game.noflashingmode;
game.savestats(map, dwgfx);
game.savestats();
if (!game.noflashingmode)
{
music.playef(18, 10);
@@ -806,7 +806,7 @@ SDL_assert(0 && "Remove open level dir");
{
//disable text outline
dwgfx.notextoutline = !dwgfx.notextoutline;
game.savestats(map, dwgfx);
game.savestats();
music.playef(11, 10);
}
else if (game.currentmenuoption == 3)
@@ -912,7 +912,7 @@ SDL_assert(0 && "Remove open level dir");
music.usingmmmmmm = !music.usingmmmmmm;
music.playef(11, 10);
music.play(6);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("mainmenu");
map.nexttowercolour();
}
@@ -975,7 +975,7 @@ SDL_assert(0 && "Remove open level dir");
music.usingmmmmmm = !music.usingmmmmmm;
music.playef(11, 10);
music.play(6);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("mainmenu");
map.nexttowercolour();
}
@@ -1004,7 +1004,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[9] = true;
game.unlocknotify[9] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 0;
}
@@ -1013,7 +1013,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[10] = true;
game.unlocknotify[10] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 1;
}
@@ -1022,7 +1022,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[11] = true;
game.unlocknotify[11] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 2;
}
@@ -1031,7 +1031,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[12] = true;
game.unlocknotify[12] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 3;
}
@@ -1040,7 +1040,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[13] = true;
game.unlocknotify[13] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 4;
}
@@ -1049,7 +1049,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlock[14] = true;
game.unlocknotify[14] = true;
music.playef(11, 10);
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenutrials");
game.currentmenuoption = 5;
}
@@ -1078,7 +1078,7 @@ SDL_assert(0 && "Remove open level dir");
game.unlocknotify[16] = true;
game.unlock[6] = true;
game.unlock[7] = true;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenu");
game.currentmenuoption = 1;
}
@@ -1088,7 +1088,7 @@ SDL_assert(0 && "Remove open level dir");
music.playef(11, 10);
game.unlock[17] = true;
game.unlocknotify[17] = true;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenu");
game.currentmenuoption = 2;
}
@@ -1098,7 +1098,7 @@ SDL_assert(0 && "Remove open level dir");
music.playef(11, 10);
game.unlock[18] = true;
game.unlocknotify[18] = true;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenu");
game.currentmenuoption = 3;
}
@@ -1107,7 +1107,7 @@ SDL_assert(0 && "Remove open level dir");
//unlock jukebox
music.playef(11, 10);
game.stat_trinkets = 20;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenu");
game.currentmenuoption = 4;
}
@@ -1117,7 +1117,7 @@ SDL_assert(0 && "Remove open level dir");
music.playef(11, 10);
game.unlock[8] = true;
game.unlocknotify[8] = true;
game.savestats(map, dwgfx);
game.savestats();
game.createmenu("unlockmenu");
game.currentmenuoption = 5;
}
@@ -1313,7 +1313,7 @@ SDL_assert(0 && "Remove open level dir");
{
//go to a menu!
music.playef(11, 10);
game.loadsummary(map, help); //Prepare save slots to display
game.loadsummary(); //Prepare save slots to display
game.createmenu("continue");
map.settowercolour(3);
}
@@ -1363,7 +1363,7 @@ SDL_assert(0 && "Remove open level dir");
{
//go to a menu!
music.playef(11, 10);
game.loadsummary(map, help); //Prepare save slots to display
game.loadsummary(); //Prepare save slots to display
game.createmenu("continue");
map.settowercolour(3);
}
@@ -1486,7 +1486,7 @@ SDL_assert(0 && "Remove open level dir");
music.playef(23, 10);
game.deletequick();
game.deletetele();
game.deletestats(map, dwgfx);
game.deletestats();
game.flashlight = 5;
game.screenshake = 15;
game.createmenu("mainmenu");
@@ -2071,7 +2071,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
dwgfx.resumegamemode = false;
game.useteleporter = true;
game.initteleportermode(map);
game.initteleportermode();
}
else
{
@@ -2403,7 +2403,7 @@ void mapinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
music.playef(18, 10);
game.gamesaved = true;
game.savetime = game.timestring(help);
game.savetime = game.timestring();
game.savearea = map.currentarea(map.area(game.roomx, game.roomy));
game.savetrinkets = game.trinkets;
@@ -2412,12 +2412,12 @@ void mapinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
#if !defined(NO_CUSTOM_LEVELS)
if(map.custommodeforreal)
{
game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename, map, obj, music);
game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename);
}
else
#endif
{
game.savequick(map, obj, music);
game.savequick();
}
}