First set of changes to move globals to instance_globals.
This commit is contained in:
24
src/save.c
24
src/save.c
@@ -71,9 +71,6 @@ 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()
|
||||
{
|
||||
@@ -213,8 +210,8 @@ dosave0()
|
||||
store_version(fd);
|
||||
store_savefileinfo(fd);
|
||||
store_plname_in_file(fd);
|
||||
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
g.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);
|
||||
|
||||
@@ -336,10 +333,10 @@ register int fd, mode;
|
||||
sizeof(struct spell) * (MAXSPELL + 1));
|
||||
save_artifacts(fd);
|
||||
save_oracles(fd, mode);
|
||||
if (ustuck_id)
|
||||
bwrite(fd, (genericptr_t) &ustuck_id, sizeof ustuck_id);
|
||||
if (usteed_id)
|
||||
bwrite(fd, (genericptr_t) &usteed_id, sizeof usteed_id);
|
||||
if (g.ustuck_id)
|
||||
bwrite(fd, (genericptr_t) &g.ustuck_id, sizeof g.ustuck_id);
|
||||
if (g.usteed_id)
|
||||
bwrite(fd, (genericptr_t) &g.usteed_id, sizeof g.usteed_id);
|
||||
bwrite(fd, (genericptr_t) pl_character, sizeof pl_character);
|
||||
bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
|
||||
savefruitchn(fd, mode);
|
||||
@@ -369,7 +366,6 @@ void
|
||||
savestateinlock()
|
||||
{
|
||||
int fd, hpid;
|
||||
static boolean havestate = TRUE;
|
||||
char whynot[BUFSZ];
|
||||
|
||||
/* When checkpointing is on, the full state needs to be written
|
||||
@@ -383,7 +379,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 || havestate) {
|
||||
if (flags.ins_chkpt || g.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
|
||||
@@ -421,13 +417,13 @@ savestateinlock()
|
||||
store_savefileinfo(fd);
|
||||
store_plname_in_file(fd);
|
||||
|
||||
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
|
||||
g.usteed_id = (u.usteed ? u.usteed->m_id : 0);
|
||||
savegamestate(fd, WRITE_SAVE);
|
||||
}
|
||||
bclose(fd);
|
||||
}
|
||||
havestate = flags.ins_chkpt;
|
||||
g.havestate = flags.ins_chkpt;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user