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:
20
src/wizard.c
20
src/wizard.c
@@ -68,7 +68,7 @@ amulet(void)
|
||||
if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
|
||||
|| ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
|
||||
&& !rn2(15)) {
|
||||
for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) {
|
||||
for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) {
|
||||
if (ttmp->ttyp == MAGIC_PORTAL) {
|
||||
int du = distu(ttmp->tx, ttmp->ty);
|
||||
if (du <= 9)
|
||||
@@ -83,7 +83,7 @@ amulet(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (!g.context.no_of_wizards)
|
||||
if (!gc.context.no_of_wizards)
|
||||
return;
|
||||
/* find Wizard, and wake him if necessary */
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
@@ -284,7 +284,7 @@ strategy(struct monst *mtmp)
|
||||
break;
|
||||
}
|
||||
|
||||
if (g.context.made_amulet)
|
||||
if (gc.context.made_amulet)
|
||||
if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
|
||||
return strat;
|
||||
|
||||
@@ -328,7 +328,7 @@ choose_stairs(
|
||||
if (!stway) {
|
||||
/* no ladder either; look for branch stairs or ladder in any
|
||||
direction */
|
||||
for (stway = g.stairs; stway; stway = stway->next)
|
||||
for (stway = gs.stairs; stway; stway = stway->next)
|
||||
if (stway->tolev.dnum != u.uz.dnum)
|
||||
break;
|
||||
/* if no branch stairs/ladder, check for regular stairs in
|
||||
@@ -525,7 +525,7 @@ pick_nasty(
|
||||
master mind flayer -> mind flayer,
|
||||
but the substitutes are likely to be genocided too */
|
||||
alt = res;
|
||||
if ((g.mvitals[res].mvflags & G_GENOD) != 0
|
||||
if ((gm.mvitals[res].mvflags & G_GENOD) != 0
|
||||
|| (difcap > 0 && mons[res].difficulty >= difcap)
|
||||
/* note: nasty() -> makemon() ignores G_HELL|G_NOHELL;
|
||||
arch-lich and master lich are both flagged as hell-only;
|
||||
@@ -533,7 +533,7 @@ pick_nasty(
|
||||
outside of Gehennom (unless the latter has been genocided) */
|
||||
|| (mons[res].geno & (Inhell ? G_NOHELL : G_HELL)) != 0)
|
||||
alt = big_to_little(res);
|
||||
if (alt != res && (g.mvitals[alt].mvflags & G_GENOD) == 0) {
|
||||
if (alt != res && (gm.mvitals[alt].mvflags & G_GENOD) == 0) {
|
||||
const char *mnam = mons[alt].pmnames[NEUTRAL],
|
||||
*lastspace = strrchr(mnam, ' ');
|
||||
|
||||
@@ -683,7 +683,7 @@ resurrect(void)
|
||||
long elapsed;
|
||||
const char *verb;
|
||||
|
||||
if (!g.context.no_of_wizards) {
|
||||
if (!gc.context.no_of_wizards) {
|
||||
/* make a new Wizard */
|
||||
verb = "kill";
|
||||
mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
|
||||
@@ -694,12 +694,12 @@ resurrect(void)
|
||||
} else {
|
||||
/* look for a migrating Wizard */
|
||||
verb = "elude";
|
||||
mmtmp = &g.migrating_mons;
|
||||
mmtmp = &gm.migrating_mons;
|
||||
while ((mtmp = *mmtmp) != 0) {
|
||||
if (mtmp->iswiz
|
||||
/* if he has the Amulet, he won't bring it to you */
|
||||
&& !mon_has_amulet(mtmp)
|
||||
&& (elapsed = g.moves - mtmp->mlstmv) > 0L) {
|
||||
&& (elapsed = gm.moves - mtmp->mlstmv) > 0L) {
|
||||
mon_catchup_elapsed_time(mtmp, elapsed);
|
||||
if (elapsed >= LARGEST_INT)
|
||||
elapsed = LARGEST_INT - 1;
|
||||
@@ -776,7 +776,7 @@ intervene(void)
|
||||
void
|
||||
wizdead(void)
|
||||
{
|
||||
g.context.no_of_wizards--;
|
||||
gc.context.no_of_wizards--;
|
||||
if (!u.uevent.udemigod) {
|
||||
u.uevent.udemigod = TRUE;
|
||||
u.udg_cnt = rn1(250, 50);
|
||||
|
||||
Reference in New Issue
Block a user