1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)externs.h	5.1 (Berkeley) 5/29/85
   7:  */
   8: 
   9: #include <stdio.h>
  10: #include <signal.h>
  11: #include <ctype.h>
  12: #include <setjmp.h>
  13: #include "machdep.h"
  14: 
  15:     /* program mode */
  16: int mode;
  17: jmp_buf restart;
  18: #define MODE_PLAYER 1
  19: #define MODE_DRIVER 2
  20: #define MODE_LOGGER 3
  21: 
  22:     /* command line flags */
  23: char debug;             /* -D */
  24: char randomize;             /* -x, give first available ship */
  25: char longfmt;               /* -l, print score in long format */
  26: char nobells;               /* -b, don't ring bell before Signal */
  27: 
  28:     /* other initial modes */
  29: char issetuid;              /* running setuid */
  30: 
  31: #define die()       ((rand() >> 3) % 6 + 1)
  32: #define sqr(a)      ((a) * (a))
  33: #define abs(a)      ((a) > 0 ? (a) : -(a))
  34: #define min(a,b)    ((a) < (b) ? (a) : (b))
  35: 
  36: #define grappled(a) ((a)->file->ngrap)
  37: #define fouled(a)   ((a)->file->nfoul)
  38: #define snagged(a)  (grappled(a) + fouled(a))
  39: 
  40: #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
  41: #define fouled2(a, b)   ((a)->file->foul[(b)->file->index].sn_count)
  42: #define snagged2(a, b)  (grappled2(a, b) + fouled2(a, b))
  43: 
  44: #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
  45: #define Xfouled2(a, b)  ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
  46: #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
  47: 
  48: #define cleangrapple(a, b, c)   Cleansnag(a, b, c, 1)
  49: #define cleanfoul(a, b, c)  Cleansnag(a, b, c, 2)
  50: #define cleansnag(a, b, c)  Cleansnag(a, b, c, 3)
  51: 
  52: #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
  53: #define sternrow(sp)    ((sp)->file->row + dr[(sp)->file->dir])
  54: #define sterncol(sp)    ((sp)->file->col + dc[(sp)->file->dir])
  55: 
  56: #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
  57: 
  58: #define readyname(r)    ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
  59: 
  60: /* loadL and loadR, should match loadname[] */
  61: #define L_EMPTY     0       /* should be 0, don't change */
  62: #define L_GRAPE     1
  63: #define L_CHAIN     2
  64: #define L_ROUND     3
  65: #define L_DOUBLE    4
  66: #define L_EXPLODE   5
  67: 
  68: /*
  69:  * readyL and readyR, these are bits, except R_EMPTY
  70:  */
  71: #define R_EMPTY     0       /* not loaded and not loading */
  72: #define R_LOADING   1       /* loading */
  73: #define R_DOUBLE    2       /* loading double */
  74: #define R_LOADED    4       /* loaded */
  75: #define R_INITIAL   8       /* loaded initial */
  76: 
  77: #define HULL        0
  78: #define RIGGING     1
  79: 
  80: #define W_CAPTAIN   1
  81: #define W_CAPTURED  2
  82: #define W_CLASS     3
  83: #define W_CREW      4
  84: #define W_DBP       5
  85: #define W_DRIFT     6
  86: #define W_EXPLODE   7
  87: #define W_FILE      8
  88: #define W_FOUL      9
  89: #define W_GUNL      10
  90: #define W_GUNR      11
  91: #define W_HULL      12
  92: #define W_MOVE      13
  93: #define W_OBP       14
  94: #define W_PCREW     15
  95: #define W_UNFOUL    16
  96: #define W_POINTS    17
  97: #define W_QUAL      18
  98: #define W_UNGRAP    19
  99: #define W_RIGG      20
 100: #define W_COL       21
 101: #define W_DIR       22
 102: #define W_ROW       23
 103: #define W_SIGNAL    24
 104: #define W_SINK      25
 105: #define W_STRUCK    26
 106: #define W_TA        27
 107: #define W_ALIVE     28
 108: #define W_TURN      29
 109: #define W_WIND      30
 110: #define W_FS        31
 111: #define W_GRAP      32
 112: #define W_RIG1      33
 113: #define W_RIG2      34
 114: #define W_RIG3      35
 115: #define W_RIG4      36
 116: #define W_BEGIN     37
 117: #define W_END       38
 118: #define W_DDEAD     39
 119: 
 120: #define NLOG 10
 121: struct logs {
 122:     char l_name[20];
 123:     int l_uid;
 124:     int l_shipnum;
 125:     int l_gamenum;
 126:     int l_netpoints;
 127: };
 128: 
 129: struct BP {
 130:     short turnsent;
 131:     struct ship *toship;
 132:     short mensent;
 133: };
 134: 
 135: struct snag {
 136:     short sn_count;
 137:     short sn_turn;
 138: };
 139: 
 140: #define NSCENE  nscene
 141: #define NSHIP   10
 142: #define NBP 3
 143: 
 144: #define NNATION 8
 145: #define N_A 0
 146: #define N_B 1
 147: #define N_S 2
 148: #define N_F 3
 149: #define N_J 4
 150: #define N_D 5
 151: #define N_K 6
 152: #define N_O 7
 153: 
 154: struct File {
 155:     int index;
 156:     char captain[20];       /* 0 */
 157:     short points;           /* 20 */
 158:     char loadL;         /* 22 */
 159:     char loadR;         /* 24 */
 160:     char readyL;            /* 26 */
 161:     char readyR;            /* 28 */
 162:     struct BP OBP[NBP];     /* 30 */
 163:     struct BP DBP[NBP];     /* 48 */
 164:     char struck;            /* 66 */
 165:     struct ship *captured;      /* 68 */
 166:     short pcrew;            /* 70 */
 167:     char movebuf[10];       /* 72 */
 168:     char drift;         /* 82 */
 169:     short nfoul;
 170:     short ngrap;
 171:     struct snag foul[NSHIP];    /* 84 */
 172:     struct snag grap[NSHIP];    /* 124 */
 173:     char RH;            /* 224 */
 174:     char RG;            /* 226 */
 175:     char RR;            /* 228 */
 176:     char FS;            /* 230 */
 177:     char explode;           /* 232 */
 178:     char sink;          /* 234 */
 179:     char dir;
 180:     short col;
 181:     short row;
 182:     char loadwith;
 183:     char stern;
 184: };
 185: 
 186: struct ship {
 187:     char *shipname;         /* 0 */
 188:     struct shipspecs *specs;    /* 2 */
 189:     char nationality;       /* 4 */
 190:     short shiprow;          /* 6 */
 191:     short shipcol;          /* 8 */
 192:     char shipdir;           /* 10 */
 193:     struct File *file;      /* 12 */
 194: };
 195: 
 196: struct scenario {
 197:     char winddir;           /* 0 */
 198:     char windspeed;         /* 2 */
 199:     char windchange;        /* 4 */
 200:     char vessels;           /* 12 */
 201:     char *name;         /* 14 */
 202:     struct ship ship[NSHIP];    /* 16 */
 203: };
 204: struct scenario scene[];
 205: int nscene;
 206: 
 207: struct shipspecs {
 208:     char bs;
 209:     char fs;
 210:     char ta;
 211:     short guns;
 212:     char class;
 213:     char hull;
 214:     char qual;
 215:     char crew1;
 216:     char crew2;
 217:     char crew3;
 218:     char gunL;
 219:     char gunR;
 220:     char carL;
 221:     char carR;
 222:     char rig1;
 223:     char rig2;
 224:     char rig3;
 225:     char rig4;
 226:     short pts;
 227: };
 228: struct shipspecs specs[];
 229: 
 230: struct scenario *cc;        /* the current scenario */
 231: struct ship *ls;        /* &cc->ship[cc->vessels] */
 232: 
 233: #define SHIP(s)     (&cc->ship[s])
 234: #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
 235: 
 236: struct windeffects {
 237:     char A, B, C, D;
 238: };
 239: struct windeffects WET[7][6];
 240: 
 241: struct Tables {
 242:     char H, G, C, R;
 243: };
 244: struct Tables RigTable[11][6];
 245: struct Tables HullTable[11][6];
 246: 
 247: char AMMO[9][4];
 248: char HDT[9][10];
 249: char HDTrake[9][10];
 250: char QUAL[9][5];
 251: char MT[9][3];
 252: 
 253: char *countryname[];
 254: char *classname[];
 255: char *directionname[];
 256: char *qualname[];
 257: char loadname[];
 258: 
 259: char rangeofshot[];
 260: 
 261: char dr[], dc[];
 262: 
 263: int winddir;
 264: int windspeed;
 265: int turn;
 266: int game;
 267: int alive;
 268: int people;
 269: char hasdriver;
 270: 
 271: char *info();
 272: char *quality();
 273: double arctan();
 274: char *saywhat();
 275: struct ship *closestenemy();
 276: 
 277: char *calloc();
 278: char *rindex();
 279: char *strcpy();
 280: char *strcat();
 281: char *strncpy();
 282: char *getenv();
 283: char *gets();

Defined variables

AMMO defined in line 247; used 2 times
HDT defined in line 248; used 2 times
HDTrake defined in line 249; used 2 times
HullTable defined in line 245; used 2 times
MT defined in line 251; used 2 times
QUAL defined in line 250; used 2 times
RigTable defined in line 244; used 2 times
WET defined in line 239; used 4 times
alive defined in line 267; used 3 times
cc defined in line 230; used 17 times
dc defined in line 261; used 22 times
debug defined in line 23; used 1 times
directionname defined in line 255; used 1 times
dr defined in line 261; used 22 times
loadname defined in line 257; used 2 times
longfmt defined in line 25; used 2 times
ls defined in line 231; used 5 times
mode defined in line 16; used 9 times
nobells defined in line 26; used 2 times
nscene defined in line 205; used 1 times
qualname defined in line 256; used 1 times
randomize defined in line 24; used 2 times
rangeofshot defined in line 259; used 1 times
restart defined in line 17; used 2 times

Defined struct's

BP defined in line 129; used 26 times
File defined in line 154; used 16 times
Tables defined in line 241; used 12 times
logs defined in line 121; used 14 times
scenario defined in line 196; used 8 times
ship defined in line 186; used 266 times
shipspecs defined in line 207; used 17 times
snag defined in line 135; used 12 times
windeffects defined in line 236; used 4 times

Defined macros

HULL defined in line 77; used 2 times
L_EMPTY defined in line 61; used 5 times
L_EXPLODE defined in line 66; used 1 times
MODE_DRIVER defined in line 19; used 3 times
MODE_LOGGER defined in line 20; used 2 times
MODE_PLAYER defined in line 18; used 2 times
NBP defined in line 142; used 14 times
NLOG defined in line 120; used 11 times
NNATION defined in line 144; used 4 times
NSCENE defined in line 140; used 3 times
NSHIP defined in line 141; used 8 times
N_A defined in line 145; used 27 times
N_B defined in line 146; used 50 times
N_D defined in line 150; used 4 times
N_F defined in line 148; used 33 times
N_J defined in line 149; used 3 times
N_K defined in line 151; used 2 times
N_O defined in line 152; used 2 times
N_S defined in line 147; used 10 times
RIGGING defined in line 78; used 5 times
R_DOUBLE defined in line 73; used 3 times
R_EMPTY defined in line 71; used 4 times
R_LOADING defined in line 72; used 7 times
W_ALIVE defined in line 107; used 1 times
W_BEGIN defined in line 116; used 1 times
W_CAPTAIN defined in line 80; used 1 times
W_CAPTURED defined in line 81; used 2 times
W_CLASS defined in line 82; never used
W_COL defined in line 100; used 1 times
W_CREW defined in line 83; used 2 times
W_DDEAD defined in line 118; used 1 times
W_DIR defined in line 101; used 2 times
W_DRIFT defined in line 85; used 1 times
W_END defined in line 117; used 1 times
W_EXPLODE defined in line 86; used 2 times
W_FILE defined in line 87; never used
W_FOUL defined in line 88; used 2 times
W_GRAP defined in line 111; used 4 times
W_GUNL defined in line 89; used 2 times
W_GUNR defined in line 90; used 2 times
W_HULL defined in line 91; used 2 times
W_MOVE defined in line 92; used 1 times
W_PCREW defined in line 94; used 2 times
W_QUAL defined in line 97; never used
W_RIG1 defined in line 112; used 1 times
W_RIG2 defined in line 113; used 1 times
W_RIG3 defined in line 114; used 1 times
W_RIG4 defined in line 115; used 1 times
W_RIGG defined in line 99; used 1 times
W_ROW defined in line 102; used 1 times
W_SINK defined in line 104; used 2 times
W_STRUCK defined in line 105; used 1 times
W_TA defined in line 106; used 1 times
W_TURN defined in line 108; used 1 times
W_UNFOUL defined in line 95; used 2 times
W_UNGRAP defined in line 98; used 2 times
W_WIND defined in line 109; used 1 times
Xfouled2 defined in line 45; used 1 times
  • in line 46
Xgrappled2 defined in line 44; used 1 times
  • in line 46
Xsnagged2 defined in line 46; used 1 times
abs defined in line 33; used 8 times
cleanfoul defined in line 49; used 2 times
cleangrapple defined in line 48; used 2 times
cleansnag defined in line 50; used 1 times
fouled defined in line 37; used 2 times
fouled2 defined in line 41; used 7 times
grappled defined in line 36; used 2 times
min defined in line 34; used 6 times
readyname defined in line 58; used 2 times
snagged2 defined in line 42; used 2 times
sqr defined in line 32; never used
sterncol defined in line 54; used 1 times
sternrow defined in line 53; used 1 times

Usage of this include

Last modified: 1985-05-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3378
Valid CSS Valid XHTML 1.0 Strict