diff options
-rw-r--r-- | games/battlestar/com2.c | 41 | ||||
-rw-r--r-- | games/battlestar/com3.c | 18 | ||||
-rw-r--r-- | games/battlestar/com4.c | 63 | ||||
-rw-r--r-- | games/battlestar/com5.c | 13 | ||||
-rw-r--r-- | games/battlestar/com6.c | 7 | ||||
-rw-r--r-- | games/battlestar/cypher.c | 11 | ||||
-rw-r--r-- | games/battlestar/extern.h | 16 | ||||
-rw-r--r-- | games/battlestar/globals.c | 47 | ||||
-rw-r--r-- | games/battlestar/parse.c | 28 |
9 files changed, 148 insertions, 96 deletions
diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c index dcc5b5d1783..06ff869c542 100644 --- a/games/battlestar/com2.c +++ b/games/battlestar/com2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com2.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $ */ +/* $OpenBSD: com2.c,v 1.10 2000/09/23 03:02:35 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.9 2000/09/17 21:28:32 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com2.c,v 1.10 2000/09/23 03:02:35 pjanzen Exp $"; #endif #endif /* not lint */ @@ -47,15 +47,15 @@ static char rcsid[] = "$OpenBSD: com2.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $" int wearit() { /* synonyms = {sheathe, sheath} */ - int n; int firstnumber, value; firstnumber = wordnumber; - while (wordtype[++wordnumber] == ADJS); + wordnumber++; while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || - wordtype[wordnumber] == NOUNS)) { + (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] != DOOR))) { value = wordvalue[wordnumber]; - for (n = 0; objsht[value][n]; n++); + if (objsht[value] == NULL) + break; switch (value) { case -1: @@ -63,7 +63,9 @@ wearit() return (firstnumber); default: - printf("You can't wear%s%s!\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]); + printf("You can't wear %s%s!\n", + (IsPluralObject(value) ? "" : AorAn(value)), + objsht[value]); return (firstnumber); case KNIFE: @@ -92,7 +94,7 @@ wearit() encumber -= objcumber[value]; ourtime++; printf("You are now wearing %s%s.\n", - (objsht[value][n - 1] == 's' ? "the " : + (IsPluralObject(value) ? "the " : (AorAn(value))), objsht[value]); } else if (TestBit(wear, value)) @@ -137,7 +139,7 @@ draw() int use() { - while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount); + wordnumber++; if (wordvalue[wordnumber] == AMULET && TestBit(inven, AMULET) && position != FINAL) { puts("The amulet begins to glow."); @@ -184,35 +186,34 @@ murder() if (n == NUMOFOBJECTS) { if (TestBit(inven, LASER)) { printf("Your laser should do the trick.\n"); - n = wordnumber; - while (wordtype[++n] == ADJS) - ; - switch(wordvalue[n]) { + wordnumber++; + switch(wordvalue[wordnumber]) { case NORMGOD: case TIMER: case NATIVE: case MAN: - wordvalue[wordnumber] = SHOOT; + wordvalue[--wordnumber] = SHOOT; cypher(); break; case -1: puts("Kill what?"); break; default: - if (wordtype[n] != OBJECT || + if (wordtype[wordnumber] != OBJECT || wordvalue[wordnumber] == EVERYTHING) puts("You can't kill that!"); else - printf("You can't kill the %s!\n", - objsht[wordvalue[n]]); + printf("You can't kill %s%s!\n", + (IsPluralObject(wordvalue[wordnumber]) ? "" : + AorAn(wordvalue[wordnumber])), + objsht[wordvalue[wordnumber]]); break; } } else puts("You don't have suitable weapons to kill."); } else { printf("Your %s should do the trick.\n", objsht[n]); - while (wordtype[++wordnumber] == ADJS) - ; + wordnumber++; switch (wordvalue[wordnumber]) { case NORMGOD: @@ -232,7 +233,7 @@ murder() if (wintime) live(); } else - puts("I dont see her anywhere."); + puts("I don't see her anywhere."); break; case TIMER: if (TestBit(location[position].objects, TIMER)) { diff --git a/games/battlestar/com3.c b/games/battlestar/com3.c index 43ef6a5eb19..1f733ccd03c 100644 --- a/games/battlestar/com3.c +++ b/games/battlestar/com3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com3.c,v 1.7 2000/07/03 05:23:44 pjanzen Exp $ */ +/* $OpenBSD: com3.c,v 1.8 2000/09/23 03:02:35 pjanzen Exp $ */ /* $NetBSD: com3.c,v 1.3 1995/03/21 15:07:00 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com3.c,v 1.7 2000/07/03 05:23:44 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com3.c,v 1.8 2000/09/23 03:02:35 pjanzen Exp $"; #endif #endif /* not lint */ @@ -88,7 +88,7 @@ jump() position = 145; break; case 232: - position = 275; + position = FINAL; break; case 3: position = 1; @@ -114,7 +114,7 @@ bury() int value; if (TestBit(inven, SHOVEL)) { - while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount); + while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber <= wordcount); value = wordvalue[wordnumber]; if (wordtype[wordnumber] == NOUNS && (TestBit(location[position].objects, value) || value == BODY)) switch (value) { @@ -194,26 +194,24 @@ int shoot() { int firstnumber, value; - int n; firstnumber = wordnumber; if (!TestBit(inven, LASER)) puts("You aren't holding a blaster."); else { - while(wordtype[++wordnumber] == ADJS) - ; + wordnumber++; while(wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) { value = wordvalue[wordnumber]; printf("%s:\n", objsht[value]); - for (n=0; objsht[value][n]; n++); if (TestBit(location[position].objects, value)) { ClearBit(location[position].objects, value); ourtime++; - printf("The %s explode%s\n", objsht[value], (objsht[value][n-1]=='s' ? (objsht[value][n-2]=='s' ? "s." : ".") : "s.")); + printf("The %s explode%s\n", objsht[value], + (IsPluralObject(value) ? "." : "s.")); if (value == BOMB) die(0); } else - printf("I dont see any %s around here.\n", objsht[value]); + printf("I don't see any %s around here.\n", objsht[value]); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else diff --git a/games/battlestar/com4.c b/games/battlestar/com4.c index aed8434e69b..5ea47299fb1 100644 --- a/games/battlestar/com4.c +++ b/games/battlestar/com4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com4.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $ */ +/* $OpenBSD: com4.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com4.c,v 1.9 2000/09/17 21:28:32 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com4.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -49,7 +49,6 @@ take(from) unsigned int from[]; { int firstnumber, heavy, bulky, value; - int n; firstnumber = wordnumber; if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) { @@ -57,11 +56,10 @@ take(from) wordvalue[wordnumber] = TAKEOFF; return (cypher()); } else { - while (wordtype[++wordnumber] == ADJS); + wordnumber++; while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) { value = wordvalue[wordnumber]; printf("%s:\n", objsht[value]); - for (n = 0; objsht[value][n]; n++); heavy = (carrying + objwt[value]) <= WEIGHT; bulky = (encumber + objcumber[value]) <= CUMBER; if ((TestBit(from, value) || wiz || tempwiz) && heavy && bulky && !TestBit(inven, value)) { @@ -76,17 +74,18 @@ take(from) ClearBit(from, value); if (value == MEDALION) win--; - } else - if (TestBit(inven, value)) - printf("You're already holding %s%s.\n", - (objsht[value][n-1] == 's' ? "" : - (AorAn(value))), objsht[value]); - else if (!heavy) - printf("The %s %s too heavy.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is")); - else if (!bulky) - printf("The %s %s too cumbersome to hold.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is")); - else - printf("I dont see any %s around here.\n", objsht[value]); + } else if (TestBit(inven, value)) + printf("You're already holding %s%s.\n", + (IsPluralObject(value) ? "" : + (AorAn(value))), objsht[value]); + else if (!TestBit(from, value)) + printf("I don't see any %s around here.\n", objsht[value]); + else if (!heavy) + printf("The %s %s too heavy.\n", objsht[value], + (IsPluralObject(value) ? "are" : "is")); + else + printf("The %s %s too cumbersome to hold.\n", objsht[value], + (IsPluralObject(value) ? "are" : "is")); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else @@ -226,8 +225,7 @@ throw(name) deposit = location[position].down; break; } - wordnumber = first; - while (wordtype[++wordnumber] == ADJS); + wordnumber++; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; if (deposit && TestBit(location[position].objects, value)) { @@ -279,8 +277,7 @@ drop(name) int firstnumber, value; firstnumber = wordnumber; - while (wordtype[++wordnumber] == ADJS) - ; + wordnumber++; while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) { value = wordvalue[wordnumber]; if (value == BODY) { /* special case */ @@ -296,11 +293,16 @@ drop(name) if (TestBit(inven, DEADNATIVE) || TestBit(location[position].objects, DEADNATIVE)) value = DEADNATIVE; } - if (wordtype[wordnumber] == NOUNS) { - if (value == DOOR) + if (wordtype[wordnumber] == NOUNS && value == DOOR) { + if (*name == 'K') puts("You hurt your foot."); else + puts("You're not holding a door."); + } else if (objsht[value] == NULL) { + if (*name == 'K') puts("That's not for kicking!"); + else + puts("You don't have that."); } else { printf("%s:\n", objsht[value]); if (TestBit(inven, value)) { @@ -366,11 +368,17 @@ eat() int firstnumber, value; firstnumber = wordnumber; - while (wordtype[++wordnumber] == ADJS); + wordnumber++; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; + if (wordtype[wordnumber] != OBJECT || objsht[value] == NULL) + value = -2; switch (value) { + case -2: + puts("You can't eat that!"); + return (firstnumber); + case -1: puts("Eat what?"); return (firstnumber); @@ -378,7 +386,7 @@ eat() default: printf("You can't eat %s%s!\n", wordtype[wordnumber] == OBJECT && - objsht[value][strlen(objsht[value]) - 1] == 's' ? "" : + IsPluralObject(value) ? "" : (AorAn(value)), objsht[value]); return (firstnumber); @@ -398,13 +406,12 @@ eat() snooze += CYCLE / 10; ourtime++; puts("Eaten. You can explore a little longer now."); - } - else if (ourtime < ate - CYCLE) - puts("You're stuffed."); + } else if (!TestBit(inven, value)) + printf("You aren't holding the %s.\n", objsht[value]); else if (!TestBit(inven, KNIFE)) puts("You need a knife."); else - printf("You aren't holding the %s.\n", objsht[value]); + puts("You're stuffed."); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else diff --git a/games/battlestar/com5.c b/games/battlestar/com5.c index e86982890c2..906fae36242 100644 --- a/games/battlestar/com5.c +++ b/games/battlestar/com5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com5.c,v 1.6 2000/07/03 05:23:44 pjanzen Exp $ */ +/* $OpenBSD: com5.c,v 1.7 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: com5.c,v 1.3 1995/03/21 15:07:07 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com5.c,v 1.6 2000/07/03 05:23:44 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com5.c,v 1.7 2000/09/23 03:02:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -105,7 +105,11 @@ love() if (wordtype[wordnumber] == NOUNS) { if ((TestBit(location[position].objects, BATHGOD) || TestBit(location[position].objects, NORMGOD)) && - wordvalue[wordnumber] == NORMGOD && !loved) { + wordvalue[wordnumber] == NORMGOD) { + if (loved) { + printf("Loved.\n"); + return; + } if (godready >= 2) { puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet. The lovely goddess, Purl, was she. The Empire\ncaptured her just after the Darkness came. My other sister, Vert, was killed\nby the Dark Lord himself. He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill. I will leave you my amulet,"); puts("which you may use as you wish. As for me, I am the last goddess of the\nwaters. My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed."); @@ -126,6 +130,7 @@ love() ourtime += 10; printf("Loved.\n"); zzz(); + return; } else { puts("You wish!"); return; @@ -146,6 +151,8 @@ love() wordvalue[wordnumber] == ELF || wordvalue[wordnumber] == TIMER) puts("Kinky!"); + else + puts("It doesn't seem to work."); } else puts("Where's your lover?"); } else diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c index 9936f7d50c0..6d63fc5e000 100644 --- a/games/battlestar/com6.c +++ b/games/battlestar/com6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com6.c,v 1.13 2000/09/21 00:23:43 pjanzen Exp $ */ +/* $OpenBSD: com6.c,v 1.14 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: com6.c,v 1.5 1995/04/27 21:30:23 mycroft Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: com6.c,v 1.13 2000/09/21 00:23:43 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: com6.c,v 1.14 2000/09/23 03:02:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -234,8 +234,7 @@ light() void dooropen() { /* synonyms = {open, unlock} */ - while(wordtype[++wordnumber] == ADJS) - ; + wordnumber++; if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == DOOR) { switch(position) { diff --git a/games/battlestar/cypher.c b/games/battlestar/cypher.c index e4e6fa6799c..a8ed667c5d9 100644 --- a/games/battlestar/cypher.c +++ b/games/battlestar/cypher.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cypher.c,v 1.9 2000/07/24 01:02:43 pjanzen Exp $ */ +/* $OpenBSD: cypher.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: cypher.c,v 1.3 1995/03/21 15:07:15 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: cypher.c,v 1.9 2000/07/24 01:02:43 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: cypher.c,v 1.10 2000/09/23 03:02:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -55,9 +55,12 @@ cypher() char *filename, *rfilename; size_t filename_len; - while (wordtype[wordnumber] == ADJS) - wordnumber++; while (wordnumber <= wordcount) { + if (wordtype[wordnumber] != VERB) { + printf("%s: How's that?\n", words[wordnumber]); + return (-1); + } + switch (wordvalue[wordnumber]) { case UP: diff --git a/games/battlestar/extern.h b/games/battlestar/extern.h index fb8fbcbdc03..1e911bfa111 100644 --- a/games/battlestar/extern.h +++ b/games/battlestar/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.8 2000/09/17 21:28:32 pjanzen Exp $ */ +/* $OpenBSD: extern.h,v 1.9 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: extern.h,v 1.5 1995/04/24 12:22:18 cgd Exp $ */ /* @@ -60,7 +60,8 @@ #define SetBit(array, index) (array[index/BITS] |= (1 << (index % BITS))) #define ClearBit(array, index) (array[index/BITS] &= ~(1 << (index % BITS))) /* "a " vs "an " before an object */ -#define AorAn(value) (strchr("aeiou", objsht[value][0]) ? "an " : "a ") +#define AorAn(value) (objflags[(value)] & OBJ_AN ? "an " : "a ") +#define IsPluralObject(value) (objflags[(value)] & OBJ_PLURAL) /* well known rooms */ #define FINAL 275 @@ -110,8 +111,8 @@ #define MACE 29 #define SHOVEL 30 #define HALBERD 31 -#define COMPASS 32 -#define CRASH 33 +#define COMPASS 32 +#define CRASH 33 #define ELF 34 #define FOOT 35 #define COINS 36 @@ -209,7 +210,7 @@ #define NUMOFINJURIES 13 /* notes */ -#define CANTLAUNCH 0 +#define CANTLAUNCH 0 #define LAUNCHED 1 #define CANTSEE 2 #define CANTMOVE 3 @@ -235,6 +236,10 @@ #define MAXWEIGHT 60 #define MAXCUMBER 10 +/* Flags for objects */ +#define OBJ_PLURAL 1 +#define OBJ_AN 2 + struct room { const char *name; int link[8]; @@ -259,6 +264,7 @@ extern const char *const objsht[NUMOFOBJECTS]; extern const char *const ouch[NUMOFINJURIES]; extern const int objwt[NUMOFOBJECTS]; extern const int objcumber[NUMOFOBJECTS]; +extern const int objflags[NUMOFOBJECTS]; /* current input line */ #define WORDLEN 15 diff --git a/games/battlestar/globals.c b/games/battlestar/globals.c index b686ed2653e..42dca2bba0c 100644 --- a/games/battlestar/globals.c +++ b/games/battlestar/globals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: globals.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $ */ +/* $OpenBSD: globals.c,v 1.8 2000/09/23 03:02:36 pjanzen Exp $ */ /* $NetBSD: globals.c,v 1.3 1995/03/21 15:07:32 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: globals.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: globals.c,v 1.8 2000/09/23 03:02:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -50,7 +50,7 @@ int CUMBER = MAXCUMBER; const char *const objdes[NUMOFOBJECTS] = { "There is a knife here.", "There are an exquisitely crafted sword and scabbard here.", - 0, /* can land from here */ + NULL, /* can land from here */ "There is a fierce woodsman here brandishing a heavy mallet.", "There is an unwieldy two-handed sword here.", "There is a bloody meat cleaver here.", @@ -62,7 +62,7 @@ const char *const objdes[NUMOFOBJECTS] = { "There is a Viper ready for launch here.", "A kerosene lantern is burning luridly here.", "An old pair of shoes has been discarded here.", - 0, /* cylon */ + NULL, /* cylon */ "There is a pair of pajamas here.", "A kingly robe of royal purple and spun gold is draped here.", "There is a strange golden amulet on the floor here.", @@ -118,7 +118,7 @@ const char *const objdes[NUMOFOBJECTS] = { const char *const objsht[NUMOFOBJECTS] = { "knife", "fine sword", - 0, + NULL, "Woodsman", "two-handed sword", "meat cleaver", @@ -130,7 +130,7 @@ const char *const objsht[NUMOFOBJECTS] = { "viper", "lantern", "shoes", - 0, + NULL, "pajamas", "robe", "amulet", @@ -139,8 +139,8 @@ const char *const objsht[NUMOFOBJECTS] = { "woodsman's body", "wooden mallet", "laser", - 0, - 0, + NULL, + NULL, "grenade", "chain", "rope", @@ -149,12 +149,12 @@ const char *const objsht[NUMOFOBJECTS] = { "shovel", "halberd", "compass", - 0, + NULL, "Elf", - 0, + NULL, "coins", "match book", - 0, + NULL, "papayas", "pineapple", "kiwi", @@ -163,18 +163,18 @@ const char *const objsht[NUMOFOBJECTS] = { "ring", "potion", "bracelet", - 0, - 0, + NULL, + NULL, "Dark Lord", - 0, - 0, - 0, - 0, + NULL, + NULL, + NULL, + NULL, "warhead", "goddess's body", "old-timer's body", "girl's body", - 0, + NULL, "stallion", "car", "pot of jewels", @@ -220,6 +220,17 @@ const int objcumber[NUMOFOBJECTS] = { 10, 8, 8, 10, 10, 3, 1, 2 }; +const int objflags[NUMOFOBJECTS] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, OBJ_PLURAL, 0, OBJ_PLURAL, + 0, OBJ_AN, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, OBJ_PLURAL, 0, 0, 0, + 0, 0, OBJ_AN, 0, OBJ_PLURAL, 0, 0, OBJ_PLURAL, + 0, 0, OBJ_PLURAL, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + int win = 1; int matchcount = 20; int followgod = -1; diff --git a/games/battlestar/parse.c b/games/battlestar/parse.c index 9a96dac673a..37265f2b1d5 100644 --- a/games/battlestar/parse.c +++ b/games/battlestar/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $ */ +/* $OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $ */ /* $NetBSD: parse.c,v 1.3 1995/03/21 15:07:48 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: parse.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.8 2000/09/23 03:02:38 pjanzen Exp $"; #endif #endif /* not lint */ @@ -110,13 +110,33 @@ parse() wordtype[n] = wp->article; } } + /* Don't let a comma mean AND if followed by a verb. */ + for (n = 0; n < wordcount; n++) + if (wordvalue[n] == AND && words[n][0] == ',' + && wordtype[n + 1] == VERB) { + wordvalue[n] = -1; + wordtype[n] = -1; + } + /* We never use adjectives, so yank them all; disambiguation + * code would need to go before this. + */ + for (n = 1; n < wordcount; n++) + if (wordtype[n] == ADJS) { + int i; + for (i = n + 1; i < wordcount; i++) { + wordtype[i - 1] = wordtype[i]; + wordvalue[i - 1] = wordvalue[i]; + strlcpy(words[i - 1], words[i], WORDLEN); + } + wordcount--; + } /* Trim "AND AND" which can happen naturally at the end of a - * comma-delimited list + * comma-delimited list. */ for (n = 1; n < wordcount; n++) if (wordvalue[n - 1] == AND && wordvalue[n] == AND) { int i; - for (i = n + 1; i < wordcount; i++) { + for (i = n + 1; i <= wordcount; i++) { wordtype[i - 1] = wordtype[i]; wordvalue[i - 1] = wordvalue[i]; strlcpy(words[i - 1], words[i], WORDLEN); |