move 'g.restoring' to 'g.program_state.restoring'
Move the core's global restoring flag (not the same as main()'s local resuming flag) to a more logical place. Add a saving flag in the process, but it isn't being set or cleared anywhere yet. (Once in use it will probably fix the exception during save that was just reported, but before that it would be useful to figure out what specifically caused the event.) The program_state struct really ought to be standalone rather than part of struct g but I haven't made that change. Removing an unused variable for wishing and some reformatting that whent along with it got mixed in. Removes some trailing whitespace in sfstruct.c too. Only lightly tested...
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.367 $ $NHDT-Date: 1606697932 2020/11/30 00:58:52 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.368 $ $NHDT-Date: 1606765210 2020/11/30 19:40:10 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -736,3 +736,8 @@ add an additional note to mextra.h and obj.h comments that reminds people to
|
||||
appropriately init new fields if they need to initialize to something
|
||||
other than zero
|
||||
rework stairs structure into a linked list
|
||||
move 'restoring' to the program_state struct; add corresponding 'saving';
|
||||
both used to enforce no updating of status lines or of persistent
|
||||
inventory when the relevant activity is in progress
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 decl.h $NHDT-Date: 1600468452 2020/09/18 22:34:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.242 $ */
|
||||
/* NetHack 3.7 decl.h $NHDT-Date: 1606765210 2020/11/30 19:40:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.246 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2007. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -94,6 +94,8 @@ struct sinfo {
|
||||
int something_worth_saving; /* in case of panic */
|
||||
int panicking; /* `panic' is in progress */
|
||||
int exiting; /* an exit handler is executing */
|
||||
int saving;
|
||||
int restoring;
|
||||
int in_moveloop;
|
||||
int in_impossible;
|
||||
int in_self_recover;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 artifact.c $NHDT-Date: 1596498149 2020/08/03 23:42:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.159 $ */
|
||||
/* NetHack 3.7 artifact.c $NHDT-Date: 1606765210 2020/11/30 19:40:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.161 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -534,7 +534,8 @@ long wp_mask;
|
||||
* that can print a message--need to guard against being printed
|
||||
* when restoring a game
|
||||
*/
|
||||
(void) make_hallucinated((long) !on, g.restoring ? FALSE : TRUE,
|
||||
(void) make_hallucinated((long) !on,
|
||||
g.program_state.restoring ? FALSE : TRUE,
|
||||
wp_mask);
|
||||
}
|
||||
if (spfx & SPFX_ESP) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 botl.c $NHDT-Date: 1606008998 2020/11/22 01:36:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.192 $ */
|
||||
/* NetHack 3.7 botl.c $NHDT-Date: 1606765211 2020/11/30 19:40:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.193 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -238,7 +238,8 @@ void
|
||||
bot()
|
||||
{
|
||||
/* dosave() flags completion by setting u.uhp to -1 */
|
||||
if ((u.uhp != -1) && g.youmonst.data && iflags.status_updates) {
|
||||
if (u.uhp != -1 && g.youmonst.data && iflags.status_updates
|
||||
&& !g.program_state.saving && !g.program_state.restoring) {
|
||||
if (VIA_WINDOWPORT()) {
|
||||
bot_via_windowport();
|
||||
} else {
|
||||
@@ -254,7 +255,8 @@ bot()
|
||||
void
|
||||
timebot()
|
||||
{
|
||||
if (flags.time && iflags.status_updates) {
|
||||
if (flags.time && iflags.status_updates
|
||||
&& !g.program_state.saving && !g.program_state.restoring) {
|
||||
if (VIA_WINDOWPORT()) {
|
||||
stat_update_time();
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1606528765 2020/11/28 01:59:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.307 $ */
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1606765212 2020/11/30 19:40:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.308 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2496,7 +2496,7 @@ learn_unseen_invent()
|
||||
void
|
||||
update_inventory()
|
||||
{
|
||||
if (g.restoring)
|
||||
if (g.program_state.saving || g.program_state.restoring)
|
||||
return;
|
||||
|
||||
/*
|
||||
|
||||
38
src/objnam.c
38
src/objnam.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 objnam.c $NHDT-Date: 1604745123 2020/11/07 10:32:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.305 $ */
|
||||
/* NetHack 3.7 objnam.c $NHDT-Date: 1606765213 2020/11/30 19:40:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.307 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1293,8 +1293,8 @@ unsigned doname_flags;
|
||||
/* treat 'restoring' like suppress_price because shopkeeper and
|
||||
bill might not be available yet while restore is in progress
|
||||
(objects won't normally be formatted during that time, but if
|
||||
'perm_invent' is enabled then they might be) */
|
||||
if (iflags.suppress_price || g.restoring) {
|
||||
'perm_invent' is enabled then they might be [not any more...]) */
|
||||
if (iflags.suppress_price || g.program_state.restoring) {
|
||||
; /* don't attempt to obtain any shop pricing, even if 'with_price' */
|
||||
} else if (is_unpaid(obj)) { /* in inventory or in container in invent */
|
||||
long quotedprice = unpaid_cost(obj, TRUE);
|
||||
@@ -3261,10 +3261,11 @@ char *bp;
|
||||
struct _readobjnam_data *d;
|
||||
{
|
||||
d->cnt = d->spe = d->spesgn = d->typ = 0;
|
||||
d->very = d->rechrg = d->blessed = d->uncursed = d->iscursed = d->ispoisoned =
|
||||
d->isgreased = d->eroded = d->eroded2 = d->erodeproof = d->halfeaten =
|
||||
d->islit = d->unlabeled = d->ishistoric = d->isdiluted = d->trapped =
|
||||
d->locked = d->unlocked = d->broken = d->real = d->fake = 0;
|
||||
d->very = d->rechrg = d->blessed = d->uncursed = d->iscursed
|
||||
= d->ispoisoned = d->isgreased = d->eroded = d->eroded2
|
||||
= d->erodeproof = d->halfeaten = d->islit = d->unlabeled
|
||||
= d->ishistoric = d->isdiluted = d->trapped = d->locked
|
||||
= d->unlocked = d->broken = d->real = d->fake = 0;
|
||||
d->tvariety = RANDOM_TIN;
|
||||
d->mntmp = NON_PM;
|
||||
d->contents = UNDEFINED;
|
||||
@@ -4078,13 +4079,12 @@ readobjnam(bp, no_wish)
|
||||
register char *bp;
|
||||
struct obj *no_wish;
|
||||
{
|
||||
register char *p;
|
||||
struct _readobjnam_data d;
|
||||
|
||||
readobjnam_init(bp, &d);
|
||||
|
||||
if (!bp)
|
||||
goto any;
|
||||
|
||||
/* first, remove extra whitespace they may have typed */
|
||||
(void) mungspaces(bp);
|
||||
/* allow wishing for "nothing" to preserve wishless conduct...
|
||||
@@ -4145,7 +4145,7 @@ struct obj *no_wish;
|
||||
wiztrap:
|
||||
if (wizard && !g.program_state.wizkit_wishing) {
|
||||
/* [inline code moved to separate routine to unclutter readobjnam] */
|
||||
if ((d.otmp = wizterrainwish(d.bp, p, d.locked, d.trapped)) != 0)
|
||||
if ((d.otmp = wizterrainwish(d.bp, d.p, d.locked, d.trapped)) != 0)
|
||||
return d.otmp;
|
||||
}
|
||||
|
||||
@@ -4196,7 +4196,8 @@ struct obj *no_wish;
|
||||
|
||||
/* if asking for corpse of a monster which leaves behind a glob, give
|
||||
glob instead of rejecting the monster type to create random corpse */
|
||||
if (d.typ == CORPSE && d.mntmp >= LOW_PM && mons[d.mntmp].mlet == S_PUDDING) {
|
||||
if (d.typ == CORPSE && d.mntmp >= LOW_PM
|
||||
&& mons[d.mntmp].mlet == S_PUDDING) {
|
||||
d.typ = GLOB_OF_GRAY_OOZE + (d.mntmp - PM_GRAY_OOZE);
|
||||
d.mntmp = NON_PM; /* not used for globs */
|
||||
}
|
||||
@@ -4206,8 +4207,9 @@ struct obj *no_wish;
|
||||
d.otmp = d.typ ? mksobj(d.typ, TRUE, FALSE) : mkobj(d.oclass, FALSE);
|
||||
d.typ = d.otmp->otyp, d.oclass = d.otmp->oclass; /* what we actually got */
|
||||
|
||||
if (d.islit && (d.typ == OIL_LAMP || d.typ == MAGIC_LAMP || d.typ == BRASS_LANTERN
|
||||
|| Is_candle(d.otmp) || d.typ == POT_OIL)) {
|
||||
if (d.islit && (d.typ == OIL_LAMP || d.typ == MAGIC_LAMP
|
||||
|| d.typ == BRASS_LANTERN
|
||||
|| Is_candle(d.otmp) || d.typ == POT_OIL)) {
|
||||
place_object(d.otmp, u.ux, u.uy); /* make it viable light source */
|
||||
begin_burn(d.otmp, FALSE);
|
||||
obj_extract_self(d.otmp); /* now release it for caller's use */
|
||||
@@ -4348,7 +4350,8 @@ struct obj *no_wish;
|
||||
case SCALE_MAIL:
|
||||
/* Dragon mail - depends on the order of objects & dragons. */
|
||||
if (d.mntmp >= PM_GRAY_DRAGON && d.mntmp <= PM_YELLOW_DRAGON)
|
||||
d.otmp->otyp = GRAY_DRAGON_SCALE_MAIL + d.mntmp - PM_GRAY_DRAGON;
|
||||
d.otmp->otyp = GRAY_DRAGON_SCALE_MAIL
|
||||
+ d.mntmp - PM_GRAY_DRAGON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4380,7 +4383,8 @@ struct obj *no_wish;
|
||||
* armor modified by confused reading of cursed destroy armor)
|
||||
* so don't prevent player from wishing for such a combination.
|
||||
*/
|
||||
if (d.erodeproof && (is_damageable(d.otmp) || d.otmp->otyp == CRYSKNIFE))
|
||||
if (d.erodeproof
|
||||
&& (is_damageable(d.otmp) || d.otmp->otyp == CRYSKNIFE))
|
||||
d.otmp->oerodeproof = (Luck >= 0 || wizard);
|
||||
}
|
||||
|
||||
@@ -4431,8 +4435,8 @@ struct obj *no_wish;
|
||||
if (d.isgreased)
|
||||
d.otmp->greased = 1;
|
||||
|
||||
if (d.isdiluted && d.otmp->oclass == POTION_CLASS && d.otmp->otyp != POT_WATER)
|
||||
d.otmp->odiluted = 1;
|
||||
if (d.isdiluted && d.otmp->oclass == POTION_CLASS)
|
||||
d.otmp->odiluted = (d.otmp->otyp != POT_WATER);
|
||||
|
||||
/* set tin variety */
|
||||
if (d.otmp->otyp == TIN && d.tvariety >= 0 && (rn2(4) || wizard))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 restore.c $NHDT-Date: 1605305492 2020/11/13 22:11:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.171 $ */
|
||||
/* NetHack 3.7 restore.c $NHDT-Date: 1606765214 2020/11/30 19:40:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.173 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -643,9 +643,9 @@ unsigned int *stuckid, *steedid;
|
||||
while (bc_obj) {
|
||||
struct obj *nobj = bc_obj->nobj;
|
||||
|
||||
bc_obj->nobj = (struct obj *) 0;
|
||||
if (bc_obj->owornmask)
|
||||
setworn(bc_obj, bc_obj->owornmask);
|
||||
bc_obj->nobj = (struct obj *) 0;
|
||||
bc_obj = nobj;
|
||||
}
|
||||
g.migrating_objs = restobjchn(nhfp, FALSE);
|
||||
@@ -771,7 +771,7 @@ NHFILE *nhfp;
|
||||
int rtmp;
|
||||
struct obj *otmp;
|
||||
|
||||
g.restoring = TRUE;
|
||||
g.program_state.restoring = 1;
|
||||
get_plname_from_file(nhfp, g.plname);
|
||||
getlev(nhfp, 0, (xchar) 0);
|
||||
if (!restgamestate(nhfp, &stuckid, &steedid)) {
|
||||
@@ -786,7 +786,7 @@ NHFILE *nhfp;
|
||||
is not really affiliated with an open file */
|
||||
close_nhfile(nhfp);
|
||||
(void) delete_savefile();
|
||||
g.restoring = FALSE;
|
||||
g.program_state.restoring = 0;
|
||||
return 0;
|
||||
}
|
||||
restlevelstate(stuckid, steedid);
|
||||
@@ -895,8 +895,8 @@ NHFILE *nhfp;
|
||||
g.vision_full_recalc = 1; /* recompute vision (not saved) */
|
||||
|
||||
run_timers(); /* expire all timers that have gone off while away */
|
||||
g.program_state.restoring = 0; /* affects bot() so clear before docrt() */
|
||||
docrt();
|
||||
g.restoring = FALSE;
|
||||
clear_nhwindow(WIN_MESSAGE);
|
||||
|
||||
/* Success! */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 sfstruct.c $NHDT-Date: 1593953360 2020/07/05 12:49:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $ */
|
||||
/* NetHack 3.7 sfstruct.c $NHDT-Date: 1606765215 2020/11/30 19:40:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.4 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -75,8 +75,8 @@ static FILE *bw_FILE[MAXFD] = {0,0,0,0,0};
|
||||
* Some notes:
|
||||
*
|
||||
* Once buffered IO (stdio) has been enabled on the file
|
||||
* associated with a descriptor via fdopen():
|
||||
*
|
||||
* associated with a descriptor via fdopen():
|
||||
*
|
||||
* 1. If you use bufoff and bufon to try and toggle the
|
||||
* use of write vs fwrite; the code just tracks which
|
||||
* routine is to be called through the tracking
|
||||
@@ -86,7 +86,7 @@ static FILE *bw_FILE[MAXFD] = {0,0,0,0,0};
|
||||
* if it is a free slot.
|
||||
* bw_buffered[] - indicator that buffered IO routines
|
||||
* are available for use.
|
||||
* bw_FILE[] - the non-zero FILE * for use in calling
|
||||
* bw_FILE[] - the non-zero FILE * for use in calling
|
||||
* fwrite() when bw_buffered[] is also
|
||||
* non-zero.
|
||||
*
|
||||
@@ -265,7 +265,7 @@ register unsigned int len;
|
||||
return;
|
||||
} else {
|
||||
pline("Read %d instead of %u bytes.", rlen, len);
|
||||
if (g.restoring) {
|
||||
if (g.program_state.restoring) {
|
||||
(void) nhclose(fd);
|
||||
(void) delete_savefile();
|
||||
error("Error restoring old game.");
|
||||
@@ -291,7 +291,7 @@ int fd;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
bufon(fd);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ int fd;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
bufoff(fd);
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ int fd;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
bflush(fd);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ register unsigned num;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
bwrite(fd, loc, num);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ int fd;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
bclose(fd);
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ register unsigned int len;
|
||||
const char *fncname;
|
||||
int linenum;
|
||||
{
|
||||
TRACE(fd);
|
||||
TRACE(fd);
|
||||
mread(fd, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -76,7 +76,6 @@ extern int attrib_text_normal; /* text mode normal attribute */
|
||||
extern int attrib_gr_normal; /* graphics mode normal attribute */
|
||||
extern int attrib_gr_intense; /* graphics mode intense attribute */
|
||||
extern boolean inmap; /* in the map window */
|
||||
/* extern boolean g.restoring; */
|
||||
|
||||
/*
|
||||
* Global Variables
|
||||
@@ -786,7 +785,7 @@ int x, y;
|
||||
clipymax = ROWNO - 1;
|
||||
}
|
||||
if (clipx != oldx || clipy != oldy) {
|
||||
if (on_level(&u.uz0, &u.uz) && !g.restoring)
|
||||
if (on_level(&u.uz0, &u.uz) && !g.program_state.restoring)
|
||||
/* (void) doredraw(); */
|
||||
vesa_redrawmap();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 vidvga.c $NHDT-Date: 1596498278 2020/08/03 23:44:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.25 $ */
|
||||
/* NetHack 3.7 vidvga.c $NHDT-Date: 1606765216 2020/11/30 19:40:16 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.26 $ */
|
||||
/* Copyright (c) NetHack PC Development Team 1995 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
/*
|
||||
@@ -430,7 +430,6 @@ static void
|
||||
vga_cliparound(x, y)
|
||||
int x, y;
|
||||
{
|
||||
/* extern boolean g.restoring; */
|
||||
int oldx = clipx;
|
||||
|
||||
if (!iflags.tile_view || iflags.over_view || iflags.traditional_view)
|
||||
@@ -444,7 +443,7 @@ int x, y;
|
||||
clipx = clipxmax - (viewport_size - 1);
|
||||
}
|
||||
if (clipx != oldx) {
|
||||
if (on_level(&u.uz0, &u.uz) && !g.restoring)
|
||||
if (on_level(&u.uz0, &u.uz) && !g.program_state.restoring)
|
||||
/* (void) doredraw(); */
|
||||
vga_redrawmap(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user