-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
-----------------------------------
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
+
+
-/* 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. */
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;
-/* 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. */
* 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) {
-/* 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. */
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 {
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 {
-/* 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. */
void
update_inventory()
{
- if (g.restoring)
+ if (g.program_state.saving || g.program_state.restoring)
return;
/*
-/* 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. */
/* 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);
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;
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...
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;
}
/* 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 */
}
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 */
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;
}
}
* 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);
}
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))
-/* 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. */
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);
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)) {
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);
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! */
-/* 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. */
* 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
* 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.
*
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.");
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
bufon(fd);
}
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
bufoff(fd);
}
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
bflush(fd);
}
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
bwrite(fd, loc, num);
}
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
bclose(fd);
}
const char *fncname;
int linenum;
{
- TRACE(fd);
+ TRACE(fd);
mread(fd, buf, len);
}
#endif
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
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();
}
-/* 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. */
/*
vga_cliparound(x, y)
int x, y;
{
-/* extern boolean g.restoring; */
int oldx = clipx;
if (!iflags.tile_view || iflags.over_view || iflags.traditional_view)
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);
}