mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 15:23:33 +02:00
Fix hack(6).
- Write savegames and scorefiles to the current directory instead of /var - Save oc_name and oc_descr alongside oc_uname in all situations - When a levitation potion times out, explicitly float down These patches were contributed last year by "tonypony76"; thanks! ok deraadt@, with added enthusiasm from tedu@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $OpenBSD: 4.4BSD.dist,v 1.308 2019/04/01 07:21:37 deraadt Exp $
|
||||
# $OpenBSD: 4.4BSD.dist,v 1.309 2019/04/05 09:02:27 bentley Exp $
|
||||
|
||||
/set type=dir uname=root gname=wheel mode=0755
|
||||
|
||||
@@ -433,6 +433,8 @@ usr
|
||||
..
|
||||
fortune
|
||||
..
|
||||
hack
|
||||
..
|
||||
quiz.db
|
||||
..
|
||||
..
|
||||
@@ -634,10 +636,6 @@ var
|
||||
|
||||
# ./var/games
|
||||
games uname=root gname=games mode=0775
|
||||
hackdir uname=root gname=games mode=0775
|
||||
save uname=root gname=games mode=0770
|
||||
..
|
||||
..
|
||||
save uname=root gname=games mode=0775
|
||||
..
|
||||
phantasia uname=root gname=games mode=0775
|
||||
|
||||
+2
-7
@@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.16 2017/07/10 21:30:37 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.17 2019/04/05 09:02:27 bentley Exp $
|
||||
|
||||
PROG= hack
|
||||
CFLAGS+=-I.
|
||||
@@ -27,12 +27,7 @@ makedefs: makedefs.c
|
||||
${HOSTCC} ${CFLAGS} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${.CURDIR}/${.PREFIX}.c ${LDADD}
|
||||
|
||||
beforeinstall:
|
||||
${INSTALL} ${INSTALL_COPY} -o root -g games -m 660 /dev/null \
|
||||
${DESTDIR}/var/games/hackdir/perm
|
||||
${INSTALL} ${INSTALL_COPY} -o root -g games -m 660 /dev/null \
|
||||
${DESTDIR}/var/games/hackdir/record
|
||||
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/help \
|
||||
${.CURDIR}/hh ${.CURDIR}/data ${DESTDIR}/var/games/hackdir
|
||||
rm -f ${DESTDIR}/var/games/hackdir/bones*
|
||||
${.CURDIR}/hh ${.CURDIR}/data ${.CURDIR}/rumors ${DESTDIR}/usr/share/games/hack
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: config.h,v 1.13 2015/10/16 07:37:46 tobias Exp $ */
|
||||
/* $OpenBSD: config.h,v 1.14 2019/04/05 09:02:27 bentley Exp $ */
|
||||
/* * $NetBSD: config.h,v 1.3 1995/03/23 08:29:15 cgd Exp $*/
|
||||
|
||||
/*
|
||||
@@ -77,10 +77,10 @@
|
||||
#define WIZARD "bruno" /* the person allowed to use the -D option */
|
||||
#define RECORD "record"/* the file containing the list of topscorers */
|
||||
#define NEWS "news" /* the file containing the latest hack news */
|
||||
#define HELP "help" /* the file containing a description of the commands */
|
||||
#define SHELP "hh" /* abbreviated form of the same */
|
||||
#define RUMORFILE "rumors" /* a file with fortune cookies */
|
||||
#define DATAFILE "data" /* a file giving the meaning of symbols used */
|
||||
#define HELP "/usr/share/games/hack/help" /* the file containing a description of the commands */
|
||||
#define SHELP "/usr/share/games/hack/hh" /* abbreviated form of the same */
|
||||
#define RUMORFILE "/usr/share/games/hack/rumors" /* a file with fortune cookies */
|
||||
#define DATAFILE "/usr/share/games/hack/data" /* a file giving the meaning of symbols used */
|
||||
#define FMASK 0660 /* file creation mask */
|
||||
#define HLOCK "perm" /* an empty file used for locking purposes */
|
||||
#define LLOCK "safelock" /* link to previous */
|
||||
@@ -93,7 +93,7 @@
|
||||
* (This might be preferable for security reasons.)
|
||||
* #define DEF_PAGER ".../mydir/mypager"
|
||||
*/
|
||||
#define DEF_PAGER _PATH_PAGER
|
||||
/* #define DEF_PAGER _PATH_PAGER */
|
||||
|
||||
/*
|
||||
* If you define MAIL, then the player will be notified of new mail
|
||||
@@ -120,7 +120,7 @@
|
||||
#ifdef QUEST
|
||||
#define HACKDIR _PATH_QUEST
|
||||
#else /* QUEST */
|
||||
#define HACKDIR _PATH_HACK
|
||||
/* #define HACKDIR _PATH_HACK */
|
||||
#endif /* QUEST */
|
||||
|
||||
/*
|
||||
@@ -130,7 +130,7 @@
|
||||
* since the user might create files in a directory of his choice.
|
||||
* Of course SECURE is meaningful only if HACKDIR is defined.
|
||||
*/
|
||||
#define SECURE /* do setuid(getuid()) after chdir() */
|
||||
/* #define SECURE */ /* do setuid(getuid()) after chdir() */
|
||||
|
||||
/*
|
||||
* If it is desirable to limit the number of people that can play Hack
|
||||
|
||||
+2
-12
@@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: hack.6,v 1.20 2016/09/09 15:32:28 tb Exp $
|
||||
.\" $OpenBSD: hack.6,v 1.21 2019/04/05 09:02:27 bentley Exp $
|
||||
.\" $NetBSD: hack.6,v 1.5 1995/07/03 19:44:30 jtc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -59,7 +59,7 @@
|
||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd $Mdocdate: September 9 2016 $
|
||||
.Dd $Mdocdate: April 5 2019 $
|
||||
.Dt HACK 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -75,13 +75,6 @@
|
||||
.Op Fl d Ar directory
|
||||
.Op Ar playername ...
|
||||
.Sh DESCRIPTION
|
||||
.Bf -symbolic
|
||||
.Nm
|
||||
is currently unusable because it relies on
|
||||
.Xr setgid 2
|
||||
to allow multiple users read and write access to the same files.
|
||||
.Ef
|
||||
.Pp
|
||||
.Nm
|
||||
is a display oriented dungeons & dragons - like game.
|
||||
Both display and command structure resemble rogue.
|
||||
@@ -121,9 +114,6 @@ This same directory contains several auxiliary files such as lockfiles and
|
||||
the list of topscorers and a subdirectory
|
||||
.Pa save
|
||||
where games are saved.
|
||||
The game administrator may however choose to install hack with a fixed
|
||||
playing ground, usually
|
||||
.Pa /var/games/hackdir .
|
||||
.Pp
|
||||
The
|
||||
.Fl n
|
||||
|
||||
+14
-2
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: hack.main.c,v 1.22 2016/01/09 21:54:11 mestre Exp $ */
|
||||
/* $OpenBSD: hack.main.c,v 1.23 2019/04/05 09:02:27 bentley Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -62,6 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -538,6 +539,8 @@ chdirx(char *dir, boolean wr)
|
||||
}
|
||||
|
||||
/* warn the player if he cannot write the record file */
|
||||
/* warn the player if he cannot read the permanent lock file */
|
||||
/* warn the player if he cannot create the save directory */
|
||||
/* perhaps we should also test whether . is writable */
|
||||
/* unfortunately the access systemcall is worthless */
|
||||
if(wr) {
|
||||
@@ -545,11 +548,20 @@ chdirx(char *dir, boolean wr)
|
||||
|
||||
if(dir == NULL)
|
||||
dir = ".";
|
||||
if((fd = open(RECORD, O_RDWR)) < 0) {
|
||||
if((fd = open(RECORD, O_RDWR | O_CREAT, FMASK)) < 0) {
|
||||
printf("Warning: cannot write %s/%s", dir, RECORD);
|
||||
getret();
|
||||
} else
|
||||
(void) close(fd);
|
||||
if((fd = open(HLOCK, O_RDONLY | O_CREAT, FMASK)) < 0) {
|
||||
printf("Warning: cannot read %s/%s", dir, HLOCK);
|
||||
getret();
|
||||
} else
|
||||
(void) close(fd);
|
||||
if(mkdir("save", 0770) && errno != EEXIST) {
|
||||
printf("Warning: cannot create %s/save", dir);
|
||||
getret();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: hack.o_init.c,v 1.8 2016/01/09 21:54:11 mestre Exp $ */
|
||||
/* $OpenBSD: hack.o_init.c,v 1.9 2019/04/05 09:02:27 bentley Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -173,18 +173,29 @@ savenames(int fd)
|
||||
{
|
||||
int i;
|
||||
unsigned len;
|
||||
unsigned zero = 0;
|
||||
|
||||
bwrite(fd, bases, sizeof bases);
|
||||
bwrite(fd, objects, sizeof objects);
|
||||
/* as long as we use only one version of Hack/Quest we
|
||||
need not save oc_name and oc_descr, but we must save
|
||||
oc_uname for all objects */
|
||||
for(i=0; i < SIZE(objects); i++) {
|
||||
if(objects[i].oc_name) {
|
||||
len = strlen(objects[i].oc_name)+1;
|
||||
bwrite(fd, &len, sizeof len);
|
||||
bwrite(fd, objects[i].oc_name, len);
|
||||
} else
|
||||
bwrite(fd, &zero, sizeof len);
|
||||
if(objects[i].oc_descr) {
|
||||
len = strlen(objects[i].oc_descr)+1;
|
||||
bwrite(fd, &len, sizeof len);
|
||||
bwrite(fd, objects[i].oc_descr, len);
|
||||
} else
|
||||
bwrite(fd, &zero, sizeof len);
|
||||
if(objects[i].oc_uname) {
|
||||
len = strlen(objects[i].oc_uname)+1;
|
||||
bwrite(fd, &len, sizeof len);
|
||||
bwrite(fd, objects[i].oc_uname, len);
|
||||
}
|
||||
} else
|
||||
bwrite(fd, &zero, sizeof len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +207,25 @@ restnames(int fd)
|
||||
|
||||
mread(fd, (char *) bases, sizeof bases);
|
||||
mread(fd, (char *) objects, sizeof objects);
|
||||
for(i=0; i < SIZE(objects); i++) if(objects[i].oc_uname) {
|
||||
for(i=0; i < SIZE(objects); i++) {
|
||||
mread(fd, (char *) &len, sizeof len);
|
||||
objects[i].oc_uname = (char *) alloc(len);
|
||||
mread(fd, objects[i].oc_uname, len);
|
||||
if(len) {
|
||||
objects[i].oc_name = (char *) alloc(len);
|
||||
mread(fd, objects[i].oc_name, len);
|
||||
} else
|
||||
objects[i].oc_name = 0;
|
||||
mread(fd, (char *) &len, sizeof len);
|
||||
if(len) {
|
||||
objects[i].oc_descr = (char *) alloc(len);
|
||||
mread(fd, objects[i].oc_descr, len);
|
||||
} else
|
||||
objects[i].oc_descr = 0;
|
||||
mread(fd, (char *) &len, sizeof len);
|
||||
if(len) {
|
||||
objects[i].oc_uname = (char *) alloc(len);
|
||||
mread(fd, objects[i].oc_uname, len);
|
||||
} else
|
||||
objects[i].oc_uname = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: hack.timeout.c,v 1.7 2016/01/09 18:33:15 mestre Exp $ */
|
||||
/* $OpenBSD: hack.timeout.c,v 1.8 2019/04/05 09:02:27 bentley Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -73,7 +73,7 @@ hacktimeout(void)
|
||||
if(Stoned) stoned_dialogue();
|
||||
for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++)
|
||||
if((upp->p_flgs & TIMEOUT) && !--upp->p_flgs) {
|
||||
if(upp->p_tofn) (*upp->p_tofn)();
|
||||
if(upp->p_tofn) float_down();
|
||||
else switch(upp - u.uprops){
|
||||
case STONED:
|
||||
killer = "cockatrice";
|
||||
|
||||
Reference in New Issue
Block a user