few assorted adjustments and a fix for #8883
[super-star-trek.git] / src / sst.c
index ccf7470b64ea04fc4f39152e0fa75ff6e272f5a5..d0d5d05ec97033fbf774c790f97cc08032f2f34f 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -282,7 +282,7 @@ commands[] = {
 #endif
 };
 
-#define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])
+#define NUMCOMMANDS    ARRAY_SIZE(commands)
 #define ACCEPT(i)      (!commands[i].option || (commands[i].option & game.options))
 
 static void listCommands(void) 
@@ -387,13 +387,6 @@ static void helpme(void)
     fclose(fp);
 }
 
-void enqueue(char *s)
-/* enqueue input for the command parser */
-{
-    chew();
-    strcpy(line, s);
-}
-
 static void makemoves(void)
 /* command-interpretation loop */
 {
@@ -413,7 +406,8 @@ static void makemoves(void)
            clrscr();
            proutn("COMMAND> ");
            if (scan() == IHEOL) {
-               makechart();
+               if (game.options & OPTION_CURSES)
+                   makechart();
                continue;
            }
            game.ididit = false;
@@ -439,13 +433,13 @@ static void makemoves(void)
        commandhook(commands[i].name, true);
        switch (v) { /* command switch */
        case SRSCAN:                 // srscan
-           srscan(SCAN_FULL);
+           srscan();
            break;
        case STATUS:                 // status
-           srscan(SCAN_STATUS);
+           status(0);
            break;
        case REQUEST:                   // status request 
-           srscan(SCAN_REQUEST);
+           request();
            break;
        case LRSCAN:                    // lrscan
            lrscan();
@@ -476,7 +470,7 @@ static void makemoves(void)
            dreprt();
            break;
        case CHART:                     // chart
-           chart(false);
+           makechart();
            break;
        case IMPULSE:                   // impulse
            impuls();
@@ -640,11 +634,12 @@ int main(int argc, char **argv)
     }
     /* where to save the input in case of bugs */
     logfp = fopen("/usr/tmp/sst-input.log", "w");
-    setlinebuf(logfp);
-    fprintf(logfp, "seed %d\n", seed);
+    if (logfp) {
+       setlinebuf(logfp);
+       fprintf(logfp, "seed %d\n", seed);
+    }
     srand(seed);
 
-    srand(seed);
     iostart();
 
     line[0] = '\0';