Allow using 'help', 'graphics', 'music', 'game', 'key', 'map', and 'obj' everywhere #129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes:
Allow using
help
,graphics
,music
,game
,key
,map
, andobj
everywhereThis PR makes
help
,graphics
,music
,game
,key
,map
, andobj
essentially static global objects that can be used everywhere. This is useful in case we ever need to add a new function in the future, so we don't have to bother with passing a new argument in which means we have to pass a new argument in to the function that calls that function which means having to pass a new argument into the function that calls that function, etc. which is a real headache when working on fan mods of the source code.Note that this changes none of the existing function signatures, it merely just makes those variables accessible everywhere in the same way
script
anded
are.Also note that some classes had to be initialized after the filesystem was initialized, or else the game would segfault. But C++ would keep initializing them before the filesystem got initialized, because I had to put them at the top of
main.cpp
, or else they wouldn't be global variables.The only way to work around this was to use entityclass's initialization style (which I'm pretty sure entityclass of all things doesn't need to be initialized this way), where you actually initialize the class in an
init()
function, and so then you dographics.init()
after the filesystem initialization, after doingGraphics graphics
up at the top.I've had to do this for
graphics
(but only because its child GraphicsResourcesgrphx
needs to be initialized this way),music
, andgame
. I don't think this will affect anything. Other than that,help
,key
, andmap
are still using the C++-intended method of having ClassName::ClassName() functions.Legal Stuff:
By submitting this pull request, I confirm that...
example, a 2.3 update on Steam for Windows/macOS/Linux)
CONTRIBUTORS
file for all of said releases, butwill NOT be compensated for these changes