Annotation of 43BSDReno/games/trek/trek.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  *
                     19:  *     @(#)trek.h      5.5 (Berkeley) 6/1/90
                     20:  */
                     21: 
                     22: /*
                     23: **  Global Declarations
                     24: **
                     25: **     Virtually all non-local variable declarations are made in this
                     26: **     file.  Exceptions are those things which are initialized, which
                     27: **     are defined in "externs.c", and things which are local to one
                     28: **     program file.
                     29: **
                     30: **     So far as I know, nothing in here must be preinitialized to
                     31: **     zero.
                     32: **
                     33: **     You may have problems from the loader if you move this to a
                     34: **     different machine.  These things actually get allocated in each
                     35: **     source file, which UNIX allows; however, you may (on other
                     36: **     systems) have to change everything in here to be "extern" and
                     37: **     actually allocate stuff in "externs.c"
                     38: */
                     39: 
                     40: /* external function definitions */
                     41: extern double  franf();        /* floating random number function */
                     42: extern double  sqrt();         /* square root */
                     43: extern double  sin(), cos();   /* trig functions */
                     44: extern double  atan2();        /* fancy arc tangent function */
                     45: extern double  log();          /* log base e */
                     46: extern double  pow();          /* power function */
                     47: extern double  fabs();         /* absolute value function */
                     48: extern double  exp();          /* exponential function */
                     49: 
                     50: /*********************  GALAXY  **************************/
                     51: 
                     52: /* galactic parameters */
                     53: # define       NSECTS          10      /* dimensions of quadrant in sectors */
                     54: # define       NQUADS          8       /* dimension of galazy in quadrants */
                     55: # define       NINHAB          32      /* number of quadrants which are inhabited */
                     56: 
                     57: struct quad            /* definition for each quadrant */
                     58: {
                     59:        char    bases;          /* number of bases in this quadrant */
                     60:        char    klings;         /* number of Klingons in this quadrant */
                     61:        char    holes;          /* number of black holes in this quadrant */
                     62:        int     scanned;        /* star chart entry (see below) */
                     63:        char    stars;          /* number of stars in this quadrant */
                     64:        char    qsystemname;    /* starsystem name (see below) */
                     65: };
                     66: 
                     67: # define       Q_DISTRESSED    0200
                     68: # define       Q_SYSTEM        077
                     69: 
                     70: /*  systemname conventions:
                     71:  *     1 -> NINHAB     index into Systemname table for live system.
                     72:  *     + Q_DISTRESSED  distressed starsystem -- systemname & Q_SYSTEM
                     73:  *                     is the index into the Event table which will
                     74:  *                     have the system name
                     75:  *     0               dead or nonexistent starsystem
                     76:  *
                     77:  *  starchart ("scanned") conventions:
                     78:  *     0 -> 999        taken as is
                     79:  *     -1              not yet scanned ("...")
                     80:  *     1000            supernova ("///")
                     81:  *     1001            starbase + ??? (".1.")
                     82: */
                     83: 
                     84: /* ascii names of systems */
                     85: extern char    *Systemname[NINHAB];
                     86: 
                     87: /* quadrant definition */
                     88: struct quad    Quad[NQUADS][NQUADS];
                     89: 
                     90: /* defines for sector map  (below) */
                     91: # define       EMPTY           '.'
                     92: # define       STAR            '*'
                     93: # define       BASE            '#'
                     94: # define       ENTERPRISE      'E'
                     95: # define       QUEENE          'Q'
                     96: # define       KLINGON         'K'
                     97: # define       INHABIT         '@'
                     98: # define       HOLE            ' '
                     99: 
                    100: /* current sector map */
                    101: char   Sect[NSECTS][NSECTS];
                    102: 
                    103: 
                    104: /************************ DEVICES ******************************/
                    105: 
                    106: # define       NDEV            16      /* max number of devices */
                    107: 
                    108: /* device tokens */
                    109: # define       WARP            0       /* warp engines */
                    110: # define       SRSCAN          1       /* short range scanners */
                    111: # define       LRSCAN          2       /* long range scanners */
                    112: # define       PHASER          3       /* phaser control */
                    113: # define       TORPED          4       /* photon torpedo control */
                    114: # define       IMPULSE         5       /* impulse engines */
                    115: # define       SHIELD          6       /* shield control */
                    116: # define       COMPUTER        7       /* on board computer */
                    117: # define       SSRADIO         8       /* subspace radio */
                    118: # define       LIFESUP         9       /* life support systems */
                    119: # define       SINS            10      /* Space Inertial Navigation System */
                    120: # define       CLOAK           11      /* cloaking device */
                    121: # define       XPORTER         12      /* transporter */
                    122: # define       SHUTTLE         13      /* shuttlecraft */
                    123: 
                    124: /* device names */
                    125: struct device
                    126: {
                    127:        char    *name;          /* device name */
                    128:        char    *person;        /* the person who fixes it */
                    129: };
                    130: 
                    131: struct device  Device[NDEV];
                    132: 
                    133: /***************************  EVENTS  ****************************/
                    134: 
                    135: # define       NEVENTS         12      /* number of different event types */
                    136: 
                    137: # define       E_LRTB          1       /* long range tractor beam */
                    138: # define       E_KATSB         2       /* Klingon attacks starbase */
                    139: # define       E_KDESB         3       /* Klingon destroys starbase */
                    140: # define       E_ISSUE         4       /* distress call is issued */
                    141: # define       E_ENSLV         5       /* Klingons enslave a quadrant */
                    142: # define       E_REPRO         6       /* a Klingon is reproduced */
                    143: # define       E_FIXDV         7       /* fix a device */
                    144: # define       E_ATTACK        8       /* Klingon attack during rest period */
                    145: # define       E_SNAP          9       /* take a snapshot for time warp */
                    146: # define       E_SNOVA         10      /* supernova occurs */
                    147: 
                    148: # define       E_GHOST         0100    /* ghost of a distress call if ssradio out */
                    149: # define       E_HIDDEN        0200    /* event that is unreportable because ssradio out */
                    150: # define       E_EVENT         077     /* mask to get event code */
                    151: 
                    152: struct event
                    153: {
                    154:        char    x, y;                   /* coordinates */
                    155:        double  date;                   /* trap stardate */
                    156:        char    evcode;                 /* event type */
                    157:        char    systemname;             /* starsystem name */
                    158: };
                    159: /* systemname conventions:
                    160:  *     1 -> NINHAB     index into Systemname table for reported distress calls
                    161:  *
                    162:  * evcode conventions:
                    163:  *     1 -> NEVENTS-1  event type
                    164:  *     + E_HIDDEN      unreported (SSradio out)
                    165:  *     + E_GHOST       actually already expired
                    166:  *     0               unallocated
                    167:  */
                    168: 
                    169: # define       MAXEVENTS       25      /* max number of concurrently pending events */
                    170: 
                    171: struct event   Event[MAXEVENTS];       /* dynamic event list; one entry per pending event */
                    172: 
                    173: /*****************************  KLINGONS  *******************************/
                    174: 
                    175: struct kling
                    176: {
                    177:        char    x, y;           /* coordinates */
                    178:        int     power;          /* power left */
                    179:        double  dist;           /* distance to Enterprise */
                    180:        double  avgdist;        /* average over this move */
                    181:        char    srndreq;        /* set if surrender has been requested */
                    182: };
                    183: 
                    184: # define       MAXKLQUAD       9       /* maximum klingons per quadrant */
                    185: 
                    186: /********************** MISCELLANEOUS ***************************/
                    187: 
                    188: /* condition codes */
                    189: # define       GREEN           0
                    190: # define       DOCKED          1
                    191: # define       YELLOW          2
                    192: # define       RED             3
                    193: 
                    194: /* starbase coordinates */
                    195: # define       MAXBASES        9       /* maximum number of starbases in galaxy */
                    196: 
                    197: /*  distress calls  */
                    198: # define       MAXDISTR        5       /* maximum concurrent distress calls */
                    199: 
                    200: /* phaser banks */
                    201: # define       NBANKS          6       /* number of phaser banks */
                    202: 
                    203: struct xy
                    204: {
                    205:        char    x, y;           /* coordinates */
                    206: };
                    207: 
                    208: 
                    209: /*
                    210:  *     note that much of the stuff in the following structs CAN NOT
                    211:  *     be moved around!!!!
                    212:  */
                    213: 
                    214: 
                    215: /* information regarding the state of the starship */
                    216: struct
                    217: {
                    218:        double  warp;           /* warp factor */
                    219:        double  warp2;          /* warp factor squared */
                    220:        double  warp3;          /* warp factor cubed */
                    221:        char    shldup;         /* shield up flag */
                    222:        char    cloaked;        /* set if cloaking device on */
                    223:        int     energy;         /* starship's energy */
                    224:        int     shield;         /* energy in shields */
                    225:        double  reserves;       /* life support reserves */
                    226:        int     crew;           /* ship's complement */
                    227:        int     brigfree;       /* space left in brig */
                    228:        char    torped;         /* torpedoes */
                    229:        char    cloakgood;      /* set if we have moved */
                    230:        int     quadx;          /* quadrant x coord */
                    231:        int     quady;          /* quadrant y coord */
                    232:        int     sectx;          /* sector x coord */
                    233:        int     secty;          /* sector y coord */
                    234:        char    cond;           /* condition code */
                    235:        char    sinsbad;        /* Space Inertial Navigation System condition */
                    236:        char    *shipname;      /* name of current starship */
                    237:        char    ship;           /* current starship */
                    238:        int     distressed;     /* number of distress calls */
                    239: }      Ship;
                    240: 
                    241: /* sinsbad is set if SINS is working but not calibrated */
                    242: 
                    243: /* game related information, mostly scoring */
                    244: struct
                    245: {
                    246:        int     killk;          /* number of klingons killed */
                    247:        int     deaths;         /* number of deaths onboard Enterprise */
                    248:        char    negenbar;       /* number of hits on negative energy barrier */
                    249:        char    killb;          /* number of starbases killed */
                    250:        int     kills;          /* number of stars killed */
                    251:        char    skill;          /* skill rating of player */
                    252:        char    length;         /* length of game */
                    253:        char    killed;         /* set if you were killed */
                    254:        char    killinhab;      /* number of inhabited starsystems killed */
                    255:        char    tourn;          /* set if a tournament game */
                    256:        char    passwd[15];     /* game password */
                    257:        char    snap;           /* set if snapshot taken */
                    258:        char    helps;          /* number of help calls */
                    259:        int     captives;       /* total number of captives taken */
                    260: }      Game;
                    261: 
                    262: /* per move information */
                    263: struct
                    264: {
                    265:        char    free;           /* set if a move is free */
                    266:        char    endgame;        /* end of game flag */
                    267:        char    shldchg;        /* set if shields changed this move */
                    268:        char    newquad;        /* set if just entered this quadrant */
                    269:        char    resting;        /* set if this move is a rest */
                    270:        double  time;           /* time used this move */
                    271: }      Move;
                    272: 
                    273: /* parametric information */
                    274: struct
                    275: {
                    276:        char    bases;          /* number of starbases */
                    277:        char    klings;         /* number of klingons */
                    278:        double  date;           /* stardate */
                    279:        double  time;           /* time left */
                    280:        double  resource;       /* Federation resources */
                    281:        int     energy;         /* starship's energy */
                    282:        int     shield;         /* energy in shields */
                    283:        double  reserves;       /* life support reserves */
                    284:        int     crew;           /* size of ship's complement */
                    285:        int     brigfree;       /* max possible number of captives */
                    286:        char    torped;         /* photon torpedos */
                    287:        double  damfac[NDEV];   /* damage factor */
                    288:        double  dockfac;        /* docked repair time factor */
                    289:        double  regenfac;       /* regeneration factor */
                    290:        int     stopengy;       /* energy to do emergency stop */
                    291:        int     shupengy;       /* energy to put up shields */
                    292:        int     klingpwr;       /* Klingon initial power */
                    293:        int     warptime;       /* time chewer multiplier */
                    294:        double  phasfac;        /* Klingon phaser power eater factor */
                    295:        char    moveprob[6];    /* probability that a Klingon moves */
                    296:        double  movefac[6];     /* Klingon move distance multiplier */
                    297:        double  eventdly[NEVENTS];      /* event time multipliers */
                    298:        double  navigcrud[2];   /* navigation crudup factor */
                    299:        int     cloakenergy;    /* cloaking device energy per stardate */
                    300:        double  damprob[NDEV];  /* damage probability */
                    301:        double  hitfac;         /* Klingon attack factor */
                    302:        int     klingcrew;      /* number of Klingons in a crew */
                    303:        double  srndrprob;      /* surrender probability */
                    304:        int     energylow;      /* low energy mark (cond YELLOW) */
                    305: }      Param;
                    306: 
                    307: /* Sum of damage probabilities must add to 1000 */
                    308: 
                    309: /* other information kept in a snapshot */
                    310: struct
                    311: {
                    312:        char    bases;          /* number of starbases */
                    313:        char    klings;         /* number of klingons */
                    314:        double  date;           /* stardate */
                    315:        double  time;           /* time left */
                    316:        double  resource;       /* Federation resources */
                    317:        char    distressed;     /* number of currently distressed quadrants */
                    318:        struct event    *eventptr[NEVENTS];     /* pointer to event structs */
                    319:        struct xy       base[MAXBASES];         /* locations of starbases */
                    320: }      Now;
                    321: 
                    322: /* Other stuff, not dumped in a snapshot */
                    323: struct
                    324: {
                    325:        struct kling    klingon[MAXKLQUAD];     /* sorted Klingon list */
                    326:        char            nkling;                 /* number of Klingons in this sector */
                    327:                                                /* < 0 means automatic override mode */
                    328:        char            fast;                   /* set if speed > 300 baud */
                    329:        struct xy       starbase;       /* starbase in current quadrant */
                    330:        char            snapshot[sizeof Quad + sizeof Event + sizeof Now];      /* snapshot for time warp */
                    331:        char            statreport;             /* set to get a status report on a srscan */
                    332: }      Etc;
                    333: 
                    334: /*
                    335:  *     eventptr is a pointer to the event[] entry of the last
                    336:  *     scheduled event of each type.  Zero if no such event scheduled.
                    337:  */
                    338: 
                    339: /* Klingon move indicies */
                    340: # define       KM_OB           0       /* Old quadrant, Before attack */
                    341: # define       KM_OA           1       /* Old quadrant, After attack */
                    342: # define       KM_EB           2       /* Enter quadrant, Before attack */
                    343: # define       KM_EA           3       /* Enter quadrant, After attack */
                    344: # define       KM_LB           4       /* Leave quadrant, Before attack */
                    345: # define       KM_LA           5       /* Leave quadrant, After attack */
                    346: 
                    347: /* you lose codes */
                    348: # define       L_NOTIME        1       /* ran out of time */
                    349: # define       L_NOENGY        2       /* ran out of energy */
                    350: # define       L_DSTRYD        3       /* destroyed by a Klingon */
                    351: # define       L_NEGENB        4       /* ran into the negative energy barrier */
                    352: # define       L_SUICID        5       /* destroyed in a nova */
                    353: # define       L_SNOVA         6       /* destroyed in a supernova */
                    354: # define       L_NOLIFE        7       /* life support died (so did you) */
                    355: # define       L_NOHELP        8       /* you could not be rematerialized */
                    356: # define       L_TOOFAST       9       /* pretty stupid going at warp 10 */
                    357: # define       L_STAR          10      /* ran into a star */
                    358: # define       L_DSTRCT        11      /* self destructed */
                    359: # define       L_CAPTURED      12      /* captured by Klingons */
                    360: # define       L_NOCREW        13      /* you ran out of crew */
                    361: 
                    362: /******************  COMPILE OPTIONS  ***********************/
                    363: 
                    364: /* Trace info */
                    365: # define       xTRACE          1
                    366: int    Trace;

unix.superglobalmegacorp.com

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