|
|
1.1 ! root 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();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.