split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.
It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.
Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.
To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.
A global variable named 'amulets', would be found in ga.
ga.amulets
^ ^
A global varable named 'move', would be found in gm.
gm.moves
^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
gv.val_for_n_or_more
^ ^
A global variable named 'youmonst' would be found in gy.
gy.youmonst
^ ^
This commit is contained in:
@@ -220,7 +220,7 @@ curses_character_input_dialog(
|
||||
re-activate them now that input is being requested */
|
||||
curses_got_input();
|
||||
|
||||
if (g.invent || (g.moves > 1)) {
|
||||
if (gi.invent || (gm.moves > 1)) {
|
||||
curses_get_window_size(MAP_WIN, &map_height, &map_width);
|
||||
} else {
|
||||
map_height = term_rows;
|
||||
@@ -775,7 +775,7 @@ curses_display_nhmenu(
|
||||
menu_determine_pages(current_menu);
|
||||
|
||||
/* Display pre and post-game menus centered */
|
||||
if ((g.moves <= 1 && !g.invent) || g.program_state.gameover) {
|
||||
if ((gm.moves <= 1 && !gi.invent) || gp.program_state.gameover) {
|
||||
win = curses_create_window(current_menu->width,
|
||||
current_menu->height, CENTER);
|
||||
} else { /* Display during-game menus on the right out of the way */
|
||||
@@ -1018,7 +1018,7 @@ menu_win_size(nhmenu *menu)
|
||||
int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0;
|
||||
nhmenu_item *menu_item_ptr;
|
||||
|
||||
if (g.program_state.gameover) {
|
||||
if (gp.program_state.gameover) {
|
||||
/* for final inventory disclosure, use full width */
|
||||
maxwidth = term_cols - 2; /* +2: borders assumed */
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user