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

@@ -325,7 +325,7 @@ obj_is_pname(struct obj *obj)
{
if (!obj->oartifact || !has_oname(obj))
return FALSE;
if (!gp.program_state.gameover && !iflags.override_ID) {
if (!svp.program_state.gameover && !iflags.override_ID) {
if (not_fully_identified(obj))
return FALSE;
}
@@ -371,7 +371,7 @@ distant_name(
against a potential extra chance to browse the map with getpos()
during final disclosure (not currently implemented, nor planned) */
save_oid = obj->o_id;
if (gp.program_state.gameover)
if (svp.program_state.gameover)
obj->o_id = 0;
/* this maybe-nearby part used to be replicated in multiple callers */
@@ -406,12 +406,12 @@ fruitname(
boolean juice) /* whether or not to append " juice" to the name */
{
char *buf = nextobuf();
const char *fruit_nam = strstri(gp.pl_fruit, " of ");
const char *fruit_nam = strstri(svp.pl_fruit, " of ");
if (fruit_nam)
fruit_nam += 4; /* skip past " of " */
else
fruit_nam = gp.pl_fruit; /* use it as is */
fruit_nam = svp.pl_fruit; /* use it as is */
Sprintf(buf, "%s%s", makesingular(fruit_nam), juice ? " juice" : "");
return buf;
@@ -955,7 +955,7 @@ xname_flags(
"You were acid resistant because of your alchemy smock \
with text \"Kiss the cook\"."
when disclosing attributes anyway */
if (gp.program_state.gameover && obj->o_id && bufspaceleft > 0) {
if (svp.program_state.gameover && obj->o_id && bufspaceleft > 0) {
const char *lbl;
char tmpbuf[BUFSZ];
@@ -1444,7 +1444,7 @@ doname_base(
the message as it gets added to invent and also if it
gets snuffed out immediately (where it will end up as
not partly used after all) */
turns_left += peek_timer(BURN_OBJECT, &timer) - gm.moves;
turns_left += peek_timer(BURN_OBJECT, &timer) - svm.moves;
}
if (turns_left < full_burn_time)
Strcat(prefix, "partly used ");
@@ -1503,7 +1503,7 @@ doname_base(
Strcat(prefix, "stale ");
#endif
if (ismnum(omndx)
&& (known || (gm.mvitals[omndx].mvflags & MV_KNOWS_EGG))) {
&& (known || (svm.mvitals[omndx].mvflags & MV_KNOWS_EGG))) {
Strcat(prefix, mons[omndx].pmnames[NEUTRAL]);
Strcat(prefix, " ");
if (obj->spe == 1)
@@ -1625,7 +1625,7 @@ doname_base(
bill might not be available yet while restore is in progress
(objects won't normally be formatted during that time, but if
'perm_invent' is enabled then they might be [not any more...]) */
if (iflags.suppress_price || gp.program_state.restoring) {
if (iflags.suppress_price || svp.program_state.restoring) {
; /* don't attempt to obtain any shop pricing, even if 'with_price' */
} else if (is_unpaid(obj)) { /* in inventory or in container in invent */
char pricebuf[40];
@@ -3379,7 +3379,7 @@ rnd_otyp_by_wpnskill(schar skill)
int i, n = 0;
short otyp = STRANGE_OBJECT;
for (i = gb.bases[WEAPON_CLASS];
for (i = svb.bases[WEAPON_CLASS];
i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++)
if (objects[i].oc_skill == skill) {
n++;
@@ -3387,7 +3387,7 @@ rnd_otyp_by_wpnskill(schar skill)
}
if (n > 0) {
n = rn2(n);
for (i = gb.bases[WEAPON_CLASS];
for (i = svb.bases[WEAPON_CLASS];
i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++)
if (objects[i].oc_skill == skill)
if (--n < 0)
@@ -3419,8 +3419,8 @@ rnd_otyp_by_namedesc(
(void) memset((genericptr_t) validobjs, 0, sizeof validobjs);
if (oclass) {
lo = gb.bases[(uchar) oclass];
hi = gb.bases[(uchar) oclass + 1] - 1;
lo = svb.bases[(uchar) oclass];
hi = svb.bases[(uchar) oclass + 1] - 1;
} else {
lo = MAXOCLASSES; /* STRANGE_OBJECT + 1; */
hi = NUM_OBJECTS - 1;
@@ -3521,7 +3521,7 @@ wizterrainwish(struct _readobjnam_data *d)
if (!BSTRCMPI(bp, p - 8, "fountain")) {
lev->typ = FOUNTAIN;
if (oldtyp != FOUNTAIN)
gl.level.flags.nfountains++;
svl.level.flags.nfountains++;
lev->looted = d->looted ? F_LOOTED : 0; /* overlays 'flags' */
lev->blessedftn = d->blessed || !strncmpi(bp, "magic ", 6);
pline("A %sfountain.", lev->blessedftn ? "magic " : "");
@@ -3534,7 +3534,7 @@ wizterrainwish(struct _readobjnam_data *d)
} else if (!BSTRCMPI(bp, p - 4, "sink")) {
lev->typ = SINK;
if (oldtyp != SINK)
gl.level.flags.nsinks++;
svl.level.flags.nsinks++;
lev->looted = d->looted ? (S_LPUDDING | S_LDWASHER | S_LRING) : 0;
pline("A sink.");
madeterrain = TRUE;
@@ -3568,7 +3568,7 @@ wizterrainwish(struct _readobjnam_data *d)
} else {
dbterrainmesg("Moat", x, y);
}
water_damage_chain(gl.level.objects[x][y], TRUE);
water_damage_chain(svl.level.objects[x][y], TRUE);
madeterrain = TRUE;
/* also matches "molten lava" */
@@ -3592,7 +3592,7 @@ wizterrainwish(struct _readobjnam_data *d)
} else {
dbterrainmesg("Lava", x, y);
}
fire_damage_chain(gl.level.objects[x][y], TRUE, TRUE, x, y);
fire_damage_chain(svl.level.objects[x][y], TRUE, TRUE, x, y);
madeterrain = TRUE;
} else if (!BSTRCMPI(bp, p - 3, "ice")) {
if (!is_dbridge) {
@@ -3890,7 +3890,7 @@ readobjnam_init(char *bp, struct _readobjnam_data *d)
d->bp = d->origbp = bp;
d->p = (char *) 0;
d->name = (const char *) 0;
d->ftype = gc.context.current_fruit;
d->ftype = svc.context.current_fruit;
(void) memset(d->globbuf, '\0', sizeof d->globbuf);
(void) memset(d->fruitbuf, '\0', sizeof d->fruitbuf);
}
@@ -4651,7 +4651,7 @@ readobjnam_postparse3(struct _readobjnam_data *d)
/* check real names of gems first */
if (!d->oclass && d->actualn) {
for (i = gb.bases[GEM_CLASS]; i <= LAST_REAL_GEM; i++) {
for (i = svb.bases[GEM_CLASS]; i <= LAST_REAL_GEM; i++) {
const char *zn;
if ((zn = OBJ_NAME(objects[i])) != 0 && !strcmpi(d->actualn, zn)) {
@@ -4894,7 +4894,7 @@ readobjnam(char *bp, struct obj *no_wish)
* Disallow such topology tweaks for WIZKIT startup wishes.
*/
wiztrap:
if (wizard && !gp.program_state.wizkit_wishing && !d.oclass) {
if (wizard && !svp.program_state.wizkit_wishing && !d.oclass) {
/* [inline code moved to separate routine to unclutter readobjnam] */
if ((d.otmp = wizterrainwish(&d)) != 0)
return d.otmp;
@@ -4982,7 +4982,7 @@ readobjnam(char *bp, struct obj *no_wish)
if (rn1cnt > 6 - d.gsize)
rn1cnt = 6 - d.gsize;
if (d.cnt > rn1cnt
&& (!wizard || gp.program_state.wizkit_wishing
&& (!wizard || svp.program_state.wizkit_wishing
|| y_n("Override glob weight limit?") != 'y'))
d.cnt = rn1cnt;
d.otmp->owt *= (unsigned) d.cnt;
@@ -5116,7 +5116,7 @@ readobjnam(char *bp, struct obj *no_wish)
corpses and tins, switch to their corresponding human form;
for figurines, override the can't-be-human restriction instead */
if (d.typ != FIGURINE && is_were(&mons[d.mntmp])
&& (gm.mvitals[d.mntmp].mvflags & G_NOCORPSE) != 0
&& (svm.mvitals[d.mntmp].mvflags & G_NOCORPSE) != 0
&& (humanwere = counter_were(d.mntmp)) != NON_PM)
d.mntmp = humanwere;
@@ -5125,14 +5125,14 @@ readobjnam(char *bp, struct obj *no_wish)
if (dead_species(d.mntmp, FALSE)) {
d.otmp->corpsenm = NON_PM; /* it's empty */
} else if ((!(mons[d.mntmp].geno & G_UNIQ) || wizard)
&& !(gm.mvitals[d.mntmp].mvflags & G_NOCORPSE)
&& !(svm.mvitals[d.mntmp].mvflags & G_NOCORPSE)
&& mons[d.mntmp].cnutrit != 0) {
d.otmp->corpsenm = d.mntmp;
}
break;
case CORPSE:
if ((!(mons[d.mntmp].geno & G_UNIQ) || wizard)
&& !(gm.mvitals[d.mntmp].mvflags & G_NOCORPSE)) {
&& !(svm.mvitals[d.mntmp].mvflags & G_NOCORPSE)) {
if (mons[d.mntmp].msound == MS_GUARDIAN)
d.mntmp = genus(d.mntmp, 1);
set_corpsenm(d.otmp, d.mntmp);