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

@@ -244,11 +244,8 @@ static const struct instance_globals_b g_init_b = {
0L, /* bl_hilite_moves */
#endif
/* decl.c */
DUMMY, /* bases */
{ 0, 0 }, /* bhitpos */
UNDEFINED_PTR, /* billobjs */
/* dungeon.c */
UNDEFINED_PTR, /* branches */
/* files.c */
BONESINIT, /* bones */
/* hack.c */
@@ -257,7 +254,6 @@ static const struct instance_globals_b g_init_b = {
/* mkmaze.c */
{ {COLNO, ROWNO, 0, 0}, {COLNO, ROWNO, 0, 0},
FALSE, FALSE, 0, 0, { 0 } }, /* bughack */
UNDEFINED_PTR, /* bbubbles */
/* pickup.c */
FALSE, /* bucx_filter */
/* zap.c */
@@ -285,7 +281,6 @@ static const struct instance_globals_c g_init_c = {
#ifdef DEF_PAGER
NULL, /* catmore */
#endif
DUMMY, /* context */
/* dog.c */
DUMMY, /* catname */
/* end.c */
@@ -326,16 +321,7 @@ static const struct instance_globals_d g_init_d = {
0L, /* done_money */
0L, /* domove_attempting */
0L, /* domove_succeeded */
{ { {0},{0},{0},{0}, 0, {0}, 0, 0, 0, 0, 0 } }, /* dungeons */
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* dndest */
FALSE, /* defer_see_monsters */
{ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
0, 0, 0, 0, 0,
{0}, {0}, {0},
{0}, {0}, {0} }, /* dungeon_topology */
0, /* doors_alloc */
NULL, /* doors */
/* dig.c */
UNDEFINED_VALUE, /* did_dig_msg */
/* do.c */
@@ -348,8 +334,6 @@ static const struct instance_globals_d g_init_d = {
0L, /* done_seq */
/* mon.c */
FALSE, /* disintegested */
/* o_init.c */
DUMMY, /* disco */
/* objname.c */
0, /* distantname */
/* pickup.c */
@@ -369,7 +353,6 @@ static const struct instance_globals_e g_init_e = {
/* mkmaze.c */
UNDEFINED_PTR, /* ebubbles */
/* new */
NULL, /* exclusion_zones */
0, /* early_raw_messages */
TRUE, /* havestate*/
IVMAGIC /* e_magic to validate that structure layout has been preserved */
@@ -434,7 +417,6 @@ static const struct instance_globals_g g_init_g = {
static const struct instance_globals_h g_init_h = {
/* decl.c */
NULL, /* hname */
0, /* hackpid */
#if defined(MICRO) || defined(WIN32)
UNDEFINED_VALUES, /* hackdir */
#endif /* MICRO || WIN32 */
@@ -454,7 +436,6 @@ static const struct instance_globals_h g_init_h = {
static const struct instance_globals_i g_init_i = {
/* decl.c */
0, /* in_doagain */
{ 0, 0 } , /* inv_pos */
FALSE, /* in_mklev */
FALSE, /* in_steed_dismounting */
UNDEFINED_PTR, /* invent */
@@ -486,7 +467,6 @@ static const struct instance_globals_k g_init_k = {
{ 0, 0 }, /* kickedloc */
/* decl.c */
UNDEFINED_PTR, /* kickedobj */
DUMMY, /* killer */
/* read.c */
UNDEFINED_VALUE, /* known */
TRUE, /* havestate*/
@@ -497,12 +477,6 @@ static const struct instance_globals_l g_init_l = {
/* cmd.c */
UNDEFINED_VALUE, /* last_command_count */
/* decl.c */
{ { 0 } }, /* lastseentyp */
{ UNDEFINED_VALUES }, /* level_info */
{ { { UNDEFINED_VALUES } }, /* level.locations */
{ { UNDEFINED_PTR } }, /* level.objects */
{ { UNDEFINED_PTR } }, /* level.monsters */
NULL, NULL, NULL, NULL, NULL, {0} }, /* level */
#if defined(UNIX) || defined(VMS)
0, /* locknum */
#endif
@@ -563,16 +537,12 @@ static const struct instance_globals_m g_init_m = {
{ 0, 0, STRANGE_OBJECT, FALSE }, /* m_shot */
FALSE, /* mrg_to_wielded */
UNDEFINED_PTR, /* menu_colorings */
1L, /* moves; misnamed turn counter */
UNDEFINED_PTR, /* migrating_objs */
/* dog.c */
UNDEFINED_PTR, /* mydogs */
UNDEFINED_PTR, /* migrating_mons */
{ UNDEFINED_VALUES }, /* mvitals */
/* dokick.c */
UNDEFINED_PTR, /* maploc */
/* dungeon.c */
UNDEFINED_PTR, /* mapseenchn */
/* mhitu.c */
UNDEFINED_VALUE, /* mhitu_dieroll */
/* mklev.c */
@@ -607,12 +577,9 @@ static const struct instance_globals_n g_init_n = {
0, /* now_or_before_idx */
/* decl.c */
NULL, /* nomovemsg */
0, /* nroom */
0, /* nsubroom */
/* dokick.c */
UNDEFINED_VALUES, /* nowhere */
/* dungeon.c */
0, /* n_dgns */
/* files.c */
0, /* nesting */
0, /* no_sound_notified */
@@ -627,8 +594,6 @@ static const struct instance_globals_n g_init_n = {
FALSE, /* notonhead */
/* questpgr.c */
UNDEFINED_VALUES, /* nambuf */
/* region.c */
0, /* n_regions */
/* restore.c */
0, /* n_ids_mapped */
/* sp_lev.c */
@@ -677,7 +642,6 @@ static const struct instance_globals_o g_init_o = {
0L, /* omoves */
/* rumors.c */
0, /* oracle_flag */
0U, /* oracle_cnt */
UNDEFINED_PTR, /* oracle_loc */
/* uhitm.c */
FALSE, /* override_confirmation */
@@ -692,13 +656,9 @@ static const struct instance_globals_p g_init_p = {
-1, /* polearm_range_min */
-1, /* polearm_range_max */
/* decl.c */
DUMMY, /* plname */
0, /* plnamelen */
DUMMY, /* pl_character */
'\0', /* pl_race */
DUMMY, /* pl_fruit */
UNDEFINED_PTR, /* plinemsg_types */
UNDEFINED_VALUES, /* program_state */
/* dog.c */
0, /* petname_used */
UNDEFINED_VALUE, /* preferred_pet */
@@ -728,15 +688,11 @@ static const struct instance_globals_p g_init_p = {
};
static const struct instance_globals_q g_init_q = {
/* quest.c */
DUMMY, /* quest_status */
TRUE, /* havestate*/
IVMAGIC /* q_magic to validate that structure layout has been preserved */
};
static const struct instance_globals_r g_init_r = {
/* decl.c */
{ DUMMY }, /* rooms */
/* symbols.c */
DUMMY, /* rogue_syms */
/* extralev.c */
@@ -761,11 +717,9 @@ static const struct instance_globals_s g_init_s = {
/* artifact.c */
0, /* spec_dbon_applies */
/* decl.c */
UNDEFINED_PTR, /* sp_levchn */
UNDEFINED_PTR, /* stairs */
DUMMY, /* smeq */
FALSE, /* stoned */
{ DUMMY }, /* spl_book */
UNDEFINED_PTR, /* subrooms */
/* do.c */
{ 0, 0 }, /* save_dlevel */
@@ -820,7 +774,6 @@ static const struct instance_globals_t g_init_t = {
/* apply.c */
UNDEFINED_VALUES, /* trapinfo */
/* decl.c */
DUMMY, /* tune */
0, /* tbx */
0, /* tby */
UNDEFINED_VALUES, /* toplines */
@@ -843,7 +796,6 @@ static const struct instance_globals_t g_init_t = {
FALSE, /* themeroom_failed */
/* timeout.c */
UNDEFINED_PTR, /* timer_base */
1UL, /* timer_id */
/* topten.c */
WIN_ERR, /* toptenwin */
/* uhitm.c */
@@ -857,7 +809,6 @@ static const struct instance_globals_u g_init_u = {
/* botl.c */
FALSE, /* update_all */
/* decl.c */
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* updest */
FALSE, /* unweapon */
/* role.c */
UNDEFINED_ROLE, /* urole */
@@ -917,9 +868,6 @@ static const struct instance_globals_x g_init_x = {
(COLNO - 1) & ~1, /* x_maze_max */
/* lock.c */
UNDEFINED_VALUES, /* xlock */
/* mkmaze.c */
UNDEFINED_VALUE, /* xmin */
UNDEFINED_VALUE, /* xmax */
/* objnam.c */
NULL, /* xnamep */
/* sp_lev.c */
@@ -933,9 +881,6 @@ static const struct instance_globals_y g_init_y = {
/* decl.c */
(ROWNO - 1) & ~1, /* y_maze_max */
DUMMY, /* youmonst */
/* mkmaze.c */
UNDEFINED_VALUE, /* ymin */
UNDEFINED_VALUE, /* ymax */
/* pline.c */
NULL, /* you_buf */
0, /* you_buf_siz */
@@ -955,6 +900,135 @@ static const struct instance_globals_z g_init_z = {
IVMAGIC /* z_magic to validate that structure layout has been preserved */
};
static const struct instance_globals_saved_b init_svb = {
/* dungeon.c */
UNDEFINED_PTR, /* branches */
/* mkmaze.c */
UNDEFINED_PTR, /* bbubbles */
DUMMY /* bases */
};
static const struct instance_globals_saved_c init_svc = {
/* decl.c */
DUMMY, /* context */
};
static const struct instance_globals_saved_d init_svd = {
/* dungeon.c */
{ { {0},{0},{0},{0}, 0, {0}, 0, 0, 0, 0, 0 } }, /* dungeons */
{ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
0, 0, 0, 0, 0,
{0}, {0}, {0},
{0}, {0}, {0} }, /* dungeon_topology */
/* decl.c */
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* dndest */
NULL, /* doors */
0, /* doors_alloc */
/* o_init.c */
DUMMY, /* disco */
};
static const struct instance_globals_saved_e init_sve = {
/* decl.c */
NULL /* exclusion_zones */
};
static const struct instance_globals_saved_h init_svh = {
/* decl.c */
0 /* hackpid */
};
static const struct instance_globals_saved_i init_svi = {
/* decl.c */
{ 0, 0 } /* inv_pos */
};
static const struct instance_globals_saved_k init_svk = {
/* decl.c */
DUMMY /* killer */
};
static const struct instance_globals_saved_l init_svl = {
/* decl.c */
{ { 0 } }, /* lastseentyp */
{ { { UNDEFINED_VALUES } }, /* level.locations */
{ { UNDEFINED_PTR } }, /* level.objects */
{ { UNDEFINED_PTR } }, /* level.monsters */
NULL, NULL, NULL, NULL, NULL, {0} }, /* level */
{ UNDEFINED_VALUES } /* level_info */
};
static const struct instance_globals_saved_m init_svm = {
/* dungeon.c */
UNDEFINED_PTR, /* mapseenchn */
/* decl.c */
1L, /* moves; misnamed turn counter */
{ UNDEFINED_VALUES } /* mvitals */
};
static const struct instance_globals_saved_n init_svn = {
/* dungeon.c */
0, /* n_dgns */
/* mkroom.c */
0, /* nroom */
/* region.c */
0 /* n_regions */
};
static const struct instance_globals_saved_o init_svo = {
/* rumors.c */
0U /* oracle_cnt */
};
static const struct instance_globals_saved_p init_svp = {
/* decl.c */
DUMMY, /* plname */
DUMMY, /* pl_character */
DUMMY, /* pl_fruit */
UNDEFINED_VALUES, /* program_state */
};
static const struct instance_globals_saved_q init_svq = {
/* quest.c */
DUMMY /* quest_status */
};
static const struct instance_globals_saved_r init_svr = {
/* mkroom.c */
{ DUMMY }, /* rooms */
};
static const struct instance_globals_saved_s init_svs = {
/* decl.c */
{ DUMMY }, /* spl_book */
UNDEFINED_PTR /* sp_levchn */
};
static const struct instance_globals_saved_t init_svt = {
/* decl.c */
DUMMY, /* tune */
/* timeout.c */
1UL, /* timer_id */
};
static const struct instance_globals_saved_u init_svu = {
/* decl.c */
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* updest */
};
static const struct instance_globals_saved_x init_svx = {
/* mkmaze.c */
UNDEFINED_VALUE, /* xmin */
UNDEFINED_VALUE /* xmax */
};
static const struct instance_globals_saved_y init_svy = {
/* mkmaze.c */
UNDEFINED_VALUE, /* ymin */
UNDEFINED_VALUE /* ymax */
};
#if 0
struct instance_globals g;
#endif /* 0 */
@@ -985,6 +1059,25 @@ struct instance_globals_w gw;
struct instance_globals_x gx;
struct instance_globals_y gy;
struct instance_globals_z gz;
struct instance_globals_saved_b svb;
struct instance_globals_saved_c svc;
struct instance_globals_saved_d svd;
struct instance_globals_saved_e sve;
struct instance_globals_saved_h svh;
struct instance_globals_saved_i svi;
struct instance_globals_saved_k svk;
struct instance_globals_saved_l svl;
struct instance_globals_saved_m svm;
struct instance_globals_saved_n svn;
struct instance_globals_saved_o svo;
struct instance_globals_saved_p svp;
struct instance_globals_saved_q svq;
struct instance_globals_saved_r svr;
struct instance_globals_saved_s svs;
struct instance_globals_saved_t svt;
struct instance_globals_saved_u svu;
struct instance_globals_saved_x svx;
struct instance_globals_saved_y svy;
const struct const_globals cg = {
DUMMY, /* zeroobj */
@@ -1042,6 +1135,25 @@ decl_globals_init(void)
gx = g_init_x;
gy = g_init_y;
gz = g_init_z;
svb = init_svb;
svc = init_svc;
svd = init_svd;
sve = init_sve;
svh = init_svh;
svi = init_svi;
svk = init_svk;
svl = init_svl;
svm = init_svm;
svn = init_svn;
svo = init_svo;
svp = init_svp;
svq = init_svq;
svr = init_svr;
svs = init_svs;
svt = init_svt;
svu = init_svu;
svx = init_svx;
svy = init_svy;
gv.valuables[0].list = gg.gems;
gv.valuables[0].size = SIZE(gg.gems);
@@ -1084,7 +1196,7 @@ decl_globals_init(void)
sfrestinfo = default_sfinfo;
sfsaveinfo = default_sfinfo;
gs.subrooms = &gr.rooms[MAXNROFROOMS + 1];
gs.subrooms = &svr.rooms[MAXNROFROOMS + 1];
ZERO(flags);
ZERO(iflags);
@@ -1107,11 +1219,11 @@ decl_globals_init(void)
/* fields in 'hands_obj' don't matter, just its distinct address */
struct obj hands_obj = DUMMY;
/* gcc 12.2's static analyzer thinks that some fields of gc.context.victual
/* gcc 12.2's static analyzer thinks that some fields of svc.context.victual
are uninitialized when compiling 'bite(eat.c)' but that's impossible;
it is defined at global scope so guaranteed to be given implicit
initialization for fields that aren't explicitly initialized (all of
'context'); having bite() pass &gc.context.victual to this no-op
'context'); having bite() pass &svc.context.victual to this no-op
eliminates the analyzer's very verbose complaint */
void
sa_victual(