lost ball and chain (trunk only)

Saving the game while punished, not carrying the attached ball,
and while swallowed by a purple worm resulted in losing the
ball and chain.

Since the required information was not being written to the
save file at all, I couldn't come up with a clean way to do this
for the branch, and preserve save file format. I could think
of lots of kludgy ways to do it (insert ball and chain into
the hero's inventory prior to saving, and remove it on restore, etc.)
This commit is contained in:
nethack.allison
2006-06-03 17:48:22 +00:00
parent d25ede0819
commit d046be66bc
5 changed files with 25 additions and 2 deletions

View File

@@ -511,7 +511,7 @@ unsigned int *stuckid, *steedid; /* STEED */
{
/* discover is actually flags.explore */
boolean remember_discover = discover;
struct obj *otmp;
struct obj *otmp, *tmp_bc;
int uid;
mread(fd, (genericptr_t) &uid, sizeof uid);
@@ -563,6 +563,19 @@ unsigned int *stuckid, *steedid; /* STEED */
#ifndef GOLDOBJ
put_gold_back(&invent, &u.ugold);
#endif
/* 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");
}
migrating_objs = restobjchn(fd, FALSE, FALSE);
migrating_mons = restmonchn(fd, FALSE);
mread(fd, (genericptr_t) mvitals, sizeof(mvitals));

View File

@@ -347,6 +347,13 @@ register int fd, mode;
if (!release_data(mode))
put_gold_back(&invent, &u.ugold);
#endif
if (BALL_IN_MON) {
/* prevent loss of ball & chain when swallowed */
uball->nobj = uchain;
uchain->nobj = (struct obj *)0;
saveobjchn(fd, uball, mode);
}
saveobjchn(fd, migrating_objs, mode);
savemonchn(fd, migrating_mons, mode);
if (release_data(mode)) {