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

unix.superglobalmegacorp.com

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