]> granicus.if.org Git - nethack/commitdiff
remove an argument that is no longer necessary from a few functions
authornhmall <nhmall@nethack.org>
Mon, 3 Feb 2020 03:54:44 +0000 (22:54 -0500)
committernhmall <nhmall@nethack.org>
Mon, 3 Feb 2020 03:54:44 +0000 (22:54 -0500)
Passing a boolean 'ghostly' argument to some functions that are also passed
an NHFILE * is unnecessary now.

include/extern.h
src/bones.c
src/do.c
src/files.c
src/region.c
src/restore.c
src/save.c
src/timeout.c

index b43df085eb3b8ad4816a72a35997935ee97ebdc2..f08f922dfc884ed4a8b0c09218350b7992a5cd69 100644 (file)
@@ -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);
index 6816baa876e732a050679f5de36a61d0c35dfc44..623eeea29c28203af80e840a1852d6eade39f10d 100644 (file)
@@ -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
index d392cdbf3e574b089e4a95c8568f20d6317c8644..2a58939f20bd290d7b2f8948a45a698f19a3ea6d 100644 (file)
--- 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 */
index 82d6330df5a44f7404007b3355b3f6da7d844fe2..1ffe4ce820d57ae7142a2f30f16f06cbd0f3d3b8 100644 (file)
@@ -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;
index aca233561d8815f066a2bfe9e539d8734be80bf7..cb01de2768f1862ba130d0f0aef584e5eee68b1e 100644 (file)
@@ -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)
index 297080abca0e70129e3b13c8fa5c96d3ef8723ad..d2ca2177758317b19d7d0bff400a84bd0fb4e276 100644 (file)
@@ -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... */
index 55fcc8b73571913a0540c055ebf0635975de18e5..a8729f7355efa826d28646c132f0e4337c0d9602 100644 (file)
@@ -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) &ltmp, sizeof ltmp); /* level number*/
index 5ded819047490967f86b16d40c4ecfe77b139593..5388e876d9a4f637dd86ba8114872cbffef7e034 100644 (file)
@@ -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)