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:
@@ -1035,7 +1035,7 @@ void NetHackQtMainWindow::doQuit(bool)
|
||||
// in case someone wants to change that
|
||||
#ifdef MACOS
|
||||
QString info = nh_qsprintf("This will end your NetHack session.%s",
|
||||
!g.program_state.something_worth_saving ? ""
|
||||
!gp.program_state.something_worth_saving ? ""
|
||||
: "\n(Cancel quitting and use the Save command"
|
||||
"\nto save your current game.)");
|
||||
/* this is similar to closeEvent but the details are different;
|
||||
@@ -1053,7 +1053,7 @@ void NetHackQtMainWindow::doQuit(bool)
|
||||
break; // return to game
|
||||
case 1:
|
||||
// quit -- bypass the prompting preformed by done2()
|
||||
g.program_state.stopprint++;
|
||||
gp.program_state.stopprint++;
|
||||
::done(QUIT);
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
@@ -1320,7 +1320,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
event->key() >= Qt::Key_Left && event->key() <= Qt::Key_Down )
|
||||
return;
|
||||
|
||||
const char* d = g.Cmd.dirchars;
|
||||
const char* d = gc.Cmd.dirchars;
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Up:
|
||||
if ( dirkey == d[0] )
|
||||
@@ -1382,7 +1382,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
|
||||
{
|
||||
int ok = 0;
|
||||
if ( g.program_state.something_worth_saving ) {
|
||||
if ( gp.program_state.something_worth_saving ) {
|
||||
/* this used to offer "Save" and "Cancel"
|
||||
but cancel (ignoring the close attempt) won't work
|
||||
if user has clicked on the window's Close button */
|
||||
@@ -1397,7 +1397,7 @@ void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
|
||||
case 1:
|
||||
// quit -- bypass the prompting preformed by done2()
|
||||
ok = 1;
|
||||
g.program_state.stopprint++;
|
||||
gp.program_state.stopprint++;
|
||||
::done(QUIT);
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user