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

@@ -134,14 +134,14 @@ stoned_dialogue(void)
char buf[BUFSZ];
Strcpy(buf, stoned_texts[SIZE(stoned_texts) - i]);
if (nolimbs(g.youmonst.data) && strstri(buf, "limbs"))
if (nolimbs(gy.youmonst.data) && strstri(buf, "limbs"))
(void) strsubst(buf, "limbs", "extremities");
urgent_pline("%s", buf);
}
switch ((int) i) {
case 5: /* slowing down */
HFast = 0L;
if (g.multi > 0)
if (gm.multi > 0)
nomul(0);
break;
case 4: /* limbs stiffening */
@@ -149,14 +149,14 @@ stoned_dialogue(void)
don't stop attempt to eat tin--might be lizard or acidic */
if (!Popeye(STONED))
stop_occupation();
if (g.multi > 0)
if (gm.multi > 0)
nomul(0);
break;
case 3: /* limbs turned to stone */
stop_occupation();
nomul(-3); /* can't move anymore */
g.multi_reason = "getting stoned";
g.nomovemsg = You_can_move_again; /* not unconscious */
gm.multi_reason = "getting stoned";
gn.nomovemsg = You_can_move_again; /* not unconscious */
/* "your limbs have turned to stone" so terminate wounded legs */
if (Wounded_legs && !u.usteed)
heal_legs(2);
@@ -210,7 +210,7 @@ vomiting_dialogue(void)
/*FALLTHRU*/
case 9:
make_confused((HConfusion & TIMEOUT) + (long) d(2, 4), FALSE);
if (g.multi > 0)
if (gm.multi > 0)
nomul(0);
break;
case 8:
@@ -223,7 +223,7 @@ vomiting_dialogue(void)
break;
case 2:
txt = vomiting_texts[4];
if (cantvomit(g.youmonst.data))
if (cantvomit(gy.youmonst.data))
txt = "gag uncontrollably.";
else if (Hallucination)
/* "hurl" is short for "hurl chunks" which is slang for
@@ -232,7 +232,7 @@ vomiting_dialogue(void)
break;
case 0:
stop_occupation();
if (!cantvomit(g.youmonst.data)) {
if (!cantvomit(gy.youmonst.data)) {
morehungry(20);
/* case 2 used to be "You suddenly vomit!" but it wasn't sudden
since you've just been through the earlier messages of the
@@ -314,7 +314,7 @@ sickness_dialogue(void)
(void) strsubst(buf, "illness", "sickness");
if (Hallucination && strstri(buf, "Death's door")) {
/* youmonst: for Hallucination, mhe()'s mon argument isn't used */
Strcpy(pronounbuf, mhe(&g.youmonst));
Strcpy(pronounbuf, mhe(&gy.youmonst));
Sprintf(eos(buf), " %s %s inviting you in.",
/* upstart() modifies its argument but vtense() doesn't
care whether or not that has already happened */
@@ -374,8 +374,8 @@ slime_dialogue(void)
/* display as green slime during "You have become green slime."
but don't worry about not being able to see self; if already
mimicking something else at the time, implicitly be revealed */
g.youmonst.m_ap_type = M_AP_MONSTER;
g.youmonst.mappearance = PM_GREEN_SLIME;
gy.youmonst.m_ap_type = M_AP_MONSTER;
gy.youmonst.mappearance = PM_GREEN_SLIME;
/* no message given when 't' is odd, so no automatic update of
self; force one */
newsym(u.ux, u.uy);
@@ -385,7 +385,7 @@ slime_dialogue(void)
char buf[BUFSZ];
Strcpy(buf, slime_texts[SIZE(slime_texts) - i - 1L]);
if (nolimbs(g.youmonst.data) && strstri(buf, "limbs"))
if (nolimbs(gy.youmonst.data) && strstri(buf, "limbs"))
(void) strsubst(buf, "limbs", "extremities");
if (strchr(buf, '%')) {
@@ -406,7 +406,7 @@ slime_dialogue(void)
HFast = 0L; /* lose intrinsic speed */
if (!Popeye(SLIMED))
stop_occupation();
if (g.multi > 0)
if (gm.multi > 0)
nomul(0);
break;
case 2L: /* skin begins to peel */
@@ -439,17 +439,17 @@ slimed_to_death(struct kinfo* kptr)
uchar save_mvflags;
/* redundant: polymon() cures sliming when polying into green slime */
if (Upolyd && g.youmonst.data == &mons[PM_GREEN_SLIME]) {
if (Upolyd && gy.youmonst.data == &mons[PM_GREEN_SLIME]) {
dealloc_killer(kptr);
return;
}
/* more sure killer reason is set up */
if (kptr && kptr->name[0]) {
g.killer.format = kptr->format;
Strcpy(g.killer.name, kptr->name);
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
} else {
g.killer.format = NO_KILLER_PREFIX;
Strcpy(g.killer.name, "turned into green slime");
gk.killer.format = NO_KILLER_PREFIX;
Strcpy(gk.killer.name, "turned into green slime");
}
dealloc_killer(kptr);
@@ -465,22 +465,22 @@ slimed_to_death(struct kinfo* kptr)
* [formerly implicit] change of form; polymon() takes care of that.
* Temporarily ungenocide if necessary.
*/
if (emits_light(g.youmonst.data))
del_light_source(LS_MONSTER, monst_to_any(&g.youmonst));
save_mvflags = g.mvitals[PM_GREEN_SLIME].mvflags;
g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD;
if (emits_light(gy.youmonst.data))
del_light_source(LS_MONSTER, monst_to_any(&gy.youmonst));
save_mvflags = gm.mvitals[PM_GREEN_SLIME].mvflags;
gm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD;
/* become a green slime; also resets youmonst.m_ap_type+.mappearance */
(void) polymon(PM_GREEN_SLIME);
g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags;
gm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags;
done_timeout(TURNED_SLIME, SLIMED);
/* life-saved; even so, hero still has turned into green slime;
player may have genocided green slimes after being infected */
if ((g.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) {
if ((gm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) {
char slimebuf[BUFSZ];
g.killer.format = KILLED_BY;
Strcpy(g.killer.name, "slimicide");
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, "slimicide");
/* vary the message depending upon whether life-save was due to
amulet or due to declining to die in explore or wizard mode */
Strcpy(slimebuf, "green slime has been genocided...");
@@ -535,7 +535,7 @@ done_timeout(int how, int which)
/* life-saved */
*intrinsic_p &= ~I_SPECIAL;
g.context.botl = TRUE;
gc.context.botl = TRUE;
}
void
@@ -551,11 +551,11 @@ nh_timeout(void)
if (flags.friday13)
baseluck -= 1;
if (g.quest_status.killed_leader)
if (gq.quest_status.killed_leader)
baseluck -= 4;
if (u.uluck != baseluck
&& g.moves % ((u.uhave.amulet || u.ugangr) ? 300 : 600) == 0) {
&& gm.moves % ((u.uhave.amulet || u.ugangr) ? 300 : 600) == 0) {
/* Cursed luckstones stop bad luck from timing out; blessed luckstones
* stop good luck from timing out; normal luckstones stop both;
* neither is stopped if you don't have a luckstone.
@@ -587,8 +587,8 @@ nh_timeout(void)
phaze_dialogue();
if (u.mtimedone && !--u.mtimedone) {
if (Unchanging)
u.mtimedone = rnd(100 * g.youmonst.data->mlevel + 1);
else if (is_were(g.youmonst.data))
u.mtimedone = rnd(100 * gy.youmonst.data->mlevel + 1);
else if (is_were(gy.youmonst.data))
you_unwere(FALSE); /* if polycontrl, asks whether to rehumanize */
else
rehumanize();
@@ -620,11 +620,11 @@ nh_timeout(void)
switch (upp - u.uprops) {
case STONED:
if (kptr && kptr->name[0]) {
g.killer.format = kptr->format;
Strcpy(g.killer.name, kptr->name);
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
} else {
g.killer.format = NO_KILLER_PREFIX;
Strcpy(g.killer.name, "killed by petrification");
gk.killer.format = NO_KILLER_PREFIX;
Strcpy(gk.killer.name, "killed by petrification");
}
dealloc_killer(kptr);
/* (unlike sliming, you aren't changing form here) */
@@ -649,21 +649,21 @@ nh_timeout(void)
}
urgent_pline("You die from your illness.");
if (kptr && kptr->name[0]) {
g.killer.format = kptr->format;
Strcpy(g.killer.name, kptr->name);
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
} else {
g.killer.format = KILLED_BY_AN;
g.killer.name[0] = 0; /* take the default */
gk.killer.format = KILLED_BY_AN;
gk.killer.name[0] = 0; /* take the default */
}
dealloc_killer(kptr);
if ((m_idx = name_to_mon(g.killer.name,
if ((m_idx = name_to_mon(gk.killer.name,
(int *) 0)) >= LOW_PM) {
if (type_is_pname(&mons[m_idx])) {
g.killer.format = KILLED_BY;
gk.killer.format = KILLED_BY;
} else if (mons[m_idx].geno & G_UNIQ) {
Strcpy(g.killer.name, the(g.killer.name));
g.killer.format = KILLED_BY;
Strcpy(gk.killer.name, the(gk.killer.name));
gk.killer.format = KILLED_BY;
}
}
done_timeout(POISONING, SICK);
@@ -696,7 +696,7 @@ nh_timeout(void)
case DEAF:
set_itimeout(&HDeaf, 1L);
make_deaf(0L, TRUE);
g.context.botl = TRUE;
gc.context.botl = TRUE;
if (!Deaf)
stop_occupation();
break;
@@ -749,7 +749,7 @@ nh_timeout(void)
case FLYING:
/* timed Flying is via #wizintrinsic only */
if (was_flying && !Flying) {
g.context.botl = 1;
gc.context.botl = 1;
You("land.");
spoteffects(TRUE);
}
@@ -775,11 +775,11 @@ nh_timeout(void)
case WARN_OF_MON:
/* timed Warn_of_mon is via #wizintrinsic only */
if (!Warn_of_mon) {
g.context.warntype.speciesidx = NON_PM;
if (g.context.warntype.species) {
gc.context.warntype.speciesidx = NON_PM;
if (gc.context.warntype.species) {
You("are no longer warned about %s.",
makeplural(g.context.warntype.species->pmnames[NEUTRAL]));
g.context.warntype.species = (struct permonst *) 0;
makeplural(gc.context.warntype.species->pmnames[NEUTRAL]));
gc.context.warntype.species = (struct permonst *) 0;
}
}
break;
@@ -793,8 +793,8 @@ nh_timeout(void)
}
break;
case STRANGLED:
g.killer.format = KILLED_BY;
Strcpy(g.killer.name,
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name,
(u.uburied) ? "suffocation" : "strangulation");
done_timeout(DIED, STRANGLED);
/* must be declining to die in explore|wizard mode;
@@ -810,8 +810,8 @@ nh_timeout(void)
if (u.umoved && !(Levitation || Flying)) {
slip_or_trip();
nomul(-2);
g.multi_reason = "fumbling";
g.nomovemsg = "";
gm.multi_reason = "fumbling";
gn.nomovemsg = "";
/* The more you are carrying the more likely you
* are to make noise when you fumble. Adjustments
* to this number must be thoroughly play tested.
@@ -850,18 +850,18 @@ fall_asleep(int how_long, boolean wakeup_msg)
{
stop_occupation();
nomul(how_long);
g.multi_reason = "sleeping";
gm.multi_reason = "sleeping";
/* generally don't notice sounds while sleeping */
if (wakeup_msg && g.multi == how_long) {
if (wakeup_msg && gm.multi == how_long) {
/* caller can follow with a direct call to Hear_again() if
there's a need to override this when wakeup_msg is true */
incr_itimeout(&HDeaf, how_long);
g.context.botl = TRUE;
g.afternmv = Hear_again; /* this won't give any messages */
gc.context.botl = TRUE;
ga.afternmv = Hear_again; /* this won't give any messages */
}
/* early wakeup from combat won't be possible until next monster turn */
u.usleep = g.moves;
g.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;
u.usleep = gm.moves;
gn.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;
}
/* Attach an egg hatch timeout to the given egg.
@@ -924,14 +924,14 @@ hatch_egg(anything *arg, long timeout)
mnum = big_to_little(egg->corpsenm);
/* The identity of one's father is learned, not innate */
yours = (egg->spe || (!flags.female && carried(egg) && !rn2(2)));
silent = (timeout != g.moves); /* hatched while away */
silent = (timeout != gm.moves); /* hatched while away */
/* only can hatch when in INVENT, FLOOR, MINVENT */
if (get_obj_location(egg, &x, &y, 0)) {
hatchcount = rnd((int) egg->quan);
cansee_hatchspot = cansee(x, y) && !silent;
if (!(mons[mnum].geno & G_UNIQ)
&& !(g.mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) {
&& !(gm.mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) {
for (i = hatchcount; i > 0; i--) {
if (!enexto(&cc, x, y, &mons[mnum])
|| !(mon = makemon(&mons[mnum], cc.x, cc.y,
@@ -947,7 +947,7 @@ hatch_egg(anything *arg, long timeout)
mon->mtame = 20;
}
}
if (g.mvitals[mnum].mvflags & G_EXTINCT)
if (gm.mvitals[mnum].mvflags & G_EXTINCT)
break; /* just made last one */
mon2 = mon; /* in case makemon() fails on 2nd egg */
}
@@ -1075,7 +1075,7 @@ learn_egg_type(int mnum)
{
/* baby monsters hatch from grown-up eggs */
mnum = little_to_big(mnum);
g.mvitals[mnum].mvflags |= MV_KNOWS_EGG;
gm.mvitals[mnum].mvflags |= MV_KNOWS_EGG;
/* we might have just learned about other eggs being carried */
update_inventory();
}
@@ -1138,9 +1138,9 @@ slip_or_trip(void)
}
if (!uarmf && otmp->otyp == CORPSE
&& touch_petrifies(&mons[otmp->corpsenm]) && !Stone_resistance) {
Sprintf(g.killer.name, "tripping over %s corpse",
Sprintf(gk.killer.name, "tripping over %s corpse",
an(mons[otmp->corpsenm].pmnames[NEUTRAL]));
instapetrify(g.killer.name);
instapetrify(gk.killer.name);
}
} else if (rn2(3) && is_ice(u.ux, u.uy)) {
pline("%s %s%s on the ice.",
@@ -1240,8 +1240,8 @@ burn_object(anything *arg, long timeout)
many = menorah ? obj->spe > 1 : obj->quan > 1L;
/* timeout while away */
if (timeout != g.moves) {
long how_long = g.moves - timeout;
if (timeout != gm.moves) {
long how_long = gm.moves - timeout;
if (how_long >= obj->age) {
obj->age = 0;
@@ -1681,7 +1681,7 @@ cleanup_burn(anything *arg, long expire_time)
del_light_source(LS_OBJECT, obj_to_any(obj));
/* restore unused time */
obj->age += expire_time - g.moves;
obj->age += expire_time - gm.moves;
obj->lamplit = 0;
if (obj->where == OBJ_INVENT)
@@ -1722,12 +1722,12 @@ do_storms(void)
/* Even if already deaf, we sense the thunder's vibrations. */
pline("Kaboom!!! Boom!! Boom!!");
incr_itimeout(&HDeaf, rn1(20, 30));
g.context.botl = TRUE;
gc.context.botl = TRUE;
if (!u.uinvulnerable) {
stop_occupation();
nomul(-3);
g.multi_reason = "hiding from thunderstorm";
g.nomovemsg = 0;
gm.multi_reason = "hiding from thunderstorm";
gn.nomovemsg = 0;
}
} else
You_hear("a rumbling noise.");
@@ -1744,7 +1744,7 @@ do_storms(void)
* boolean start_timer(long timeout,short kind,short func_index,
* anything *arg)
* Start a timer of kind 'kind' that will expire at time
* g.moves+'timeout'. Call the function at 'func_index'
* gm.moves+'timeout'. Call the function at 'func_index'
* in the timeout table using argument 'arg'. Return TRUE if
* a timer was started. This places the timer on a list ordered
* "sooner" to "later". If an object, increment the object's
@@ -1884,12 +1884,12 @@ wiz_timeout_queue(void)
if (win == WIN_ERR)
return ECMD_OK;
Sprintf(buf, "Current time = %ld.", g.moves);
Sprintf(buf, "Current time = %ld.", gm.moves);
putstr(win, 0, buf);
putstr(win, 0, "");
putstr(win, 0, "Active timeout queue:");
putstr(win, 0, "");
print_queue(win, g.timer_base);
print_queue(win, gt.timer_base);
/* Timed properies:
* check every one; the majority can't obtain temporary timeouts in
@@ -1955,7 +1955,7 @@ timer_sanity_check(void)
timer_element *curr;
/* this should be much more complete */
for (curr = g.timer_base; curr; curr = curr->next) {
for (curr = gt.timer_base; curr; curr = curr->next) {
if (curr->kind == TIMER_OBJECT) {
struct obj *obj = curr->arg.a_obj;
@@ -1993,9 +1993,9 @@ run_timers(void)
* any time. The list is ordered, we are done when the first element
* is in the future.
*/
while (g.timer_base && g.timer_base->timeout <= g.moves) {
curr = g.timer_base;
g.timer_base = curr->next;
while (gt.timer_base && gt.timer_base->timeout <= gm.moves) {
curr = gt.timer_base;
gt.timer_base = curr->next;
if (curr->kind == TIMER_OBJECT)
(curr->arg.a_obj)->timed--;
@@ -2021,7 +2021,7 @@ start_timer(
panic("start_timer (%s: %d)", kind_name(kind), (int) func_index);
/* fail if <arg> already has a <func_index> timer running */
for (dup = g.timer_base; dup; dup = dup->next)
for (dup = gt.timer_base; dup; dup = dup->next)
if (dup->kind == kind
&& dup->func_index == func_index
&& dup->arg.a_void == arg->a_void)
@@ -2041,8 +2041,8 @@ start_timer(
gnu = (timer_element *) alloc(sizeof *gnu);
(void) memset((genericptr_t) gnu, 0, sizeof *gnu);
gnu->next = 0;
gnu->tid = g.timer_id++;
gnu->timeout = g.moves + when;
gnu->tid = gt.timer_id++;
gnu->timeout = gm.moves + when;
gnu->kind = kind;
gnu->needs_fixup = 0;
gnu->func_index = func_index;
@@ -2066,7 +2066,7 @@ stop_timer(short func_index, anything *arg)
timer_element *doomed;
long timeout;
doomed = remove_timer(&g.timer_base, func_index, arg);
doomed = remove_timer(&gt.timer_base, func_index, arg);
if (doomed) {
timeout = doomed->timeout;
@@ -2075,7 +2075,7 @@ stop_timer(short func_index, anything *arg)
if ((cleanup_func = timeout_funcs[doomed->func_index].cleanup) != 0)
(*cleanup_func)(arg, timeout);
free((genericptr_t) doomed);
return (timeout - g.moves);
return (timeout - gm.moves);
}
return 0L;
}
@@ -2088,7 +2088,7 @@ peek_timer(short type, anything *arg)
{
timer_element *curr;
for (curr = g.timer_base; curr; curr = curr->next) {
for (curr = gt.timer_base; curr; curr = curr->next) {
if (curr->func_index == type && curr->arg.a_void == arg->a_void)
return curr->timeout;
}
@@ -2104,7 +2104,7 @@ obj_move_timers(struct obj* src, struct obj* dest)
int count;
timer_element *curr;
for (count = 0, curr = g.timer_base; curr; curr = curr->next)
for (count = 0, curr = gt.timer_base; curr; curr = curr->next)
if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) {
curr->arg.a_obj = dest;
dest->timed++;
@@ -2123,10 +2123,10 @@ obj_split_timers(struct obj* src, struct obj* dest)
{
timer_element *curr, *next_timer = 0;
for (curr = g.timer_base; curr; curr = next_timer) {
for (curr = gt.timer_base; curr; curr = next_timer) {
next_timer = curr->next; /* things may be inserted */
if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) {
(void) start_timer(curr->timeout - g.moves, TIMER_OBJECT,
(void) start_timer(curr->timeout - gm.moves, TIMER_OBJECT,
curr->func_index, obj_to_any(dest));
}
}
@@ -2142,13 +2142,13 @@ obj_stop_timers(struct obj* obj)
timeout_proc cleanup_func;
timer_element *curr, *prev, *next_timer = 0;
for (prev = 0, curr = g.timer_base; curr; curr = next_timer) {
for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) {
next_timer = curr->next;
if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == obj) {
if (prev)
prev->next = curr->next;
else
g.timer_base = curr->next;
gt.timer_base = curr->next;
if ((cleanup_func = timeout_funcs[curr->func_index].cleanup) != 0)
(*cleanup_func)(&curr->arg, curr->timeout);
free((genericptr_t) curr);
@@ -2181,14 +2181,14 @@ spot_stop_timers(coordxy x, coordxy y, short func_index)
timer_element *curr, *prev, *next_timer = 0;
long where = (((long) x << 16) | ((long) y));
for (prev = 0, curr = g.timer_base; curr; curr = next_timer) {
for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) {
next_timer = curr->next;
if (curr->kind == TIMER_LEVEL && curr->func_index == func_index
&& curr->arg.a_long == where) {
if (prev)
prev->next = curr->next;
else
g.timer_base = curr->next;
gt.timer_base = curr->next;
if ((cleanup_func = timeout_funcs[curr->func_index].cleanup) != 0)
(*cleanup_func)(&curr->arg, curr->timeout);
free((genericptr_t) curr);
@@ -2208,7 +2208,7 @@ spot_time_expires(coordxy x, coordxy y, short func_index)
timer_element *curr;
long where = (((long) x << 16) | ((long) y));
for (curr = g.timer_base; curr; curr = curr->next) {
for (curr = gt.timer_base; curr; curr = curr->next) {
if (curr->kind == TIMER_LEVEL && curr->func_index == func_index
&& curr->arg.a_long == where)
return curr->timeout;
@@ -2220,7 +2220,7 @@ long
spot_time_left(coordxy x, coordxy y, short func_index)
{
long expires = spot_time_expires(x, y, func_index);
return (expires > 0L) ? expires - g.moves : 0L;
return (expires > 0L) ? expires - gm.moves : 0L;
}
/* Insert timer into the global queue */
@@ -2229,7 +2229,7 @@ insert_timer(timer_element* gnu)
{
timer_element *curr, *prev;
for (prev = 0, curr = g.timer_base; curr; prev = curr, curr = curr->next)
for (prev = 0, curr = gt.timer_base; curr; prev = curr, curr = curr->next)
if (curr->timeout >= gnu->timeout)
break;
@@ -2237,7 +2237,7 @@ insert_timer(timer_element* gnu)
if (prev)
prev->next = gnu;
else
g.timer_base = gnu;
gt.timer_base = gnu;
}
static timer_element *
@@ -2351,11 +2351,11 @@ mon_is_local(struct monst* mon)
{
struct monst *curr;
for (curr = g.migrating_mons; curr; curr = curr->nmon)
for (curr = gm.migrating_mons; curr; curr = curr->nmon)
if (curr == mon)
return FALSE;
/* `g.mydogs' is used during level changes, never saved and restored */
for (curr = g.mydogs; curr; curr = curr->nmon)
/* `gm.mydogs' is used during level changes, never saved and restored */
for (curr = gm.mydogs; curr; curr = curr->nmon)
if (curr == mon)
return FALSE;
return TRUE;
@@ -2395,7 +2395,7 @@ maybe_write_timer(NHFILE* nhfp, int range, boolean write_it)
int count = 0;
timer_element *curr;
for (curr = g.timer_base; curr; curr = curr->next) {
for (curr = gt.timer_base; curr; curr = curr->next) {
if (range == RANGE_GLOBAL) {
/* global timers */
@@ -2439,7 +2439,7 @@ save_timers(NHFILE* nhfp, int range)
if (perform_bwrite(nhfp)) {
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.timer_id, sizeof(g.timer_id));
bwrite(nhfp->fd, (genericptr_t) &gt.timer_id, sizeof(gt.timer_id));
}
count = maybe_write_timer(nhfp, range, FALSE);
if (nhfp->structlevel)
@@ -2448,14 +2448,14 @@ save_timers(NHFILE* nhfp, int range)
}
if (release_data(nhfp)) {
for (prev = 0, curr = g.timer_base; curr; curr = next_timer) {
for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) {
next_timer = curr->next; /* in case curr is removed */
if (!(!!(range == RANGE_LEVEL) ^ !!timer_is_local(curr))) {
if (prev)
prev->next = curr->next;
else
g.timer_base = curr->next;
gt.timer_base = curr->next;
free((genericptr_t) curr);
/* prev stays the same */
} else {
@@ -2478,7 +2478,7 @@ restore_timers(NHFILE* nhfp, int range, long adjust)
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.timer_id, sizeof g.timer_id);
mread(nhfp->fd, (genericptr_t) &gt.timer_id, sizeof gt.timer_id);
}
/* restore elements */
@@ -2505,7 +2505,7 @@ timer_stats(const char* hdrfmt, char *hdrbuf, long *count, long *size)
Sprintf(hdrbuf, hdrfmt, (long) sizeof (timer_element));
*count = *size = 0L;
for (te = g.timer_base; te; te = te->next) {
for (te = gt.timer_base; te; te = te->next) {
++*count;
*size += (long) sizeof *te;
}
@@ -2520,7 +2520,7 @@ relink_timers(boolean ghostly)
timer_element *curr;
unsigned nid;
for (curr = g.timer_base; curr; curr = curr->next) {
for (curr = gt.timer_base; curr; curr = curr->next) {
if (curr->needs_fixup) {
if (curr->kind == TIMER_OBJECT) {
if (ghostly) {