projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More uses of distance() macro. Eliminate some magic numbers.
[super-star-trek.git]
/
src
/
sst.h
diff --git
a/src/sst.h
b/src/sst.h
index 27040e8ae52f194d5b2eedd07d8a9b1374ac059e..89cb16f69c58261d0f9bdede84062b9f1af2dce4 100644
(file)
--- a/
src/sst.h
+++ b/
src/sst.h
@@
-42,7
+42,9
@@
typedef struct {int x; int y;} coord;
typedef struct {int x; int y;} coord;
-#define same(c1, c2) (c1.x == c2.x && c1.y == c2.y)
+#define square(i) ((i)*(i))
+#define same(c1, c2) ((c1.x == c2.x) && (c1.y == c2.y))
+#define distance(c1, c2) sqrt(square(c1.x - c2.x) + square(c1.y - c2.y))
typedef struct {
coord w;
typedef struct {
coord w;
@@
-210,11
+212,17
@@
struct game {
alive, // we are alive (not killed)
justin, // just entered quadrant
shldup, // shields are up
alive, // we are alive (not killed)
justin, // just entered quadrant
shldup, // shields are up
+ ishere, // super-commander in quadrant
+ ientesc, // attempted escape from supercommander
+ ithere, // Tholian is here
resting, // rest time
resting, // rest time
+ icraft, // Kirk in Galileo
alldone, // game is now finished
neutz, // Romulan Neutral Zone
isarmed, // probe is armed
inorbit, // orbiting a planet
alldone, // game is now finished
neutz, // Romulan Neutral Zone
isarmed, // probe is armed
inorbit, // orbiting a planet
+ imine, // mining
+ icrystl, // dilithium crystals aboard
thawed; // thawed game
int inkling, // initial number of klingons
inbase, // initial number of bases
thawed; // thawed game
int inkling, // initial number of klingons
inbase, // initial number of bases
@@
-237,20
+245,14
@@
struct game {
shldchg, // shield is changing (affects efficiency)
landed, // party on planet (1), on ship (-1)
iplnet, // planet # in quadrant
shldchg, // shield is changing (affects efficiency)
landed, // party on planet (1), on ship (-1)
iplnet, // planet # in quadrant
- imine, // mining
inplan, // initial planets
nenhere, // number of enemies in quadrant
inplan, // initial planets
nenhere, // number of enemies in quadrant
- ishere, // super-commander in quandrant
irhere, // Romulans in quadrant
irhere, // Romulans in quadrant
- icraft, // Kirk in Galileo
- ientesc, // attempted escape from supercommander
iscraft, // =1 if craft on ship, -1 if removed from game
isatb, // =1 if super commander is attacking base
iscate, // super commander is here
iattak, // attack recursion elimination (was cracks[4])
iscraft, // =1 if craft on ship, -1 if removed from game
isatb, // =1 if super commander is attacking base
iscate, // super commander is here
iattak, // attack recursion elimination (was cracks[4])
- icrystl, // dilithium crystals aboard
tourn, // tournament number
tourn, // tournament number
- ithere, // Tholian is here
iseenit, // seen base attack report
proben, // number of moves for probe
nprobes; // number of probes available
iseenit, // seen base attack report
proben, // number of moves for probe
nprobes; // number of probes available
@@
-292,7
+294,7
@@
extern FILE *logfp, *replayfp;
/* the Space Thingy's global state should *not* be saved! */
extern coord thing;
/* the Space Thingy's global state should *not* be saved! */
extern coord thing;
-extern
int
iqhere, iqengry;
+extern
bool
iqhere, iqengry;
typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
@@
-328,11
+330,11
@@
enum loctype {neither, quadrant, sector};
/* Function prototypes */
void prelim(void);
/* Function prototypes */
void prelim(void);
-void attack(
int
);
+void attack(
bool
);
bool choose(bool);
bool choose(bool);
-void setup(
int
);
+void setup(
bool
);
void score(void);
void score(void);
-void atover(
int
);
+void atover(
bool
);
int srscan(int);
void lrscan(void);
void phasers(void);
int srscan(int);
void lrscan(void);
void phasers(void);
@@
-341,7
+343,7
@@
void warp(bool);
void doshield(int);
void dock(bool);
void dreprt(void);
void doshield(int);
void dock(bool);
void dreprt(void);
-void chart(
int
);
+void chart(
bool
);
void rechart(void);
void impuls(void);
void wait(void);
void rechart(void);
void impuls(void);
void wait(void);
@@
-352,10
+354,10
@@
void eta(void);
void mayday(void);
void abandn(void);
void finish(FINTYPE);
void mayday(void);
void abandn(void);
void finish(FINTYPE);
-void
dstr
ct(void);
+void
selfdestru
ct(void);
void kaboom(void);
void freeze(bool);
void kaboom(void);
void freeze(bool);
-
int
thaw(void);
+
bool
thaw(void);
void plaque(void);
int scan(void);
#define IHEOL (0)
void plaque(void);
int scan(void);
#define IHEOL (0)
@@
-374,22
+376,21
@@
void crmshp(void);
char *cramlc(enum loctype, coord w);
double expran(double);
double Rand(void);
char *cramlc(enum loctype, coord w);
double expran(double);
double Rand(void);
-void iran(int, int *, int *);
-#define square(i) ((i)*(i))
-void dropin(int, coord*);
+coord iran(int);
+coord dropin(int);
void newcnd(void);
void sortkl(void);
void imove(void);
void newcnd(void);
void sortkl(void);
void imove(void);
-void ram(
int
, int, coord);
-void crmena(
int, int, int
, coord w);
+void ram(
bool
, int, coord);
+void crmena(
bool, int, enum loctype
, coord w);
void deadkl(coord, int, int, int);
void timwrp(void);
void movcom(void);
void torpedo(double, double, int, int, double *, int, int);
void huh(void);
void pause_game(int);
void deadkl(coord, int, int, int);
void timwrp(void);
void movcom(void);
void torpedo(double, double, int, int, double *, int, int);
void huh(void);
void pause_game(int);
-void nova(
int, int
);
-void snova(
int, int
);
+void nova(
coord
);
+void snova(
bool, coord *
);
void scom(bool *);
void hittem(double *);
void prouts(char *, ...);
void scom(bool *);
void hittem(double *);
void prouts(char *, ...);
@@
-397,21
+398,21
@@
int isit(char *);
void preport(void);
void orbit(void);
void sensor(void);
void preport(void);
void orbit(void);
void sensor(void);
-void drawmaps(
shor
t);
+void drawmaps(
in
t);
void beam(void);
void mine(void);
void usecrystals(void);
void shuttle(void);
void deathray(void);
void debugme(void);
void beam(void);
void mine(void);
void usecrystals(void);
void shuttle(void);
void deathray(void);
void debugme(void);
-void attakreport(
int
);
+void attakreport(
bool
);
void movetho(void);
void probe(void);
void iostart(void);
void setwnd(WINDOW *);
void warble(void);
void movetho(void);
void probe(void);
void iostart(void);
void setwnd(WINDOW *);
void warble(void);
-void boom(
int ii, int jj
);
-void tracktorpedo(
int ix, int iy, int l, int i, int n, int iquad
);
+void boom(
coord
);
+void tracktorpedo(
coord, int, int, int, int
);
void cgetline(char *, int);
void waitfor(void);
void setpassword(void);
void cgetline(char *, int);
void waitfor(void);
void setpassword(void);
@@
-419,7
+420,7
@@
void commandhook(char *, bool);
void makechart(void);
void enqueue(char *);
char *systemname(int);
void makechart(void);
void enqueue(char *);
char *systemname(int);
-
void newkling(int, coord *
);
+
coord newkling(int
);
/* mode arguments for srscan() */
#define SCAN_FULL 1
/* mode arguments for srscan() */
#define SCAN_FULL 1