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

@@ -200,7 +200,7 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb)
might have been thrown by a giant or launched by
a rolling boulder trap triggered by a monster or
dropped by a scroll of earth read by a monster */
if (gc.context.mon_moving) {
if (svc.context.mon_moving) {
/* normally we'd use ohitmon() but it can call
drop_throw() which calls flooreffects() */
damage = dmgval(obj, mtmp);
@@ -304,10 +304,10 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb)
(void) obj_meld(&globbyobj, &otmp);
}
res = (boolean) !globbyobj;
} else if (gc.context.mon_moving && IS_ALTAR(levl[x][y].typ)
} else if (svc.context.mon_moving && IS_ALTAR(levl[x][y].typ)
&& cansee(x,y)) {
doaltarobj(obj);
} else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0
} else if (obj->oclass == POTION_CLASS && svl.level.flags.temperature > 0
&& (levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) {
/* Potions are sometimes destroyed when landing on very hot
ground. The basic odds are 50% for nonblessed potions and
@@ -359,7 +359,7 @@ doaltarobj(struct obj *obj)
if (obj->oclass != COIN_CLASS) {
/* KMH, conduct */
if (!gc.context.mon_moving && !u.uconduct.gnostic++)
if (!svc.context.mon_moving && !u.uconduct.gnostic++)
livelog_printf(LL_CONDUCT,
"eschewed atheism, by dropping %s on an altar",
doname(obj));
@@ -403,7 +403,7 @@ polymorph_sink(void)
return;
sinklooted = levl[u.ux][u.uy].looted != 0;
/* gl.level.flags.nsinks--; // set_levltyp() will update this */
/* svl.level.flags.nsinks--; // set_levltyp() will update this */
levl[u.ux][u.uy].flags = 0;
switch (rn2(4)) {
default:
@@ -547,7 +547,7 @@ dosinkring(struct obj *obj)
break;
case RIN_HUNGER:
ideed = FALSE;
for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
for (otmp = svl.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
otmp2 = otmp->nexthere;
if (otmp != uball && otmp != uchain
&& !obj_resists(otmp, 1, 99)) {
@@ -822,7 +822,7 @@ dropz(struct obj *obj, boolean with_impact)
impact_disturbs_zombies(obj, with_impact);
if (obj == uball)
drop_ball(u.ux, u.uy);
else if (gl.level.flags.has_shop)
else if (svl.level.flags.has_shop)
sellobj(obj, u.ux, u.uy);
stackobj(obj);
if (Blind && Levitation)
@@ -900,7 +900,7 @@ obj_no_longer_held(struct obj *obj)
*/
if (!obj->oerodeproof || !rn2(10)) {
/* if monsters aren't moving, assume player is responsible */
if (!gc.context.mon_moving && !gp.program_state.gameover)
if (!svc.context.mon_moving && !svp.program_state.gameover)
costly_alteration(obj, COST_DEGRD);
obj->otyp = WORM_TOOTH;
obj->oerodeproof = 0;
@@ -1133,8 +1133,8 @@ dodown(void)
for (obj = gi.invent; obj; obj = obj->nobj) {
if (obj->oartifact
&& artifact_has_invprop(obj, LEVITATION)) {
if (obj->age < gm.moves)
obj->age = gm.moves;
if (obj->age < svm.moves)
obj->age = svm.moves;
obj->age += rnz(100);
}
}
@@ -1201,7 +1201,7 @@ dodown(void)
return ECMD_TIME;
} else if (!trap || !is_hole(trap->ttyp)
|| !Can_fall_thru(&u.uz) || !trap->tseen) {
if (flags.autodig && !gc.context.nopick && uwep && is_pick(uwep)) {
if (flags.autodig && !svc.context.nopick && uwep && is_pick(uwep)) {
return use_pick_axe2(uwep);
} else {
You_cant("go down here%s.",
@@ -1348,7 +1348,7 @@ save_currentstate(void)
{
NHFILE *nhfp;
gp.program_state.in_checkpoint++;
svp.program_state.in_checkpoint++;
if (flags.ins_chkpt) {
/* write out just-attained level, with pets and everything */
nhfp = currentlevel_rewrite();
@@ -1363,7 +1363,7 @@ save_currentstate(void)
/* write out non-level state */
savestateinlock();
gp.program_state.in_checkpoint--;
svp.program_state.in_checkpoint--;
}
#endif
@@ -1468,7 +1468,7 @@ goto_level(
char whynot[BUFSZ];
int dist = depth(newlevel) - depth(&u.uz);
boolean do_fall_dmg = FALSE;
schar prev_temperature = gl.level.flags.temperature;
schar prev_temperature = svl.level.flags.temperature;
if (dunlev(newlevel) > dunlevs_in_dungeon(newlevel))
newlevel->dlevel = dunlevs_in_dungeon(newlevel);
@@ -1512,7 +1512,7 @@ goto_level(
*/
if (Inhell && up && u.uhave.amulet && !newdungeon && !portal
&& (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) {
if (!rn2(4 + gc.context.mysteryforce)) {
if (!rn2(4 + svc.context.mysteryforce)) {
int odds = 3 + (int) u.ualign.type, /* 2..4 */
diff = (odds <= 1) ? 0 : rn2(odds); /* paranoia */
@@ -1532,7 +1532,7 @@ goto_level(
that drops faster, on average, when being sent down farther so
while the impact is reduced for everybody compared to earlier
versions, it is reduced least for chaotics, most for lawfuls */
gc.context.mysteryforce += rn2(diff + 2); /* L:0-4, N:0-3, C:0-2 */
svc.context.mysteryforce += rn2(diff + 2); /* L:0-4, N:0-3, C:0-2 */
if (on_level(newlevel, &u.uz)) {
(void) safe_teleds(TELEDS_NO_FLAGS);
@@ -1577,7 +1577,7 @@ goto_level(
maybe_reset_pick((struct obj *) 0);
reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */
iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination cache */
gc.context.polearm.hitmon = (struct monst *) 0; /* polearm target */
svc.context.polearm.hitmon = (struct monst *) 0; /* polearm target */
/* digging context is level-aware and can actually be resumed if
hero returns to the previous level without any intervening dig */
@@ -1628,7 +1628,7 @@ goto_level(
if (!leaving_tutorial || ledger_to_dnum(l_idx) == tutorial_dnum)
delete_levelfile(l_idx);
/* mark #overview data for all dungeon branches as uninteresting */
for (l_idx = 0; l_idx < gn.n_dgns; ++l_idx)
for (l_idx = 0; l_idx < svn.n_dgns; ++l_idx)
if (!leaving_tutorial || l_idx == tutorial_dnum)
remdun_mapseen(l_idx);
/* get rid of mons & objs scheduled to migrate to discarded levels */
@@ -1659,18 +1659,18 @@ goto_level(
stairway_free_all();
/* set default level change destination areas */
/* the special level code may override these */
(void) memset((genericptr_t) &gu.updest, 0, sizeof gu.updest);
(void) memset((genericptr_t) &gd.dndest, 0, sizeof gd.dndest);
(void) memset((genericptr_t) &svu.updest, 0, sizeof svu.updest);
(void) memset((genericptr_t) &svd.dndest, 0, sizeof svd.dndest);
if (!(gl.level_info[new_ledger].flags & LFILE_EXISTS)) {
if (!(svl.level_info[new_ledger].flags & LFILE_EXISTS)) {
/* entering this level for first time; make it now */
if (gl.level_info[new_ledger].flags & (VISITED)) {
if (svl.level_info[new_ledger].flags & (VISITED)) {
impossible("goto_level: returning to discarded level?");
gl.level_info[new_ledger].flags &= ~(VISITED);
svl.level_info[new_ledger].flags &= ~(VISITED);
}
mklev();
new = TRUE; /* made the level */
familiar = bones_include_name(gp.plname);
familiar = bones_include_name(svp.plname);
} else {
/* returning to previously visited level; reload it */
nhfp = open_levelfile(new_ledger, whynot);
@@ -1681,7 +1681,7 @@ goto_level(
reseed_random(rn2);
reseed_random(rn2_on_display_rng);
minit(); /* ZEROCOMP */
getlev(nhfp, gh.hackpid, new_ledger);
getlev(nhfp, svh.hackpid, new_ledger);
close_nhfile(nhfp);
oinit(); /* reassign level dependent obj probabilities */
}
@@ -1803,7 +1803,7 @@ goto_level(
/* initial movement of bubbles just before vision_recalc */
if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
movebubbles();
else if (gl.level.flags.fumaroles)
else if (svl.level.flags.fumaroles)
fumaroles();
/* Reset the screen. */
@@ -1865,7 +1865,7 @@ goto_level(
onquest(); /* might be reaching locate|goal level */
} else if (Is_knox(&u.uz)) {
/* alarm stops working once Croesus has died */
if (new || !gm.mvitals[PM_CROESUS].died) {
if (new || !svm.mvitals[PM_CROESUS].died) {
You("have penetrated a high security area!");
Soundeffect(se_alarm, 100);
pline("An alarm sounds!");
@@ -1890,7 +1890,7 @@ goto_level(
/* main dungeon message from your quest leader */
if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest")
&& !(u.uevent.qcompleted || u.uevent.qexpelled
|| gq.quest_status.leader_is_dead)) {
|| svq.quest_status.leader_is_dead)) {
/* [TODO: copy of same TODO below; if an achievement for
receiving quest call from leader gets added, that should
come after logging new level entry] */
@@ -1960,11 +1960,11 @@ goto_level(
void
hellish_smoke_mesg(void)
{
if (gl.level.flags.temperature)
if (svl.level.flags.temperature)
pline("It is %s here.",
gl.level.flags.temperature > 0 ? "hot" : "cold");
svl.level.flags.temperature > 0 ? "hot" : "cold");
if (In_hell(&u.uz) && gl.level.flags.temperature > 0)
if (In_hell(&u.uz) && svl.level.flags.temperature > 0)
You("%s smoke...",
olfaction(gy.youmonst.data) ? "smell" : "sense");
}
@@ -1973,8 +1973,8 @@ hellish_smoke_mesg(void)
staticfn void
temperature_change_msg(schar prev_temperature)
{
if (prev_temperature != gl.level.flags.temperature) {
if (gl.level.flags.temperature)
if (prev_temperature != svl.level.flags.temperature) {
if (svl.level.flags.temperature)
hellish_smoke_mesg();
else if (prev_temperature > 0)
pline_The("heat %s gone.",
@@ -2238,7 +2238,7 @@ revive_mon(anything *arg, long timeout UNUSED)
if (!obj_has_timer(body, ROT_CORPSE))
You_feel("%sless hassled.", is_rider(mptr) ? "much " : "");
action = ROT_CORPSE;
when = (long) d(5, 50) - (gm.moves - body->age);
when = (long) d(5, 50) - (svm.moves - body->age);
if (when < 1L)
when = 1L;
}
@@ -2254,7 +2254,7 @@ zombify_mon(anything *arg, long timeout)
struct obj *body = arg->a_obj;
int zmon = zombie_form(&mons[body->corpsenm]);
if (zmon != NON_PM && !(gm.mvitals[zmon].mvflags & G_GENOD)) {
if (zmon != NON_PM && !(svm.mvitals[zmon].mvflags & G_GENOD)) {
if (has_omid(body))
free_omid(body);
if (has_omonst(body))