distinguish global variables that get written to savefile

The g? structs had a mix of variables that were written to
the savefile, and those that were not.

For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.

This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.

Details:

    gb.bases            -> svb.bases
    gb.bbubbles         -> svb.bbubbles
    gb.branches         -> svb.branches
    gc.context          -> svc.context
    gd.disco            -> svd.disco
    gd.dndest           -> svd.dndest
    gd.doors            -> svd.doors
    gd.doors_alloc      -> svd.doors_alloc
    gd.dungeon_topology -> svd.dungeon_topology
    gd.dungeons         -> svd.dungeons
    ge.exclusion_zones  -> sve.exclusion_zones
    gh.hackpid          -> svh.hackpid
    gi.inv_pos          -> svi.inv_pos
    gk.killer           -> svk.killer
    gl.lastseentyp      -> svl.lastseentyp
    gl.level            -> svl.level
    gl.level_info       -> svl.level_info
    gm.mapseenchn       -> svm.mapseenchn
    gm.moves            -> svm.moves
    gm.mvitals          -> svm.mvitals
    gn.n_dgns           -> svn.n_dgns
    gn.n_regions        -> svn.n_regions
    gn.nroom            -> svn.nroom
    go.oracle_cnt       -> svo.oracle_cnt
    gp.pl_character     -> svp.pl_character
    gp.pl_fruit         -> svp.pl_fruit
    gp.plname           -> svp.plname
    gp.program_state    -> svp.program_state
    gq.quest_status     -> svq.quest_status
    gr.rooms            -> svr.rooms
    gs.sp_levchn        -> svs.sp_levchn
    gs.spl_book         -> svs.spl_book
    gt.timer_id         -> svt.timer_id
    gt.tune             -> svt.tune
    gu.updest           -> svu.updest
    gx.xmax             -> svx.xmax
    gx.xmin             -> svx.xmin
    gy.ymax             -> svy.ymax
    gy.ymin             -> svy.ymin

Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
          gf.ftrap, gl.light_base, gt.timer_base
This commit is contained in:
nhmall
2024-07-13 14:57:50 -04:00
parent 0e4083153c
commit 6c0ae092c6
174 changed files with 3502 additions and 3305 deletions

View File

@@ -460,11 +460,11 @@ slimed_to_death(struct kinfo *kptr)
}
/* more sure killer reason is set up */
if (kptr && kptr->name[0]) {
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
svk.killer.format = kptr->format;
Strcpy(svk.killer.name, kptr->name);
} else {
gk.killer.format = NO_KILLER_PREFIX;
Strcpy(gk.killer.name, "turned into green slime");
svk.killer.format = NO_KILLER_PREFIX;
Strcpy(svk.killer.name, "turned into green slime");
}
dealloc_killer(kptr);
@@ -482,20 +482,20 @@ slimed_to_death(struct kinfo *kptr)
*/
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;
save_mvflags = svm.mvitals[PM_GREEN_SLIME].mvflags;
svm.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);
gm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags;
svm.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 ((gm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) {
if ((svm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) {
char slimebuf[BUFSZ];
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, "slimicide");
svk.killer.format = KILLED_BY;
Strcpy(svk.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...");
@@ -566,11 +566,11 @@ nh_timeout(void)
if (flags.friday13)
baseluck -= 1;
if (gq.quest_status.killed_leader)
if (svq.quest_status.killed_leader)
baseluck -= 4;
if (u.uluck != baseluck
&& gm.moves % ((u.uhave.amulet || u.ugangr) ? 300 : 600) == 0) {
&& svm.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.
@@ -637,11 +637,11 @@ nh_timeout(void)
switch (upp - u.uprops) {
case STONED:
if (kptr && kptr->name[0]) {
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
svk.killer.format = kptr->format;
Strcpy(svk.killer.name, kptr->name);
} else {
gk.killer.format = NO_KILLER_PREFIX;
Strcpy(gk.killer.name, "killed by petrification");
svk.killer.format = NO_KILLER_PREFIX;
Strcpy(svk.killer.name, "killed by petrification");
}
dealloc_killer(kptr);
/* (unlike sliming, you aren't changing form here) */
@@ -666,21 +666,21 @@ nh_timeout(void)
}
urgent_pline("You die from your illness.");
if (kptr && kptr->name[0]) {
gk.killer.format = kptr->format;
Strcpy(gk.killer.name, kptr->name);
svk.killer.format = kptr->format;
Strcpy(svk.killer.name, kptr->name);
} else {
gk.killer.format = KILLED_BY_AN;
gk.killer.name[0] = 0; /* take the default */
svk.killer.format = KILLED_BY_AN;
svk.killer.name[0] = 0; /* take the default */
}
dealloc_killer(kptr);
if ((m_idx = name_to_mon(gk.killer.name,
if ((m_idx = name_to_mon(svk.killer.name,
(int *) 0)) >= LOW_PM) {
if (type_is_pname(&mons[m_idx])) {
gk.killer.format = KILLED_BY;
svk.killer.format = KILLED_BY;
} else if (mons[m_idx].geno & G_UNIQ) {
Strcpy(gk.killer.name, the(gk.killer.name));
gk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, the(svk.killer.name));
svk.killer.format = KILLED_BY;
}
}
done_timeout(POISONING, SICK);
@@ -826,10 +826,10 @@ nh_timeout(void)
case WARN_OF_MON:
/* timed Warn_of_mon is via #wizintrinsic only */
if (!Warn_of_mon) {
struct permonst *wptr = gc.context.warntype.species;
struct permonst *wptr = svc.context.warntype.species;
gc.context.warntype.species = (struct permonst *) 0;
gc.context.warntype.speciesidx = NON_PM;
svc.context.warntype.species = (struct permonst *) 0;
svc.context.warntype.speciesidx = NON_PM;
if (wptr)
You("are no longer warned about %s.",
makeplural(wptr->pmnames[NEUTRAL]));
@@ -845,8 +845,8 @@ nh_timeout(void)
}
break;
case STRANGLED:
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name,
svk.killer.format = KILLED_BY;
Strcpy(svk.killer.name,
(u.uburied) ? "suffocation" : "strangulation");
done_timeout(DIED, STRANGLED);
/* must be declining to die in explore|wizard mode;
@@ -920,7 +920,7 @@ fall_asleep(int how_long, boolean wakeup_msg)
}
#endif
/* early wakeup from combat won't be possible until next monster turn */
u.usleep = gm.moves;
u.usleep = svm.moves;
gn.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;
}
@@ -984,7 +984,7 @@ 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 != gm.moves); /* hatched while away */
silent = (timeout != svm.moves); /* hatched while away */
/* only can hatch when in INVENT, FLOOR, MINVENT;
get_obj_location() will fail for MIGRATING, also for CONTAINED
@@ -993,7 +993,7 @@ hatch_egg(anything *arg, long timeout)
hatchcount = rnd((int) egg->quan);
cansee_hatchspot = cansee(x, y) && !silent;
if (!(mons[mnum].geno & G_UNIQ)
&& !(gm.mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) {
&& !(svm.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,
@@ -1009,7 +1009,7 @@ hatch_egg(anything *arg, long timeout)
mon->mtame = 20;
}
}
if (gm.mvitals[mnum].mvflags & G_EXTINCT)
if (svm.mvitals[mnum].mvflags & G_EXTINCT)
break; /* just made last one */
mon2 = mon; /* in case makemon() fails on 2nd egg */
}
@@ -1145,7 +1145,7 @@ learn_egg_type(int mnum)
{
/* baby monsters hatch from grown-up eggs */
mnum = little_to_big(mnum);
gm.mvitals[mnum].mvflags |= MV_KNOWS_EGG;
svm.mvitals[mnum].mvflags |= MV_KNOWS_EGG;
/* we might have just learned about other eggs being carried */
update_inventory();
}
@@ -1206,9 +1206,9 @@ slip_or_trip(void)
}
if (!uarmf && otmp->otyp == CORPSE
&& touch_petrifies(&mons[otmp->corpsenm]) && !Stone_resistance) {
Sprintf(gk.killer.name, "tripping over %s corpse",
Sprintf(svk.killer.name, "tripping over %s corpse",
an(mons[otmp->corpsenm].pmnames[NEUTRAL]));
instapetrify(gk.killer.name);
instapetrify(svk.killer.name);
}
} else if ((HFumbling & FROMOUTSIDE) || (is_ice(u.ux, u.uy) && !rn2(3))) {
/* is fumbling from ice alone? */
@@ -1342,8 +1342,8 @@ burn_object(anything *arg, long timeout)
many = menorah ? obj->spe > 1 : obj->quan > 1L;
/* timeout while away */
if (timeout != gm.moves) {
long how_long = gm.moves - timeout;
if (timeout != svm.moves) {
long how_long = svm.moves - timeout;
if (how_long >= obj->age) {
obj->age = 0;
@@ -1783,7 +1783,7 @@ cleanup_burn(anything *arg, long expire_time)
del_light_source(LS_OBJECT, obj_to_any(obj));
/* restore unused time */
obj->age += expire_time - gm.moves;
obj->age += expire_time - svm.moves;
obj->lamplit = 0;
if (obj->where == OBJ_INVENT)
@@ -1799,7 +1799,7 @@ do_storms(void)
int count;
/* no lightning if not stormy level or too often, even then */
if (!gl.level.flags.stormy || rn2(8))
if (!svl.level.flags.stormy || rn2(8))
return;
/* the number of strikes is 8-log2(nstrike) */
@@ -1849,7 +1849,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
* gm.moves+'timeout'. Call the function at 'func_index'
* svm.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
@@ -1997,7 +1997,7 @@ wiz_timeout_queue(void)
if (win == WIN_ERR)
return ECMD_OK;
Sprintf(buf, "Current time = %ld.", gm.moves);
Sprintf(buf, "Current time = %ld.", svm.moves);
putstr(win, 0, buf);
putstr(win, 0, "");
putstr(win, 0, "Active timeout queue:");
@@ -2158,7 +2158,7 @@ run_timers(void)
* any time. The list is ordered, we are done when the first element
* is in the future.
*/
while (gt.timer_base && gt.timer_base->timeout <= gm.moves) {
while (gt.timer_base && gt.timer_base->timeout <= svm.moves) {
curr = gt.timer_base;
gt.timer_base = curr->next;
@@ -2207,8 +2207,8 @@ start_timer(
gnu = (timer_element *) alloc(sizeof *gnu);
(void) memset((genericptr_t) gnu, 0, sizeof *gnu);
gnu->next = 0;
gnu->tid = gt.timer_id++;
gnu->timeout = gm.moves + when;
gnu->tid = svt.timer_id++;
gnu->timeout = svm.moves + when;
gnu->kind = kind;
gnu->needs_fixup = 0;
gnu->func_index = func_index;
@@ -2242,7 +2242,7 @@ stop_timer(short func_index, anything *arg)
(*cleanup_func)(arg, timeout);
(void) memset((genericptr_t) doomed, 0, sizeof(timer_element));
free((genericptr_t) doomed);
return (timeout - gm.moves);
return (timeout - svm.moves);
}
return 0L;
}
@@ -2293,7 +2293,7 @@ obj_split_timers(struct obj *src, struct obj *dest)
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 - gm.moves, TIMER_OBJECT,
(void) start_timer(curr->timeout - svm.moves, TIMER_OBJECT,
curr->func_index, obj_to_any(dest));
}
}
@@ -2389,7 +2389,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 - gm.moves : 0L;
return (expires > 0L) ? expires - svm.moves : 0L;
}
/* Insert timer into the global queue */
@@ -2608,7 +2608,7 @@ save_timers(NHFILE *nhfp, int range)
if (perform_bwrite(nhfp)) {
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &gt.timer_id, sizeof(gt.timer_id));
bwrite(nhfp->fd, (genericptr_t) &svt.timer_id, sizeof(svt.timer_id));
}
count = maybe_write_timer(nhfp, range, FALSE);
if (nhfp->structlevel)
@@ -2648,7 +2648,7 @@ restore_timers(NHFILE *nhfp, int range, long adjust)
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &gt.timer_id, sizeof gt.timer_id);
mread(nhfp->fd, (genericptr_t) &svt.timer_id, sizeof svt.timer_id);
}
/* restore elements */