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

@@ -112,7 +112,7 @@ dowrite(struct obj *pen)
boolean by_descr = FALSE;
const char *typeword;
if (nohands(g.youmonst.data)) {
if (nohands(gy.youmonst.data)) {
You("need hands to be able to write!");
return ECMD_OK;
} else if (Glib) {
@@ -170,8 +170,8 @@ dowrite(struct obj *pen)
deferred = real = 0; /* not any scroll or book */
deferralchance = 0; /* incremented for each oc_uname match */
first = g.bases[(int) paper->oclass];
last = g.bases[(int) paper->oclass + 1] - 1;
first = gb.bases[(int) paper->oclass];
last = gb.bases[(int) paper->oclass + 1] - 1;
/* first loop: look for match with name/description */
for (i = first; i <= last; i++) {
/* extra shufflable descr not representing a real object */
@@ -335,7 +335,7 @@ dowrite(struct obj *pen)
/* if known, then either by-name or by-descr works */
if (!objects[new_obj->otyp].oc_name_known
/* else if named, then only by-descr works */
&& !(by_descr && label_known(new_obj->otyp, g.invent))
&& !(by_descr && label_known(new_obj->otyp, gi.invent))
/* and Luck might override after both checks have failed */
&& rnl(Role_if(PM_WIZARD) ? 5 : 15)) {
You("%s to write that.", by_descr ? "fail" : "don't know how");
@@ -349,7 +349,7 @@ dowrite(struct obj *pen)
Strcpy(namebuf, OBJ_DESCR(objects[new_obj->otyp]));
wipeout_text(namebuf, (6 + MAXULEV - u.ulevel) / 6, 0);
} else
Sprintf(namebuf, "%s was here!", g.plname);
Sprintf(namebuf, "%s was here!", gp.plname);
You("write \"%s\" and the scroll disappears.", namebuf);
useup(paper);
}
@@ -391,7 +391,7 @@ dowrite(struct obj *pen)
specifically chosen item so hero recognizes it even if blind;
the exception is for being lucky writing an undiscovered scroll,
where the label associated with the type-name isn't known yet */
new_obj->dknown = label_known(new_obj->otyp, g.invent) ? 1 : 0;
new_obj->dknown = label_known(new_obj->otyp, gi.invent) ? 1 : 0;
new_obj = hold_another_object(new_obj, "Oops! %s out of your grasp!",
The(aobjnam(new_obj, "slip")),