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

@@ -213,13 +213,13 @@ worm_move(struct monst *worm)
seg->nseg = new_seg; /* attach it to the end of the list */
wheads[wnum] = new_seg; /* move the end pointer */
if (wgrowtime[wnum] <= g.moves) {
if (wgrowtime[wnum] <= gm.moves) {
int whplimit, whpcap, prev_mhp, wsegs = count_wsegs(worm);
/* first set up for the next time to grow */
if (!wgrowtime[wnum]) {
/* new worm; usually grow a tail segment on its next turn */
wgrowtime[wnum] = g.moves + rnd(5);
wgrowtime[wnum] = gm.moves + rnd(5);
} else {
int mmove = mcalcmove(worm, FALSE),
/* prior to 3.7.0, next-grow increment was 3..17 but since
@@ -232,7 +232,7 @@ worm_move(struct monst *worm)
* speed of 3, effective value is 8..48 */
incr = (incr * NORMAL_SPEED) / max(mmove, 1);
wgrowtime[wnum] = g.moves + incr;
wgrowtime[wnum] = gm.moves + incr;
}
/* increase HP based on number of segments; if it has shrunk, it
@@ -434,7 +434,7 @@ cutworm(struct monst *worm, coordxy x, coordxy y,
/* Sometimes the tail end dies. */
if (!new_worm) {
place_worm_seg(worm, x, y); /* place the "head" segment back */
if (g.context.mon_moving) {
if (gc.context.mon_moving) {
if (canspotmon(worm))
pline("Part of %s tail has been cut off.",
s_suffix(mon_nam(worm)));
@@ -468,7 +468,7 @@ cutworm(struct monst *worm, coordxy x, coordxy y,
/* Place the new monster at all the segment locations. */
place_wsegs(new_worm, worm);
if (g.context.mon_moving)
if (gc.context.mon_moving)
pline("%s is cut in half.", Monnam(worm));
else
You("cut %s in half.", mon_nam(worm));
@@ -672,9 +672,9 @@ sanity_check_worm(struct monst *worm)
x = curr->wx, y = curr->wy;
if (!isok(x, y))
impossible("worm seg not isok <%d,%d>", x, y);
else if (g.level.monsters[x][y] != worm)
else if (gl.level.monsters[x][y] != worm)
impossible("mon (%s) at seg location is not worm (%s)",
fmt_ptr((genericptr_t) g.level.monsters[x][y]),
fmt_ptr((genericptr_t) gl.level.monsters[x][y]),
fmt_ptr((genericptr_t) worm));
curr = curr->nseg;