(linenum→info "unix/slp.c:2238")

bsd-games/2.17/sail/extern.h

    1: /*      $NetBSD: extern.h,v 1.27 2004/02/08 00:32:48 jsm Exp $ */
    2: 
    3: /*
    4:  * Copyright (c) 1983, 1993
    5:  *      The Regents of the University of California.  All rights reserved.
    6:  *
    7:  * Redistribution and use in source and binary forms, with or without
    8:  * modification, are permitted provided that the following conditions
    9:  * are met:
   10:  * 1. Redistributions of source code must retain the above copyright
   11:  *    notice, this list of conditions and the following disclaimer.
   12:  * 2. Redistributions in binary form must reproduce the above copyright
   13:  *    notice, this list of conditions and the following disclaimer in the
   14:  *    documentation and/or other materials provided with the distribution.
   15:  * 3. Neither the name of the University nor the names of its contributors
   16:  *    may be used to endorse or promote products derived from this software
   17:  *    without specific prior written permission.
   18:  *
   19:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29:  * SUCH DAMAGE.
   30:  *
   31:  *      @(#)externs.h        8.1 (Berkeley) 5/31/93
   32:  */
   33: 
   34: #include <sys/types.h>
   35: 
   36: #include "machdep.h"
   37: 
   38:         /* program mode */
   39: extern int mode;
   40: #define MODE_PLAYER     1
   41: #define MODE_DRIVER     2
   42: #define MODE_LOGGER     3
   43: 
   44:         /* command line flags */
   45: extern int randomize;                   /* -x, give first available ship */
   46: extern int longfmt;                     /* -l, print score in long format */
   47: extern int nobells;                     /* -b, don't ring bell before Signal */
   48: 
   49:         /* other initial modes */
   50: extern gid_t gid;
   51: extern gid_t egid;
   52: 
   53: #define dieroll()               ((random()) % 6 + 1)
   54: #define sqr(a)          ((a) * (a))
   55: #define min(a,b)        ((a) < (b) ? (a) : (b))
   56: 
   57: #define grappled(a)     ((a)->file->ngrap)
   58: #define fouled(a)       ((a)->file->nfoul)
   59: #define snagged(a)      (grappled(a) + fouled(a))
   60: 
   61: #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
   62: #define fouled2(a, b)   ((a)->file->foul[(b)->file->index].sn_count)
   63: #define snagged2(a, b)  (grappled2(a, b) + fouled2(a, b))
   64: 
   65: #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
   66: #define Xfouled2(a, b)  ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
   67: #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
   68: 
   69: #define cleangrapple(a, b, c)   Cleansnag(a, b, c, 1)
   70: #define cleanfoul(a, b, c)      Cleansnag(a, b, c, 2)
   71: #define cleansnag(a, b, c)      Cleansnag(a, b, c, 3)
   72: 
   73: #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
   74: #define sternrow(sp)    ((sp)->file->row + dr[(sp)->file->dir])
   75: #define sterncol(sp)    ((sp)->file->col + dc[(sp)->file->dir])
   76: 
   77: #define capship(sp)     ((sp)->file->captured?(sp)->file->captured:(sp))
   78: 
   79: #define readyname(r)    ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
   80: 
   81: /* loadL and loadR, should match loadname[] */
   82: #define L_EMPTY         0              /* should be 0, don't change */
   83: #define L_GRAPE         1
   84: #define L_CHAIN         2
   85: #define L_ROUND         3
   86: #define L_DOUBLE        4
   87: #define L_EXPLODE       5
   88: 
   89: /*
   90:  * readyL and readyR, these are bits, except R_EMPTY
   91:  */
   92: #define R_EMPTY         0              /* not loaded and not loading */
   93: #define R_LOADING       1             /* loading */
   94: #define R_DOUBLE        2              /* loading double */
   95: #define R_LOADED        4              /* loaded */
   96: #define R_INITIAL       8             /* loaded initial */
   97: 
   98: #define HULL            0
   99: #define RIGGING         1
  100: 
  101: #define W_CAPTAIN       1
  102: #define W_CAPTURED      2
  103: #define W_CLASS         3
  104: #define W_CREW          4
  105: #define W_DBP           5
  106: #define W_DRIFT         6
  107: #define W_EXPLODE       7
  108: #define W_FILE          8
  109: #define W_FOUL          9
  110: #define W_GUNL          10
  111: #define W_GUNR          11
  112: #define W_HULL          12
  113: #define W_MOVE          13
  114: #define W_OBP           14
  115: #define W_PCREW         15
  116: #define W_UNFOUL        16
  117: #define W_POINTS        17
  118: #define W_QUAL          18
  119: #define W_UNGRAP        19
  120: #define W_RIGG          20
  121: #define W_COL           21
  122: #define W_DIR           22
  123: #define W_ROW           23
  124: #define W_SIGNAL        24
  125: #define W_SINK          25
  126: #define W_STRUCK        26
  127: #define W_TA            27
  128: #define W_ALIVE         28
  129: #define W_TURN          29
  130: #define W_WIND          30
  131: #define W_FS            31
  132: #define W_GRAP          32
  133: #define W_RIG1          33
  134: #define W_RIG2          34
  135: #define W_RIG3          35
  136: #define W_RIG4          36
  137: #define W_BEGIN         37
  138: #define W_END           38
  139: #define W_DDEAD         39
  140: 
  141: #define NLOG 10
  142: struct logs {
  143:         char l_name[20];
  144:         int l_uid;
  145:         int l_shipnum;
  146:         int l_gamenum;
  147:         int l_netpoints;
  148: };
  149: 
  150: struct BP {
  151:         short turnsent;
  152:         struct ship *toship;
  153:         short mensent;
  154: };
  155: 
  156: struct snag {
  157:         short sn_count;
  158:         short sn_turn;
  159: };
  160: 
  161: #define NSCENE  nscene
  162: #define NSHIP   10
  163: #define NBP     3
  164: 
  165: #define NNATION 8
  166: #define N_A     0
  167: #define N_B     1
  168: #define N_S     2
  169: #define N_F     3
  170: #define N_J     4
  171: #define N_D     5
  172: #define N_K     6
  173: #define N_O     7
  174: 
  175: struct File {
  176:         int index;
  177:         char captain[20];              /* 0 */
  178:         short points;                  /* 20 */
  179:         unsigned char loadL;           /* 22 */
  180:         unsigned char loadR;           /* 24 */
  181:         unsigned char readyL;          /* 26 */
  182:         unsigned char readyR;          /* 28 */
  183:         struct BP OBP[NBP];            /* 30 */
  184:         struct BP DBP[NBP];            /* 48 */
  185:         char struck;                   /* 66 */
  186:         struct ship *captured;         /* 68 */
  187:         short pcrew;                   /* 70 */
  188:         char movebuf[10];              /* 72 */
  189:         char drift;                    /* 82 */
  190:         short nfoul;
  191:         short ngrap;
  192:         struct snag foul[NSHIP];       /* 84 */
  193:         struct snag grap[NSHIP];       /* 124 */
  194:         char RH;                       /* 224 */
  195:         char RG;                       /* 226 */
  196:         char RR;                       /* 228 */
  197:         char FS;                       /* 230 */
  198:         char explode;                  /* 232 */
  199:         char sink;                     /* 234 */
  200:         unsigned char dir;
  201:         short col;
  202:         short row;
  203:         char loadwith;
  204:         char stern;
  205: };
  206: 
  207: struct ship {
  208:         const char *shipname;          /* 0 */
  209:         struct shipspecs *specs;       /* 2 */
  210:         unsigned char nationality;     /* 4 */
  211:         short shiprow;                 /* 6 */
  212:         short shipcol;                 /* 8 */
  213:         char shipdir;                  /* 10 */
  214:         struct File *file;             /* 12 */
  215: };
  216: 
  217: struct scenario {
  218:         char winddir;                  /* 0 */
  219:         char windspeed;                        /* 2 */
  220:         char windchange;               /* 4 */
  221:         unsigned char vessels;         /* 12 */
  222:         const char *name;              /* 14 */
  223:         struct ship ship[NSHIP];       /* 16 */
  224: };
  225: extern struct scenario scene[];
  226: extern int nscene;
  227: 
  228: struct shipspecs {
  229:         char bs;
  230:         char fs;
  231:         char ta;
  232:         short guns;
  233:         unsigned char class;
  234:         char hull;
  235:         unsigned char qual;
  236:         char crew1;
  237:         char crew2;
  238:         char crew3;
  239:         char gunL;
  240:         char gunR;
  241:         char carL;
  242:         char carR;
  243:         int rig1;
  244:         int rig2;
  245:         int rig3;
  246:         int rig4;
  247:         short pts;
  248: };
  249: extern struct shipspecs specs[];
  250: 
  251: extern struct scenario *cc;             /* the current scenario */
  252: extern struct ship *ls;         /* &cc->ship[cc->vessels] */
  253: 
  254: #define SHIP(s)         (&cc->ship[s])
  255: #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
  256: 
  257: struct windeffects {
  258:         char A, B, C, D;
  259: };
  260: extern const struct windeffects WET[7][6];
  261: 
  262: struct Tables {
  263:         char H, G, C, R;
  264: };
  265: extern const struct Tables RigTable[11][6];
  266: extern const struct Tables HullTable[11][6];
  267: 
  268: extern const char AMMO[9][4];
  269: extern const char HDT[9][10];
  270: extern const char HDTrake[9][10];
  271: extern const char QUAL[9][5];
  272: extern const char MT[9][3];
  273: 
  274: extern const char *const countryname[];
  275: extern const char *const classname[];
  276: extern const char *const directionname[];
  277: extern const char *const qualname[];
  278: extern const char loadname[];
  279: 
  280: extern const char rangeofshot[];
  281: 
  282: extern const char dr[], dc[];
  283: 
  284: extern int winddir;
  285: extern int windspeed;
  286: extern int turn;
  287: extern int game;
  288: extern int alive;
  289: extern int people;
  290: extern int hasdriver;
  291: 
  292: /* assorted.c */
  293: void table (struct ship *, struct ship *, int, int, int, int);
  294: void Cleansnag (struct ship *, struct ship *, int, int);
  295: 
  296: /* dr_1.c */
  297: void unfoul (void);
  298: void boardcomp (void);
  299: void resolve (void);
  300: void compcombat (void);
  301: int next (void);
  302: 
  303: /* dr_2.c */
  304: void thinkofgrapples (void);
  305: void checkup (void);
  306: void prizecheck (void);
  307: void closeon (struct ship *, struct ship *, char *, int, int, int);
  308: 
  309: /* dr_3.c */
  310: void moveall (void);
  311: void sendbp (struct ship *, struct ship *, int, int);
  312: int is_toughmelee (struct ship *, struct ship *, int, int);
  313: void reload (void);
  314: void checksails (void);
  315: 
  316: /* dr_4.c */
  317: void ungrap (struct ship *, struct ship *);
  318: void grap (struct ship *, struct ship *);
  319: 
  320: /* dr_5.c */
  321: void subtract (struct ship *, struct ship *, int, int [3], int);
  322: int mensent (struct ship *, struct ship *, int[3], struct ship **, int *,
  323:     int);
  324: 
  325: /* dr_main.c */
  326: int dr_main (void);
  327: 
  328: /* game.c */
  329: int maxturns (struct ship *, char *);
  330: int maxmove (struct ship *, int, int);
  331: 
  332: /* lo_main.c */
  333: int lo_main (void);
  334: 
  335: /* misc.c */
  336: int range (struct ship *, struct ship *);
  337: struct ship *closestenemy (struct ship *, int, int);
  338: int gunsbear (struct ship *, struct ship *);
  339: int portside (struct ship *, struct ship *, int);
  340: int colours (struct ship *);
  341: void logger (struct ship *);
  342: 
  343: /* parties.c */
  344: int meleeing (struct ship *, struct ship *);
  345: int boarding (struct ship *, int);
  346: void unboard (struct ship *, struct ship *, int);
  347: 
  348: /* pl_1.c */
  349: void leave (int) __attribute__((__noreturn__));
  350: void choke (int) __attribute__((__noreturn__));
  351: void child (int);
  352: 
  353: /* pl_2.c */
  354: void play (void) __attribute__((__noreturn__));
  355: 
  356: /* pl_3.c */
  357: void acceptcombat (void);
  358: void grapungrap (void);
  359: void unfoulplayer (void);
  360: 
  361: /* pl_4.c */
  362: void changesail (void);
  363: void acceptsignal (void);
  364: void lookout (void);
  365: const char *saywhat (struct ship *, int);
  366: void eyeball (struct ship *);
  367: 
  368: /* pl_5.c */
  369: void acceptmove (void);
  370: void acceptboard (void);
  371: 
  372: /* pl_6.c */
  373: void repair (void);
  374: void loadplayer (void);
  375: 
  376: /* pl_7.c */
  377: void initscreen (void);
  378: void cleanupscreen (void);
  379: void newturn (int);
  380: void Signal (const char *, struct ship *, ...)
  381:          __attribute__((__format__(__printf__,1,3)));
  382: void Msg (const char *, ...)
  383:          __attribute__((__format__(__printf__,1,2)));
  384: void prompt (const char *, struct ship *);
  385: int sgetch (const char *, struct ship *, int);
  386: void sgetstr (const char *, char *, int);
  387: void draw_screen (void);
  388: void draw_view (void);
  389: void draw_turn (void);
  390: void draw_stat (void);
  391: void draw_slot (void);
  392: void draw_board (void);
  393: void centerview (void);
  394: void upview (void);
  395: void downview (void);
  396: void leftview (void);
  397: void rightview (void);
  398: 
  399: /* pl_main.c */
  400: int pl_main (void);
  401: 
  402: /* sync.c */
  403: void fmtship (char *, size_t, const char *, struct ship *);
  404: void makesignal (struct ship *, const char *, struct ship *, ...)
  405:          __attribute__((__format__(__printf__,2,4)));
  406: void makemsg (struct ship *, const char *, ...)
  407:          __attribute__((__format__(__printf__,2,3)));
  408: int sync_exists (int);
  409: int sync_open (void);
  410: void sync_close (int);
  411: void Write (int, struct ship *, long, long, long, long);
  412: void Writestr (int, struct ship *, const char *);
  413: int Sync (void);
Syntax (Markdown)