X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=sst.c;h=888b7ec4780b01333e7a04905a7dbef65e07d6c5;hb=cf91699c89b88f76dcf63c60624635184e8cb7eb;hp=f65a2a5e70aaabd347b0a44ce0920b63238a1080;hpb=a6c062d033c2cf9be1eb9e1164de84ba45379681;p=super-star-trek.git diff --git a/sst.c b/sst.c index f65a2a5..888b7ec 100644 --- a/sst.c +++ b/sst.c @@ -1,6 +1,7 @@ #define INCLUDED // Define externs here -#include "sst.h" #include +#include +#include "sst.h" #ifndef SSTDOC #define SSTDOC "sst.doc" @@ -189,6 +190,7 @@ static void makemoves(void) { } else prout("UNRECOGNIZED COMMAND."); } + commandhook(commands[i], TRUE); switch (i) { /* command switch */ case 0: // srscan srscan(1); @@ -215,7 +217,8 @@ static void makemoves(void) { } break; case 6: // dock - dock(); + dock(1); + if (ididit) attack(0); break; case 7: // damages dreprt(); @@ -313,6 +316,7 @@ static void makemoves(void) { helpme(); // get help break; } + commandhook(commands[i], FALSE); for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG @@ -344,20 +348,28 @@ static void makemoves(void) { int main(int argc, char **argv) { - int i; + int i, option, usecurses = TRUE; int hitme; char ch; + while ((option = getopt(argc, argv, "t")) != -1) { + switch (option) { + case 't': + usecurses = FALSE; + break; + default: + fprintf(stderr, "usage: sst [-t] [startcommand...].\n"); + exit(0); + } + } + + iostart(usecurses); prelim(); - iostart(); line[0] = '\0'; - if (argc > 1) { - while (--argc > 0) { - strcat(line, *(++argv)); - strcat(line, " "); - } + for (i = optind; i < argc; i++) { + strcat(line, argv[i]); + strcat(line, " "); } - while (TRUE) { /* Play a game */ setup(line[0] == '\0'); if (alldone) { @@ -380,7 +392,8 @@ int main(int argc, char **argv) { if (!ja()) break; } skip(1); - prout("May the Great Bird of the Galaxy roost upon your home planet."); + ioend(); + puts("May the Great Bird of the Galaxy roost upon your home planet."); } @@ -399,6 +412,7 @@ void cramen(int i) { case IHBLANK: s = "Black hole"; break; case IHT: s = "Tholian"; break; case IHWEB: s = "Tholian web"; break; + case IHQUEST: s = "Stranger"; break; default: s = "Unknown??"; break; } proutn(s); @@ -479,7 +493,6 @@ int scan(void) { return IHEOL; } getline(line, sizeof(line)); - line[strlen(line)-1] = '\0'; linep = line; } // Skip leading white space @@ -491,6 +504,7 @@ int scan(void) { } if (isdigit(*linep) || *linep=='+' || *linep=='-' || *linep=='.') { // treat as a number + i = 0; if (sscanf(linep, "%lf%n", &aaitem, &i) < 1) { linep = line; // Invalid numbers are ignored *linep = 0; @@ -523,8 +537,6 @@ int ja(void) { } } -double square(double i) { return i*i; } - void huh(void) { chew(); skip(1);