[BACK]Return to extern.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / games / battlestar

Annotation of src/games/battlestar/extern.h, Revision 1.30

1.30    ! jsm         1: /*     $NetBSD: extern.h,v 1.29 2003/08/07 09:37:02 agc Exp $ */
1.3       tls         2:
1.1       tls         3: /*
                      4:  * Copyright (c) 1983, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
1.29      agc        15:  * 3. Neither the name of the University nor the names of its contributors
1.1       tls        16:  *    may be used to endorse or promote products derived from this software
                     17:  *    without specific prior written permission.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  *
                     31:  *     @(#)externs.h   8.1 (Berkeley) 5/31/93
                     32:  */
1.7       perry      33:
1.5       lukem      34: #include <ctype.h>
1.6       lukem      35: #include <err.h>
1.5       lukem      36: #include <pwd.h>
1.2       tls        37: #include <signal.h>
1.1       tls        38: #include <stdio.h>
1.5       lukem      39: #include <stdlib.h>
1.2       tls        40: #include <string.h>
1.14      jsm        41: #include <time.h>
1.5       lukem      42: #include <unistd.h>
1.1       tls        43:
                     44: #define BITS (8 * sizeof (int))
                     45:
                     46: #define OUTSIDE                (position > 68 && position < 246 && position != 218)
                     47: #define rnd(x)         (rand() % (x))
                     48: #define max(a,b)       ((a) < (b) ? (b) : (a))
                     49: #define testbit(array, index)  (array[index/BITS] & (1 << (index % BITS)))
                     50: #define setbit(array, index)   (array[index/BITS] |= (1 << (index % BITS)))
                     51: #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
                     52:
1.6       lukem      53:  /* well known rooms */
1.1       tls        54: #define FINAL  275
                     55: #define GARDEN 197
                     56: #define POOLS  126
                     57: #define DOCK   93
                     58:
1.6       lukem      59:  /* word types */
1.1       tls        60: #define VERB   0
                     61: #define OBJECT  1
                     62: #define NOUNS  2
                     63: #define PREPS  3
                     64: #define ADJS   4
                     65: #define CONJ   5
                     66:
1.6       lukem      67:  /* words numbers */
                     68: #define KNIFE          0
1.1       tls        69: #define SWORD          1
                     70: #define LAND           2
                     71: #define WOODSMAN       3
                     72: #define TWO_HANDED     4
                     73: #define CLEAVER                5
                     74: #define BROAD          6
                     75: #define MAIL           7
                     76: #define HELM           8
                     77: #define SHIELD         9
                     78: #define MAID           10
                     79: #define BODY           10
                     80: #define VIPER          11
                     81: #define LAMPON         12
                     82: #define SHOES          13
                     83: #define CYLON          14
                     84: #define PAJAMAS                15
                     85: #define ROBE           16
                     86: #define AMULET         17
                     87: #define MEDALION       18
                     88: #define TALISMAN       19
                     89: #define DEADWOOD       20
                     90: #define MALLET         21
                     91: #define LASER          22
                     92: #define BATHGOD                23
                     93: #define NORMGOD                24
                     94: #define GRENADE                25
                     95: #define CHAIN          26
                     96: #define ROPE           27
                     97: #define LEVIS          28
                     98: #define MACE           29
                     99: #define SHOVEL         30
                    100: #define HALBERD                31
                    101: #define        COMPASS         32
                    102: #define        CRASH           33
                    103: #define ELF            34
                    104: #define FOOT           35
                    105: #define COINS          36
                    106: #define MATCHES                37
                    107: #define MAN            38
                    108: #define PAPAYAS                39
                    109: #define PINEAPPLE      40
                    110: #define KIWI           41
                    111: #define COCONUTS       42
                    112: #define MANGO          43
                    113: #define RING           44
                    114: #define POTION         45
                    115: #define BRACELET       46
                    116: #define GIRL           47
                    117: #define GIRLTALK       48
                    118: #define DARK           49
                    119: #define TIMER          50
                    120: #define CHAR           53
                    121: #define BOMB           54
                    122: #define DEADGOD                55
                    123: #define DEADTIME       56
                    124: #define DEADNATIVE     57
                    125: #define NATIVE         58
                    126: #define HORSE          59
                    127: #define CAR            60
                    128: #define POT            61
                    129: #define BAR            62
                    130: #define        BLOCK           63
                    131: #define NUMOFOBJECTS   64
1.6       lukem     132:  /* non-objects below */
1.1       tls       133: #define UP     1000
                    134: #define DOWN   1001
                    135: #define AHEAD  1002
                    136: #define BACK   1003
                    137: #define RIGHT  1004
                    138: #define LEFT   1005
                    139: #define TAKE   1006
                    140: #define USE    1007
                    141: #define LOOK   1008
                    142: #define QUIT   1009
                    143: #define NORTH  1010
                    144: #define SOUTH  1011
                    145: #define EAST   1012
                    146: #define WEST   1013
                    147: #define SU      1014
                    148: #define DROP   1015
                    149: #define TAKEOFF        1016
                    150: #define DRAW   1017
                    151: #define PUTON  1018
                    152: #define WEARIT 1019
                    153: #define PUT    1020
                    154: #define INVEN  1021
                    155: #define EVERYTHING 1022
                    156: #define AND    1023
                    157: #define KILL   1024
                    158: #define RAVAGE 1025
                    159: #define UNDRESS        1026
                    160: #define THROW  1027
                    161: #define LAUNCH 1028
                    162: #define LANDIT 1029
                    163: #define LIGHT  1030
                    164: #define FOLLOW 1031
                    165: #define KISS   1032
                    166: #define LOVE   1033
                    167: #define GIVE   1034
                    168: #define SMITE  1035
                    169: #define SHOOT  1036
                    170: #define ON     1037
                    171: #define        OFF     1038
                    172: #define TIME   1039
                    173: #define SLEEP  1040
                    174: #define DIG    1041
                    175: #define EAT    1042
                    176: #define SWIM   1043
                    177: #define DRINK  1044
                    178: #define DOOR   1045
                    179: #define SAVE   1046
                    180: #define RIDE   1047
                    181: #define DRIVE  1048
                    182: #define SCORE  1049
1.6       lukem     183: #define BURY   1050
1.1       tls       184: #define JUMP   1051
                    185: #define KICK   1052
1.20      jsm       186: #define OPEN   1053
                    187: #define VERBOSE        1054
                    188: #define BRIEF  1055
1.28      jsm       189: #define AUXVERB        1056
1.1       tls       190:
1.6       lukem     191:  /* injuries */
1.1       tls       192: #define ARM    6               /* broken arm */
                    193: #define RIBS   7               /* broken ribs */
                    194: #define SPINE  9               /* broken back */
                    195: #define SKULL  11              /* fractured skull */
                    196: #define INCISE 10              /* deep incisions */
                    197: #define NECK   12              /* broken NECK */
                    198: #define NUMOFINJURIES 13
                    199:
1.6       lukem     200:  /* notes */
1.1       tls       201: #define        CANTLAUNCH      0
                    202: #define LAUNCHED       1
                    203: #define CANTSEE                2
1.6       lukem     204: #define CANTMOVE       3
1.1       tls       205: #define JINXED         4
                    206: #define DUG            5
                    207: #define NUMOFNOTES     6
1.17      jsm       208:
                    209: /* Number of times room description shown. */
                    210: #define ROOMDESC       3
1.1       tls       211:
1.6       lukem     212:  /* fundamental constants */
1.1       tls       213: #define NUMOFROOMS     275
                    214: #define NUMOFWORDS     ((NUMOFOBJECTS + BITS - 1) / BITS)
                    215: #define LINELENGTH     81
                    216:
                    217: #define TODAY          0
                    218: #define TONIGHT                1
                    219: #define CYCLE          100
                    220:
1.6       lukem     221:  /* initial variable values */
1.1       tls       222: #define TANKFULL       250
                    223: #define TORPEDOES      10
                    224: #define MAXWEIGHT      60
                    225: #define MAXCUMBER      10
                    226:
1.27      jsm       227: /*
                    228:  * These are flags for objects in the objflags array.  OBJ_PLURAL means
                    229:  * that the object short name is plural; OBJ_AN that it begins with a
                    230:  * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON
                    231:  * that it is a living person; OBJ_NONOBJ that it is not an object (to
                    232:  * which any game action can be applied) at all (e.g. footsteps, asteroids).
                    233:  * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ.
                    234:  */
1.22      jsm       235: #define OBJ_PLURAL     1
1.26      jsm       236: #define OBJ_AN         2
1.27      jsm       237: #define OBJ_PERSON     4
                    238: #define OBJ_NONOBJ     8
1.22      jsm       239:
1.1       tls       240: struct room {
1.10      hubertf   241:        const char   *name;
1.6       lukem     242:        int     link[8];
1.1       tls       243: #define north  link[0]
                    244: #define south  link[1]
                    245: #define east   link[2]
                    246: #define west   link[3]
                    247: #define up     link[4]
                    248: #define access link[5]
                    249: #define down   link[6]
                    250: #define flyhere        link[7]
1.10      hubertf   251:        const char   *desc;
1.1       tls       252:        unsigned int objects[NUMOFWORDS];
                    253: };
1.8       mrg       254: extern struct room dayfile[];
                    255: extern struct room nightfile[];
1.15      jsm       256: extern struct room *location;
1.1       tls       257:
1.6       lukem     258:  /* object characteristics */
1.15      jsm       259: extern const char   *const objdes[NUMOFOBJECTS];
                    260: extern const char   *const objsht[NUMOFOBJECTS];
                    261: extern const char   *const ouch[NUMOFINJURIES];
                    262: extern const int     objwt[NUMOFOBJECTS];
                    263: extern const int     objcumber[NUMOFOBJECTS];
1.22      jsm       264: extern const int     objflags[NUMOFOBJECTS];
                    265: #define is_plural_object(n)    (objflags[(n)] & OBJ_PLURAL)
1.26      jsm       266: /*
                    267:  * These macros yield words to use with objects (followed but not preceded
                    268:  * by spaces, or with no spaces if the expansion is the empty string).
                    269:  */
                    270: #define A_OR_AN(n)             (objflags[(n)] & OBJ_AN ? "an " : "a ")
                    271: #define A_OR_AN_OR_THE(n)      (is_plural_object((n)) ? "the " : A_OR_AN((n)))
                    272: #define A_OR_AN_OR_BLANK(n)    (is_plural_object((n)) ? "" : A_OR_AN((n)))
                    273: #define IS_OR_ARE(n)           (is_plural_object((n)) ? "are " : "is ")
1.6       lukem     274:
                    275:  /* current input line */
1.21      jsm       276: #define WORDLEN        15
1.6       lukem     277: #define NWORD  20              /* words per line */
1.21      jsm       278: extern char    words[NWORD][WORDLEN];
1.15      jsm       279: extern int     wordvalue[NWORD];
                    280: extern int     wordtype[NWORD];
                    281: extern int     wordcount, wordnumber;
1.6       lukem     282:
                    283:  /* state of the game */
1.15      jsm       284: extern int     ourtime;
                    285: extern int     position;
                    286: extern int     direction;
                    287: extern int     left, right, ahead, back;
                    288: extern int     ourclock, fuel, torps;
                    289: extern int     carrying, encumber;
                    290: extern int     rythmn;
                    291: extern int     followfight;
                    292: extern int     ate;
                    293: extern int     snooze;
                    294: extern int     meetgirl;
                    295: extern int     followgod;
                    296: extern int     godready;
                    297: extern int     win;
                    298: extern int     wintime;
                    299: extern int     wiz;
                    300: extern int     tempwiz;
                    301: extern int     matchlight, matchcount;
                    302: extern int     loved;
                    303: extern int     pleasure, power, ego;
                    304: extern int     WEIGHT;
                    305: extern int     CUMBER;
                    306: extern int     notes[NUMOFNOTES];
                    307: extern unsigned int inven[NUMOFWORDS];
                    308: extern unsigned int wear[NUMOFWORDS];
                    309: extern char    beenthere[NUMOFROOMS + 1];
                    310: extern char    injuries[NUMOFINJURIES];
1.20      jsm       311: extern int     verbose;
1.1       tls       312:
1.19      jsm       313: extern const char *username;
1.1       tls       314:
                    315: struct wlist {
1.10      hubertf   316:        const char   *string;
1.6       lukem     317:        int     value, article;
1.1       tls       318:        struct wlist *next;
                    319: };
1.8       mrg       320: extern struct wlist wlist[];
1.1       tls       321:
                    322: struct objs {
1.6       lukem     323:        short   room;
                    324:        short   obj;
1.1       tls       325: };
1.10      hubertf   326: extern const struct objs dayobjs[];
                    327: extern const struct objs nightobjs[];
1.5       lukem     328:
1.12      hubertf   329: #define DEFAULT_SAVE_FILE      ".Bstar"
                    330:
1.30    ! jsm       331: void bury(void);
        !           332: int card(const char *, int);
        !           333: void chime(void);
        !           334: void convert(int);
        !           335: void crash(void);
        !           336: int cypher(void);
        !           337: void die(void) __attribute__((__noreturn__));
        !           338: void diesig(int) __attribute__((__noreturn__));
        !           339: void dig(void);
        !           340: void dooropen(void);
        !           341: int draw(void);
        !           342: void drink(void);
        !           343: int drive(void);
        !           344: int drop(const char *);
        !           345: int eat(void);
        !           346: int fight(int, int);
        !           347: int follow(void);
        !           348: char *getcom(char *, int, const char *, const char *);
        !           349: char *getword(char *, char *, int);
        !           350: int give(void);
        !           351: void initialize(const char *);
        !           352: int jump(void);
        !           353: void kiss(void);
        !           354: int land(void);
        !           355: int launch(void);
        !           356: void light(void);
        !           357: void live(void) __attribute__((__noreturn__));
        !           358: void love(void);
        !           359: int moveplayer(int, int);
        !           360: void murder(void);
        !           361: void news(void);
        !           362: void newway(int);
        !           363: void open_score_file(void);
        !           364: void parse(void);
        !           365: void post(char);
        !           366: void printobjs(void);
        !           367: int put(void);
        !           368: int puton(void);
        !           369: const char *rate(void);
        !           370: void ravage(void);
        !           371: void restore(const char *);
        !           372: int ride(void);
        !           373: void save(const char *);
        !           374: char *save_file_name(const char *, size_t);
        !           375: int shoot(void);
        !           376: int take(unsigned int[]);
        !           377: int takeoff(void);
        !           378: int throw(const char *);
        !           379: const char *truedirec(int, char);
        !           380: int ucard(const unsigned int *);
        !           381: int use(void);
        !           382: int visual(void);
        !           383: int wearit(void);
        !           384: void whichway(struct room);
        !           385: void wordinit(void);
        !           386: void writedes(void);
        !           387: int zzz(void);

CVSweb <webmaster@jp.NetBSD.org>