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:
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
gh.hname = argv[0];
|
||||
gh.hackpid = getpid();
|
||||
svh.hackpid = getpid();
|
||||
(void) umask(0777 & ~FCMASK);
|
||||
|
||||
choose_windows(DEFAULT_WINDOW_SYS);
|
||||
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
u.uhp = 1; /* prevent RIP on early quits */
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 1;
|
||||
svp.program_state.preserve_locks = 1;
|
||||
#ifndef NO_SIGNAL
|
||||
sethanguphandler((SIG_RET_TYPE) hangup);
|
||||
#endif
|
||||
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
|
||||
/* wizard mode access is deferred until here */
|
||||
set_playmode(); /* sets plname to "wizard" for wizard mode */
|
||||
/* hide any hyphens from plnamesuffix() */
|
||||
gp.plnamelen = exact_username ? (int) strlen(gp.plname) : 0;
|
||||
gp.plnamelen = exact_username ? (int) strlen(svp.plname) : 0;
|
||||
/* strip role,race,&c suffix; calls askname() if plname[] is empty
|
||||
or holds a generic user name like "player" or "games" */
|
||||
plnamesuffix();
|
||||
@@ -236,14 +236,14 @@ main(int argc, char *argv[])
|
||||
* clock, &c not currently in use in the playground directory
|
||||
* (for gl.locknum > 0).
|
||||
*/
|
||||
if (*gp.plname) {
|
||||
if (*svp.plname) {
|
||||
getlock();
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 0; /* after getlock() */
|
||||
svp.program_state.preserve_locks = 0; /* after getlock() */
|
||||
#endif
|
||||
}
|
||||
|
||||
if (*gp.plname && (nhfp = restore_saved_game()) != 0) {
|
||||
if (*svp.plname && (nhfp = restore_saved_game()) != 0) {
|
||||
const char *fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1);
|
||||
|
||||
(void) chmod(fq_save, 0); /* disallow parallel restores */
|
||||
@@ -276,13 +276,13 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gp.program_state.in_self_recover) {
|
||||
gp.program_state.in_self_recover = FALSE;
|
||||
if (svp.program_state.in_self_recover) {
|
||||
svp.program_state.in_self_recover = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!resuming) {
|
||||
boolean neednewlock = (!*gp.plname);
|
||||
boolean neednewlock = (!*svp.plname);
|
||||
/* new game: start by choosing role, race, etc;
|
||||
player might change the hero's name while doing that,
|
||||
in which case we try to restore under the new name
|
||||
@@ -291,7 +291,7 @@ main(int argc, char *argv[])
|
||||
if (!plsel_once)
|
||||
player_selection();
|
||||
plsel_once = TRUE;
|
||||
if (neednewlock && *gp.plname)
|
||||
if (neednewlock && *svp.plname)
|
||||
goto attempt_restore;
|
||||
if (iflags.renameinprogress) {
|
||||
/* player has renamed the hero while selecting role;
|
||||
@@ -474,12 +474,12 @@ process_options(int argc, char *argv[])
|
||||
break;
|
||||
case 'u':
|
||||
if (arg[2]) {
|
||||
(void) strncpy(gp.plname, arg + 2, sizeof gp.plname - 1);
|
||||
(void) strncpy(svp.plname, arg + 2, sizeof svp.plname - 1);
|
||||
gp.plnamelen = 0; /* plname[] might have -role-race attached */
|
||||
} else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
(void) strncpy(gp.plname, argv[0], sizeof gp.plname - 1);
|
||||
(void) strncpy(svp.plname, argv[0], sizeof svp.plname - 1);
|
||||
gp.plnamelen = 0;
|
||||
} else {
|
||||
config_error_add("Character name expected after -u");
|
||||
@@ -916,7 +916,7 @@ whoami(void)
|
||||
* Note that we trust the user here; it is possible to play under
|
||||
* somebody else's name.
|
||||
*/
|
||||
if (!*gp.plname) {
|
||||
if (!*svp.plname) {
|
||||
register const char *s;
|
||||
|
||||
s = nh_getenv("USER");
|
||||
@@ -926,8 +926,8 @@ whoami(void)
|
||||
s = getlogin();
|
||||
|
||||
if (s && *s) {
|
||||
(void) strncpy(gp.plname, s, sizeof gp.plname - 1);
|
||||
if (strchr(gp.plname, '-'))
|
||||
(void) strncpy(svp.plname, s, sizeof svp.plname - 1);
|
||||
if (strchr(svp.plname, '-'))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1052,7 +1052,7 @@ check_user_string(const char *optstr)
|
||||
if (optstr[0] == '*')
|
||||
return TRUE; /* allow any user */
|
||||
if (sysopt.check_plname)
|
||||
pwname = gp.plname;
|
||||
pwname = svp.plname;
|
||||
else if ((pw = get_unix_pw()) != 0)
|
||||
pwname = pw->pw_name;
|
||||
if (!pwname || !*pwname)
|
||||
|
||||
@@ -82,7 +82,7 @@ eraseoldlocks(void)
|
||||
int i;
|
||||
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 0; /* not required but shows intent */
|
||||
svp.program_state.preserve_locks = 0; /* not required but shows intent */
|
||||
/* cannot use maxledgerno() here, because we need to find a lock name
|
||||
* before starting everything (including the dungeon initialization
|
||||
* that sets astral_level, needed for maxledgerno()) up
|
||||
@@ -132,7 +132,7 @@ getlock(void)
|
||||
'a','b',&c below; override the default and use <uid><charname>
|
||||
if we aren't restricting the number of simultaneous games */
|
||||
if (!gl.locknum)
|
||||
Sprintf(gl.lock, "%u%s", (unsigned) getuid(), gp.plname);
|
||||
Sprintf(gl.lock, "%u%s", (unsigned) getuid(), svp.plname);
|
||||
|
||||
regularize(gl.lock);
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
@@ -216,7 +216,7 @@ getlock(void)
|
||||
}
|
||||
#ifdef SELF_RECOVER
|
||||
if (c == 'r' || c == 'R') {
|
||||
if (recover_savefile() && gp.program_state.in_self_recover) {
|
||||
if (recover_savefile() && svp.program_state.in_self_recover) {
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
fq_lock = fqname(gl.lock, LEVELPREFIX, 0);
|
||||
goto gotlock;
|
||||
@@ -246,8 +246,8 @@ getlock(void)
|
||||
error("cannot creat lock file (%s).", fq_lock);
|
||||
/*NOTREACHED*/
|
||||
} else {
|
||||
if (write(fd, (genericptr_t) &gh.hackpid, sizeof gh.hackpid)
|
||||
!= sizeof gh.hackpid) {
|
||||
if (write(fd, (genericptr_t) &svh.hackpid, sizeof svh.hackpid)
|
||||
!= sizeof svh.hackpid) {
|
||||
error("cannot write lock (%s)", fq_lock);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user