Fix dangling chain bug.

If a punished player picks up the iron ball, gets engulfed and
saves, then the saved game will have missed saving the dangling
chain since it was not on the floor or in the inventory.  Upon
restoring the saved game, the game will be in a bad state since
the ball will be worn but the chain will be missing.
This commit is contained in:
Bart House
2019-06-23 21:39:22 -07:00
parent 87be6fad43
commit ed08938ada
3 changed files with 28 additions and 19 deletions

View File

@@ -280,6 +280,7 @@ savegamestate(fd, mode)
register int fd, mode;
{
unsigned long uid;
struct obj * bc_objs = (struct obj *)0;
#ifdef MFLOPPY
count_only = (mode & COUNT_SAVE);
@@ -307,14 +308,18 @@ register int fd, mode;
save_light_sources(fd, mode, RANGE_GLOBAL);
saveobjchn(fd, invent, mode);
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);
/* 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) {
uball->nobj = bc_objs;
bc_objs = uball;
}
saveobjchn(fd, bc_objs, mode);
saveobjchn(fd, migrating_objs, mode);
savemonchn(fd, migrating_mons, mode);