]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - battlestar/command3.c
Simplify, little KNF
[bsdgames-darwin.git] / battlestar / command3.c
index f8a01101ee81caf3bd89e7e23f11dfd970a92f99..f4ccb6d916e3b5375bc05ef0260798aaf19ddda6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: command3.c,v 1.1 2001/10/19 03:06:11 tv Exp $  */
+/*     $NetBSD: command3.c,v 1.5 2019/02/03 03:19:25 mrg Exp $ */
 
 /*
  * Copyright (c) 1983, 1993
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
 #if 0
 static char sccsid[] = "@(#)com3.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: command3.c,v 1.1 2001/10/19 03:06:11 tv Exp $");
+__RCSID("$NetBSD: command3.c,v 1.5 2019/02/03 03:19:25 mrg Exp $");
 #endif
 #endif                         /* not lint */
 
 #include "extern.h"
 
 void
-dig()
+dig(void)
 {
        if (testbit(inven, SHOVEL)) {
                puts("OK");
@@ -69,7 +65,7 @@ dig()
 }
 
 int
-jump()
+jump(void)
 {
        int     n;
 
@@ -109,36 +105,51 @@ jump()
 }
 
 void
-bury()
+bury(void)
 {
        int     value;
 
        if (testbit(inven, SHOVEL)) {
-               while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
+               while (wordtype[++wordnumber] != OBJECT && 
+                   wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
                        continue;
                value = wordvalue[wordnumber];
-               if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, value) || value == BODY))
+               if (wordtype[wordnumber] == NOUNS && 
+                   (testbit(location[position].objects, value) || 
+                   value == BODY))
                        switch (value) {
                        case BODY:
                                wordtype[wordnumber] = OBJECT;
-                               if (testbit(inven, MAID) || testbit(location[position].objects, MAID))
+                               if (testbit(inven, MAID) || 
+                                   testbit(location[position].objects, MAID))
                                        value = MAID;
-                               if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD))
+                               if (testbit(inven, DEADWOOD) || 
+                                   testbit(location[position].objects, 
+                                       DEADWOOD))
                                        value = DEADWOOD;
-                               if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD))
+                               if (testbit(inven, DEADGOD) || 
+                                   testbit(location[position].objects, 
+                                       DEADGOD))
                                        value = DEADGOD;
-                               if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME))
+                               if (testbit(inven, DEADTIME) || 
+                                   testbit(location[position].objects, 
+                                       DEADTIME))
                                        value = DEADTIME;
-                               if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE))
+                               if (testbit(inven, DEADNATIVE) || 
+                                   testbit(location[position].objects, 
+                                       DEADNATIVE))
                                        value = DEADNATIVE;
                                break;
 
                        case NATIVE:
                        case NORMGOD:
-                               puts("She screams as you wrestle her into the hole.");
+                               printf("She screams as you wrestle her into ");
+                               puts("the hole.");
+                               /* FALLTHROUGH */
                        case TIMER:
                                power += 7;
                                ego -= 10;
+                               /* FALLTHROUGH */
                        case AMULET:
                        case MEDALION:
                        case TALISMAN:
@@ -148,7 +159,9 @@ bury()
                        default:
                                puts("Wha..?");
                        }
-               if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven, value) || testbit(location[position].objects, value))) {
+               if (wordtype[wordnumber] == OBJECT && position > 88 && 
+                   (testbit(inven, value) || 
+                   testbit(location[position].objects, value))) {
                        puts("Buried.");
                        if (testbit(inven, value)) {
                                clearbit(inven, value);
@@ -163,7 +176,8 @@ bury()
                        case DEADTIME:
                        case DEADGOD:
                                ego += 2;
-                               printf("The %s should rest easier now.\n", objsht[value]);
+                               printf("The %s should rest easier now.\n", 
+                                   objsht[value]);
                        }
                } else
                        puts("It doesn't seem to work.");
@@ -172,13 +186,15 @@ bury()
 }
 
 void
-drink()
+drink(void)
 {
        int     n;
 
        if (testbit(inven, POTION)) {
-               puts("The cool liquid runs down your throat but turns to fire and you choke.");
-               puts("The heat reaches your limbs and tingles your spirit.  You feel like falling");
+               printf("The cool liquid runs down your throat but turns to ");
+               puts("fire and you choke.");
+               printf("The heat reaches your limbs and tingles your spirit.");
+               puts("  You feel like falling");
                puts("asleep.");
                clearbit(inven, POTION);
                WEIGHT = MAXWEIGHT;
@@ -192,7 +208,7 @@ drink()
 }
 
 int
-shoot()
+shoot(void)
 {
        int     firstnumber, value;
 
@@ -201,7 +217,8 @@ shoot()
                puts("You aren't holding a blaster.");
        else {
                wordnumber++;
-               while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
+               while (wordnumber <= wordcount && 
+                   wordtype[wordnumber] == OBJECT) {
                        value = wordvalue[wordnumber];
                        printf("%s:\n", objsht[value]);
                        if (testbit(location[position].objects, value)) {
@@ -212,8 +229,10 @@ shoot()
                                if (value == BOMB)
                                        die();
                        } else
-                               printf("I don't see any %s around here.\n", objsht[value]);
-                       if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
+                               printf("I don't see any %s around here.\n", 
+                                   objsht[value]);
+                       if (wordnumber < wordcount - 1 && 
+                           wordvalue[++wordnumber] == AND)
                                wordnumber++;
                        else
                                return (firstnumber);
@@ -239,11 +258,15 @@ shoot()
                                        whichway(location[position]);
                                        break;
                                case 31:
-                                       puts("The laser blast has no effect on the door.");
+                                       printf("The laser blast has no ");
+                                       puts("effect on the door.");
                                        break;
                                case 20:
-                                       puts("The blast hits the door and it explodes into flame.  The magnesium burns");
-                                       puts("so rapidly that we have no chance to escape.");
+                                       printf("The blast hits the door and ");
+                                       printf("it explodes into flame.  The ");
+                                       puts("magnesium burns");
+                                       printf("so rapidly that we have no ");
+                                       puts("chance to escape.");
                                        die();
                                default:
                                        puts("Nothing happens.");
@@ -251,19 +274,31 @@ shoot()
                                break;
 
                        case NORMGOD:
-                               if (testbit(location[position].objects, BATHGOD)) {
-                                       puts("The goddess is hit in the chest and splashes back against the rocks.");
-                                       puts("Dark blood oozes from the charred blast hole.  Her naked body floats in the");
+                               if (testbit(location[position].objects, 
+                                   BATHGOD)) {
+                                       printf("The goddess is hit in the ");
+                                       printf("chest and splashes back ");
+                                       puts("against the rocks.");
+                                       printf("Dark blood oozes from the ");
+                                       printf("charred blast hole.  Her ");
+                                       puts("naked body floats in the");
                                        puts("pools and then off downstream.");
-                                       clearbit(location[position].objects, BATHGOD);
+                                       clearbit(location[position].objects, 
+                                           BATHGOD);
                                        setbit(location[180].objects, DEADGOD);
                                        power += 5;
                                        ego -= 10;
                                        notes[JINXED]++;
                                } else
-                                       if (testbit(location[position].objects, NORMGOD)) {
-                                               puts("The blast catches the goddess in the stomach, knocking her to the ground.");
-                                               puts("She writhes in the dirt as the agony of death taunts her.");
+                                       if (testbit(location[position].objects,
+                                           NORMGOD)) {
+                                               printf("The blast catches ");
+                                               printf("the goddess in the ");
+                                               printf("stomach, knocking ");
+                                               puts("her to the ground.");
+                                               printf("She writhes in the ");
+                                               printf("dirt as the agony of ");
+                                               puts("death taunts her.");
                                                puts("She has stopped moving.");
                                                clearbit(location[position].objects, NORMGOD);
                                                setbit(location[position].objects, DEADGOD);
@@ -273,34 +308,47 @@ shoot()
                                                if (wintime)
                                                        live();
                                                break;
-                                       } else
-                                               puts("I don't see any goddess around here.");
+                                       } else {
+                                               printf("I don't see any ");
+                                               puts("goddess around here.");
+                                       }
                                break;
 
                        case TIMER:
-                               if (testbit(location[position].objects, TIMER)) {
-                                       puts("The old man slumps over the bar.");
+                               if (testbit(location[position].objects, 
+                                   TIMER)) {
+                                       printf("The old man slumps over ");
+                                       puts("the bar.");
                                        power++;
                                        ego -= 2;
                                        notes[JINXED]++;
-                                       clearbit(location[position].objects, TIMER);
-                                       setbit(location[position].objects, DEADTIME);
+                                       clearbit(location[position].objects, 
+                                           TIMER);
+                                       setbit(location[position].objects, 
+                                           DEADTIME);
                                } else
                                        puts("What old-timer?");
                                break;
                        case MAN:
                                if (testbit(location[position].objects, MAN)) {
-                                       puts("The man falls to the ground with blood pouring all over his white suit.");
+                                       printf("The man falls to the ground ");
+                                       printf("with blood pouring all over ");
+                                       puts("his white suit.");
                                        puts("Your fantasy is over.");
                                        die();
                                } else
                                        puts("What man?");
                                break;
                        case NATIVE:
-                               if (testbit(location[position].objects, NATIVE)) {
-                                       puts("The girl is blown backwards several feet and lies in a pool of blood.");
-                                       clearbit(location[position].objects, NATIVE);
-                                       setbit(location[position].objects, DEADNATIVE);
+                               if (testbit(location[position].objects, 
+                                   NATIVE)) {
+                                       printf("The girl is blown backwards ");
+                                       printf("several feet and lies in a ");
+                                       puts("pool of blood.");
+                                       clearbit(location[position].objects, 
+                                           NATIVE);
+                                       setbit(location[position].objects, 
+                                           DEADNATIVE);
                                        power += 5;
                                        ego -= 2;
                                        notes[JINXED]++;
@@ -312,7 +360,8 @@ shoot()
                                break;
 
                        default:
-                               printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]);
+                               printf("You can't shoot the %s.\n", 
+                                   objsht[wordvalue[wordnumber]]);
                        }
                } else
                        puts("You must be a looney.");