X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fsst.c;h=d19698491d71a64611cf7b7a0fd6a99591a9d6cd;hp=6d440f93d24bf809dfa0fbce078ea3de51a0c9de;hb=0f68a074434296ae409accdc39ba0142600ea255;hpb=2b37ecca0c3bb58ae15b492f536303776eda9d73 diff --git a/src/sst.c b/src/sst.c index 6d440f9..d196984 100644 --- a/src/sst.c +++ b/src/sst.c @@ -168,6 +168,11 @@ for a lot of magic numbers and refactored the heck out of it. worlds enabled, they must have one in the quadrant to beam down to; otherwise they die in space and this counts heavily against your score. Docking at a starbase replenishes your crew. + + 8. Still more BSD-Trek: we now have a weighted damage table. + Also, the nav subsystem (enabling automatic course + setting) can be damaged separately from the main computer (which + handles weapons targeting, ETA calculation, and self-destruct). */ /* the input queue */ @@ -175,7 +180,7 @@ static char line[128], *linep = line; struct game game; coord thing; -int iqhere, iqengry; +bool iqhere, iqengry; int iscore, iskill; // Common PLAQ double aaitem; double perdate; @@ -196,6 +201,7 @@ char *device[NDEVICES] = { "Subspace Radio", "Shuttle Craft", "Computer", + "Navigation System", "Transporter", "Shield Control", "Death Ray", @@ -290,7 +296,9 @@ commands[] = { #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++) { @@ -304,7 +312,8 @@ static void listCommands(void) { skip(1); } -static void helpme(void) +static void helpme(void) +/* browse on-line help */ { int i, j; char cmdbuf[32], *cp; @@ -383,12 +392,14 @@ static void helpme(void) fclose(fp); } -void enqueue(char *s) +void enqueue(char *s) +/* enqueue input for the command parser */ { strcpy(line, s); } -static void makemoves(void) +static void makemoves(void) +/* command-interpretation loop */ { int key, i, v = 0; bool hitme; @@ -398,7 +409,7 @@ static void makemoves(void) drawmaps(1); for(;;) { /* get a command */ hitme = false; - game.justin = 0; + game.justin = false; game.optime = 0.0; i = -1; chew(); @@ -455,10 +466,10 @@ static void makemoves(void) warp(false); break; case SHIELDS: // shields - doshield(1); + doshield(false); if (game.ididit) { - hitme=true; - game.shldchg = 0; + hitme = true; + game.shldchg = false; } break; case DOCK: // dock @@ -551,7 +562,7 @@ static void makemoves(void) 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 @@ -647,7 +658,7 @@ int main(int argc, char **argv) setup(line[0] == '\0'); if (game.alldone) { score(); - game.alldone = 0; + game.alldone = false; } else makemoves(); skip(1); @@ -670,7 +681,8 @@ int main(int argc, char **argv) } -void cramen(int i) +void cramen(feature i) +/* print the name of an enemy */ { /* return an enemy */ char *s; @@ -693,6 +705,7 @@ void cramen(int i) } char *cramlc(enum loctype key, coord w) +/* name a location */ { static char buf[32]; buf[0] = '\0'; @@ -702,7 +715,8 @@ char *cramlc(enum loctype key, coord w) return buf; } -void crmena(bool stars, int enemy, enum loctype key, coord w) +void crmena(bool stars, feature enemy, enum loctype key, coord w) +/* print an enemy and his location */ { if (stars) proutn("***"); cramen(enemy); @@ -710,7 +724,8 @@ void crmena(bool stars, int enemy, enum loctype key, coord w) proutn(cramlc(key, w)); } -void crmshp(void) +void crmshp(void) +/* print our ship name */ { char *s; switch (game.ship) { @@ -721,7 +736,8 @@ void crmshp(void) proutn(s); } -void stars(void) +void stars(void) +/* print a line of stars */ { prouts("******************************************************"); skip(1); @@ -737,10 +753,13 @@ double Rand(void) return rand()/(1.0 + (double)RAND_MAX); } -void iran(int size, int *i, int *j) +coord randplace(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) @@ -811,7 +830,8 @@ int scan(void) return IHALPHA; } -bool ja(void) +bool ja(void) +/* yes-or-no confirmation */ { chew(); for(;;) { @@ -823,23 +843,22 @@ bool ja(void) } } -void huh(void) +void huh(void) +/* complain about unparseable input */ { chew(); skip(1); prout("Beg your pardon, Captain?"); } -int isit(char *s) +bool 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; - } -void debugme(void) +void debugme(void) +/* access to the internals for debugging */ { proutn("Reset levels? "); if (ja() == true) {