+/* $NetBSD: trek.h,v 1.11 2005/02/15 12:54:50 jsm Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)trek.h 5.5 (Berkeley) 6/1/90
+ * @(#)trek.h 8.1 (Berkeley) 5/31/93
*/
/*
**
** 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 */
};
/* 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(int);
+
+/* attack.c */
+void attack(int);
+
+/* autover.c */
+void autover(void);
+
+/* capture.c */
+void capture(int);
+struct kling *selectklingon(void);
+
+/* cgetc.c */
+char cgetc(int);
+
+/* check_out.c */
+int check_out(int);
+
+/* checkcond.c */
+void checkcond(void);
+
+/* compkl.c */
+void compkldist(int);
+
+/* computer.c */
+void computer(int);
+
+/* damage.c */
+void damage(int, double);
+
+/* damaged.c */
+int damaged(int);
+
+/* dcrept.c */
+void dcrept(int);
+
+/* destruct.c */
+void destruct(int);
+
+/* dock.c */
+void dock(int);
+void undock(int);
+
+/* dumpgame.c */
+void dumpgame(int);
+int restartgame(void);
+
+/* dumpme.c */
+void dumpme(int);
+
+/* dumpssradio.c */
+int dumpssradio(void);
+
+/* events.c */
+int events(int);
+
+/* externs.c */
+
+/* getcodi.c */
+int getcodi(int *, double *);
+
+/* help.c */
+void help(int);
+
+/* impulse.c */
+void impulse(int);
+
+/* initquad.c */
+void initquad(int);
+void sector(int *, int *);
+
+/* kill.c */
+void killk(int, int );
+void killb(int, int );
+void kills(int, int , int);
+void killd(int, int , int);
+
+/* klmove.c */
+void klmove(int);
+
+/* lose.c */
+void lose(int) __attribute__((__noreturn__));
+
+/* lrscan.c */
+void lrscan(int);
+
+/* move.c */
+double move(int, int, double, double);
+
+/* nova.c */
+void nova(int, int );
+
+/* out.c */
+void out(int);
+
+/* phaser.c */
+void phaser(int);
+
+/* play.c */
+void myreset(int) __attribute__((__noreturn__));
+void play(void) __attribute__((__noreturn__));
+
+/* ram.c */
+void ram(int, int );
+
+/* ranf.c */
+int ranf(int);
+double franf(void);
+
+/* rest.c */
+void rest(int);
+
+/* schedule.c */
+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 */
+long score(void);
+
+/* setup.c */
+void setup(void);
+
+/* setwarp.c */
+void setwarp(int);
+
+/* shield.c */
+void shield(int);
+
+/* snova.c */
+void snova(int, int );
+
+/* srscan.c */
+void srscan(int);
+
+/* systemname.c */
+const char *systemname(const struct quad *);
+
+/* torped.c */
+void torped(int);
+
+/* visual.c */
+void visual(int);
+
+/* warp.c */
+void dowarp(int);
+void warp(int, int, double);
+
+/* win.c */
+void win(void) __attribute__((__noreturn__));