few assorted adjustments and a fix for #8883
[super-star-trek.git] / src / sst.c
index 00e384e0520f2b4f6af7f3e6a7d8624c43e0bb60..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();
@@ -469,14 +463,14 @@ static void makemoves(void)
            }
            break;
        case DOCK:                      // dock
-           dock(1);
-           if (game.ididit) attack(0);
+           dock(true);
+           if (game.ididit) attack(false);
            break;
        case DAMAGES:                   // damages
            dreprt();
            break;
        case CHART:                     // chart
-           chart(false);
+           makechart();
            break;
        case IMPULSE:                   // impulse
            impuls();
@@ -586,7 +580,7 @@ static void makemoves(void)
                continue;
            }
            if (hitme && !game.justin) {
-               attack(2);
+               attack(true);
                if (game.alldone) break;
                if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) {    // went NOVA! 
                    atover(false);
@@ -639,12 +633,13 @@ int main(int argc, char **argv)
        }
     }
     /* where to save the input in case of bugs */
-    logfp = fopen("sst-input.log", "w");
-    setlinebuf(logfp);
-    fprintf(logfp, "seed %d\n", seed);
+    logfp = fopen("/usr/tmp/sst-input.log", "w");
+    if (logfp) {
+       setlinebuf(logfp);
+       fprintf(logfp, "seed %d\n", seed);
+    }
     srand(seed);
 
-    srand(seed);
     iostart();
 
     line[0] = '\0';