Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way too many global variables #614

Open
CelticMinstrel opened this issue Feb 15, 2025 · 3 comments
Open

Way too many global variables #614

CelticMinstrel opened this issue Feb 15, 2025 · 3 comments
Labels
work Non coding related task

Comments

@CelticMinstrel
Copy link
Member

There are tons and tons of global variables tracking all manner of state and it's pretty confusing. We should reduce the number of globals as much as possible – even just gathering related individual globals into a global struct would be a huge improvement to how things are now.

The fact that some targets require spurious declarations just to compile is also a problem. We should avoid declaring extern globals in headers that are included in more than one target.

@CelticMinstrel CelticMinstrel added the work Non coding related task label Feb 15, 2025
@NQNStudios
Copy link
Collaborator

I think if all the game global state was rounded up into a struct in boe.global.hpp like:

#define GAME

struct game_state_t {

eGameMode overall_mode;
short store_spell_whatever;
// and so on...

}

extern game_state_t game;

Then code paths shared between the game and editors, when referencing game state, could use

#ifdef GAME and this would eliminate the need for the editors to declare global variables they won't use.

We would do this for global state in the PC and scenario editors as well.

@CelticMinstrel
Copy link
Member Author

Something like that, yeah. It may turn out we have a good reason to split it between a few structs, though – either independent structs, or sub-structs of the main one.

@NQNStudios
Copy link
Collaborator

Oh, we actually can't use #ifdef GAME to separate code paths in common sources, because the define for GAME won't be set when it's build time for the common project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work Non coding related task
Projects
None yet
Development

No branches or pull requests

2 participants