summaryrefslogtreecommitdiffstats
path: root/monop/execute.c
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2008-02-24 02:43:18 +0000
committerdholland <dholland@NetBSD.org>2008-02-24 02:43:18 +0000
commit21d886f3ff24a8a1d26df7ec7bf76a0381850557 (patch)
treee03575a6a40a703af06cf302a0af5c4afe32b5e1 /monop/execute.c
parent858a6720891a7ac54475ce092705f4a9c8ec4f64 (diff)
downloadbsdgames-darwin-21d886f3ff24a8a1d26df7ec7bf76a0381850557.tar.gz
bsdgames-darwin-21d886f3ff24a8a1d26df7ec7bf76a0381850557.tar.zst
bsdgames-darwin-21d886f3ff24a8a1d26df7ec7bf76a0381850557.zip
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.)
Diffstat (limited to 'monop/execute.c')
-rw-r--r--monop/execute.c19
1 files changed, 12 insertions, 7 deletions
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; j<dp->num_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 {