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:
@@ -288,7 +288,7 @@ saveDiskPrompt(start)
|
||||
BPTR fileLock;
|
||||
if (sysflags.asksavedisk) {
|
||||
/* Don't prompt if you can find the save file */
|
||||
if (fileLock = Lock(g.SAVEF, SHARED_LOCK)) {
|
||||
if (fileLock = Lock(gs.SAVEF, SHARED_LOCK)) {
|
||||
UnLock(fileLock);
|
||||
#if defined(TTY_GRAPHICS)
|
||||
if (windowprocs.win_init_nhwindows
|
||||
@@ -303,7 +303,7 @@ saveDiskPrompt(start)
|
||||
return 1;
|
||||
}
|
||||
pline("If save file is on a SAVE disk, put that disk in now.");
|
||||
if (strlen(g.SAVEF) > QBUFSZ - 25 - 22)
|
||||
if (strlen(gs.SAVEF) > QBUFSZ - 25 - 22)
|
||||
panic("not enough buffer space for prompt");
|
||||
/* THIS IS A HACK */
|
||||
#if defined(TTY_GRAPHICS)
|
||||
@@ -314,7 +314,7 @@ saveDiskPrompt(start)
|
||||
#endif
|
||||
#if defined(AMII_GRAPHICS)
|
||||
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) {
|
||||
getlind("File name ?", buf, g.SAVEF);
|
||||
getlind("File name ?", buf, gs.SAVEF);
|
||||
clear_nhwindow(WIN_BASE);
|
||||
}
|
||||
#endif
|
||||
@@ -323,11 +323,11 @@ saveDiskPrompt(start)
|
||||
return 0;
|
||||
|
||||
/* Strip any whitespace. Also, if nothing was entered except
|
||||
* whitespace, do not change the value of g.SAVEF.
|
||||
* whitespace, do not change the value of gs.SAVEF.
|
||||
*/
|
||||
for (bp = buf; *bp; bp++) {
|
||||
if (!isspace(*bp)) {
|
||||
strncpy(g.SAVEF, bp, PATHLEN);
|
||||
strncpy(gs.SAVEF, bp, PATHLEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,12 +185,12 @@ time_t when;
|
||||
SetDrMd(rp, JAM1);
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(buf, "%s", g.plname);
|
||||
Sprintf(buf, "%s", gp.plname);
|
||||
buf[STONE_LINE_LEN] = 0;
|
||||
tomb_text(buf);
|
||||
|
||||
/* Put $ on stone */
|
||||
Sprintf(buf, "%ld Au", g.done_money);
|
||||
Sprintf(buf, "%ld Au", gd.done_money);
|
||||
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
|
||||
tomb_text(buf);
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ menu_item **retmip;
|
||||
nw->Screen = HackScreen;
|
||||
|
||||
if (win == WIN_INVEN) {
|
||||
sprintf(title, "%s the %s's Inventory", g.plname, g.pl_character);
|
||||
sprintf(title, "%s the %s's Inventory", gp.plname, gp.pl_character);
|
||||
nw->Title = title;
|
||||
if (lastinvent.MaxX != 0) {
|
||||
nw->LeftEdge = lastinvent.MinX;
|
||||
|
||||
@@ -437,10 +437,10 @@ amii_askname()
|
||||
amii_getlin("Who are you?", plnametmp);
|
||||
} while (strlen(plnametmp) == 0);
|
||||
|
||||
strncpy(g.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
g.plname[PL_NSIZ - 1] = 0;
|
||||
strncpy(gp.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
gp.plname[PL_NSIZ - 1] = 0;
|
||||
|
||||
if (*g.plname == '\33') {
|
||||
if (*gp.plname == '\33') {
|
||||
clearlocks();
|
||||
exit_nhwindows(NULL);
|
||||
nh_terminate(0);
|
||||
@@ -474,9 +474,9 @@ amii_player_selection()
|
||||
#if 0 /* Don't query the user ... instead give random character -jhsa */
|
||||
|
||||
#if 0 /* OBSOLETE */
|
||||
if( *g.pl_character ){
|
||||
g.pl_character[ 0 ] = toupper( g.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, g.pl_character[ 0 ] ) )
|
||||
if( *gp.pl_character ){
|
||||
gp.pl_character[ 0 ] = toupper( gp.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, gp.pl_character[ 0 ] ) )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -530,19 +530,19 @@ amii_player_selection()
|
||||
case VANILLAKEY:
|
||||
if( strchr( pl_classes, toupper( code ) ) )
|
||||
{
|
||||
g.pl_character[0] = toupper( code );
|
||||
gp.pl_character[0] = toupper( code );
|
||||
aredone = 1;
|
||||
}
|
||||
else if( code == ' ' || code == '\n' || code == '\r' )
|
||||
{
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( g.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
aredone = 1;
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( g.pl_character );
|
||||
RandomWindow( gp.pl_character );
|
||||
return;
|
||||
}
|
||||
else if( code == 'q' || code == 'Q' )
|
||||
@@ -562,15 +562,15 @@ amii_player_selection()
|
||||
case 1: /* Random Character */
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( g.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( g.pl_character );
|
||||
RandomWindow( gp.pl_character );
|
||||
return;
|
||||
|
||||
default:
|
||||
g.pl_character[0] = gd->GadgetID;
|
||||
gp.pl_character[0] = gd->GadgetID;
|
||||
break;
|
||||
}
|
||||
aredone = 1;
|
||||
|
||||
@@ -81,8 +81,8 @@ const char *str;
|
||||
|
||||
while (isspace(*str))
|
||||
str++;
|
||||
strncpy(g.toplines, str, TBUFSZ);
|
||||
g.toplines[TBUFSZ - 1] = 0;
|
||||
strncpy(gt.toplines, str, TBUFSZ);
|
||||
gt.toplines[TBUFSZ - 1] = 0;
|
||||
|
||||
/* For initial message to be visible, we need to explicitly position
|
||||
* the
|
||||
@@ -101,15 +101,15 @@ const char *str;
|
||||
memcpy(cw->data, &cw->data[1],
|
||||
(iflags.msg_history - 1) * sizeof(char *));
|
||||
cw->data[iflags.msg_history - 1] =
|
||||
(char *) alloc(strlen(g.toplines) + 5);
|
||||
(char *) alloc(strlen(gt.toplines) + 5);
|
||||
strcpy(cw->data[i = iflags.msg_history - 1] + SOFF
|
||||
+ (scrollmsg != 0),
|
||||
g.toplines);
|
||||
gt.toplines);
|
||||
} else {
|
||||
/* Otherwise, allocate a new one and copy the line in */
|
||||
cw->data[cw->maxrow] = (char *) alloc(strlen(g.toplines) + 5);
|
||||
cw->data[cw->maxrow] = (char *) alloc(strlen(gt.toplines) + 5);
|
||||
strcpy(cw->data[i = cw->maxrow++] + SOFF + (scrollmsg != 0),
|
||||
g.toplines);
|
||||
gt.toplines);
|
||||
}
|
||||
cw->data[i][SEL_ITEM] = 1;
|
||||
cw->data[i][VATTR] = attr + 1;
|
||||
@@ -182,7 +182,7 @@ const char *str;
|
||||
/ w->RPort->TxHeight,
|
||||
totalvis, totalvis);
|
||||
}
|
||||
i = strlen(g.toplines + SOFF);
|
||||
i = strlen(gt.toplines + SOFF);
|
||||
cw->maxcol = max(cw->maxcol, i);
|
||||
cw->vwy = cw->maxrow;
|
||||
break;
|
||||
@@ -191,7 +191,7 @@ const char *str;
|
||||
if (cw->data[cw->cury] == NULL)
|
||||
panic("NULL pointer for status window");
|
||||
ob = &cw->data[cw->cury][j = cw->curx];
|
||||
if (g.context.botlx)
|
||||
if (gc.context.botlx)
|
||||
*ob = 0;
|
||||
|
||||
/* Display when beam at top to avoid flicker... */
|
||||
|
||||
Reference in New Issue
Block a user