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 boolean cleanups. More consistent use of coord type
[super-star-trek.git]
/
src
/
sst.c
diff --git
a/src/sst.c
b/src/sst.c
index 6d440f93d24bf809dfa0fbce078ea3de51a0c9de..cef3f7a8dd9ca9f9f1d40f6e4edc04fc2ee17fd7 100644
(file)
--- a/
src/sst.c
+++ b/
src/sst.c
@@
-175,7
+175,7
@@
static char line[128], *linep = line;
struct game game;
coord thing;
struct game game;
coord thing;
-
int
iqhere, iqengry;
+
bool
iqhere, iqengry;
int iscore, iskill; // Common PLAQ
double aaitem;
double perdate;
int iscore, iskill; // Common PLAQ
double aaitem;
double perdate;
@@
-290,7
+290,9
@@
commands[] = {
#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
#define ACCEPT(i) (!commands[i].option || (commands[i].option & game.options))
#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
#define ACCEPT(i) (!commands[i].option || (commands[i].option & game.options))
-static void listCommands(void) {
+static void listCommands(void)
+/* generate a list of legal commands */
+{
int i, k = 0;
proutn("LEGAL COMMANDS ARE:");
for (i = 0; i < NUMCOMMANDS; i++) {
int i, k = 0;
proutn("LEGAL COMMANDS ARE:");
for (i = 0; i < NUMCOMMANDS; i++) {
@@
-304,7
+306,8
@@
static void listCommands(void) {
skip(1);
}
skip(1);
}
-static void helpme(void)
+static void helpme(void)
+/* browse on-line help */
{
int i, j;
char cmdbuf[32], *cp;
{
int i, j;
char cmdbuf[32], *cp;
@@
-383,12
+386,14
@@
static void helpme(void)
fclose(fp);
}
fclose(fp);
}
-void enqueue(char *s)
+void enqueue(char *s)
+/* enqueue input for the command parser */
{
strcpy(line, s);
}
{
strcpy(line, s);
}
-static void makemoves(void)
+static void makemoves(void)
+/* command-interpretation loop */
{
int key, i, v = 0;
bool hitme;
{
int key, i, v = 0;
bool hitme;
@@
-551,7
+556,7
@@
static void makemoves(void)
if (game.ididit) hitme = true;
break;
case QUIT:
if (game.ididit) hitme = true;
break;
case QUIT:
- game.alldone =
1;
// quit the game
+ game.alldone =
true;
// quit the game
break;
case HELP:
helpme(); // get help
break;
case HELP:
helpme(); // get help
@@
-647,7
+652,7
@@
int main(int argc, char **argv)
setup(line[0] == '\0');
if (game.alldone) {
score();
setup(line[0] == '\0');
if (game.alldone) {
score();
- game.alldone =
0
;
+ game.alldone =
false
;
}
else makemoves();
skip(1);
}
else makemoves();
skip(1);
@@
-671,6
+676,7
@@
int main(int argc, char **argv)
void cramen(int i)
void cramen(int i)
+/* print the name of an enemy */
{
/* return an enemy */
char *s;
{
/* return an enemy */
char *s;
@@
-693,6
+699,7
@@
void cramen(int i)
}
char *cramlc(enum loctype key, coord w)
}
char *cramlc(enum loctype key, coord w)
+/* name a location */
{
static char buf[32];
buf[0] = '\0';
{
static char buf[32];
buf[0] = '\0';
@@
-703,6
+710,7
@@
char *cramlc(enum loctype key, coord w)
}
void crmena(bool stars, int enemy, enum loctype key, coord w)
}
void crmena(bool stars, int enemy, enum loctype key, coord w)
+/* print an enemy and his location */
{
if (stars) proutn("***");
cramen(enemy);
{
if (stars) proutn("***");
cramen(enemy);
@@
-710,7
+718,8
@@
void crmena(bool stars, int enemy, enum loctype key, coord w)
proutn(cramlc(key, w));
}
proutn(cramlc(key, w));
}
-void crmshp(void)
+void crmshp(void)
+/* print our ship name */
{
char *s;
switch (game.ship) {
{
char *s;
switch (game.ship) {
@@
-721,7
+730,8
@@
void crmshp(void)
proutn(s);
}
proutn(s);
}
-void stars(void)
+void stars(void)
+/* print a line of stars */
{
prouts("******************************************************");
skip(1);
{
prouts("******************************************************");
skip(1);
@@
-737,10
+747,13
@@
double Rand(void)
return rand()/(1.0 + (double)RAND_MAX);
}
return rand()/(1.0 + (double)RAND_MAX);
}
-void iran(int size, int *i, int *j)
+coord iran(int size)
+/* choose a random location */
{
{
- *i = Rand()*(size*1.0) + 1.0;
- *j = Rand()*(size*1.0) + 1.0;
+ coord w;
+ w.x = Rand()*(size*1.0) + 1.0;
+ w.y = Rand()*(size*1.0) + 1.0;
+ return w;
}
void chew(void)
}
void chew(void)
@@
-811,7
+824,8
@@
int scan(void)
return IHALPHA;
}
return IHALPHA;
}
-bool ja(void)
+bool ja(void)
+/* yes-or-no confirmation */
{
chew();
for(;;) {
{
chew();
for(;;) {
@@
-823,7
+837,8
@@
bool ja(void)
}
}
}
}
-void huh(void)
+void huh(void)
+/* complain about unparseable input */
{
chew();
skip(1);
{
chew();
skip(1);
@@
-831,15
+846,13
@@
void huh(void)
}
int isit(char *s)
}
int isit(char *s)
+/* compares s to citem and returns true if it matches to the length of s */
{
{
- /* New function -- compares s to scanned citem and returns true if it
- matches to the length of s */
-
return strncasecmp(s, citem, max(1, strlen(citem))) == 0;
return strncasecmp(s, citem, max(1, strlen(citem))) == 0;
-
}
}
-void debugme(void)
+void debugme(void)
+/* access to the internals for debugging */
{
proutn("Reset levels? ");
if (ja() == true) {
{
proutn("Reset levels? ");
if (ja() == true) {