diff options
-rw-r--r-- | battlestar/extern.h | 297 | ||||
-rw-r--r-- | sail/extern.h | 310 |
2 files changed, 607 insertions, 0 deletions
diff --git a/battlestar/extern.h b/battlestar/extern.h new file mode 100644 index 00000000..76cf14a1 --- /dev/null +++ b/battlestar/extern.h @@ -0,0 +1,297 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)externs.h 8.1 (Berkeley) 5/31/93 + */ + +#include <sys/signal.h> +#include <stdio.h> + +#define BITS (8 * sizeof (int)) + +#define OUTSIDE (position > 68 && position < 246 && position != 218) +#define rnd(x) (rand() % (x)) +#define max(a,b) ((a) < (b) ? (b) : (a)) +#define testbit(array, index) (array[index/BITS] & (1 << (index % BITS))) +#define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS))) +#define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS))) + + /* well known rooms */ +#define FINAL 275 +#define GARDEN 197 +#define POOLS 126 +#define DOCK 93 + + /* word types */ +#define VERB 0 +#define OBJECT 1 +#define NOUNS 2 +#define PREPS 3 +#define ADJS 4 +#define CONJ 5 + + /* words numbers */ +#define KNIFE 0 +#define SWORD 1 +#define LAND 2 +#define WOODSMAN 3 +#define TWO_HANDED 4 +#define CLEAVER 5 +#define BROAD 6 +#define MAIL 7 +#define HELM 8 +#define SHIELD 9 +#define MAID 10 +#define BODY 10 +#define VIPER 11 +#define LAMPON 12 +#define SHOES 13 +#define CYLON 14 +#define PAJAMAS 15 +#define ROBE 16 +#define AMULET 17 +#define MEDALION 18 +#define TALISMAN 19 +#define DEADWOOD 20 +#define MALLET 21 +#define LASER 22 +#define BATHGOD 23 +#define NORMGOD 24 +#define GRENADE 25 +#define CHAIN 26 +#define ROPE 27 +#define LEVIS 28 +#define MACE 29 +#define SHOVEL 30 +#define HALBERD 31 +#define COMPASS 32 +#define CRASH 33 +#define ELF 34 +#define FOOT 35 +#define COINS 36 +#define MATCHES 37 +#define MAN 38 +#define PAPAYAS 39 +#define PINEAPPLE 40 +#define KIWI 41 +#define COCONUTS 42 +#define MANGO 43 +#define RING 44 +#define POTION 45 +#define BRACELET 46 +#define GIRL 47 +#define GIRLTALK 48 +#define DARK 49 +#define TIMER 50 +#define CHAR 53 +#define BOMB 54 +#define DEADGOD 55 +#define DEADTIME 56 +#define DEADNATIVE 57 +#define NATIVE 58 +#define HORSE 59 +#define CAR 60 +#define POT 61 +#define BAR 62 +#define BLOCK 63 +#define NUMOFOBJECTS 64 + /* non-objects below */ +#define UP 1000 +#define DOWN 1001 +#define AHEAD 1002 +#define BACK 1003 +#define RIGHT 1004 +#define LEFT 1005 +#define TAKE 1006 +#define USE 1007 +#define LOOK 1008 +#define QUIT 1009 +#define NORTH 1010 +#define SOUTH 1011 +#define EAST 1012 +#define WEST 1013 +#define SU 1014 +#define DROP 1015 +#define TAKEOFF 1016 +#define DRAW 1017 +#define PUTON 1018 +#define WEARIT 1019 +#define PUT 1020 +#define INVEN 1021 +#define EVERYTHING 1022 +#define AND 1023 +#define KILL 1024 +#define RAVAGE 1025 +#define UNDRESS 1026 +#define THROW 1027 +#define LAUNCH 1028 +#define LANDIT 1029 +#define LIGHT 1030 +#define FOLLOW 1031 +#define KISS 1032 +#define LOVE 1033 +#define GIVE 1034 +#define SMITE 1035 +#define SHOOT 1036 +#define ON 1037 +#define OFF 1038 +#define TIME 1039 +#define SLEEP 1040 +#define DIG 1041 +#define EAT 1042 +#define SWIM 1043 +#define DRINK 1044 +#define DOOR 1045 +#define SAVE 1046 +#define RIDE 1047 +#define DRIVE 1048 +#define SCORE 1049 +#define BURY 1050 +#define JUMP 1051 +#define KICK 1052 + + /* injuries */ +#define ARM 6 /* broken arm */ +#define RIBS 7 /* broken ribs */ +#define SPINE 9 /* broken back */ +#define SKULL 11 /* fractured skull */ +#define INCISE 10 /* deep incisions */ +#define NECK 12 /* broken NECK */ +#define NUMOFINJURIES 13 + + /* notes */ +#define CANTLAUNCH 0 +#define LAUNCHED 1 +#define CANTSEE 2 +#define CANTMOVE 3 +#define JINXED 4 +#define DUG 5 +#define NUMOFNOTES 6 + + /* fundamental constants */ +#define NUMOFROOMS 275 +#define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS) +#define LINELENGTH 81 + +#define TODAY 0 +#define TONIGHT 1 +#define CYCLE 100 + + /* initial variable values */ +#define TANKFULL 250 +#define TORPEDOES 10 +#define MAXWEIGHT 60 +#define MAXCUMBER 10 + +struct room { + char *name; + int link[8]; +#define north link[0] +#define south link[1] +#define east link[2] +#define west link[3] +#define up link[4] +#define access link[5] +#define down link[6] +#define flyhere link[7] + char *desc; + unsigned int objects[NUMOFWORDS]; +}; +struct room dayfile[]; +struct room nightfile[]; +struct room *location; + + /* object characteristics */ +char *objdes[NUMOFOBJECTS]; +char *objsht[NUMOFOBJECTS]; +char *ouch[NUMOFINJURIES]; +int objwt[NUMOFOBJECTS]; +int objcumber[NUMOFOBJECTS]; + + /* current input line */ +#define NWORD 20 /* words per line */ +char words[NWORD][15]; +int wordvalue[NWORD]; +int wordtype[NWORD]; +int wordcount, wordnumber; + +char *truedirec(), *rate(); +char *getcom(), *getword(); + + /* state of the game */ +int time; +int position; +int direction; +int left, right, ahead, back; +int clock, fuel, torps; +int carrying, encumber; +int rythmn; +int followfight; +int ate; +int snooze; +int meetgirl; +int followgod; +int godready; +int win; +int wintime; +int wiz; +int tempwiz; +int matchlight, matchcount; +int loved; +int pleasure, power, ego; +int WEIGHT; +int CUMBER; +int notes[NUMOFNOTES]; +unsigned int inven[NUMOFWORDS]; +unsigned int wear[NUMOFWORDS]; +char beenthere[NUMOFROOMS+1]; +char injuries[NUMOFINJURIES]; + +char uname[9]; + +struct wlist { + char *string; + int value, article; + struct wlist *next; +}; +#define HASHSIZE 256 +#define HASHMUL 81 +#define HASHMASK (HASHSIZE - 1) +struct wlist *hashtab[HASHSIZE]; +struct wlist wlist[]; + +struct objs { + short room; + short obj; +}; +struct objs dayobjs[]; +struct objs nightobjs[]; diff --git a/sail/extern.h b/sail/extern.h new file mode 100644 index 00000000..4ee80754 --- /dev/null +++ b/sail/extern.h @@ -0,0 +1,310 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)externs.h 8.1 (Berkeley) 5/31/93 + */ + +#include <stdio.h> +#include <signal.h> +#include <ctype.h> +#include <setjmp.h> +#include "machdep.h" + + /* program mode */ +int mode; +jmp_buf restart; +#define MODE_PLAYER 1 +#define MODE_DRIVER 2 +#define MODE_LOGGER 3 + + /* command line flags */ +char debug; /* -D */ +char randomize; /* -x, give first available ship */ +char longfmt; /* -l, print score in long format */ +char nobells; /* -b, don't ring bell before Signal */ + + /* other initial modes */ +char issetuid; /* running setuid */ + +#define die() ((rand() >> 3) % 6 + 1) +#define sqr(a) ((a) * (a)) +#define abs(a) ((a) > 0 ? (a) : -(a)) +#define min(a,b) ((a) < (b) ? (a) : (b)) + +#define grappled(a) ((a)->file->ngrap) +#define fouled(a) ((a)->file->nfoul) +#define snagged(a) (grappled(a) + fouled(a)) + +#define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count) +#define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count) +#define snagged2(a, b) (grappled2(a, b) + fouled2(a, b)) + +#define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0) +#define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0) +#define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b)) + +#define cleangrapple(a, b, c) Cleansnag(a, b, c, 1) +#define cleanfoul(a, b, c) Cleansnag(a, b, c, 2) +#define cleansnag(a, b, c) Cleansnag(a, b, c, 3) + +#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0)) +#define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir]) +#define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir]) + +#define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp)) + +#define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' ')) + +/* loadL and loadR, should match loadname[] */ +#define L_EMPTY 0 /* should be 0, don't change */ +#define L_GRAPE 1 +#define L_CHAIN 2 +#define L_ROUND 3 +#define L_DOUBLE 4 +#define L_EXPLODE 5 + +/* + * readyL and readyR, these are bits, except R_EMPTY + */ +#define R_EMPTY 0 /* not loaded and not loading */ +#define R_LOADING 1 /* loading */ +#define R_DOUBLE 2 /* loading double */ +#define R_LOADED 4 /* loaded */ +#define R_INITIAL 8 /* loaded initial */ + +#define HULL 0 +#define RIGGING 1 + +#define W_CAPTAIN 1 +#define W_CAPTURED 2 +#define W_CLASS 3 +#define W_CREW 4 +#define W_DBP 5 +#define W_DRIFT 6 +#define W_EXPLODE 7 +#define W_FILE 8 +#define W_FOUL 9 +#define W_GUNL 10 +#define W_GUNR 11 +#define W_HULL 12 +#define W_MOVE 13 +#define W_OBP 14 +#define W_PCREW 15 +#define W_UNFOUL 16 +#define W_POINTS 17 +#define W_QUAL 18 +#define W_UNGRAP 19 +#define W_RIGG 20 +#define W_COL 21 +#define W_DIR 22 +#define W_ROW 23 +#define W_SIGNAL 24 +#define W_SINK 25 +#define W_STRUCK 26 +#define W_TA 27 +#define W_ALIVE 28 +#define W_TURN 29 +#define W_WIND 30 +#define W_FS 31 +#define W_GRAP 32 +#define W_RIG1 33 +#define W_RIG2 34 +#define W_RIG3 35 +#define W_RIG4 36 +#define W_BEGIN 37 +#define W_END 38 +#define W_DDEAD 39 + +#define NLOG 10 +struct logs { + char l_name[20]; + int l_uid; + int l_shipnum; + int l_gamenum; + int l_netpoints; +}; + +struct BP { + short turnsent; + struct ship *toship; + short mensent; +}; + +struct snag { + short sn_count; + short sn_turn; +}; + +#define NSCENE nscene +#define NSHIP 10 +#define NBP 3 + +#define NNATION 8 +#define N_A 0 +#define N_B 1 +#define N_S 2 +#define N_F 3 +#define N_J 4 +#define N_D 5 +#define N_K 6 +#define N_O 7 + +struct File { + int index; + char captain[20]; /* 0 */ + short points; /* 20 */ + char loadL; /* 22 */ + char loadR; /* 24 */ + char readyL; /* 26 */ + char readyR; /* 28 */ + struct BP OBP[NBP]; /* 30 */ + struct BP DBP[NBP]; /* 48 */ + char struck; /* 66 */ + struct ship *captured; /* 68 */ + short pcrew; /* 70 */ + char movebuf[10]; /* 72 */ + char drift; /* 82 */ + short nfoul; + short ngrap; + struct snag foul[NSHIP]; /* 84 */ + struct snag grap[NSHIP]; /* 124 */ + char RH; /* 224 */ + char RG; /* 226 */ + char RR; /* 228 */ + char FS; /* 230 */ + char explode; /* 232 */ + char sink; /* 234 */ + char dir; + short col; + short row; + char loadwith; + char stern; +}; + +struct ship { + char *shipname; /* 0 */ + struct shipspecs *specs; /* 2 */ + char nationality; /* 4 */ + short shiprow; /* 6 */ + short shipcol; /* 8 */ + char shipdir; /* 10 */ + struct File *file; /* 12 */ +}; + +struct scenario { + char winddir; /* 0 */ + char windspeed; /* 2 */ + char windchange; /* 4 */ + char vessels; /* 12 */ + char *name; /* 14 */ + struct ship ship[NSHIP]; /* 16 */ +}; +struct scenario scene[]; +int nscene; + +struct shipspecs { + char bs; + char fs; + char ta; + short guns; + char class; + char hull; + char qual; + char crew1; + char crew2; + char crew3; + char gunL; + char gunR; + char carL; + char carR; + char rig1; + char rig2; + char rig3; + char rig4; + short pts; +}; +struct shipspecs specs[]; + +struct scenario *cc; /* the current scenario */ +struct ship *ls; /* &cc->ship[cc->vessels] */ + +#define SHIP(s) (&cc->ship[s]) +#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++) + +struct windeffects { + char A, B, C, D; +}; +struct windeffects WET[7][6]; + +struct Tables { + char H, G, C, R; +}; +struct Tables RigTable[11][6]; +struct Tables HullTable[11][6]; + +char AMMO[9][4]; +char HDT[9][10]; +char HDTrake[9][10]; +char QUAL[9][5]; +char MT[9][3]; + +char *countryname[]; +char *classname[]; +char *directionname[]; +char *qualname[]; +char loadname[]; + +char rangeofshot[]; + +char dr[], dc[]; + +int winddir; +int windspeed; +int turn; +int game; +int alive; +int people; +char hasdriver; + +char *info(); +char *quality(); +double arctan(); +char *saywhat(); +struct ship *closestenemy(); + +char *calloc(); +char *rindex(); +char *strcpy(); +char *strcat(); +char *strncpy(); +char *getenv(); +char *gets(); |