diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-09-17 21:28:34 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-09-17 21:28:34 +0000 |
commit | ea0d3a5d75c75fde6f0c685b99a2101c68dbb67c (patch) | |
tree | c1201fa143c4c79f84013cea3c06e7fe0727feb4 /games/battlestar/com2.c | |
parent | 7bf1025fb37d8f364d6e054c148a119f34d28825 (diff) |
Fewer segfaults ("take all and all", "wear wear"), better parsing
(e.g. disambiguation of "drop body"). Also, use "a" or "an" correctly,
don't overflow the words array, and don't kick items you're wearing.
Diffstat (limited to 'games/battlestar/com2.c')
-rw-r--r-- | games/battlestar/com2.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c index 792e9efe468..dcc5b5d1783 100644 --- a/games/battlestar/com2.c +++ b/games/battlestar/com2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com2.c,v 1.8 2000/07/03 05:23:44 pjanzen Exp $ */ +/* $OpenBSD: com2.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $ */ /* $NetBSD: com2.c,v 1.3 1995/03/21 15:06:55 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com2.c,v 1.8 2000/07/03 05:23:44 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com2.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $"; #endif #endif /* not lint */ @@ -52,7 +52,8 @@ wearit() firstnumber = wordnumber; while (wordtype[++wordnumber] == ADJS); - while (wordnumber <= wordcount) { + while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || + wordtype[wordnumber] == NOUNS)) { value = wordvalue[wordnumber]; for (n = 0; objsht[value][n]; n++); switch (value) { @@ -90,9 +91,9 @@ wearit() carrying -= objwt[value]; encumber -= objcumber[value]; ourtime++; - printf("You are now wearing %s %s.\n", - (objsht[value][n - 1] == 's' ? "the" : "a"), - objsht[value]); + printf("You are now wearing %s%s.\n", + (objsht[value][n - 1] == 's' ? "the " : + (AorAn(value))), objsht[value]); } else if (TestBit(wear, value)) printf("You are already wearing the %s.\n", @@ -198,11 +199,12 @@ murder() puts("Kill what?"); break; default: - if (wordtype[n] != OBJECT) + if (wordtype[n] != OBJECT || + wordvalue[wordnumber] == EVERYTHING) puts("You can't kill that!"); else printf("You can't kill the %s!\n", - objsht[wordvalue[n]]); + objsht[wordvalue[n]]); break; } } else @@ -263,7 +265,8 @@ murder() break; default: - if (wordtype[wordnumber] != OBJECT) + if (wordtype[wordnumber] != OBJECT || + wordvalue[wordnumber] == EVERYTHING) puts("You can't kill that!"); else printf("You can't kill the %s!\n", |