NetBSD/games/trek/trek.h

519 lines
14 KiB
C
Raw Normal View History

2009-08-12 12:54:54 +04:00
/* $NetBSD: trek.h,v 1.18 2009/08/12 08:54:54 dholland Exp $ */
1995-04-22 14:58:17 +04:00
1993-03-21 12:45:37 +03:00
/*
1995-04-22 14:58:17 +04:00
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
1993-03-21 12:45:37 +03:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
1993-03-21 12:45:37 +03:00
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
1995-04-22 14:58:17 +04:00
* @(#)trek.h 8.1 (Berkeley) 5/31/93
1993-03-21 12:45:37 +03:00
*/
/*
** Global Declarations
**
** Virtually all non-local variable declarations are made in this
** file. Exceptions are those things which are initialized, which
** are defined in "externs.c", and things which are local to one
** program file.
**
** So far as I know, nothing in here must be preinitialized to
** zero.
*/
/* external function definitions */
/********************* GALAXY **************************/
/* galactic parameters */
#define NSECTS 10 /* dimensions of quadrant in sectors */
#define NQUADS 8 /* dimension of galazy in quadrants */
#define NINHAB 32 /* number of quadrants which are inhabited */
1993-03-21 12:45:37 +03:00
/* definition for each quadrant */
struct quad {
unsigned char bases; /* number of bases in this quadrant */
1993-03-21 12:45:37 +03:00
char klings; /* number of Klingons in this quadrant */
char holes; /* number of black holes in this quadrant */
int scanned; /* star chart entry (see below) */
short stars; /* number of stars in this quadrant */
1993-03-21 12:45:37 +03:00
char qsystemname; /* starsystem name (see below) */
};
#define Q_DISTRESSED 0200
#define Q_SYSTEM 077
1993-03-21 12:45:37 +03:00
/*
* systemname conventions:
1993-03-21 12:45:37 +03:00
* 1 -> NINHAB index into Systemname table for live system.
* + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
* is the index into the Event table which will
* have the system name
* 0 dead or nonexistent starsystem
*
* starchart ("scanned") conventions:
* 0 -> 999 taken as is
* -1 not yet scanned ("...")
* 1000 supernova ("///")
* 1001 starbase + ??? (".1.")
*/
1993-03-21 12:45:37 +03:00
/* ascii names of systems */
extern const char *const Systemname[NINHAB];
1993-03-21 12:45:37 +03:00
/* quadrant definition */
extern struct quad Quad[NQUADS][NQUADS];
1993-03-21 12:45:37 +03:00
/* defines for sector map (below) */
#define EMPTY '.'
#define STAR '*'
#define BASE '#'
#define ENTERPRISE 'E'
#define QUEENE 'Q'
#define KLINGON 'K'
#define INHABIT '@'
#define HOLE ' '
1993-03-21 12:45:37 +03:00
/* current sector map */
extern char Sect[NSECTS][NSECTS];
1993-03-21 12:45:37 +03:00
1993-03-21 12:45:37 +03:00
/************************ DEVICES ******************************/
#define NDEV 16 /* max number of devices */
1993-03-21 12:45:37 +03:00
/* device tokens */
#define WARP 0 /* warp engines */
#define SRSCAN 1 /* short range scanners */
#define LRSCAN 2 /* long range scanners */
#define PHASER 3 /* phaser control */
#define TORPED 4 /* photon torpedo control */
#define IMPULSE 5 /* impulse engines */
#define SHIELD 6 /* shield control */
#define COMPUTER 7 /* on board computer */
#define SSRADIO 8 /* subspace radio */
#define LIFESUP 9 /* life support systems */
#define SINS 10 /* Space Inertial Navigation System */
#define CLOAK 11 /* cloaking device */
#define XPORTER 12 /* transporter */
#define SHUTTLE 13 /* shuttlecraft */
1993-03-21 12:45:37 +03:00
/* device names */
struct device {
const char *name; /* device name */
const char *person; /* the person who fixes it */
1993-03-21 12:45:37 +03:00
};
extern const struct device Device[NDEV];
1993-03-21 12:45:37 +03:00
/*************************** EVENTS ****************************/
#define NEVENTS 12 /* number of different event types */
1993-03-21 12:45:37 +03:00
#define E_LRTB 1 /* long range tractor beam */
#define E_KATSB 2 /* Klingon attacks starbase */
#define E_KDESB 3 /* Klingon destroys starbase */
#define E_ISSUE 4 /* distress call is issued */
#define E_ENSLV 5 /* Klingons enslave a quadrant */
#define E_REPRO 6 /* a Klingon is reproduced */
#define E_FIXDV 7 /* fix a device */
#define E_ATTACK 8 /* Klingon attack during rest period */
#define E_SNAP 9 /* take a snapshot for time warp */
#define E_SNOVA 10 /* supernova occurs */
1993-03-21 12:45:37 +03:00
#define E_GHOST 0100 /* ghost of a distress call if ssradio out */
#define E_HIDDEN 0200 /* event unreportable because ssradio out */
#define E_EVENT 077 /* mask to get event code */
1993-03-21 12:45:37 +03:00
struct event {
unsigned char x, y; /* coordinates */
double date; /* trap stardate */
char evcode; /* event type */
unsigned char systemname; /* starsystem name */
1993-03-21 12:45:37 +03:00
};
/*
* systemname conventions:
1993-03-21 12:45:37 +03:00
* 1 -> NINHAB index into Systemname table for reported distress calls
*
* evcode conventions:
* 1 -> NEVENTS-1 event type
* + E_HIDDEN unreported (SSradio out)
* + E_GHOST actually already expired
* 0 unallocated
*/
/* max number of concurrently pending events */
#define MAXEVENTS 25
1993-03-21 12:45:37 +03:00
/* dynamic event list; one entry per pending event */
extern struct event Event[MAXEVENTS];
1993-03-21 12:45:37 +03:00
/***************************** KLINGONS *******************************/
struct kling {
unsigned char x, y; /* coordinates */
1993-03-21 12:45:37 +03:00
int power; /* power left */
double dist; /* distance to Enterprise */
double avgdist; /* average over this move */
char srndreq; /* set if surrender has been requested */
};
#define MAXKLQUAD 9 /* maximum klingons per quadrant */
1993-03-21 12:45:37 +03:00
/********************** MISCELLANEOUS ***************************/
/* condition codes */
#define GREEN 0
#define DOCKED 1
#define YELLOW 2
#define RED 3
1993-03-21 12:45:37 +03:00
/* starbase coordinates */
#define MAXBASES 9 /* maximum number of starbases in galaxy */
1993-03-21 12:45:37 +03:00
/* distress calls */
#define MAXDISTR 5 /* maximum concurrent distress calls */
1993-03-21 12:45:37 +03:00
/* phaser banks */
#define NBANKS 6 /* number of phaser banks */
1993-03-21 12:45:37 +03:00
struct xy {
unsigned char x, y; /* coordinates */
1993-03-21 12:45:37 +03:00
};
/*
* note that much of the stuff in the following structs CAN NOT
* be moved around!!!!
*/
/* information regarding the state of the starship */
struct Ship_struct {
1993-03-21 12:45:37 +03:00
double warp; /* warp factor */
double warp2; /* warp factor squared */
double warp3; /* warp factor cubed */
char shldup; /* shield up flag */
char cloaked; /* set if cloaking device on */
int energy; /* starship's energy */
int shield; /* energy in shields */
double reserves; /* life support reserves */
int crew; /* ship's complement */
int brigfree; /* space left in brig */
char torped; /* torpedoes */
char cloakgood; /* set if we have moved */
int quadx; /* quadrant x coord */
int quady; /* quadrant y coord */
int sectx; /* sector x coord */
int secty; /* sector y coord */
unsigned char cond; /* condition code */
/* sinsbad is set if SINS is working but not calibrated */
char sinsbad; /* Space Inertial Navigation System condition*/
const char *shipname; /* name of current starship */
1993-03-21 12:45:37 +03:00
char ship; /* current starship */
int distressed; /* number of distress calls */
};
extern struct Ship_struct Ship;
1993-03-21 12:45:37 +03:00
/* game related information, mostly scoring */
struct Game_struct {
1993-03-21 12:45:37 +03:00
int killk; /* number of klingons killed */
int deaths; /* number of deaths onboard Enterprise */
char negenbar; /* number of hits on negative energy barrier */
char killb; /* number of starbases killed */
int kills; /* number of stars killed */
char skill; /* skill rating of player */
char length; /* length of game */
char killed; /* set if you were killed */
char killinhab; /* number of inhabited starsystems killed */
char tourn; /* set if a tournament game */
char passwd[15]; /* game password */
char snap; /* set if snapshot taken */
char helps; /* number of help calls */
int captives; /* total number of captives taken */
};
extern struct Game_struct Game;
1993-03-21 12:45:37 +03:00
/* per move information */
struct Move_struct {
1993-03-21 12:45:37 +03:00
char free; /* set if a move is free */
char endgame; /* end of game flag */
char shldchg; /* set if shields changed this move */
char newquad; /* set if just entered this quadrant */
char resting; /* set if this move is a rest */
double time; /* time used this move */
};
extern struct Move_struct Move;
1993-03-21 12:45:37 +03:00
/* parametric information */
struct Param_struct {
unsigned char bases; /* number of starbases */
1993-03-21 12:45:37 +03:00
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
double resource; /* Federation resources */
int energy; /* starship's energy */
int shield; /* energy in shields */
double reserves; /* life support reserves */
int crew; /* size of ship's complement */
int brigfree; /* max possible number of captives */
char torped; /* photon torpedos */
double damfac[NDEV]; /* damage factor */
double dockfac; /* docked repair time factor */
double regenfac; /* regeneration factor */
int stopengy; /* energy to do emergency stop */
int shupengy; /* energy to put up shields */
int klingpwr; /* Klingon initial power */
int warptime; /* time chewer multiplier */
double phasfac; /* Klingon phaser power eater factor */
char moveprob[6]; /* probability that a Klingon moves */
double movefac[6]; /* Klingon move distance multiplier */
double eventdly[NEVENTS]; /* event time multipliers */
double navigcrud[2]; /* navigation crudup factor */
int cloakenergy; /* cloaking device energy per stardate */
double damprob[NDEV]; /* damage probability */
double hitfac; /* Klingon attack factor */
int klingcrew; /* number of Klingons in a crew */
double srndrprob; /* surrender probability */
int energylow; /* low energy mark (cond YELLOW) */
};
extern struct Param_struct Param;
1993-03-21 12:45:37 +03:00
/* Sum of damage probabilities must add to 1000 */
/* other information kept in a snapshot */
struct Now_struct {
unsigned char bases; /* number of starbases */
1993-03-21 12:45:37 +03:00
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
double resource; /* Federation resources */
char distressed; /* number of currently distressed quadrants */
struct event *eventptr[NEVENTS]; /* pointer to event structs */
struct xy base[MAXBASES]; /* locations of starbases */
};
extern struct Now_struct Now;
1993-03-21 12:45:37 +03:00
/* Other stuff, not dumped in a snapshot */
struct Etc_struct {
struct kling klingon[MAXKLQUAD];/* sorted Klingon list */
short nkling; /* number of Klingons in this sector */
/* < 0 means automatic override mode */
char fast; /* set if speed > 300 baud */
struct xy starbase; /* starbase in current quadrant */
char snapshot[sizeof Quad + sizeof Event + sizeof Now];
/* snapshot for time warp */
char statreport; /* set to get a status report on a srscan */
};
extern struct Etc_struct Etc;
1993-03-21 12:45:37 +03:00
/*
* eventptr is a pointer to the event[] entry of the last
* scheduled event of each type. Zero if no such event scheduled.
*/
/* Klingon move indicies */
#define KM_OB 0 /* Old quadrant, Before attack */
#define KM_OA 1 /* Old quadrant, After attack */
#define KM_EB 2 /* Enter quadrant, Before attack */
#define KM_EA 3 /* Enter quadrant, After attack */
#define KM_LB 4 /* Leave quadrant, Before attack */
#define KM_LA 5 /* Leave quadrant, After attack */
1993-03-21 12:45:37 +03:00
/* you lose codes */
#define L_NOTIME 1 /* ran out of time */
#define L_NOENGY 2 /* ran out of energy */
#define L_DSTRYD 3 /* destroyed by a Klingon */
#define L_NEGENB 4 /* ran into the negative energy barrier */
#define L_SUICID 5 /* destroyed in a nova */
#define L_SNOVA 6 /* destroyed in a supernova */
#define L_NOLIFE 7 /* life support died (so did you) */
#define L_NOHELP 8 /* you could not be rematerialized */
#define L_TOOFAST 9 /* pretty stupid going at warp 10 */
#define L_STAR 10 /* ran into a star */
#define L_DSTRCT 11 /* self destructed */
#define L_CAPTURED 12 /* captured by Klingons */
#define L_NOCREW 13 /* you ran out of crew */
1993-03-21 12:45:37 +03:00
/****************** COMPILE OPTIONS ***********************/
/* Trace info */
#define xTRACE 1
extern int Trace;
#define TOOLARGE (DBL_MAX / 2) /* < DOUBLE_MAX for everyone */
/* abandon.c */
2004-01-27 23:30:28 +03:00
void abandon(int);
/* attack.c */
2004-01-27 23:30:28 +03:00
void attack(int);
/* autover.c */
2004-01-27 23:30:28 +03:00
void autover(void);
/* capture.c */
2004-01-27 23:30:28 +03:00
void capture(int);
/* check_out.c */
2004-01-27 23:30:28 +03:00
int check_out(int);
/* checkcond.c */
2004-01-27 23:30:28 +03:00
void checkcond(void);
/* compkl.c */
2004-01-27 23:30:28 +03:00
void compkldist(int);
/* computer.c */
2004-01-27 23:30:28 +03:00
void computer(int);
/* damage.c */
2004-01-27 23:30:28 +03:00
void damage(int, double);
/* damaged.c */
2004-01-27 23:30:28 +03:00
int damaged(int);
/* dcrept.c */
2004-01-27 23:30:28 +03:00
void dcrept(int);
/* destruct.c */
2004-01-27 23:30:28 +03:00
void destruct(int);
/* dock.c */
2004-01-27 23:30:28 +03:00
void dock(int);
void undock(int);
/* dumpgame.c */
2004-01-27 23:30:28 +03:00
void dumpgame(int);
int restartgame(void);
/* dumpme.c */
2004-01-27 23:30:28 +03:00
void dumpme(int);
/* dumpssradio.c */
2004-01-27 23:30:28 +03:00
int dumpssradio(void);
/* events.c */
2004-01-27 23:30:28 +03:00
int events(int);
/* externs.c */
/* getcodi.c */
2004-01-27 23:30:28 +03:00
int getcodi(int *, double *);
/* help.c */
2004-01-27 23:30:28 +03:00
void help(int);
/* impulse.c */
2004-01-27 23:30:28 +03:00
void impulse(int);
/* initquad.c */
2004-01-27 23:30:28 +03:00
void initquad(int);
void sector(int *, int *);
/* kill.c */
2004-01-27 23:30:28 +03:00
void killk(int, int );
void killb(int, int );
void kills(int, int , int);
void killd(int, int , int);
/* klmove.c */
2004-01-27 23:30:28 +03:00
void klmove(int);
/* lose.c */
void lose(int) __dead;
/* lrscan.c */
2004-01-27 23:30:28 +03:00
void lrscan(int);
/* move.c */
2004-01-27 23:30:28 +03:00
double move(int, int, double, double);
/* nova.c */
2004-01-27 23:30:28 +03:00
void nova(int, int );
/* out.c */
2004-01-27 23:30:28 +03:00
void out(int);
/* phaser.c */
2004-01-27 23:30:28 +03:00
void phaser(int);
/* play.c */
void play(void) __dead;
/* ram.c */
2004-01-27 23:30:28 +03:00
void ram(int, int );
/* ranf.c */
2004-01-27 23:30:28 +03:00
int ranf(int);
double franf(void);
/* rest.c */
2004-01-27 23:30:28 +03:00
void rest(int);
/* schedule.c */
2004-01-27 23:30:28 +03:00
struct event *schedule(int, double, int, int , int);
void reschedule(struct event *, double);
void unschedule(struct event *);
struct event *xsched(int, int, int, int , int );
void xresched(struct event *, int, int);
/* score.c */
2004-01-27 23:30:28 +03:00
long score(void);
/* setup.c */
2004-01-27 23:30:28 +03:00
void setup(void);
/* setwarp.c */
2004-01-27 23:30:28 +03:00
void setwarp(int);
/* shield.c */
2004-01-27 23:30:28 +03:00
void shield(int);
/* snova.c */
2004-01-27 23:30:28 +03:00
void snova(int, int );
/* srscan.c */
2004-01-27 23:30:28 +03:00
void srscan(int);
/* systemname.c */
2004-01-27 23:30:28 +03:00
const char *systemname(const struct quad *);
/* torped.c */
2004-01-27 23:30:28 +03:00
void torped(int);
/* visual.c */
2004-01-27 23:30:28 +03:00
void visual(int);
/* warp.c */
2004-01-27 23:30:28 +03:00
void dowarp(int);
void warp(int, int, double);
/* win.c */
void win(void) __dead;