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

@@ -107,7 +107,7 @@ enum levl_typ_types {
#define IS_DOOR(typ) ((typ) == DOOR)
#define IS_DOORJOIN(typ) (IS_ROCK(typ) || (typ) == IRONBARS)
#define IS_TREE(typ) \
((typ) == TREE || (gl.level.flags.arboreal && (typ) == STONE))
((typ) == TREE || (svl.level.flags.arboreal && (typ) == STONE))
#define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */
#define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */
#define ZAP_POS(typ) ((typ) >= POOL)
@@ -374,7 +374,7 @@ struct damage {
an existing bones level; if so, most recent victim will be first in list */
struct cemetery {
struct cemetery *next; /* next struct is previous dead character... */
/* "gp.plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */
/* "svp.plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */
char who[PL_NSIZ + 4 * (1 + 3) + 1];
/* death reason, same as in score/log file */
char how[100 + 1]; /* [DTHSZ+1] */
@@ -441,9 +441,9 @@ typedef struct {
/*
* Macros for compatibility with old code. Someday these will go away.
*/
#define levl gl.level.locations
#define fobj gl.level.objlist
#define fmon gl.level.monlist
#define levl svl.level.locations
#define fobj svl.level.objlist
#define fmon svl.level.monlist
/*
* Covert a trap number into the defsym graphics array.
@@ -453,45 +453,45 @@ typedef struct {
#define trap_to_defsym(t) (S_arrow_trap + (t) - 1)
#define defsym_to_trap(d) ((d) - S_arrow_trap + 1)
#define OBJ_AT(x, y) (gl.level.objects[x][y] != (struct obj *) 0)
#define OBJ_AT(x, y) (svl.level.objects[x][y] != (struct obj *) 0)
/*
* Macros for encapsulation of level.monsters references.
*/
#if 0
/* these wouldn't allow buried monster and surface monster at same location */
#define MON_AT(x, y) \
(gl.level.monsters[x][y] && !gl.level.monsters[x][y]->mburied)
(svl.level.monsters[x][y] && !svl.level.monsters[x][y]->mburied)
#define MON_BURIED_AT(x, y) \
(gl.level.monsters[x][y] && gl.level.monsters[x][y]->mburied)
(svl.level.monsters[x][y] && svl.level.monsters[x][y]->mburied)
#define m_at(x, y) \
(MON_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
(MON_AT(x, y) ? svl.level.monsters[x][y] : (struct monst *) 0)
#define m_buried_at(x, y) \
(MON_BURIED_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
(MON_BURIED_AT(x, y) ? svl.level.monsters[x][y] : (struct monst *) 0)
#else /* without 'mburied' */
#define MON_AT(x, y) (gl.level.monsters[x][y] != (struct monst *) 0)
#define m_at(x, y) (gl.level.monsters[x][y])
#define MON_AT(x, y) (svl.level.monsters[x][y] != (struct monst *) 0)
#define m_at(x, y) (svl.level.monsters[x][y])
#define m_buried_at(x, y) ((struct monst *) 0)
#endif
#ifdef EXTRA_SANITY_CHECKS
#define place_worm_seg(m, x, y) \
do { \
if (gl.level.monsters[x][y] && gl.level.monsters[x][y] != m) \
if (svl.level.monsters[x][y] && svl.level.monsters[x][y] != m) \
impossible("place_worm_seg over mon"); \
gl.level.monsters[x][y] = m; \
svl.level.monsters[x][y] = m; \
} while(0)
#define remove_monster(x, y) \
do { \
if (!gl.level.monsters[x][y]) \
if (!svl.level.monsters[x][y]) \
impossible("no monster to remove"); \
gl.level.monsters[x][y] = (struct monst *) 0; \
svl.level.monsters[x][y] = (struct monst *) 0; \
} while(0)
#else
#define place_worm_seg(m, x, y) gl.level.monsters[x][y] = m
#define remove_monster(x, y) gl.level.monsters[x][y] = (struct monst *) 0
#define place_worm_seg(m, x, y) svl.level.monsters[x][y] = m
#define remove_monster(x, y) svl.level.monsters[x][y] = (struct monst *) 0
#endif
/* restricted movement, potential luck penalties */
#define Sokoban gl.level.flags.sokoban_rules
#define Sokoban svl.level.flags.sokoban_rules
/*
* These prototypes are in extern.h but some of the code which uses them