summaryrefslogtreecommitdiffstats
path: root/phantasia
diff options
context:
space:
mode:
authorsimonb <simonb@NetBSD.org>2001-03-27 02:23:28 +0000
committersimonb <simonb@NetBSD.org>2001-03-27 02:23:28 +0000
commitbae50c403e053e5ef8d399f1adb6677e2c4fabf8 (patch)
treead61e58e0c87ee85362e899cdc03c25592f39846 /phantasia
parent00b8e31689c6400d8ad915067f021b8e246df989 (diff)
downloadbsdgames-darwin-bae50c403e053e5ef8d399f1adb6677e2c4fabf8.tar.gz
bsdgames-darwin-bae50c403e053e5ef8d399f1adb6677e2c4fabf8.tar.zst
bsdgames-darwin-bae50c403e053e5ef8d399f1adb6677e2c4fabf8.zip
Build the data files in the obj/compile directory and install them with
FILES and FILESDIR. "Problem" reported by David Querbach on current-users.
Diffstat (limited to 'phantasia')
-rw-r--r--phantasia/Makefile29
-rw-r--r--phantasia/setup.c34
2 files changed, 29 insertions, 34 deletions
diff --git a/phantasia/Makefile b/phantasia/Makefile
index 35afaa32..e7f31f06 100644
--- a/phantasia/Makefile
+++ b/phantasia/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.21 2000/06/20 16:07:04 matt Exp $
+# $NetBSD: Makefile,v 1.22 2001/03/27 02:23:28 simonb Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk> # for UNPRIVILEGED
@@ -12,9 +12,26 @@ HIDEGAME=hidegame
SETGIDGAME=yes
USETBL=
MAN= phantasia.6
-CLEANFILES+=map setup setup.lo host_phantglobs.lo
-realall: setup phantasia
+FILESDIR=/var/games/phantasia
+FILESOWN=games
+FILESGRP=games
+FILESMODE=0660
+ALLFILES=gold lastdead mess monsters void motd characs scoreboard
+FILES=gold lastdead mess monsters void motd
+# don't overwrite existing characters or scorefile
+.for file in characs scoreboard
+.if !exists(${DESTDIR}/${FILESDIR}/${file})
+FILES+=${file}
+.endif
+.endfor
+
+CLEANFILES+=map setup setup.lo host_phantglobs.lo ${ALLFILES}
+
+${PROG}: ${FILES}
+
+${FILES}: setup
+ ${.OBJDIR}/setup -m ${.CURDIR}/monsters.asc
setup: host_phantglobs.lo setup.lo monsters.asc ${LIBM}
${HOST_LINK.c} host_phantglobs.lo setup.lo -o ${.TARGET} -lm
@@ -25,12 +42,6 @@ host_phantglobs.lo: ${.CURDIR}/phantglobs.c
setup.lo: ${.CURDIR}/setup.c
${HOST_COMPILE.c} -o setup.lo ${.CURDIR}/setup.c
-afterinstall:
- DESTDIR=${DESTDIR} ./setup -m ${.CURDIR}/monsters.asc
-.if !defined(UNPRIVILEGED)
- chown games:games ${DESTDIR}/var/games/phantasia/*
-.endif
-
# Make Phantasia map. Change the map commands reflect your installation.
# PLOTDEVICE is used for plotting the map. Change as appropriate.
diff --git a/phantasia/setup.c b/phantasia/setup.c
index ab6e625a..6a1d4c0e 100644
--- a/phantasia/setup.c
+++ b/phantasia/setup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.10 1999/09/19 18:14:52 jsm Exp $ */
+/* $NetBSD: setup.c,v 1.11 2001/03/27 02:23:28 simonb Exp $ */
/*
* setup.c - set up all files for Phantasia
@@ -63,12 +63,12 @@ main(argc, argv)
int argc;
char *argv[];
{
- register const char *const *filename; /* for pointing to file names */
- register int fd; /* file descriptor */
- FILE *fp; /* for opening files */
+ const char *const *filename; /* for pointing to file names */
+ int fd; /* file descriptor */
+ FILE *fp; /* for opening files */
struct stat fbuf; /* for getting files statistics */
int ch;
- char path[MAXPATHLEN], *prefix;
+ char *path;
while ((ch = getopt(argc, argv, "m:")) != -1)
switch(ch) {
@@ -86,31 +86,15 @@ main(argc, argv)
umask(0117); /* only owner can read/write created files */
- prefix = getenv("DESTDIR");
-
/* try to create data files */
filename = &files[0];
while (*filename != NULL)
/* create each file */
{
- snprintf(path, sizeof(path), "%s%s", prefix?prefix:"", *filename);
+ path = strrchr(*filename, '/') + 1;
if (stat(path, &fbuf) == 0)
/* file exists; remove it */
{
- if (!strcmp(*filename, _PATH_PEOPLE))
- /* do not reset character file if it already exists */
- {
- ++filename;
- continue;
- }
-
- if (!strcmp(*filename, _PATH_SCORE))
- /* do not reset score file if it already exists */
- {
- ++filename;
- continue;
- }
-
if (unlink(path) < 0)
Error("Cannot unlink %s.\n", path);
/*NOTREACHED*/
@@ -129,7 +113,7 @@ main(argc, argv)
Enrgyvoid.ev_active = TRUE;
Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
- snprintf(path, sizeof(path), "%s%s", prefix?prefix:"", _PATH_VOID);
+ path = strrchr(_PATH_VOID, '/') + 1;
if ((fp = fopen(path, "w")) == NULL)
Error("Cannot update %s.\n", path);
else
@@ -142,7 +126,7 @@ main(argc, argv)
}
/* create binary monster data base */
- snprintf(path, sizeof(path), "%s%s", prefix?prefix:"", _PATH_MONST);
+ path = strrchr(_PATH_MONST, '/') + 1;
if ((Monstfp = fopen(path, "w")) == NULL)
Error("Cannot update %s.\n", path);
else
@@ -186,7 +170,7 @@ main(argc, argv)
printf("One line 'motd' ? ");
if (fgets(Databuf, SZ_DATABUF, stdin) == NULL)
Databuf[0] = '\0';
- snprintf(path, sizeof(path), "%s%s", prefix?prefix:"", _PATH_MOTD);
+ path = strrchr(_PATH_MOTD, '/') + 1;
if ((fp = fopen(path, "w")) == NULL)
Error("Cannot update %s.\n", path);
else