Clean up and prevent unnecessary qualifiers to self

By "unnecessary qualifiers to self", I mean something like using the
'game.' qualifier for a variable on the Game class when you're inside a
function on the Game class itself. This patch is to enforce consistency
as most of the code doesn't have these unnecessary qualifiers.

To prevent further unnecessary qualifiers to self, I made it so the
extern in each header file can be omitted by using a define. That way,
if someone writes something referring to 'game.' on a Game function,
there will be a compile error.

However, if you really need to have a reference to the global name, and
you're within the same .cpp file as the implementation of that object,
you can just do the extern at the function-level. A good example of this
is editorinput()/editorrender()/editorlogic() in editor.cpp. In my
opinion, they should probably be split off into their own separate file
because editor.cpp is getting way too big, but this will do for now.
This commit is contained in:
Misa
2020-09-27 19:15:06 -07:00
committed by Ethan Lee
parent 571ad1f7d8
commit cbceeccf78
18 changed files with 81 additions and 34 deletions

View File

@@ -1,3 +1,4 @@
#define GAME_DEFINITION
#include "Game.h"
#include <sstream>
@@ -6619,8 +6620,8 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option("animated backgrounds");
option("screen effects");
option("text outline");
option("invincibility", !ingame_titlemode || (!game.insecretlab && !game.intimetrial && !game.nodeathmode));
option("slowdown", !ingame_titlemode || (!game.insecretlab && !game.intimetrial && !game.nodeathmode));
option("invincibility", !ingame_titlemode || (!insecretlab && !intimetrial && !nodeathmode));
option("slowdown", !ingame_titlemode || (!insecretlab && !intimetrial && !nodeathmode));
option("return");
menuyoff = 0;
break;
@@ -7196,13 +7197,13 @@ void Game::returntolab()
#if !defined(NO_CUSTOM_LEVELS)
void Game::returntoeditor()
{
game.gamestate = EDITORMODE;
gamestate = EDITORMODE;
graphics.textbox.clear();
game.hascontrol = true;
game.advancetext = false;
game.completestop = false;
game.state = 0;
hascontrol = true;
advancetext = false;
completestop = false;
state = 0;
graphics.showcutscenebars = false;
graphics.fademode = 0;
@@ -7234,13 +7235,13 @@ void Game::returntopausemenu()
map.kludge_to_bg();
map.tdrawback = true;
graphics.backgrounddrawn = false;
game.mapheld = true;
mapheld = true;
graphics.flipmode = graphics.setflipmode;
if (!map.custommode && !graphics.flipmode)
{
obj.flags[73] = true;
}
game.shouldreturntopausemenu = true;
shouldreturntopausemenu = true;
}
void Game::unlockAchievement(const char *name) {