summaryrefslogtreecommitdiffstats
path: root/phantasia
diff options
context:
space:
mode:
authorjmc <jmc@NetBSD.org>2004-12-09 05:15:59 +0000
committerjmc <jmc@NetBSD.org>2004-12-09 05:15:59 +0000
commit4a8f378569210334d20eb525298086b7ea2eb672 (patch)
tree6f3b777f63a5fdca2370e27a17df4ba1219a297d /phantasia
parent0fbe5608ca10d704142f0c4b1c5b92a7ccde7379 (diff)
downloadbsdgames-darwin-4a8f378569210334d20eb525298086b7ea2eb672.tar.gz
bsdgames-darwin-4a8f378569210334d20eb525298086b7ea2eb672.tar.zst
bsdgames-darwin-4a8f378569210334d20eb525298086b7ea2eb672.zip
Redo how void gets init'd.
setup now just creates an empty file. When main starts and loads it in, it stats and if zero size init's a new location and saves it back out. Now games.tgz can be shared among MACHINE_ARCH's
Diffstat (limited to 'phantasia')
-rw-r--r--phantasia/main.c15
-rw-r--r--phantasia/setup.c19
2 files changed, 18 insertions, 16 deletions
diff --git a/phantasia/main.c b/phantasia/main.c
index b18b3240..9096e9f8 100644
--- a/phantasia/main.c
+++ b/phantasia/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.14 2004/04/11 13:35:06 he Exp $ */
+/* $NetBSD: main.c,v 1.15 2004/12/09 05:15:59 jmc Exp $ */
/*
* Phantasia 3.3.2 -- Interterminal fantasy game
@@ -27,6 +27,7 @@
* AT&T is in no way connected with this game.
*/
+#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
@@ -271,6 +272,8 @@ main(argc, argv)
void
initialstate()
{
+ struct stat sb;
+
Beyond = FALSE;
Marsh = FALSE;
Throne = FALSE;
@@ -302,6 +305,16 @@ initialstate()
if ((Energyvoidfp = fopen(_PATH_VOID, "r+")) == NULL)
error(_PATH_VOID);
+ if (fstat(fileno(Energyvoidfp), &sb) == -1)
+ error("stat");
+ if (sb.st_size == 0) {
+ /* initialize grail to new location */
+ Enrgyvoid.ev_active = TRUE;
+ Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
+ Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
+ writevoid(&Enrgyvoid, 0L);
+ }
+
/* NOTREACHED */
srandom((unsigned) time(NULL)); /* prime random numbers */
diff --git a/phantasia/setup.c b/phantasia/setup.c
index 8e7a3ed7..ea0aafa4 100644
--- a/phantasia/setup.c
+++ b/phantasia/setup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.13 2004/04/07 17:46:47 ross Exp $ */
+/* $NetBSD: setup.c,v 1.14 2004/12/09 05:15:59 jmc Exp $ */
/*
* setup.c - set up all files for Phantasia
@@ -109,21 +109,10 @@ main(argc, argv)
++filename; /* process next file */
}
- /* put holy grail info into energy void file */
- Enrgyvoid.ev_active = 1;
- Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
- Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
- path = strrchr(_PATH_VOID, '/') + 1;
+ /* Initialize an empty file placeholder for the grail location. */
if ((fp = fopen(path, "w")) == NULL)
- Error("Cannot update %s.\n", path);
- else
- {
- fwrite(&Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
- fflush(fp);
- if (ferror(fp))
- Error("Writing %s.\n", path);
- fclose(fp);
- }
+ Error("Cannot create %s.\n", path);
+ fclose(fp);
/* create binary monster data base */
path = strrchr(_PATH_MONST, '/') + 1;