From 2fc94a2a6476f927aee489e40f3575a8e78955fe Mon Sep 17 00:00:00 2001 From: dholland Date: Sat, 24 Apr 2010 00:56:14 +0000 Subject: 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... --- larn/scores.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'larn') diff --git a/larn/scores.c b/larn/scores.c index b33150c5..c17a770f 100644 --- a/larn/scores.c +++ b/larn/scores.c @@ -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 #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 #include @@ -64,7 +64,7 @@ struct wscofmt { /* This is the structure for the winning 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 @@ diedlog() 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 @@ diedlog() } 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'; -- cgit v1.2.3-56-ge451