Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/adventure This patch cleans up the handling of the var...



details:   https://anonhg.NetBSD.org/src/rev/e67eacd6d7d3
branches:  trunk
changeset: 474689:e67eacd6d7d3
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Fri Jul 16 01:38:20 1999 +0000

description:
This patch cleans up the handling of the variable `saved' in
adventure(6).  The handling of this variable is somewhat confusing,
since it is used for two different purposes (controlling the time
required before a saved game can be restored, and controlling various
aspects of dwarf behaviour); in fact, it is also declared twice in
hdr.h.  Except possibly when saving a game fails, these uses can never
interfere; when used for controlling dwarf behaviour, we always have
saved == -1.  This can be better understood with reference to the
original PDP-10 FORTRAN source (URL in patch, since hdr.h references
the comments of the FORTRAN as still relevant to this version) of
which the C version is a direct translation: the wrong value for
`saved' meant that someone was cheating and had bypassed normal
initialisation.  Saving was done by halting and telling the user to
save their core image, so the question of carrying on after saving
failed to open the output file did not arise.

This patch separates the uses of `saved' into uses of two separate
variables.

Closes PR 8005 by Joseph Myers <jsm28%cam.ac.uk@localhost>

diffstat:

 games/adventure/hdr.h    |  7 +++++--
 games/adventure/main.c   |  6 +++---
 games/adventure/save.c   |  6 +++---
 games/adventure/wizard.c |  6 +++---
 4 files changed, 14 insertions(+), 11 deletions(-)

diffs (109 lines):

diff -r 240bb5f331c8 -r e67eacd6d7d3 games/adventure/hdr.h
--- a/games/adventure/hdr.h     Thu Jul 15 23:18:41 1999 +0000
+++ b/games/adventure/hdr.h     Fri Jul 16 01:38:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hdr.h,v 1.6 1999/02/10 00:11:28 hubertf Exp $  */
+/*     $NetBSD: hdr.h,v 1.7 1999/07/16 01:38:20 hubertf Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -51,6 +51,9 @@
  *
  * The data file distributed with the fortran source is assumed to be called
  * "glorkz" in the directory where the program is first run.
+ *
+ * The original FORTRAN version can be found at
+ * <URL:ftp://ftp.gmd.de/if-archive/games/source/advent-original.tar.gz>.
  */
 
 /* hdr.h: included by c advent files */
@@ -71,7 +74,7 @@
 char   *wd1, *wd2;             /* the complete words */
 int     verb, obj, spk;
 extern int blklin;
-int     saved, savet, mxscor, latncy;
+int     saveday, savet, mxscor, latncy;
 
 #define SHORT 50               /* How short is a demo game? */
 
diff -r 240bb5f331c8 -r e67eacd6d7d3 games/adventure/main.c
--- a/games/adventure/main.c    Thu Jul 15 23:18:41 1999 +0000
+++ b/games/adventure/main.c    Fri Jul 16 01:38:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.13 1999/02/10 00:29:21 hubertf Exp $        */
+/*     $NetBSD: main.c,v 1.14 1999/07/16 01:38:20 hubertf Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -48,7 +48,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/2/93";
 #else
-__RCSID("$NetBSD: main.c,v 1.13 1999/02/10 00:29:21 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 1999/07/16 01:38:20 hubertf Exp $");
 #endif
 #endif /* not lint */
 
@@ -451,7 +451,7 @@
                        printf(" %d minutes before continuing.", latncy);
                        if (!yes(200, 54, 54))
                                goto l2012;
-                       datime(&saved, &savet);
+                       datime(&saveday, &savet);
                        ciao(); /* Do we quit? */
                        continue;       /* Maybe not */
                case 31:        /* hours=8310 */
diff -r 240bb5f331c8 -r e67eacd6d7d3 games/adventure/save.c
--- a/games/adventure/save.c    Thu Jul 15 23:18:41 1999 +0000
+++ b/games/adventure/save.c    Fri Jul 16 01:38:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: save.c,v 1.5 1998/09/13 00:07:24 hubertf Exp $ */
+/*     $NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)save.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: save.c,v 1.5 1998/09/13 00:07:24 hubertf Exp $");
+__RCSID("$NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -95,7 +95,7 @@
        {&oldlc2, sizeof(oldlc2)},
        {&oldloc, sizeof(oldloc)},
        {&panic, sizeof(panic)},
-       {&saved, sizeof(saved)},
+       {&saveday, sizeof(saveday)},
        {&savet, sizeof(savet)},
        {&scorng, sizeof(scorng)},
        {&spk, sizeof(spk)},
diff -r 240bb5f331c8 -r e67eacd6d7d3 games/adventure/wizard.c
--- a/games/adventure/wizard.c  Thu Jul 15 23:18:41 1999 +0000
+++ b/games/adventure/wizard.c  Fri Jul 16 01:38:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wizard.c,v 1.9 1999/02/10 00:11:28 hubertf Exp $       */
+/*     $NetBSD: wizard.c,v 1.10 1999/07/16 01:38:20 hubertf Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)wizard.c   8.1 (Berkeley) 6/2/93";
 #else
-__RCSID("$NetBSD: wizard.c,v 1.9 1999/02/10 00:11:28 hubertf Exp $");
+__RCSID("$NetBSD: wizard.c,v 1.10 1999/07/16 01:38:20 hubertf Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -91,7 +91,7 @@
        int     d, t, delay;
 
        datime(&d, &t);
-       delay = (d - saved) * 1440 + (t - savet);       /* good for about a
+       delay = (d - saveday) * 1440 + (t - savet);     /* good for about a
                                                         * month     */
 
        if (delay >= latncy) {



Home | Main Index | Thread Index | Old Index