]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - battlestar/com4.c
Don't try to wear anything that isn't OBJECT or NOUNS. Don't try to
[bsdgames-darwin.git] / battlestar / com4.c
index 93e17fffa2fba084164930b80d4676cc413f4038..d1be836d46e3826bc841e1c68d74f25a1e963946 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $     */
+/*     $NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
 #if 0
-static char sccsid[] = "@(#)com4.c     8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)com4.c     8.2 (Berkeley) 4/28/95";
 #else
-static char rcsid[] = "$NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $";
+__RCSID("$NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $");
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
-#include "externs.h"
+#include "extern.h"
 
+int
 take(from)
-unsigned int from[];
+       unsigned int from[];
 {
-       int firstnumber, heavy, bulky, value;
-       register int n;
+       int     firstnumber, heavy, bulky, value;
+       int     n;
 
        firstnumber = wordnumber;
-       if (wordnumber < wordcount && wordvalue[wordnumber+1] == OFF){
+       if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) {
                wordnumber++;
                wordvalue[wordnumber] = TAKEOFF;
-               return(cypher());
-       }
-       else {
-               while(wordtype[++wordnumber] == ADJS);
-               while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
+               return (cypher());
+       } else {
+               while (wordtype[++wordnumber] == ADJS);
+               while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
                        value = wordvalue[wordnumber];
                        printf("%s:\n", objsht[value]);
-                       for (n=0; objsht[value][n]; n++);
+                       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)){
-                               setbit(inven,value);
+                       if ((testbit(from, value) || wiz || tempwiz) && heavy && bulky && !testbit(inven, value)) {
+                               setbit(inven, value);
                                carrying += objwt[value];
                                encumber += objcumber[value];
-                               time++;
-                               if (testbit(from,value))
+                               ourtime++;
+                               if (testbit(from, value))
                                        printf("Taken.\n");
                                else
                                        printf("Zap! Taken from thin air.\n");
-                               clearbit(from,value);
+                               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' ? " " : " a "),objsht[value]);
+                       } else if (testbit(inven, value))
+                               printf("You're already holding%s%s.\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]);
                        else if (!heavy)
-                               printf("The %s %s too heavy.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
+                               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"));
+                               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]);
-                       if (wordnumber < wordcount -1 && wordvalue[++wordnumber] == AND)
+                       if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
                                wordnumber++;
                        else
-                               return(firstnumber);
+                               return (firstnumber);
                }
        }
-                           /* special cases with their own return()'s */
+       /* special cases with their own return()'s */
 
        if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS)
-               switch(wordvalue[wordnumber]){
-                       
-                       case SWORD:
-                               if (testbit(from, SWORD)){
-                                       wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               if (testbit(from, TWO_HANDED)){
-                                       wordvalue[wordnumber] = TWO_HANDED;
-                                       wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               wordvalue[wordnumber] = BROAD;
+               switch (wordvalue[wordnumber]) {
+
+               case SWORD:
+                       if (testbit(from, SWORD)) {
+                               wordtype[wordnumber--] = OBJECT;
+                               return (take(from));
+                       }
+                       if (testbit(from, TWO_HANDED)) {
+                               wordvalue[wordnumber] = TWO_HANDED;
                                wordtype[wordnumber--] = OBJECT;
-                               return(take(from));
+                               return (take(from));
+                       }
+                       wordvalue[wordnumber] = BROAD;
+                       wordtype[wordnumber--] = OBJECT;
+                       return (take(from));
 
-                       case BODY:
-                               if (testbit(from,MAID)){
-                                       wordvalue[wordnumber] = MAID;
-                                       wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               else if (testbit(from,DEADWOOD)){
-                                       wordvalue[wordnumber] = DEADWOOD;
-                                       wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               else if (testbit(from,DEADNATIVE)){
-                                       wordvalue[wordnumber] = DEADNATIVE;
-                                       wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               else if (testbit(from,DEADGOD)){
+               case BODY:
+                       if (testbit(from, MAID)) {
+                               wordvalue[wordnumber] = MAID;
+                               wordtype[wordnumber--] = OBJECT;
+                               return (take(from));
+                       } else if (testbit(from, DEADWOOD)) {
+                               wordvalue[wordnumber] = DEADWOOD;
+                               wordtype[wordnumber--] = OBJECT;
+                               return (take(from));
+                       } else if (testbit(from, DEADNATIVE)) {
+                               wordvalue[wordnumber] = DEADNATIVE;
+                               wordtype[wordnumber--] = OBJECT;
+                               return (take(from));
+                       } else {
+                               if (testbit(from, DEADGOD)) {
                                        wordvalue[wordnumber] = DEADGOD;
                                        wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               else {
+                                       return (take(from));
+                               } else {
                                        wordvalue[wordnumber] = DEADTIME;
                                        wordtype[wordnumber--] = OBJECT;
-                                       return(take(from));
-                               }
-                               break;
-
-                       case AMULET:
-                               if (testbit(location[position].objects,AMULET)){
-                                       puts("The amulet is warm to the touch, and its beauty catches your breath.");
-                                       puts("A mist falls over your eyes, but then it is gone.  Sounds seem clearer");
-                                       puts("and sharper but far away as if in a dream.  The sound of purling water reaches");
-                                       puts("you from afar.  The mist falls again, and your heart leaps in horror.  The gold");
-                                       puts("freezes your hands and fathomless darkness engulfs your soul.");
+                                       return (take(from));
                                }
-                               wordtype[wordnumber--] = OBJECT;
-                               return(take(from));
+                       }
+                       break;
 
-                       case MEDALION:
-                               if (testbit(location[position].objects, MEDALION)){
-                                       puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
-                                       puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
-                               }
-                               wordtype[wordnumber--] = OBJECT;
-                               return(take(from));
+               case AMULET:
+                       if (testbit(location[position].objects, AMULET)) {
+                               puts("The amulet is warm to the touch, and its beauty catches your breath.");
+                               puts("A mist falls over your eyes, but then it is gone.  Sounds seem clearer");
+                               puts("and sharper but far away as if in a dream.  The sound of purling water");
+                               puts("reaches you from afar.  The mist falls again, and your heart leaps in horror.");
+                               puts("The gold freezes your hands and fathomless darkness engulfs your soul.");
+                       }
+                       wordtype[wordnumber--] = OBJECT;
+                       return (take(from));
 
-                       case TALISMAN:
-                               if (testbit(location[position].objects,TALISMAN)){
-                                       puts("The talisman is cold to the touch, and it sends a chill down your spine.");
-                               }
-                               wordtype[wordnumber--] = OBJECT;
-                               return(take(from));
-
-                       case NORMGOD:
-                               if (testbit(location[position].objects,BATHGOD) && (testbit(wear,AMULET) || testbit(inven,AMULET))){
-                                       puts("She offers a delicate hand, and you help her out of the sparkling springs.");
-                                       puts("Water droplets like liquid silver bedew her golden skin, but when they part");
-                                       puts("from her, they fall as teardrops.  She wraps a single cloth around her and");
-                                       puts("ties it at the waist.  Around her neck hangs a golden amulet.");
-                                       puts("She bids you to follow her.");
-                                       pleasure++;
-                                       followgod = time;
-                                       clearbit(location[position].objects,BATHGOD);
-                               } else if (!testbit(location[position].objects,BATHGOD))
+               case MEDALION:
+                       if (testbit(location[position].objects, MEDALION)) {
+                               puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
+                               puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
+                       }
+                       wordtype[wordnumber--] = OBJECT;
+                       return (take(from));
+
+               case TALISMAN:
+                       if (testbit(location[position].objects, TALISMAN)) {
+                               puts("The talisman is cold to the touch, and it sends a chill down your spine.");
+                       }
+                       wordtype[wordnumber--] = OBJECT;
+                       return (take(from));
+
+               case NORMGOD:
+                       if (testbit(location[position].objects, BATHGOD) && (testbit(wear, AMULET) || testbit(inven, AMULET))) {
+                               puts("She offers a delicate hand, and you help her out of the sparkling springs.");
+                               puts("Water droplets like liquid silver bedew her golden skin, but when they part");
+                               puts("from her, they fall as teardrops.  She wraps a single cloth around her and");
+                               puts("ties it at the waist.  Around her neck hangs a golden amulet.");
+                               puts("She bids you to follow her, and walks away.");
+                               pleasure++;
+                               followgod = ourtime;
+                               clearbit(location[position].objects, BATHGOD);
+                       } else
+                               if (!testbit(location[position].objects, BATHGOD))
                                        puts("You're in no position to take her.");
-                               else 
+                               else
                                        puts("She moves away from you.");
-                               break;
+                       break;
 
-                       default:
-                               puts("It doesn't seem to work.");
+               default:
+                       puts("It doesn't seem to work.");
                }
        else
                puts("You've got to be kidding.");
-       return(firstnumber);
+       return (firstnumber);
 }
 
+int
 throw(name)
-       char *name;
+       const char   *name;
 {
-       int n;
-       int deposit = 0;
-       int first, value;
+       unsigned int     n;
+       int     deposit = 0;
+       int     first, value;
 
        first = wordnumber;
-       if (drop(name) != -1){
-               switch(wordvalue[wordnumber]){
-                       
-                       case AHEAD:
-                               deposit = ahead;
-                               break;
-
-                       case BACK:
-                               deposit = back;
-                               break;
-
-                       case LEFT:
-                               deposit = left;
-                               break;
-
-                       case RIGHT:
-                               deposit = right;
-                               break;
-
-                       case UP:
-                               deposit = location[position].up * (location[position].access || position == FINAL);
-                               break;
-
-                       case DOWN:
-                               deposit = location[position].down;
-                               break;
+       if (drop(name) != -1) {
+               switch (wordvalue[wordnumber]) {
+
+               case AHEAD:
+                       deposit = ahead;
+                       break;
+
+               case BACK:
+                       deposit = back;
+                       break;
+
+               case LEFT:
+                       deposit = left;
+                       break;
+
+               case RIGHT:
+                       deposit = right;
+                       break;
+
+               case UP:
+                       deposit = location[position].up * (location[position].access || position == FINAL);
+                       break;
+
+               case DOWN:
+                       deposit = location[position].down;
+                       break;
                }
                wordnumber = first;
                while (wordtype[++wordnumber] == ADJS);
-               while (wordnumber <= wordcount){
+               while (wordnumber <= wordcount) {
                        value = wordvalue[wordnumber];
-                       if (deposit && testbit(location[position].objects,value)){
-                               clearbit(location[position].objects,value);
+                       if (deposit && testbit(location[position].objects, value)) {
+                               clearbit(location[position].objects, value);
                                if (value != GRENADE)
-                                       setbit(location[deposit].objects,value);
-                               else{
+                                       setbit(location[deposit].objects, value);
+                               else {
                                        puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
-                                       for (n = 0; n < NUMOFWORDS; n ++)
+                                       for (n = 0; n < NUMOFWORDS; n++)
                                                location[deposit].objects[n] = 0;
-                                       setbit(location[deposit].objects,CHAR);
+                                       setbit(location[deposit].objects, CHAR);
                                }
                                if (value == ROPE && position == FINAL)
                                        location[position].access = 1;
-                               switch(deposit){
-                                       case 189:
-                                       case 231:
-                                               puts("The stone door is unhinged.");
-                                               location[189].north = 231;
-                                               location[231].south = 189;
-                                               break;
-                                       case 30:
-                                               puts("The wooden door is blown open.");
-                                               location[30].west = 25;
-                                               break;
-                                       case 31:
-                                               puts("The door is not damaged.");
+                               switch (deposit) {
+                               case 189:
+                               case 231:
+                                       puts("The stone door is unhinged.");
+                                       location[189].north = 231;
+                                       location[231].south = 189;
+                                       break;
+                               case 30:
+                                       puts("The wooden door is blown open.");
+                                       location[30].west = 25;
+                                       break;
+                               case 31:
+                                       puts("The door is not damaged.");
+                               }
+                       } else
+                               if (value == GRENADE && testbit(location[position].objects, value)) {
+                                       puts("You are blown into shreds when your grenade explodes.");
+                                       die();
                                }
-                       }
-                       else if (value == GRENADE && testbit(location[position].objects,value)){
-                               puts("You are blown into shreds when your grenade explodes.");
-                               die();
-                       }
                        if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
                                wordnumber++;
-                       else 
-                               return(first);
+                       else
+                               return (first);
                }
-               return(first);
+               return (first);
        }
-       return(first);
+       return (first);
 }
 
+int
 drop(name)
-char *name;
+       const char   *name;
 {
-       
-       int firstnumber, value;
+
+       int     firstnumber, value;
 
        firstnumber = wordnumber;
-       while (wordtype[++wordnumber] == ADJS)
-               ;
-       while (wordnumber<=wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
+       while (wordtype[++wordnumber] == ADJS);
+       while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
                value = wordvalue[wordnumber];
                printf("%s:\n", objsht[value]);
-               if (testbit(inven,value)){
-                       clearbit(inven,value);
+               if (testbit(inven, value)) {
+                       clearbit(inven, value);
                        carrying -= objwt[value];
                        encumber -= objcumber[value];
-                       if (value == BOMB){
+                       if (value == BOMB) {
                                puts("The bomb explodes.  A blinding white light and immense concussion obliterate us.");
                                die();
                        }
                        if (value != AMULET && value != MEDALION && value != TALISMAN)
-                               setbit(location[position].objects,value);
+                               setbit(location[position].objects, value);
                        else
                                tempwiz = 0;
-                       time++;
+                       ourtime++;
                        if (*name == 'K')
                                puts("Drop kicked.");
                        else
                                printf("%s.\n", name);
-               }
-               else {
+               } else {
                        if (*name != 'K') {
                                printf("You aren't holding the %s.\n", objsht[value]);
-                               if (testbit(location[position].objects,value)) {
+                               if (testbit(location[position].objects, value)) {
                                        if (*name == 'T')
                                                puts("Kicked instead.");
                                        else if (*name == 'G')
@@ -312,74 +311,78 @@ char *name;
                if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
                        wordnumber++;
                else
-                       return(firstnumber);
+                       return (firstnumber);
        }
        puts("Do what?");
-       return(-1);
+       return (-1);
 }
 
+int
 takeoff()
 {
        wordnumber = take(wear);
-       return(drop("Dropped"));
+       return (drop("Dropped"));
 }
 
+int
 puton()
 {
        wordnumber = take(location[position].objects);
-       return(wearit());
+       return (wearit());
 }
 
+int
 eat()
 {
-       int firstnumber, value;
+       int     firstnumber, value;
 
        firstnumber = wordnumber;
-       while(wordtype[++wordnumber] == ADJS);
-       while(wordnumber <= wordcount){
+       while (wordtype[++wordnumber] == ADJS);
+       while (wordnumber <= wordcount) {
                value = wordvalue[wordnumber];
-               switch(value){
-                       
-                       case -1:
-                               puts("Eat what?");
-                               return(firstnumber);
-
-                       default:
-                               printf("You can't eat%s%s!\n",
-                                       wordtype[wordnumber] == OBJECT &&
-                                       objsht[value]
-                                       [strlen(objsht[value]) - 1] == 's' ?
-                                       " " : " a ",
-                                       words[wordnumber]);
-                               return(firstnumber);
-
-                       case PAPAYAS:
-                       case PINEAPPLE:
-                       case KIWI:
-                       case COCONUTS:  /* eatable things */
-                       case MANGO:
-
-                               printf("%s:\n",objsht[value]);
-                               if (testbit(inven,value) && time > ate - CYCLE && testbit(inven,KNIFE)){
-                                       clearbit(inven,value);
-                                       carrying -= objwt[value];
-                                       encumber -= objcumber[value];
-                                       ate = max(time,ate) + CYCLE/3;
-                                       snooze += CYCLE/10;
-                                       time++;
-                                       puts("Eaten.  You can explore a little longer now.");
-                               }
-                               else if (time < ate - CYCLE)
-                                       puts("You're stuffed.");
-                               else if (!testbit(inven,KNIFE))
-                                       puts("You need a knife.");
-                               else
-                                       printf("You aren't holding the %s.\n", objsht[value]);
-                               if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
-                                       wordnumber++;
-                               else 
-                                       return(firstnumber);
-               } /* end switch */
-       } /* end while */
-       return(firstnumber);
+               switch (value) {
+
+               case -1:
+                       puts("Eat what?");
+                       return (firstnumber);
+
+               default:
+                       printf("You can't eat%s%s!\n",
+                           wordtype[wordnumber] == OBJECT &&
+                           objsht[value]
+                           [strlen(objsht[value]) - 1] == 's' ?
+                           " " : " a ",
+                           words[wordnumber]);
+                       return (firstnumber);
+
+               case PAPAYAS:
+               case PINEAPPLE:
+               case KIWI:
+               case COCONUTS:  /* eatable things */
+               case MANGO:
+
+                       printf("%s:\n", objsht[value]);
+                       if (testbit(inven, value) &&
+                           ourtime > ate - CYCLE &&
+                           testbit(inven, KNIFE)) {
+                               clearbit(inven, value);
+                               carrying -= objwt[value];
+                               encumber -= objcumber[value];
+                               ate = max(ourtime, ate) + CYCLE / 3;
+                               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, KNIFE))
+                               puts("You need a knife.");
+                       else
+                               printf("You aren't holding the %s.\n", objsht[value]);
+                       if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
+                               wordnumber++;
+                       else
+                               return (firstnumber);
+               }               /* end switch */
+       }                       /* end while */
+       return (firstnumber);
 }