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