From 1dfab5fe11290d3dca05ebce462233df0dd44e03 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 2 Feb 2020 22:54:44 -0500 Subject: [PATCH] remove an argument that is no longer necessary from a few functions Passing a boolean 'ghostly' argument to some functions that are also passed an NHFILE * is unnecessary now. --- include/extern.h | 6 ++--- src/bones.c | 2 +- src/do.c | 2 +- src/files.c | 9 ++------ src/region.c | 4 ++-- src/restore.c | 57 ++++++++++++++++++++++++------------------------ src/save.c | 2 +- src/timeout.c | 6 ++--- 8 files changed, 42 insertions(+), 46 deletions(-) diff --git a/include/extern.h b/include/extern.h index b43df085e..f08f922df 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2180,7 +2180,7 @@ E void FDECL(update_monster_region, (struct monst *)); E NhRegion *FDECL(visible_region_at, (XCHAR_P, XCHAR_P)); E void FDECL(show_region, (NhRegion *, XCHAR_P, XCHAR_P)); E void FDECL(save_regions, (NHFILE *)); -E void FDECL(rest_regions, (NHFILE *, BOOLEAN_P)); +E void FDECL(rest_regions, (NHFILE *)); E void FDECL(region_stats, (const char *, char *, long *, long *)); E NhRegion *FDECL(create_gas_cloud, (XCHAR_P, XCHAR_P, int, int)); E boolean NDECL(region_danger); @@ -2192,7 +2192,7 @@ E void FDECL(inven_inuse, (BOOLEAN_P)); E int FDECL(dorecover, (NHFILE *)); E void FDECL(restcemetery, (NHFILE *, struct cemetery **)); E void FDECL(trickery, (char *)); -E void FDECL(getlev, (NHFILE *, int, XCHAR_P, BOOLEAN_P)); +E void FDECL(getlev, (NHFILE *, int, XCHAR_P)); E void FDECL(get_plname_from_file, (NHFILE *, char *)); #ifdef SELECTSAVED E int FDECL(restore_menu, (winid)); @@ -2584,7 +2584,7 @@ E long FDECL(spot_time_expires, (XCHAR_P, XCHAR_P, SHORT_P)); E long FDECL(spot_time_left, (XCHAR_P, XCHAR_P, SHORT_P)); E boolean FDECL(obj_is_local, (struct obj *)); E void FDECL(save_timers, (NHFILE *, int)); -E void FDECL(restore_timers, (NHFILE *, int, BOOLEAN_P, long)); +E void FDECL(restore_timers, (NHFILE *, int, long)); E void FDECL(timer_stats, (const char *, char *, long *, long *)); E void FDECL(relink_timers, (BOOLEAN_P)); E int NDECL(wiz_timeout_queue); diff --git a/src/bones.c b/src/bones.c index 6816baa87..623eeea29 100644 --- a/src/bones.c +++ b/src/bones.c @@ -645,7 +645,7 @@ getbones() } else { register struct monst *mtmp; - getlev(nhfp, 0, 0, TRUE); + getlev(nhfp, 0, 0); /* Note that getlev() now keeps tabs on unique * monsters such as demon lords, and tracks the diff --git a/src/do.c b/src/do.c index d392cdbf3..2a58939f2 100644 --- a/src/do.c +++ b/src/do.c @@ -1479,7 +1479,7 @@ boolean at_stairs, falling, portal; reseed_random(rn2); reseed_random(rn2_on_display_rng); minit(); /* ZEROCOMP */ - getlev(nhfp, g.hackpid, new_ledger, FALSE); + getlev(nhfp, g.hackpid, new_ledger); /* when in wizard mode, it is possible to leave from and return to any level in the endgame; above, we discarded bubble/cloud info when leaving Plane of Water or Air so recreate some now */ diff --git a/src/files.c b/src/files.c index 82d6330df..1ffe4ce82 100644 --- a/src/files.c +++ b/src/files.c @@ -1101,12 +1101,7 @@ create_savefile() nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = WRITING; -#ifdef SYSCF - if (sysopt.saveformat[0] > historical && - sysopt.saveformat[0] <= ascii) - do_historical = FALSE; -#endif /* SYSCF */ - if (g.program_state.in_self_recover) { + if (g.program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; @@ -1162,7 +1157,7 @@ open_savefile() nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = READING; - if (g.program_state.in_self_recover) { + if (g.program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; diff --git a/src/region.c b/src/region.c index aca233561..cb01de276 100644 --- a/src/region.c +++ b/src/region.c @@ -702,14 +702,14 @@ NHFILE *nhfp; } void -rest_regions(nhfp, ghostly) +rest_regions(nhfp) NHFILE *nhfp; -boolean ghostly; /* If a bones file restore */ { int i, j; unsigned n = 0; long tmstamp = 0L; char *msg_buf; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); clear_regions(); /* Just for security */ if (nhfp->structlevel) diff --git a/src/restore.c b/src/restore.c index 297080abc..d2ca21777 100644 --- a/src/restore.c +++ b/src/restore.c @@ -23,11 +23,11 @@ static int NDECL(zerocomp_mgetc); static void NDECL(find_lev_obj); static void FDECL(restlevchn, (NHFILE *)); -static void FDECL(restdamage, (NHFILE *, BOOLEAN_P)); +static void FDECL(restdamage, (NHFILE *)); static void FDECL(restobj, (NHFILE *, struct obj *)); -static struct obj *FDECL(restobjchn, (NHFILE *, BOOLEAN_P, BOOLEAN_P)); +static struct obj *FDECL(restobjchn, (NHFILE *, BOOLEAN_P)); static void FDECL(restmon, (NHFILE *, struct monst *)); -static struct monst *FDECL(restmonchn, (NHFILE *, BOOLEAN_P)); +static struct monst *FDECL(restmonchn, (NHFILE *)); static struct fruit *FDECL(loadfruitchn, (NHFILE *)); static void FDECL(freefruitchn, (struct fruit *)); static void FDECL(ghostfruit, (struct obj *)); @@ -142,13 +142,13 @@ NHFILE *nhfp; } static void -restdamage(nhfp, ghostly) +restdamage(nhfp) NHFILE *nhfp; -boolean ghostly; { unsigned int dmgcount = 0; int counter; struct damage *tmp_dam; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) &dmgcount, sizeof(dmgcount)); @@ -263,13 +263,14 @@ struct obj *otmp; } static struct obj * -restobjchn(nhfp, ghostly, frozen) +restobjchn(nhfp, frozen) NHFILE *nhfp; -boolean ghostly, frozen; +boolean frozen; { register struct obj *otmp, *otmp2 = 0; register struct obj *first = (struct obj *) 0; int buflen = 0; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); while (1) { if (nhfp->structlevel) @@ -303,7 +304,7 @@ boolean ghostly, frozen; if (Has_contents(otmp)) { struct obj *otmp3; - otmp->cobj = restobjchn(nhfp, ghostly, Is_IceBox(otmp)); + otmp->cobj = restobjchn(nhfp, Is_IceBox(otmp)); /* restore container back pointers */ for (otmp3 = otmp->cobj; otmp3; otmp3 = otmp3->nobj) otmp3->ocontainer = otmp; @@ -424,13 +425,13 @@ struct monst *mtmp; } static struct monst * -restmonchn(nhfp, ghostly) +restmonchn(nhfp) NHFILE *nhfp; -boolean ghostly; { register struct monst *mtmp, *mtmp2 = 0; register struct monst *first = (struct monst *) 0; int offset, buflen = 0; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); while (1) { if (nhfp->structlevel) @@ -461,7 +462,7 @@ boolean ghostly; } if (mtmp->minvent) { struct obj *obj; - mtmp->minvent = restobjchn(nhfp, ghostly, FALSE); + mtmp->minvent = restobjchn(nhfp, FALSE); /* restore monster back pointer */ for (obj = mtmp->minvent; obj; obj = obj->nobj) obj->ocarry = mtmp; @@ -679,13 +680,13 @@ unsigned int *stuckid, *steedid; /* this stuff comes after potential aborted restore attempts */ restore_killers(nhfp); - restore_timers(nhfp, RANGE_GLOBAL, FALSE, 0L); + restore_timers(nhfp, RANGE_GLOBAL, 0L); restore_light_sources(nhfp); - g.invent = restobjchn(nhfp, FALSE, FALSE); + g.invent = restobjchn(nhfp, FALSE); /* restore dangling (not on floor or in inventory) ball and/or chain */ - bc_obj = restobjchn(nhfp, FALSE, FALSE); + bc_obj = restobjchn(nhfp, FALSE); while (bc_obj) { struct obj *nobj = bc_obj->nobj; @@ -694,8 +695,8 @@ unsigned int *stuckid, *steedid; bc_obj->nobj = (struct obj *) 0; bc_obj = nobj; } - g.migrating_objs = restobjchn(nhfp, FALSE, FALSE); - g.migrating_mons = restmonchn(nhfp, FALSE); + g.migrating_objs = restobjchn(nhfp, FALSE); + g.migrating_mons = restmonchn(nhfp); if (nhfp->structlevel) { mread(nhfp->fd, (genericptr_t) g.mvitals, sizeof g.mvitals); @@ -863,7 +864,7 @@ NHFILE *nhfp; g.restoring = TRUE; get_plname_from_file(nhfp, g.plname); - getlev(nhfp, 0, (xchar) 0, FALSE); + getlev(nhfp, 0, (xchar) 0); if (!restgamestate(nhfp, &stuckid, &steedid)) { NHFILE tnhfp; @@ -925,7 +926,7 @@ NHFILE *nhfp; if (restoreinfo.mread_flags == -1) break; } - getlev(nhfp, 0, ltmp, FALSE); + getlev(nhfp, 0, ltmp); #ifdef MICRO curs(WIN_MAP, 1 + dotcnt++, dotrow); if (dotcnt >= (COLNO - 1)) { @@ -946,7 +947,7 @@ NHFILE *nhfp; (void) validate(nhfp, (char *) 0); get_plname_from_file(nhfp, g.plname); - getlev(nhfp, 0, (xchar) 0, FALSE); + getlev(nhfp, 0, (xchar) 0); close_nhfile(nhfp); restlevelstate(stuckid, steedid); g.program_state.something_worth_saving = 1; /* useful data now exists */ @@ -1076,11 +1077,10 @@ char *reason; } void -getlev(nhfp, pid, lev, ghostly) +getlev(nhfp, pid, lev) NHFILE *nhfp; int pid; xchar lev; -boolean ghostly; { register struct trap *trap; register struct monst *mtmp; @@ -1089,6 +1089,7 @@ boolean ghostly; int hpid = 0; xchar dlvl = 0; int x, y; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); #ifdef TOS short tlev; #endif @@ -1157,9 +1158,9 @@ boolean ghostly; else g.doorindex = 0; - restore_timers(nhfp, RANGE_LEVEL, ghostly, elapsed); + restore_timers(nhfp, RANGE_LEVEL, elapsed); restore_light_sources(nhfp); - fmon = restmonchn(nhfp, ghostly); + fmon = restmonchn(nhfp); /* rest_worm(fd); */ /* restore worm information */ rest_worm(nhfp); /* restore worm information */ @@ -1177,12 +1178,12 @@ boolean ghostly; } dealloc_trap(trap); - fobj = restobjchn(nhfp, ghostly, FALSE); + fobj = restobjchn(nhfp, FALSE); find_lev_obj(); /* restobjchn()'s `frozen' argument probably ought to be a callback routine so that we can check for objects being buried under ice */ - g.level.buriedobjlist = restobjchn(nhfp, ghostly, FALSE); - g.billobjs = restobjchn(nhfp, ghostly, FALSE); + g.level.buriedobjlist = restobjchn(nhfp, FALSE); + g.billobjs = restobjchn(nhfp, FALSE); rest_engravings(nhfp); /* reset level.monsters for new level */ @@ -1219,8 +1220,8 @@ boolean ghostly; if (ghostly || (elapsed > 00 && elapsed > (long) rnd(10))) hide_monst(mtmp); } - restdamage(nhfp, ghostly); - rest_regions(nhfp, ghostly); + restdamage(nhfp); + rest_regions(nhfp); if (ghostly) { /* Now get rid of all the temp fruits... */ diff --git a/src/save.c b/src/save.c index 55fcc8b73..a8729f735 100644 --- a/src/save.c +++ b/src/save.c @@ -245,7 +245,7 @@ dosave0() return 0; } minit(); /* ZEROCOMP */ - getlev(onhfp, g.hackpid, ltmp, FALSE); + getlev(onhfp, g.hackpid, ltmp); close_nhfile(onhfp); if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) <mp, sizeof ltmp); /* level number*/ diff --git a/src/timeout.c b/src/timeout.c index 5ded81904..5388e876d 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1658,7 +1658,7 @@ do_storms() * are saved with a level. Object and monster timers are * saved using their respective id's instead of pointers. * - * void restore_timers(NHFILE *, int range, boolean ghostly, long adjust) + * void restore_timers(NHFILE *, int range, long adjust) * Restore timers of range 'range'. If from a ghost pile, * adjust the timeout by 'adjust'. The object and monster * ids are not restored until later. @@ -2360,14 +2360,14 @@ int range; * monster pointers. */ void -restore_timers(nhfp, range, ghostly, adjust) +restore_timers(nhfp, range, adjust) NHFILE *nhfp; int range; -boolean ghostly; /* restoring from a ghost level */ long adjust; /* how much to adjust timeout */ { int count = 0; timer_element *curr; + boolean ghostly = (nhfp->ftype == NHF_BONESFILE); /* from a ghost level */ if (range == RANGE_GLOBAL) { if (nhfp->structlevel)