Source-Changes-HG archive

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

[src/trunk]: src/games/larn Handle the "diedtime" field of the player log (wh...



details:   https://anonhg.NetBSD.org/src/rev/51de6968b014
branches:  trunk
changeset: 754227:51de6968b014
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Apr 24 00:56:14 2010 +0000

description:
Handle the "diedtime" field of the player log (which is not the high
scores file, the append-only log of all games) as int32_t instead of
time_t. Log files from before the 64-bit time_t change can now be read
again; however, log files from the last year of -current are hosed.
All none of you who play larn, take note...

diffstat:

 games/larn/scores.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (46 lines):

diff -r be45ef1e1a51 -r 51de6968b014 games/larn/scores.c
--- a/games/larn/scores.c       Sat Apr 24 00:54:07 2010 +0000
+++ b/games/larn/scores.c       Sat Apr 24 00:56:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $     */
+/*     $NetBSD: scores.c,v 1.20 2010/04/24 00:56:14 dholland Exp $     */
 
 /*
  * scores.c                     Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
  */
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $");
+__RCSID("$NetBSD: scores.c,v 1.20 2010/04/24 00:56:14 dholland Exp $");
 #endif                         /* not lint */
 #include <sys/types.h>
 #include <sys/times.h>
@@ -64,7 +64,7 @@
 
 struct log_fmt {               /* 102 bytes struct for the log file                             */
        long            score;  /* the players score                                                             */
-       time_t          diedtime;       /* time when game was over                                                       */
+       int32_t          diedtime;      /* time when game was over                                                       */
        short           cavelev;/* level in caves                                                                        */
        short           diff;   /* difficulty player played at                                           */
 #ifdef EXTRA
@@ -774,6 +774,8 @@
        char  *p;
        static char  q[] = "?";
        struct stat     stbuf;
+       time_t t;
+
        lcreat((char *) 0);
        if (lopen(logfile) < 0) {
                lprintf("Can't locate log file <%s>\n", logfile);
@@ -785,7 +787,8 @@
        }
        for (n = stbuf.st_size / sizeof(struct log_fmt); n > 0; --n) {
                lrfill((char *) &logg, sizeof(struct log_fmt));
-               if ((p = ctime(&logg.diedtime)) == NULL)
+               t = logg.diedtime;
+               if ((p = ctime(&t)) == NULL)
                        p = q;
                else {
                        p[16] = '\n';



Home | Main Index | Thread Index | Old Index