More factoring out.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index c353d04b0621bfe41e97a429c538f25b4aaac314..2e1038b0469d7b2a7a9a7f649d22e157daff8ab1 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -135,56 +135,47 @@ commands[] = {
 #endif /* SERGEEV */
 #define ORBIT  15
        {"ORBIT",       ORBIT},
-#define TRANSPORT      17
+#define TRANSPORT      16
        {"TRANSPORT",   TRANSPORT},
-#define MINE   18
+#define MINE   17
        {"MINE",        MINE},
-#define CRYSTALS 19
+#define CRYSTALS 18
        {"CRYSTALS",    CRYSTALS},
-#define SHUTTLE        20
+#define SHUTTLE        19
        {"SHUTTLE",     SHUTTLE},
-#define PLANETS        21
+#define PLANETS        20
        {"PLANETS",     PLANETS},
-#ifdef SERGEEV
-#define REQUEST        22
-       {"REQUEST",     REQUEST},
-#endif /* SERGEEV */
-#define REPORT 23
+#define REPORT 21
        {"REPORT",      REPORT},
-#define COMPUTER       24
+#define COMPUTER       23
        {"COMPUTER",    COMPUTER},
-#define COMMANDS       25
+#define COMMANDS       24
        {"COMMANDS",    COMMANDS},
-#define EMEXIT 26
+#define EMEXIT 25
        {"EMEXIT",      EMEXIT},
-#define PROBE  27
+#define PROBE  26
        {"PROBE",       PROBE},
-#define SAVE   28
+#define SAVE   27
        {"SAVE",        SAVE},
        {"FREEZE",      SAVE},
-#define ABANDON        29
+#define ABANDON        28
        {"ABANDON",     ABANDON},
-#define DESTRUCT 30
+#define DESTRUCT 29
        {"DESTRUCT",    DESTRUCT},
-#define DEATHRAY 31
+#define DEATHRAY 30
        {"DEATHRAY",    DEATHRAY},
-#define DEBUGCMD       32
+#define DEBUGCMD       31
        {"DEBUG",       DEBUGCMD},
-#define MAYDAY 33
+#define MAYDAY 32
        {"MAYDAY",      MAYDAY},
        {"SOS",         MAYDAY},
        {"CALL",        MAYDAY},
-#define QUIT   34
+#define QUIT   33
        {"QUIT",        QUIT},
-#define HELP   35
+#define HELP   34
        {"HELP",        HELP},
 };
 
-#ifdef SERGEEV
-wnd wnds[6]={{1,1,80,25},{1,1,25,12},{26,2,80,12},{65,1,80,10},{1,13,80,23},{1,24,80,25}};
-short curwnd;
-#endif /* SERGEEV */
-
 #define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])
 
 static void listCommands(int x) {
@@ -208,15 +199,11 @@ static void helpme(void) {
        key = scan();
        while (TRUE) {
                if (key == IHEOL) {
-#ifdef SERGEEV
-                        setwnd(5);
-#endif /* SERGEEV */
+                        setwnd(BOTTOM_WINDOW);
                         proutn("Help on what command? ");
                        key = scan();
                }
-#ifdef SERGEEV
-                setwnd(4);
-#endif /* SERGEEV */
+                setwnd(LOWER_WINDOW);
                if (key == IHEOL) return;
                for (i = 0; i < NUMCOMMANDS; i++) {
                    if (strcasecmp(commands[i].name, citem)==0) {
@@ -277,34 +264,10 @@ static void helpme(void) {
        fclose(fp);
 }
 
-void drawmaps(short l) {
-/* hook to be called after moving to redraw maps */
-#ifdef SERGEEV
-     _setcursortype(_NOCURSOR);
-     if (l==1) sensor();
-     if (l!=2) setwnd(1);
-     gotoxy(1,1);
-     strcpy(line,"s");
-     srscan(1);
-     if (l!=2){
-        setwnd(2);
-        clrscr();
-        srscan(2);
-        setwnd(3);
-        clrscr();
-        strcpy(line,"l");
-        lrscan();
-        _setcursortype(_NORMALCURSOR);
-     }
-#endif /* SERGEEV */
-}
-
 static void makemoves(void) {
        int i, hitme;
-#ifdef SERGEEV
         clrscr();
-        setwnd(4);
-#endif /* SERGEEV */
+        setwnd(LOWER_WINDOW);
        while (TRUE) { /* command loop */
                 drawmaps(1);
                 while (TRUE)  { /* get a command */
@@ -313,27 +276,23 @@ static void makemoves(void) {
                        Time = 0.0;
                        i = -1;
                        chew();
-#ifdef SERGEEV
-                        setwnd(5);
+                        setwnd(BOTTOM_WINDOW);
                         clrscr();
-#endif /* SERGEEV */
                        proutn("COMMAND> ");
                         if (scan() == IHEOL) {
 #ifdef SERGEEV
                             _setcursortype(_NOCURSOR);
-                            setwnd(4);
+                            setwnd(LOWER_WINDOW);
                             clrscr();
                             chart(0);
                             _setcursortype(_NORMALCURSOR);
 #endif /* SERGEEV */
                             continue;
                         }
-#ifdef SERGEEV
                         ididit=0;
                         clrscr();
-                        setwnd(4);
+                        setwnd(LOWER_WINDOW);
                         clrscr();
-#endif /* SERGEEV */
                        for (i=0; i < ABANDON; i++)
                            if (isit(commands[i].name)) {
                                i = commands[i].value;
@@ -453,9 +412,7 @@ static void makemoves(void) {
                                break;
                        case SAVE:                      // Save Game
                                freeze(FALSE);
-#ifdef SERGEEV
                                 clrscr();
-#endif /* SERGEEV */
                                if (skill > 3)
                                         prout("WARNING--Saved games produce no plaques!");
                                break;
@@ -526,14 +483,9 @@ int main(int argc, char **argv) {
            }
        }
 
-#ifndef SERGEEV
-       iostart(usecurses);
-#else
        randomize();
-        textattr(7);
-        clrscr();
-        setwnd(0);
-#endif /* SERGEEV */
+       iostart(usecurses);
+
        line[0] = '\0';
        for (i = optind; i < argc;  i++) {
                strcat(line, argv[i]);
@@ -560,15 +512,11 @@ int main(int argc, char **argv) {
                }
                proutn("Do you want to play again? ");
                if (!ja()) break;
-#ifdef SERGEEV
-               setwnd(0);
+               setwnd(FULLSCREEN_WINDOW);
                clrscr();
-#endif /* SERGEEV */
        }
        skip(1);
-#ifndef SERGEEV
        ioend();
-#endif /* SERGEEV */
        prout("May the Great Bird of the Galaxy roost upon your home planet.");
        return 0;
 }
@@ -669,15 +617,13 @@ int scan(void) {
                        chew();
                        return IHEOL;
                }
-               getline(line, sizeof(line));
-#ifdef SERGEEV
+               cgetline(line, sizeof(line));
                 fflush(stdin);
-                if (curwnd==5){
+                if (curwnd==BOTTOM_WINDOW){
                    clrscr();
-                   setwnd(4);
+                   setwnd(LOWER_WINDOW);
                    clrscr();
                 }
-#endif /* SERGEEV */
                linep = line;
        }
        // Skip leading white space