Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/tetris Disable writing scores when built for /rescue. ...



details:   https://anonhg.NetBSD.org/src/rev/ef29ef893483
branches:  trunk
changeset: 747283:ef29ef893483
user:      dholland <dholland%NetBSD.org@localhost>
date:      Tue Sep 08 13:38:01 2009 +0000

description:
Disable writing scores when built for /rescue. PR 42009

diffstat:

 games/tetris/scores.c |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (73 lines):

diff -r a52570549c16 -r ef29ef893483 games/tetris/scores.c
--- a/games/tetris/scores.c     Tue Sep 08 09:57:32 2009 +0000
+++ b/games/tetris/scores.c     Tue Sep 08 13:38:01 2009 +0000
@@ -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 @@
        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 @@
        nscores = 0;
 }
 
+#ifdef ALLOW_SCORE_UPDATES
 /*
  * Paranoid write wrapper; unlike fwrite() it preserves errno.
  */
@@ -578,6 +589,7 @@
        }
        return 0;
 }
+#endif /* ALLOW_SCORE_UPDATES */
 
 /*
  * Write the score file out.
@@ -585,6 +597,7 @@
 static void
 putscores(int sd)
 {
+#ifdef ALLOW_SCORE_UPDATES
        struct highscore_header header;
        struct highscore_ondisk buf[MAXHISCORES];
        int i;
@@ -618,6 +631,9 @@
        return;
  fail:
        warnx("high scores may be damaged");
+#else
+       (void)sd;
+#endif /* ALLOW_SCORE_UPDATES */
 }
 
 /*



Home | Main Index | Thread Index | Old Index