-/* $NetBSD: trek.h,v 1.3 1995/04/22 10:59:36 cgd Exp $ */
+/* $NetBSD: trek.h,v 1.8 1999/09/17 17:06:08 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
**
** So far as I know, nothing in here must be preinitialized to
** zero.
-**
-** You may have problems from the loader if you move this to a
-** different machine. These things actually get allocated in each
-** source file, which UNIX allows; however, you may (on other
-** systems) have to change everything in here to be "extern" and
-** actually allocate stuff in "externs.c"
*/
/* external function definitions */
-extern double franf(); /* floating random number function */
-extern double sqrt(); /* square root */
-extern double sin(), cos(); /* trig functions */
-extern double atan2(); /* fancy arc tangent function */
-extern double log(); /* log base e */
-extern double pow(); /* power function */
-extern double fabs(); /* absolute value function */
-extern double exp(); /* exponential function */
/********************* GALAXY **************************/
struct quad /* definition for each quadrant */
{
- char bases; /* number of bases in this quadrant */
+ unsigned char bases; /* number of bases in this quadrant */
char klings; /* number of Klingons in this quadrant */
char holes; /* number of black holes in this quadrant */
int scanned; /* star chart entry (see below) */
- char stars; /* number of stars in this quadrant */
+ short stars; /* number of stars in this quadrant */
char qsystemname; /* starsystem name (see below) */
};
*/
/* ascii names of systems */
-extern char *Systemname[NINHAB];
+extern const char *const Systemname[NINHAB];
/* quadrant definition */
-struct quad Quad[NQUADS][NQUADS];
+extern struct quad Quad[NQUADS][NQUADS];
/* defines for sector map (below) */
# define EMPTY '.'
# define HOLE ' '
/* current sector map */
-char Sect[NSECTS][NSECTS];
+extern char Sect[NSECTS][NSECTS];
+
/************************ DEVICES ******************************/
/* device names */
struct device
{
- char *name; /* device name */
- char *person; /* the person who fixes it */
+ const char *name; /* device name */
+ const char *person; /* the person who fixes it */
};
-struct device Device[NDEV];
+extern const struct device Device[NDEV];
/*************************** EVENTS ****************************/
struct event
{
- char x, y; /* coordinates */
- double date; /* trap stardate */
- char evcode; /* event type */
- char systemname; /* starsystem name */
+ unsigned char x, y; /* coordinates */
+ double date; /* trap stardate */
+ char evcode; /* event type */
+ unsigned char systemname; /* starsystem name */
};
/* systemname conventions:
* 1 -> NINHAB index into Systemname table for reported distress calls
# define MAXEVENTS 25 /* max number of concurrently pending events */
-struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
+extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
/***************************** KLINGONS *******************************/
struct kling
{
- char x, y; /* coordinates */
+ unsigned char x, y; /* coordinates */
int power; /* power left */
double dist; /* distance to Enterprise */
double avgdist; /* average over this move */
struct xy
{
- char x, y; /* coordinates */
+ unsigned char x, y; /* coordinates */
};
+extern const struct cvntab Skitab[];
+extern const struct cvntab Lentab[];
+
/*
* note that much of the stuff in the following structs CAN NOT
* be moved around!!!!
/* information regarding the state of the starship */
-struct
+struct Ship_struct
{
double warp; /* warp factor */
double warp2; /* warp factor squared */
int quady; /* quadrant y coord */
int sectx; /* sector x coord */
int secty; /* sector y coord */
- char cond; /* condition code */
+ unsigned char cond; /* condition code */
char sinsbad; /* Space Inertial Navigation System condition */
- char *shipname; /* name of current starship */
+ const char *shipname; /* name of current starship */
char ship; /* current starship */
int distressed; /* number of distress calls */
-} Ship;
+};
+extern struct Ship_struct Ship;
/* sinsbad is set if SINS is working but not calibrated */
/* game related information, mostly scoring */
-struct
+struct Game_struct
{
int killk; /* number of klingons killed */
int deaths; /* number of deaths onboard Enterprise */
char snap; /* set if snapshot taken */
char helps; /* number of help calls */
int captives; /* total number of captives taken */
-} Game;
+};
+extern struct Game_struct Game;
/* per move information */
-struct
+struct Move_struct
{
char free; /* set if a move is free */
char endgame; /* end of game flag */
char newquad; /* set if just entered this quadrant */
char resting; /* set if this move is a rest */
double time; /* time used this move */
-} Move;
+};
+extern struct Move_struct Move;
/* parametric information */
-struct
+struct Param_struct
{
- char bases; /* number of starbases */
+ unsigned char bases; /* number of starbases */
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
int klingcrew; /* number of Klingons in a crew */
double srndrprob; /* surrender probability */
int energylow; /* low energy mark (cond YELLOW) */
-} Param;
+};
+extern struct Param_struct Param;
/* Sum of damage probabilities must add to 1000 */
/* other information kept in a snapshot */
-struct
+struct Now_struct
{
- char bases; /* number of starbases */
+ unsigned char bases; /* number of starbases */
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
char distressed; /* number of currently distressed quadrants */
struct event *eventptr[NEVENTS]; /* pointer to event structs */
struct xy base[MAXBASES]; /* locations of starbases */
-} Now;
+};
+extern struct Now_struct Now;
/* Other stuff, not dumped in a snapshot */
-struct
+struct Etc_struct
{
struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */
- char nkling; /* number of Klingons in this sector */
+ 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 */
-} Etc;
+};
+extern struct Etc_struct Etc;
/*
* eventptr is a pointer to the event[] entry of the last
/* Trace info */
# define xTRACE 1
-int Trace;
+extern int Trace;
+
+/* abandon.c */
+void abandon __P((int));
+
+/* attack.c */
+void attack __P((int));
+
+/* autover.c */
+void autover __P((void));
+
+/* capture.c */
+void capture __P((int));
+struct kling *selectklingon __P((void));
+
+/* cgetc.c */
+char cgetc __P((int));
+
+/* check_out.c */
+int check_out __P((int));
+
+/* checkcond.c */
+void checkcond __P((void));
+
+/* compkl.c */
+void compkldist __P((int));
+
+/* computer.c */
+void computer __P((int));
+
+/* damage.c */
+void damage __P((int, double));
+
+/* damaged.c */
+int damaged __P((int));
+
+/* dcrept.c */
+void dcrept __P((int));
+
+/* destruct.c */
+void destruct __P((int));
+
+/* dock.c */
+void dock __P((int));
+void undock __P((int));
+
+/* dumpgame.c */
+void dumpgame __P((int));
+int restartgame __P((void));
+
+/* dumpme.c */
+void dumpme __P((int));
+
+/* dumpssradio.c */
+int dumpssradio __P((void));
+
+/* events.c */
+int events __P((int));
+
+/* externs.c */
+
+/* getcodi.c */
+int getcodi __P((int *, double *));
+
+/* help.c */
+void help __P((int));
+
+/* impulse.c */
+void impulse __P((int));
+
+/* initquad.c */
+void initquad __P((int));
+void sector __P((int *, int *));
+
+/* kill.c */
+void killk __P((int, int ));
+void killb __P((int, int ));
+void kills __P((int, int , int));
+void killd __P((int, int , int));
+
+/* klmove.c */
+void klmove __P((int));
+
+/* lose.c */
+void lose __P((int)) __attribute__((__noreturn__));
+
+/* lrscan.c */
+void lrscan __P((int));
+
+/* move.c */
+double move __P((int, int, double, double));
+
+/* nova.c */
+void nova __P((int, int ));
+
+/* out.c */
+void out __P((int));
+
+/* phaser.c */
+void phaser __P((int));
+
+/* play.c */
+void myreset __P((int)) __attribute__((__noreturn__));
+void play __P((void)) __attribute__((__noreturn__));
+
+/* ram.c */
+void ram __P((int, int ));
+
+/* ranf.c */
+int ranf __P((int));
+double franf __P((void));
+
+/* rest.c */
+void rest __P((int));
+
+/* schedule.c */
+struct event *schedule __P((int, double, int, int , int));
+void reschedule __P((struct event *, double));
+void unschedule __P((struct event *));
+struct event *xsched __P((int, int, int, int , int ));
+void xresched __P((struct event *, int, int));
+
+/* score.c */
+long score __P((void));
+
+/* setup.c */
+void setup __P((void));
+
+/* setwarp.c */
+void setwarp __P((int));
+
+/* shield.c */
+void shield __P((int));
+
+/* snova.c */
+void snova __P((int, int ));
+
+/* srscan.c */
+void srscan __P((int));
+
+/* systemname.c */
+const char *systemname __P((const struct quad *));
+
+/* torped.c */
+void torped __P((int));
+
+/* visual.c */
+void visual __P((int));
+
+/* warp.c */
+void dowarp __P((int));
+void warp __P((int, int, double));
+
+/* win.c */
+void win __P((void)) __attribute__((__noreturn__));