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