#define HUP
#endif
+/* need to preserve these during save to avoid accessing freed memory */
+static unsigned ustuck_id = 0, usteed_id = 0;
+
int
dosave()
{
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);
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);
savestateinlock()
{
int fd, hpid;
+ static boolean havestate = TRUE;
char whynot[BUFSZ];
/* When checkpointing is on, the full state needs to be written
* 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
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