#define POTION_OCCUPANT_CHANCE(n) (13 + 2 * (n))
#define WAND_BACKFIRE_CHANCE 100
#define BALL_IN_MON (u.uswallow && uball && uball->where == OBJ_FREE)
+#define CHAIN_IN_MON (u.uswallow && uchain && uchain->where == OBJ_FREE)
#define NODIAG(monnum) ((monnum) == PM_GRID_BUG)
/* Flags to control menus */
struct sysflag newgamesysflags;
#endif
struct context_info newgamecontext; /* all 0, but has some pointers */
- struct obj *otmp, *tmp_bc;
+ struct obj *otmp;
+ struct obj *bc_obj;
char timebuf[15];
unsigned long uid;
boolean defer_perm_invent;
restore_timers(fd, RANGE_GLOBAL, FALSE, 0L);
restore_light_sources(fd);
invent = restobjchn(fd, FALSE, FALSE);
- /* tmp_bc only gets set here if the ball & chain were orphaned
- because you were swallowed; otherwise they will be on the floor
- or in your inventory */
- tmp_bc = restobjchn(fd, FALSE, FALSE);
- if (tmp_bc) {
- for (otmp = tmp_bc; otmp; otmp = otmp->nobj) {
- if (otmp->owornmask)
- setworn(otmp, otmp->owornmask);
- }
- if (!uball || !uchain)
- impossible("restgamestate: lost ball & chain");
+
+ /* 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;
+ if (bc_obj->owornmask)
+ setworn(bc_obj, bc_obj->owornmask);
+ bc_obj->nobj = (struct obj *)0;
+ bc_obj = nobj;
}
migrating_objs = restobjchn(fd, FALSE, FALSE);
for (otmp = invent; otmp; otmp = otmp->nobj)
if (otmp->owornmask)
setworn(otmp, otmp->owornmask);
+
+ if ((uball && !uchain) || (uchain && !uball))
+ impossible("restgamestate: lost ball & chain");
+
/* reset weapon so that player will get a reminder about "bashing"
during next fight when bare-handed or wielding an unconventional
item; for pick-axe, we aren't able to distinguish between having
register int fd, mode;
{
unsigned long uid;
+ struct obj * bc_objs = (struct obj *)0;
#ifdef MFLOPPY
count_only = (mode & COUNT_SAVE);
save_light_sources(fd, mode, RANGE_GLOBAL);
saveobjchn(fd, invent, mode);
+
+ /* save ball and chain if they are currently dangling free (i.e. not on
+ floor or in inventory) */
+ if (CHAIN_IN_MON) {
+ uchain->nobj = bc_objs;
+ bc_objs = uchain;
+ }
if (BALL_IN_MON) {
- /* prevent loss of ball & chain when swallowed */
- uball->nobj = uchain;
- uchain->nobj = (struct obj *) 0;
- saveobjchn(fd, uball, mode);
- } else {
- saveobjchn(fd, (struct obj *) 0, mode);
+ uball->nobj = bc_objs;
+ bc_objs = uball;
}
+ saveobjchn(fd, bc_objs, mode);
saveobjchn(fd, migrating_objs, mode);
savemonchn(fd, migrating_mons, mode);