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

@@ -80,7 +80,7 @@ poly_when_stoned(struct permonst *ptr)
{
/* non-stone golems turn into stone golems unless latter is genocided */
return (boolean) (is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM]
&& !(g.mvitals[PM_STONE_GOLEM].mvflags & G_GENOD));
&& !(gm.mvitals[PM_STONE_GOLEM].mvflags & G_GENOD));
/* allow G_EXTINCT */
}
@@ -91,7 +91,7 @@ defended(struct monst *mon, int adtyp)
{
struct obj *o, otemp;
int mndx;
boolean is_you = (mon == &g.youmonst);
boolean is_you = (mon == &gy.youmonst);
/* is 'mon' wielding an artifact that protects against 'adtyp'? */
o = is_you ? uwep : MON_WEP(mon);
@@ -130,7 +130,7 @@ resists_drli(struct monst *mon)
if (is_undead(ptr) || is_demon(ptr) || is_were(ptr)
/* is_were() doesn't handle hero in human form */
|| (mon == &g.youmonst && u.ulycn >= LOW_PM)
|| (mon == &gy.youmonst && u.ulycn >= LOW_PM)
|| ptr == &mons[PM_DEATH] || is_vampshifter(mon))
return TRUE;
return defended(mon, AD_DRLI);
@@ -141,7 +141,7 @@ boolean
resists_magm(struct monst* mon)
{
struct permonst *ptr = mon->data;
boolean is_you = (mon == &g.youmonst);
boolean is_you = (mon == &gy.youmonst);
long slotmask;
struct obj *o;
@@ -154,7 +154,7 @@ resists_magm(struct monst* mon)
if (o && o->oartifact && defends(AD_MAGM, o))
return TRUE;
/* check for magic resistance granted by worn or carried items */
o = is_you ? g.invent : mon->minvent;
o = is_you ? gi.invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you /* assumes monsters don't wield non-weapons */
|| (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
@@ -174,7 +174,7 @@ boolean
resists_blnd(struct monst* mon)
{
struct permonst *ptr = mon->data;
boolean is_you = (mon == &g.youmonst);
boolean is_you = (mon == &gy.youmonst);
long slotmask;
struct obj *o;
@@ -191,7 +191,7 @@ resists_blnd(struct monst* mon)
o = is_you ? uwep : MON_WEP(mon);
if (o && o->oartifact && defends(AD_BLND, o))
return TRUE;
o = is_you ? g.invent : mon->minvent;
o = is_you ? gi.invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you /* assumes monsters don't wield non-weapons */
|| (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
@@ -217,7 +217,7 @@ can_blnd(
uchar aatyp,
struct obj *obj) /* aatyp == AT_WEAP, AT_SPIT */
{
boolean is_you = (mdef == &g.youmonst);
boolean is_you = (mdef == &gy.youmonst);
boolean check_visor = FALSE;
struct obj *o;
@@ -259,7 +259,7 @@ can_blnd(
return TRUE; /* no defense */
} else
return FALSE; /* other objects cannot cause blindness yet */
if ((magr == &g.youmonst) && u.uswallow)
if ((magr == &gy.youmonst) && u.uswallow)
return FALSE; /* can't affect eyes while inside monster */
break;
@@ -274,7 +274,7 @@ can_blnd(
/* e.g. raven: all ublindf, including LENSES, protect */
if (is_you && ublindf)
return FALSE;
if ((magr == &g.youmonst) && u.uswallow)
if ((magr == &gy.youmonst) && u.uswallow)
return FALSE; /* can't affect eyes while inside monster */
check_visor = TRUE;
break;
@@ -292,7 +292,7 @@ can_blnd(
/* check if wearing a visor (only checked if visor might help) */
if (check_visor) {
o = (mdef == &g.youmonst) ? g.invent : mdef->minvent;
o = (mdef == &gy.youmonst) ? gi.invent : mdef->minvent;
for (; o; o = o->nobj)
if ((o->owornmask & W_ARMH)
&& objdescr_is(o, "visored helmet"))
@@ -467,7 +467,7 @@ can_blow(struct monst* mtmp)
&& (breathless(mtmp->data) || verysmall(mtmp->data)
|| !has_head(mtmp->data) || mtmp->data->mlet == S_EEL))
return FALSE;
if ((mtmp == &g.youmonst) && Strangled)
if ((mtmp == &gy.youmonst) && Strangled)
return FALSE;
return TRUE;
}
@@ -476,7 +476,7 @@ can_blow(struct monst* mtmp)
boolean
can_chant(struct monst* mtmp)
{
if ((mtmp == &g.youmonst && Strangled)
if ((mtmp == &gy.youmonst && Strangled)
|| is_silent(mtmp->data) || !has_head(mtmp->data)
|| mtmp->data->msound == MS_BUZZ || mtmp->data->msound == MS_BURBLE)
return FALSE;
@@ -499,10 +499,10 @@ can_be_strangled(struct monst* mon)
are non-breathing creatures which have higher brain function. */
if (!has_head(mon->data))
return FALSE;
if (mon == &g.youmonst) {
if (mon == &gy.youmonst) {
/* hero can't be mindless but poly'ing into mindless form can
confer strangulation protection */
nobrainer = mindless(g.youmonst.data);
nobrainer = mindless(gy.youmonst.data);
nonbreathing = Breathless;
} else {
nobrainer = mindless(mon->data);
@@ -1270,8 +1270,8 @@ big_little_match(int montyp1, int montyp2)
const struct permonst *
raceptr(struct monst* mtmp)
{
if (mtmp == &g.youmonst && !Upolyd)
return &mons[g.urace.mnum];
if (mtmp == &gy.youmonst && !Upolyd)
return &mons[gu.urace.mnum];
else
return mtmp->data;
}