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:
nhmall
2022-11-29 21:53:21 -05:00
parent e64ed2859d
commit 02a48aa8cf
193 changed files with 10764 additions and 10148 deletions

View File

@@ -155,7 +155,7 @@ awaken_soldiers(struct monst* bugler /* monster that played instrument */)
int distance, distm;
/* distance of affected non-soldier monsters to bugler */
distance = ((bugler == &g.youmonst) ? u.ulevel : bugler->data->mlevel) * 30;
distance = ((bugler == &gy.youmonst) ? u.ulevel : bugler->data->mlevel) * 30;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
@@ -169,7 +169,7 @@ awaken_soldiers(struct monst* bugler /* monster that played instrument */)
else if (!Deaf)
Norep("%s the rattle of battle gear being readied.",
"You hear"); /* Deaf-aware */
} else if ((distm = ((bugler == &g.youmonst)
} else if ((distm = ((bugler == &gy.youmonst)
? mdistu(mtmp)
: dist2(bugler->mx, bugler->my, mtmp->mx,
mtmp->my))) < distance) {
@@ -400,7 +400,7 @@ do_earthquake(int force)
Your("chain breaks!");
reset_utrap(TRUE);
}
if (Levitation || Flying || is_clinger(g.youmonst.data)) {
if (Levitation || Flying || is_clinger(gy.youmonst.data)) {
if (!tu_pit) { /* no pit here previously */
pline("A chasm opens up under you!");
You("don't fall in!");
@@ -426,8 +426,8 @@ do_earthquake(int force)
if (keepfooting)
exercise(A_DEX, TRUE);
else
selftouch((Upolyd && (slithy(g.youmonst.data)
|| nolimbs(g.youmonst.data)))
selftouch((Upolyd && (slithy(gy.youmonst.data)
|| nolimbs(gy.youmonst.data)))
? "Shaken, you"
: "Falling down, you");
}
@@ -620,7 +620,7 @@ do_improvisation(struct obj* instr)
You("extract a loud noise from %s.", yname(instr));
else
You("blow into the bugle.");
awaken_soldiers(&g.youmonst);
awaken_soldiers(&gy.youmonst);
exercise(A_WIS, FALSE);
break;
case MAGIC_HARP: /* Charm monsters */
@@ -672,7 +672,7 @@ do_improvisation(struct obj* instr)
rn2(2) ? "butcher" : rn2(2) ? "manage" : "pull off",
an(beats[rn2(SIZE(beats))]));
awaken_monsters(u.ulevel * (mundane ? 5 : 40));
g.context.botl = TRUE;
gc.context.botl = TRUE;
break;
default:
impossible("What a weird instrument (%d)!", instr->otyp);
@@ -698,7 +698,7 @@ do_play_instrument(struct obj* instr)
} else if ((instr->otyp == WOODEN_FLUTE || instr->otyp == MAGIC_FLUTE
|| instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN
|| instr->otyp == FIRE_HORN || instr->otyp == BUGLE)
&& !can_blow(&g.youmonst)) {
&& !can_blow(&gy.youmonst)) {
You("are incapable of playing %s.", thesimpleoname(instr));
return ECMD_OK;
}
@@ -715,7 +715,7 @@ do_play_instrument(struct obj* instr)
if (c == 'q') {
goto nevermind;
} else if (c == 'y') {
Strcpy(buf, g.tune);
Strcpy(buf, gt.tune);
} else {
getlin("What tune are you playing? [5 notes, A-G]", buf);
(void) mungspaces(buf);
@@ -739,7 +739,7 @@ do_play_instrument(struct obj* instr)
*/
if (Is_stronghold(&u.uz)) {
exercise(A_WIS, TRUE); /* just for trying */
if (!strcmp(buf, g.tune)) {
if (!strcmp(buf, gt.tune)) {
/* Search for the drawbridge */
for (y = u.uy - 1; y <= u.uy + 1; y++)
for (x = u.ux - 1; x <= u.ux + 1; x++) {
@@ -779,13 +779,13 @@ do_play_instrument(struct obj* instr)
for (x = 0; x < (int) strlen(buf); x++)
if (x < 5) {
if (buf[x] == g.tune[x]) {
if (buf[x] == gt.tune[x]) {
gears++;
matched[x] = TRUE;
} else {
for (y = 0; y < 5; y++)
if (!matched[y] && buf[x] == g.tune[y]
&& buf[y] != g.tune[y]) {
if (!matched[y] && buf[x] == gt.tune[y]
&& buf[y] != gt.tune[y]) {
tumblers++;
matched[y] = TRUE;
break;