X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=sst.c;h=ee80b3fc878ba45048deeea559f9aae42f81b366;hb=bed74efa98d15a3f6497c9cc721785c6e7387c07;hp=f65a2a5e70aaabd347b0a44ce0920b63238a1080;hpb=a6c062d033c2cf9be1eb9e1164de84ba45379681;p=super-star-trek.git diff --git a/sst.c b/sst.c index f65a2a5..ee80b3f 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); @@ -313,6 +315,7 @@ static void makemoves(void) { helpme(); // get help break; } + commandhook(commands[i], FALSE); for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG @@ -344,20 +347,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 +391,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."); } @@ -479,7 +491,6 @@ int scan(void) { return IHEOL; } getline(line, sizeof(line)); - line[strlen(line)-1] = '\0'; linep = line; } // Skip leading white space