projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change the condition field from an uint with #defines to an enum.
[super-star-trek.git]
/
src
/
sst.h
diff --git
a/src/sst.h
b/src/sst.h
index a1b8b5e00386dbc4b5fb48e0f29f52b23d97adcb..18baff686650abd39c386e7d3627084be2c940ff 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,13
+212,27
@@
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
+ comhere, // commander here
+ 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
imine, // mining
alldone, // game is now finished
neutz, // Romulan Neutral Zone
isarmed, // probe is armed
inorbit, // orbiting a planet
imine, // mining
+ icrystl, // dilithium crystals aboard
+ iseenit, // seen base attack report
thawed; // thawed game
thawed; // thawed game
+ enum {
+ green = 'G',
+ yellow = 'Y',
+ red = 'R',
+ docked = 'D',
+ dead = 'Z',
+ } condition; // condition (red/yellow/green/docked)
int inkling, // initial number of klingons
inbase, // initial number of bases
incom, // initial number of commanders
int inkling, // initial number of klingons
inbase, // initial number of bases
incom, // initial number of commanders
@@
-224,14
+240,12
@@
struct game {
inrom, // initial number of commanders
instar, // initial stars
intorps, // initial/Max torpedoes
inrom, // initial number of commanders
instar, // initial stars
intorps, // initial/Max torpedoes
- condit, // condition (red/yellow/green/docked)
torps, // number of torpedoes
ship, // ship type -- 'E' is Enterprise
abandoned, // count of crew abandoned in space
length, // length of game
skill, // skill level
klhere, // klingons here
torps, // number of torpedoes
ship, // ship type -- 'E' is Enterprise
abandoned, // count of crew abandoned in space
length, // length of game
skill, // skill level
klhere, // klingons here
- comhere, // commanders here
casual, // causalties
nhelp, // calls for help
nkinks, // count of energy-barrier crossings
casual, // causalties
nhelp, // calls for help
nkinks, // count of energy-barrier crossings
@@
-240,18
+254,12
@@
struct game {
iplnet, // planet # in quadrant
inplan, // initial planets
nenhere, // number of enemies in quadrant
iplnet, // planet # 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
double inresor, // initial resources
proben, // number of moves for probe
nprobes; // number of probes available
double inresor, // initial resources
@@
-292,7
+300,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,
@@
-316,16
+324,10
@@
enum loctype {neither, quadrant, sector};
#define IHF 'F'
#define IHT 'T'
#define IHWEB '#'
#define IHF 'F'
#define IHT 'T'
#define IHWEB '#'
-#define IHGREEN 'G'
-#define IHYELLOW 'Y'
-#define IHRED 'R'
-#define IHDOCKED 'D'
-#define IHDEAD 'Z'
#define IHMATER0 '-'
#define IHMATER1 'o'
#define IHMATER2 '0'
#define IHMATER0 '-'
#define IHMATER1 'o'
#define IHMATER2 '0'
-
/* Function prototypes */
void prelim(void);
void attack(bool);
/* Function prototypes */
void prelim(void);
void attack(bool);
@@
-355,7
+357,7
@@
void finish(FINTYPE);
void selfdestruct(void);
void kaboom(void);
void freeze(bool);
void selfdestruct(void);
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,18
+376,17
@@
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 ram(bool, int, coord);
void crmena(bool, int, enum loctype, coord w);
void newcnd(void);
void sortkl(void);
void imove(void);
void ram(bool, int, coord);
void crmena(bool, int, enum loctype, coord w);
-void deadkl(coord, int,
int, int
);
+void deadkl(coord, int,
coord
);
void timwrp(void);
void movcom(void);
void timwrp(void);
void movcom(void);
-void torpedo(double, double,
int, int
, double *, int, int);
+void torpedo(double, double,
coord
, double *, int, int);
void huh(void);
void pause_game(int);
void nova(coord);
void huh(void);
void pause_game(int);
void nova(coord);
@@
-410,8
+411,8
@@
void probe(void);
void iostart(void);
void setwnd(WINDOW *);
void warble(void);
void iostart(void);
void setwnd(WINDOW *);
void warble(void);
-void boom(
int, int
);
-void tracktorpedo(
int, int
, int, int, int, int);
+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