Subject: bin/8005: [PATCH] Adventure `saved' cleanup
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 07/15/1999 11:05:50
>Number:         8005
>Category:       bin
>Synopsis:       [PATCH] Adventure `saved' cleanup
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 15 11:05:00 1999
>Last-Modified:
>Originator:     Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD-current of 1999-06-28
>Environment:
[
System: Linux decomino 2.2.10 #1 Mon Jun 14 07:48:53 UTC 1999 i686 unknown
Architecture: i686
]
>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.

>How-To-Repeat:

>Fix:

diff -ruN netbsd/adventure/hdr.h linux/adventure/hdr.h
--- netbsd/adventure/hdr.h	Wed Feb 10 12:06:40 1999
+++ linux/adventure/hdr.h	Sat Feb 20 23:38:49 1999
@@ -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 -ruN netbsd/adventure/main.c linux/adventure/main.c
--- netbsd/adventure/main.c	Wed Feb 10 12:06:41 1999
+++ linux/adventure/main.c	Sat Feb 20 23:40:29 1999
@@ -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 -ruN netbsd/adventure/save.c linux/adventure/save.c
--- netbsd/adventure/save.c	Sun Sep 13 11:05:31 1998
+++ linux/adventure/save.c	Sat Jan  9 16:52:02 1999
@@ -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 -ruN netbsd/adventure/wizard.c linux/adventure/wizard.c
--- netbsd/adventure/wizard.c	Wed Feb 10 12:06:41 1999
+++ linux/adventure/wizard.c	Sat Feb 20 23:41:36 1999
@@ -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) {
>Audit-Trail:
>Unformatted: