summaryrefslogtreecommitdiffstats
path: root/tetris
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-09-08 13:38:01 +0000
committerdholland <dholland@NetBSD.org>2009-09-08 13:38:01 +0000
commitb6fb041013522a409f29431dea8df284f29a0976 (patch)
tree31ff856183d624d4d440ab8f518e20b6ab63fa77 /tetris
parentf317851cef910ed84d916f18ef477f31e735802d (diff)
downloadbsdgames-darwin-b6fb041013522a409f29431dea8df284f29a0976.tar.gz
bsdgames-darwin-b6fb041013522a409f29431dea8df284f29a0976.tar.zst
bsdgames-darwin-b6fb041013522a409f29431dea8df284f29a0976.zip
Disable writing scores when built for /rescue. PR 42009
Diffstat (limited to 'tetris')
-rw-r--r--tetris/scores.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/tetris/scores.c b/tetris/scores.c
index 83b2c36a..eaf2618c 100644
--- a/tetris/scores.c
+++ b/tetris/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.17 2009/06/01 04:03:26 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.18 2009/09/08 13:38:01 dholland Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -59,6 +59,13 @@
#include "tetris.h"
/*
+ * Allow updating the high scores unless we're built as part of /rescue.
+ */
+#ifndef RESCUEDIR
+#define ALLOW_SCORE_UPDATES
+#endif
+
+/*
* Within this code, we can hang onto one extra "high score", leaving
* room for our current score (whether or not it is high).
*
@@ -379,11 +386,14 @@ getscores(int *fdp)
int serrno;
ssize_t result;
+#ifdef ALLOW_SCORE_UPDATES
if (fdp != NULL) {
mint = O_RDWR | O_CREAT;
human = "read/write";
lck = LOCK_EX;
- } else {
+ } else
+#endif
+ {
mint = O_RDONLY;
mstr = "r";
human = "reading";
@@ -556,6 +566,7 @@ getscores(int *fdp)
nscores = 0;
}
+#ifdef ALLOW_SCORE_UPDATES
/*
* Paranoid write wrapper; unlike fwrite() it preserves errno.
*/
@@ -578,6 +589,7 @@ dowrite(int sd, const void *vbuf, size_t len)
}
return 0;
}
+#endif /* ALLOW_SCORE_UPDATES */
/*
* Write the score file out.
@@ -585,6 +597,7 @@ dowrite(int sd, const void *vbuf, size_t len)
static void
putscores(int sd)
{
+#ifdef ALLOW_SCORE_UPDATES
struct highscore_header header;
struct highscore_ondisk buf[MAXHISCORES];
int i;
@@ -618,6 +631,9 @@ putscores(int sd)
return;
fail:
warnx("high scores may be damaged");
+#else
+ (void)sd;
+#endif /* ALLOW_SCORE_UPDATES */
}
/*