Annotation of 42BSD/games/trek/trek.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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