From 21d886f3ff24a8a1d26df7ec7bf76a0381850557 Mon Sep 17 00:00:00 2001 From: dholland Date: Sun, 24 Feb 2008 02:43:18 +0000 Subject: Abolish the initdeck program and the weird little binary file it generates. The card deck data is now compiled in. (And it always should have been, even back when memory usage counted. It's small.) This changes the save format slightly. (I am riding the previous breakage an hour ago and not providing compat. There should be no further breakage.) --- monop/execute.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'monop/execute.c') diff --git a/monop/execute.c b/monop/execute.c index 0f7036a6..e3231c21 100644 --- a/monop/execute.c +++ b/monop/execute.c @@ -1,4 +1,4 @@ -/* $NetBSD: execute.c,v 1.17 2008/02/24 01:57:34 dholland Exp $ */ +/* $NetBSD: execute.c,v 1.18 2008/02/24 02:43:18 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: execute.c,v 1.17 2008/02/24 01:57:34 dholland Exp $"); +__RCSID("$NetBSD: execute.c,v 1.18 2008/02/24 02:43:18 dholland Exp $"); #endif #endif /* not lint */ @@ -297,9 +297,9 @@ save() fprintf(outf, " numcards %d\n", deck[i].num_cards); fprintf(outf, " topcard %d\n", deck[i].top_card); fprintf(outf, " gojf_used %d\n", deck[i].gojf_used); - fprintf(outf, " offsets"); + fprintf(outf, " cards"); for (j = 0; j < deck[i].num_cards; j++) - fprintf(outf, " %ld", (long)(deck[i].offsets[j])); + fprintf(outf, " %d", deck[i].cards[j]); fprintf(outf, "\n"); fprintf(outf, "}\n"); } @@ -647,14 +647,19 @@ restore_deck_attr(const char *attribute, char *txt) return -1; } dp->gojf_used = tmp; - } else if (!strcmp(attribute, "offsets")) { + } else if (!strcmp(attribute, "cards")) { errno = 0; s = txt; for (j = 0; jnum_cards; j++) { - dp->offsets[j] = strtol(s, &s, 10); + tmp = strtol(s, &s, 10); + if (tmp < 0 || tmp >= dp->num_cards) { + printf("cards: out of range value\n"); + return -1; + } + dp->cards[j] = tmp; } if (errno) { - printf("offsets: invalid values\n"); + printf("cards: invalid values\n"); return -1; } } else { -- cgit v1.2.3