Annotation of 43BSDTahoe/games/sail/externs.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.