From 31b523eee5d3a53c7b794af8b4cc7ae820fb77f9 Mon Sep 17 00:00:00 2001 From: jsm Date: Sun, 17 Sep 2000 23:03:43 +0000 Subject: [PATCH] Patches from OpenBSD: add verbs "open"/"unlock" (essentially a no-op), and "verbose"/"brief" (in verbose mode, always show long room descriptions), and synonyms "papaya" for "papayas" and "coconut" for "coconuts". --- games/battlestar/com6.c | 38 ++++++++++++++++++++++++++++++++++++-- games/battlestar/cypher.c | 31 +++++++++++++++++++++++++++++-- games/battlestar/extern.h | 7 ++++++- games/battlestar/globals.c | 5 +++-- games/battlestar/room.c | 6 +++--- games/battlestar/words.c | 10 ++++++++-- 6 files changed, 85 insertions(+), 12 deletions(-) diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c index 5bd9ebdc95e9..6e7e6d94c5a7 100644 --- a/games/battlestar/com6.c +++ b/games/battlestar/com6.c @@ -1,4 +1,4 @@ -/* $NetBSD: com6.c,v 1.16 2000/09/10 10:51:17 jsm Exp $ */ +/* $NetBSD: com6.c,v 1.17 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: com6.c,v 1.16 2000/09/10 10:51:17 jsm Exp $"); +__RCSID("$NetBSD: com6.c,v 1.17 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -248,3 +248,37 @@ light() } else puts("You're out of matches."); } + +void +dooropen() +{ /* synonyms = {open, unlock} */ + while(wordtype[++wordnumber] == ADJS) + ; + if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS + && wordvalue[wordnumber] == DOOR) { + switch(position) { + case 189: + case 231: + if (location[189].north == 231) + puts("The door is already open."); + else + puts("The door does not budge."); + break; + case 30: + if (location[30].west == 25) + puts("The door is gone."); + else + puts("The door is locked tight."); + break; + case 31: + puts("That's one immovable door."); + break; + case 20: + puts("The door is already ajar."); + break; + default: + puts("What door?"); + } + } else + puts("That doesn't open."); +} diff --git a/games/battlestar/cypher.c b/games/battlestar/cypher.c index 51330f189d46..ea39fd39d615 100644 --- a/games/battlestar/cypher.c +++ b/games/battlestar/cypher.c @@ -1,4 +1,4 @@ -/* $NetBSD: cypher.c,v 1.13 2000/09/10 10:51:17 jsm Exp $ */ +/* $NetBSD: cypher.c,v 1.14 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: cypher.c,v 1.13 2000/09/10 10:51:17 jsm Exp $"); +__RCSID("$NetBSD: cypher.c,v 1.14 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -293,6 +293,23 @@ cypher() lflag = use(); break; + case OPEN: + if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; + for (n = 0; n < NUMOFOBJECTS; n++) + if (testbit(inven, n)) { + things++; + wordvalue[wordnumber + 1] = n; + dooropen(); + } + wordnumber += 2; + if (!things) + puts("Nothing to open!"); + } else + dooropen(); + break; + case LOOK: if (!notes[CANTSEE] || testbit(inven, LAMPON) || testbit(location[position].objects, LAMPON) @@ -387,6 +404,16 @@ cypher() free(rfilename); break; + case VERBOSE: + verbose = 1; + printf("[Maximum verbosity]\n"); + break; + + case BRIEF: + verbose = 0; + printf("[Standard verbosity]\n"); + break; + case FOLLOW: lflag = follow(); break; diff --git a/games/battlestar/extern.h b/games/battlestar/extern.h index 055466bd1078..efd6366c5959 100644 --- a/games/battlestar/extern.h +++ b/games/battlestar/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.19 2000/09/09 09:37:58 jsm Exp $ */ +/* $NetBSD: extern.h,v 1.20 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -187,6 +187,9 @@ #define BURY 1050 #define JUMP 1051 #define KICK 1052 +#define OPEN 1053 +#define VERBOSE 1054 +#define BRIEF 1055 /* injuries */ #define ARM 6 /* broken arm */ @@ -284,6 +287,7 @@ extern unsigned int inven[NUMOFWORDS]; extern unsigned int wear[NUMOFWORDS]; extern char beenthere[NUMOFROOMS + 1]; extern char injuries[NUMOFINJURIES]; +extern int verbose; extern const char *username; @@ -317,6 +321,7 @@ int cypher __P((void)); void die __P((void)) __attribute__((__noreturn__)); void diesig __P((int)) __attribute__((__noreturn__)); void dig __P((void)); +void dooropen __P((void)); int draw __P((void)); void drink __P((void)); int drive __P((void)); diff --git a/games/battlestar/globals.c b/games/battlestar/globals.c index 17d9428d7741..d285e5279c01 100644 --- a/games/battlestar/globals.c +++ b/games/battlestar/globals.c @@ -1,4 +1,4 @@ -/* $NetBSD: globals.c,v 1.11 2000/09/09 09:37:58 jsm Exp $ */ +/* $NetBSD: globals.c,v 1.12 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: globals.c,v 1.11 2000/09/09 09:37:58 jsm Exp $"); +__RCSID("$NetBSD: globals.c,v 1.12 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -256,6 +256,7 @@ unsigned int inven[NUMOFWORDS]; unsigned int wear[NUMOFWORDS]; char beenthere[NUMOFROOMS + 1]; char injuries[NUMOFINJURIES]; +int verbose = 0; const char *username; diff --git a/games/battlestar/room.c b/games/battlestar/room.c index 8dd8bec359ff..3cdc0e15c308 100644 --- a/games/battlestar/room.c +++ b/games/battlestar/room.c @@ -1,4 +1,4 @@ -/* $NetBSD: room.c,v 1.9 2000/09/10 10:52:56 jsm Exp $ */ +/* $NetBSD: room.c,v 1.10 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: room.c,v 1.9 2000/09/10 10:52:56 jsm Exp $"); +__RCSID("$NetBSD: room.c,v 1.10 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -52,7 +52,7 @@ writedes() int c; printf("\n\t%s\n", location[position].name); - if (beenthere[position] < ROOMDESC) { + if (beenthere[position] < ROOMDESC || verbose) { compass = NORTH; for (p = location[position].desc; (c = *p++) != 0;) if (c != '-' && c != '*' && c != '+') { diff --git a/games/battlestar/words.c b/games/battlestar/words.c index 429a0024e8a4..b1386938f706 100644 --- a/games/battlestar/words.c +++ b/games/battlestar/words.c @@ -1,4 +1,4 @@ -/* $NetBSD: words.c,v 1.7 2000/09/09 18:03:58 jsm Exp $ */ +/* $NetBSD: words.c,v 1.8 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: words.c,v 1.7 2000/09/09 18:03:58 jsm Exp $"); +__RCSID("$NetBSD: words.c,v 1.8 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -91,9 +91,11 @@ struct wlist wlist[] = { { "match", MATCHES, OBJECT, NULL }, { "book", MATCHES, OBJECT, NULL }, { "man", MAN, NOUNS, NULL }, + { "papaya", PAPAYAS, OBJECT, NULL }, { "papayas", PAPAYAS, OBJECT, NULL }, { "pineapple", PINEAPPLE, OBJECT, NULL }, { "kiwi", KIWI, OBJECT, NULL }, + { "coconut", COCONUTS, OBJECT, NULL }, { "coconuts", COCONUTS, OBJECT, NULL }, { "mango", MANGO, OBJECT, NULL }, { "ring", RING, OBJECT, NULL }, @@ -173,6 +175,8 @@ struct wlist wlist[] = { { "hack", SMITE, VERB, NULL }, { "shoot", SHOOT, VERB, NULL }, { "blast", SHOOT, VERB, NULL }, + { "open", OPEN, VERB, NULL }, + { "unlock", OPEN, VERB, NULL }, { "on", ON, PREPS, NULL }, { "off", OFF, PREPS, NULL }, { "time", TIME, VERB, NULL }, @@ -182,6 +186,8 @@ struct wlist wlist[] = { { "swim", SWIM, VERB, NULL }, { "drink", DRINK, VERB, NULL }, { "door", DOOR, NOUNS, NULL }, + { "verbose", VERBOSE, VERB, NULL }, + { "brief", BRIEF, VERB, NULL }, { "save", SAVE, VERB, NULL }, { "ride", RIDE, VERB, NULL }, { "mount", RIDE, VERB, NULL },