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

Defined variables

Defined struct's

device defined in line 113; used 6 times
kling defined in line 163; used 16 times
xy defined in line 191; used 10 times

Defined macros

BASE defined in line 81; used 2 times
E_ATTACK defined in line 132; used 2 times
E_ENSLV defined in line 129; used 2 times
E_ISSUE defined in line 128; used 3 times
E_KDESB defined in line 127; used 3 times
E_REPRO defined in line 130; used 4 times
E_SNAP defined in line 133; used 3 times
E_SNOVA defined in line 134; used 3 times
IMPULSE defined in line 102; used 3 times
INHABIT defined in line 85; used 2 times
KM_EA defined in line 331; used 2 times
KM_EB defined in line 330; used 2 times
KM_LA defined in line 333; used 2 times
KM_LB defined in line 332; used 2 times
KM_OA defined in line 329; used 2 times
KM_OB defined in line 328; used 2 times
LRSCAN defined in line 99; used 2 times
L_CAPTURED defined in line 347; used 1 times
L_DSTRCT defined in line 346; used 1 times
L_DSTRYD defined in line 338; used 1 times
L_NEGENB defined in line 339; used 1 times
L_NOCREW defined in line 348; used 1 times
L_NOENGY defined in line 337; used 1 times
L_NOHELP defined in line 343; used 1 times
L_NOLIFE defined in line 342; used 1 times
L_NOTIME defined in line 336; used 1 times
L_SNOVA defined in line 341; used 2 times
L_STAR defined in line 345; used 1 times
L_SUICID defined in line 340; used 1 times
L_TOOFAST defined in line 344; used 1 times
MAXBASES defined in line 183; used 1 times
MAXDISTR defined in line 186; used 1 times
NBANKS defined in line 189; used 9 times
NEVENTS defined in line 123; used 2 times
NINHAB defined in line 43; used 3 times
PHASER defined in line 100; used 3 times
QUEENE defined in line 83; used 4 times
SHUTTLE defined in line 110; used 4 times
SINS defined in line 107; used 3 times
TORPED defined in line 101; used 4 times
WARP defined in line 97; used 4 times
XPORTER defined in line 109; used 2 times
YELLOW defined in line 179; used 1 times

Usage of this include

trek.h used 45 times
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3962
Valid CSS Valid XHTML 1.0 Strict