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

@@ -254,13 +254,13 @@ check_map_spot(coordxy x, coordxy y, char oclass, unsigned material)
if (glyph_is_object(glyph)) {
/* there's some object shown here */
if (oclass == ALL_CLASSES) {
return !(gl.level.objects[x][y] /* stale if nothing here */
return !(svl.level.objects[x][y] /* stale if nothing here */
|| ((mtmp = m_at(x, y)) != 0 && mtmp->minvent));
} else {
if (material
&& objects[glyph_to_obj(glyph)].oc_material == material) {
/* object shown here is of interest because material matches */
for (otmp = gl.level.objects[x][y]; otmp;
for (otmp = svl.level.objects[x][y]; otmp;
otmp = otmp->nexthere)
if (o_material(otmp, GOLD))
return FALSE;
@@ -275,7 +275,7 @@ check_map_spot(coordxy x, coordxy y, char oclass, unsigned material)
}
if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) {
/* obj shown here is of interest because its class matches */
for (otmp = gl.level.objects[x][y]; otmp;
for (otmp = svl.level.objects[x][y]; otmp;
otmp = otmp->nexthere)
if (o_in(otmp, oclass))
return FALSE;
@@ -636,7 +636,7 @@ object_detect(struct obj *detector, /* object doing the detecting */
do_dknown_of(obj);
}
for (obj = gl.level.buriedobjlist; obj; obj = obj->nobj) {
for (obj = svl.level.buriedobjlist; obj; obj = obj->nobj) {
if (!class || o_in(obj, class)) {
if (u_at(obj->ox, obj->oy))
ctu++;
@@ -684,7 +684,7 @@ object_detect(struct obj *detector, /* object doing the detecting */
/*
* Map all buried objects first.
*/
for (obj = gl.level.buriedobjlist; obj; obj = obj->nobj)
for (obj = svl.level.buriedobjlist; obj; obj = obj->nobj)
if (!class || (otmp = o_in(obj, class)) != 0) {
if (class) {
if (otmp != obj) {
@@ -705,7 +705,7 @@ object_detect(struct obj *detector, /* object doing the detecting */
*/
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++)
for (obj = gl.level.objects[x][y]; obj; obj = obj->nexthere)
for (obj = svl.level.objects[x][y]; obj; obj = obj->nexthere)
if ((!class && !boulder) || (otmp = o_in(obj, class)) != 0
|| (otmp = o_in(obj, boulder)) != 0) {
if (class || boulder) {
@@ -933,7 +933,7 @@ display_trap_map(int cursed_src)
/* show chest traps first, first buried chests then floor chests, so
that subsequent floor trap display will override if both types are
present at the same location */
(void) detect_obj_traps(gl.level.buriedobjlist, TRUE, cursed_src);
(void) detect_obj_traps(svl.level.buriedobjlist, TRUE, cursed_src);
(void) detect_obj_traps(fobj, TRUE, cursed_src);
for (mon = fmon; mon; mon = mon->nmon) {
if (DEADMONSTER(mon) || (mon->isgd && !mon->mx))
@@ -947,7 +947,7 @@ display_trap_map(int cursed_src)
dummytrap.ttyp = TRAPPED_DOOR;
for (door = 0; door < gd.doorindex; door++) {
cc = gd.doors[door];
cc = svd.doors[door];
if (levl[cc.x][cc.y].typ == SDOOR) /* see above */
continue;
if (levl[cc.x][cc.y].doormask & D_TRAPPED) {
@@ -1004,7 +1004,7 @@ trap_detect(
}
found = TRUE;
}
if ((tr = detect_obj_traps(gl.level.buriedobjlist, FALSE, 0))
if ((tr = detect_obj_traps(svl.level.buriedobjlist, FALSE, 0))
!= OTRAP_NONE) {
if (tr & OTRAP_THERE) {
display_trap_map(cursed_src);
@@ -1027,7 +1027,7 @@ trap_detect(
found = TRUE;
/* door traps */
for (door = 0; door < gd.doorindex; door++) {
cc = gd.doors[door];
cc = svd.doors[door];
/* levl[][].doormask and .wall_info both overlay levl[][].flags;
the bit in doormask for D_TRAPPED is also a bit in wall_info;
secret doors use wall_info so can't be marked as trapped */
@@ -1362,7 +1362,7 @@ show_map_spot(coordxy x, coordxy y, boolean cnf)
* opposite to how normal vision behaves.
*/
oldglyph = glyph_at(x, y);
if (gl.level.flags.hero_memory) {
if (svl.level.flags.hero_memory) {
magic_map_background(x, y, 0);
newsym(x, y); /* show it, if not blocked */
} else {
@@ -1375,7 +1375,7 @@ show_map_spot(coordxy x, coordxy y, boolean cnf)
map_engraving(ep, 1);
} else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) {
show_glyph(x, y, oldglyph);
if (gl.level.flags.hero_memory)
if (svl.level.flags.hero_memory)
lev->glyph = oldglyph;
}
}
@@ -1395,7 +1395,7 @@ do_mapping(void)
for (zy = 0; zy < ROWNO; zy++)
show_map_spot(zx, zy, Confusion);
if (!gl.level.flags.hero_memory || unconstrained) {
if (!svl.level.flags.hero_memory || unconstrained) {
flush_screen(1); /* flush temp screen */
/* browse_map() instead of display_nhwindow(WIN_MAP, TRUE) */
browse_map(TER_DETECT | TER_MAP | TER_TRP | TER_OBJ,
@@ -1472,7 +1472,7 @@ do_vicinity_map(
if (OBJ_AT(zx, zy)) {
/* not vobj_at(); this is not vision-based access;
unlike object detection, we don't notice buried items */
otmp = gl.level.objects[zx][zy];
otmp = svl.level.objects[zx][zy];
if (extended)
otmp->dknown = 1;
map_object(otmp, TRUE);
@@ -1489,7 +1489,7 @@ do_vicinity_map(
the map and we're not doing extended/blessed clairvoyance
(hence must be swallowed or underwater), show "unseen
creature" unless map already displayed a monster here */
if ((unconstrained || !gl.level.flags.hero_memory)
if ((unconstrained || !svl.level.flags.hero_memory)
&& !extended && (zx != u.ux || zy != u.uy)
&& !glyph_is_monster(oldglyph))
map_invisible(zx, zy);
@@ -1512,7 +1512,7 @@ do_vicinity_map(
if (random_farsight && flags.quick_farsight)
mdetected = odetected = FALSE;
if (!gl.level.flags.hero_memory || unconstrained
if (!svl.level.flags.hero_memory || unconstrained
|| mdetected || odetected) {
flush_screen(1); /* flush temp screen */
/* the getpos() prompt from browse_map() is only shown when
@@ -1639,7 +1639,7 @@ openone(coordxy zx, coordxy zy, genericptr_t num)
int *num_p = (int *) num;
if (OBJ_AT(zx, zy)) {
for (otmp = gl.level.objects[zx][zy]; otmp; otmp = otmp->nexthere) {
for (otmp = svl.level.objects[zx][zy]; otmp; otmp = otmp->nexthere) {
if (Is_box(otmp) && otmp->olocked) {
otmp->olocked = 0;
(*num_p)++;
@@ -2041,14 +2041,14 @@ reveal_terrain_getglyph(
/* for 'full', show the actual terrain for the entire level,
otherwise what the hero remembers for seen locations with
monsters, objects, and/or traps removed as caller dictates */
seenv = (full || gl.level.flags.hero_memory)
seenv = (full || svl.level.flags.hero_memory)
? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
if (full) {
levl[x][y].seenv = SVALL;
glyph = back_to_glyph(x, y);
levl[x][y].seenv = seenv;
} else {
levl_glyph = gl.level.flags.hero_memory ? levl[x][y].glyph
levl_glyph = svl.level.flags.hero_memory ? levl[x][y].glyph
: seenv ? back_to_glyph(x, y)
: default_glyph;
/* glyph_at() returns the displayed glyph, which might
@@ -2074,7 +2074,7 @@ reveal_terrain_getglyph(
|| glyph_is_invisible(glyph)) {
if (!seenv) {
glyph = default_glyph;
} else if (gl.lastseentyp[x][y] == levl[x][y].typ) {
} else if (svl.lastseentyp[x][y] == levl[x][y].typ) {
glyph = back_to_glyph(x, y);
} else {
/* look for a mimic here posing as furniture;
@@ -2098,7 +2098,7 @@ reveal_terrain_getglyph(
* doormask==D_OPEN for an open door remembered as a wall.
*/
save_spot = levl[x][y];
levl[x][y].typ = gl.lastseentyp[x][y];
levl[x][y].typ = svl.lastseentyp[x][y];
if (IS_WALL(levl[x][y].typ) || levl[x][y].typ == SDOOR)
xy_set_wall_state(x, y); /* levl[x][y].wall_info */
glyph = back_to_glyph(x, y);
@@ -2122,7 +2122,7 @@ dump_map(void)
coordxy x, y;
int glyph, skippedrows, lastnonblank;
unsigned subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON;
int default_glyph = cmap_to_glyph(gl.level.flags.arboreal ? S_tree
int default_glyph = cmap_to_glyph(svl.level.flags.arboreal ? S_tree
: S_stone);
char buf[COLBUFSZ];
boolean blankrow, toprow;
@@ -2197,7 +2197,7 @@ reveal_terrain(
if (unconstrain_map())
docrt();
default_glyph = cmap_to_glyph(gl.level.flags.arboreal ? S_tree
default_glyph = cmap_to_glyph(svl.level.flags.arboreal ? S_tree
: S_stone);
for (x = 1; x < COLNO; x++)