@@ -460,11 +460,6 @@ struct instance_variables {
|
||||
boolean m_using; /* kludge to use mondided instead of killed */
|
||||
/* pickup.c */
|
||||
int oldcap; /* last encumberance */
|
||||
/* save.c */
|
||||
boolean havestate;
|
||||
unsigned ustuck_id; /* need to preserve during save */
|
||||
unsigned usteed_id; /* need to preserve during save */
|
||||
|
||||
/* trap.c */
|
||||
int force_mintrap; /* mintrap() should take a flags argument, but for time
|
||||
being we use this */
|
||||
|
||||
@@ -344,10 +344,6 @@ const struct instance_variables iv_init = {
|
||||
FALSE, /* m_using */
|
||||
/* pickup.c */
|
||||
0, /* oldcap */
|
||||
/* save.c */
|
||||
TRUE, /* havestate*/
|
||||
0, /* ustuck_id */
|
||||
0, /* usteed_id */
|
||||
/* trap.c */
|
||||
0, /* force_mintrap */
|
||||
/* u_init.c */
|
||||
@@ -374,7 +370,6 @@ instance_variable_init()
|
||||
iv = iv_init;
|
||||
|
||||
nhassert(iv_init.magic == IVMAGIC);
|
||||
nhassert(iv.havestate == TRUE);
|
||||
|
||||
sfcap = default_sfinfo;
|
||||
sfrestinfo = default_sfinfo;
|
||||
|
||||
24
src/save.c
24
src/save.c
@@ -71,6 +71,9 @@ static struct save_procs {
|
||||
#define HUP
|
||||
#endif
|
||||
|
||||
/* need to preserve these during save to avoid accessing freed memory */
|
||||
static unsigned ustuck_id = 0, usteed_id = 0;
|
||||
|
||||
int
|
||||
dosave()
|
||||
{
|
||||
@@ -210,8 +213,8 @@ dosave0()
|
||||
store_version(fd);
|
||||
store_savefileinfo(fd);
|
||||
store_plname_in_file(fd);
|
||||
iv.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
iv.usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
savelev(fd, ledger_no(&u.uz), WRITE_SAVE | FREE_SAVE);
|
||||
savegamestate(fd, WRITE_SAVE | FREE_SAVE);
|
||||
|
||||
@@ -333,10 +336,10 @@ register int fd, mode;
|
||||
sizeof(struct spell) * (MAXSPELL + 1));
|
||||
save_artifacts(fd);
|
||||
save_oracles(fd, mode);
|
||||
if (iv.ustuck_id)
|
||||
bwrite(fd, (genericptr_t) &iv.ustuck_id, sizeof iv.ustuck_id);
|
||||
if (iv.usteed_id)
|
||||
bwrite(fd, (genericptr_t) &iv.usteed_id, sizeof iv.usteed_id);
|
||||
if (ustuck_id)
|
||||
bwrite(fd, (genericptr_t) &ustuck_id, sizeof ustuck_id);
|
||||
if (usteed_id)
|
||||
bwrite(fd, (genericptr_t) &usteed_id, sizeof usteed_id);
|
||||
bwrite(fd, (genericptr_t) pl_character, sizeof pl_character);
|
||||
bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
|
||||
savefruitchn(fd, mode);
|
||||
@@ -366,6 +369,7 @@ void
|
||||
savestateinlock()
|
||||
{
|
||||
int fd, hpid;
|
||||
static boolean havestate = TRUE;
|
||||
char whynot[BUFSZ];
|
||||
|
||||
/* When checkpointing is on, the full state needs to be written
|
||||
@@ -379,7 +383,7 @@ savestateinlock()
|
||||
* noop pid rewriting will take place on the first "checkpoint" after
|
||||
* the game is started or restored, if checkpointing is off.
|
||||
*/
|
||||
if (flags.ins_chkpt || iv.havestate) {
|
||||
if (flags.ins_chkpt || havestate) {
|
||||
/* save the rest of the current game state in the lock file,
|
||||
* following the original int pid, the current level number,
|
||||
* and the current savefile name, which should not be subject
|
||||
@@ -417,13 +421,13 @@ savestateinlock()
|
||||
store_savefileinfo(fd);
|
||||
store_plname_in_file(fd);
|
||||
|
||||
iv.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
iv.usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
savegamestate(fd, WRITE_SAVE);
|
||||
}
|
||||
bclose(fd);
|
||||
}
|
||||
iv.havestate = flags.ins_chkpt;
|
||||
havestate = flags.ins_chkpt;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user