ball&chain bit
A check for bad restoration (ball without chain or vice versa) issued a warning but then left the problem around to trip up other code. 'Fix' the problem by clearing those owornmask slots and their pointers. Doesn't try to recover memory if the one that's found is OBJ_FREE. Also some formatting.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 read.c $NHDT-Date: 1560085864 2019/06/09 13:11:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.171 $ */
|
||||
/* NetHack 3.6 read.c $NHDT-Date: 1561485713 2019/06/25 18:01:53 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.172 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2391,12 +2391,14 @@ unpunish()
|
||||
{
|
||||
struct obj *savechain = uchain;
|
||||
|
||||
/* chain goes away */
|
||||
obj_extract_self(uchain);
|
||||
newsym(uchain->ox, uchain->oy);
|
||||
setworn((struct obj *) 0, W_CHAIN);
|
||||
setworn((struct obj *) 0, W_CHAIN); /* sets 'uchain' to Null */
|
||||
dealloc_obj(savechain);
|
||||
/* ball persists */
|
||||
uball->spe = 0;
|
||||
setworn((struct obj *) 0, W_BALL);
|
||||
setworn((struct obj *) 0, W_BALL); /* sets 'uball' to Null */
|
||||
}
|
||||
|
||||
/* some creatures have special data structures that only make sense in their
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 restore.c $NHDT-Date: 1555201698 2019/04/14 00:28:18 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */
|
||||
/* NetHack 3.6 restore.c $NHDT-Date: 1561485720 2019/06/25 18:02:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.131 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -647,17 +647,18 @@ unsigned int *stuckid, *steedid;
|
||||
|
||||
/* restore dangling (not on floor or in inventory) ball and/or chain */
|
||||
bc_obj = restobjchn(fd, FALSE, FALSE);
|
||||
while(bc_obj) {
|
||||
struct obj * nobj = bc_obj->nobj;
|
||||
while (bc_obj) {
|
||||
struct obj *nobj = bc_obj->nobj;
|
||||
|
||||
if (bc_obj->owornmask)
|
||||
setworn(bc_obj, bc_obj->owornmask);
|
||||
bc_obj->nobj = (struct obj *)0;
|
||||
bc_obj->nobj = (struct obj *) 0;
|
||||
bc_obj = nobj;
|
||||
}
|
||||
|
||||
migrating_objs = restobjchn(fd, FALSE, FALSE);
|
||||
migrating_mons = restmonchn(fd, FALSE);
|
||||
mread(fd, (genericptr_t) mvitals, sizeof(mvitals));
|
||||
mread(fd, (genericptr_t) mvitals, sizeof mvitals);
|
||||
|
||||
/*
|
||||
* There are some things after this that can have unintended display
|
||||
@@ -671,8 +672,12 @@ unsigned int *stuckid, *steedid;
|
||||
if (otmp->owornmask)
|
||||
setworn(otmp, otmp->owornmask);
|
||||
|
||||
if ((uball && !uchain) || (uchain && !uball))
|
||||
if ((uball && !uchain) || (uchain && !uball)) {
|
||||
impossible("restgamestate: lost ball & chain");
|
||||
/* poor man's unpunish() */
|
||||
setworn((struct obj *) 0, W_CHAIN);
|
||||
setworn((struct obj *) 0, W_BALL);
|
||||
}
|
||||
|
||||
/* reset weapon so that player will get a reminder about "bashing"
|
||||
during next fight when bare-handed or wielding an unconventional
|
||||
|
||||
Reference in New Issue
Block a user