This completely merges the line-oriented and screen I/O managers,
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index 346bb4c740c4a697ed76451183eadf6375f923b9..dc26b35442556fcf1b04a2747ec573f8d1f8c2f7 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -1,19 +1,14 @@
 #define INCLUDED       // Define externs here
 #include <ctype.h>
 #include <getopt.h>
 #define INCLUDED       // Define externs here
 #include <ctype.h>
 #include <getopt.h>
-#ifdef SERGEEV
-#include <conio.h>
 #include <time.h>
 #include "sstlinux.h"
 #include <time.h>
 #include "sstlinux.h"
-#endif /* SERGEEV */
 #include "sst.h"
 
 #ifndef SSTDOC
 #define SSTDOC "sst.doc"
 #endif
        
 #include "sst.h"
 
 #ifndef SSTDOC
 #define SSTDOC "sst.doc"
 #endif
        
-static char line[128], *linep = line;
-
 /*
 
 Here are Tom Almy's changes:
 /*
 
 Here are Tom Almy's changes:
@@ -51,139 +46,148 @@ Here are Tom Almy's changes:
 
    6. Perhaps cloaking to be added later? BSD version
 
 
    6. Perhaps cloaking to be added later? BSD version
 
-Here are Stas Sergeev's changes (controlled by the proprocessor symbol
-SERGEEV, not yet completely merged):
+Here are Stas Sergeev's changes:
 
    1. The Space Thingy can be shoved, if you it ram, and can fire back if 
       fired upon.
 
 
    1. The Space Thingy can be shoved, if you it ram, and can fire back if 
       fired upon.
 
-   1 The Tholian can be hit with phasers
+   2. The Tholian can be hit with phasers
 
 
-   2. When you are docked, base covers you with an almost invincible shields 
+   3. When you are docked, base covers you with an almost invincible shields 
       (a commander can still ram you, or a Romulan can destroy the base,
       or a SCom can even succeed with direct attack IIRC, but this rarely 
       happens).
 
       (a commander can still ram you, or a Romulan can destroy the base,
       or a SCom can even succeed with direct attack IIRC, but this rarely 
       happens).
 
-    3. SCom can't escape from you if no more enemies remain (without this, 
-       chasing SCom can take an eternity).
+   4. SCom can't escape from you if no more enemies remain (without this, 
+      chasing SCom can take an eternity).
 
 
-    4. Probe target you enter is now the destination quadrant. Before I don't 
-       remember what it was, but it was something I had difficulty using)
+   5. Probe target you enter is now the destination quadrant. Before I don't 
+      remember what it was, but it was something I had difficulty using)
 
 
-    5. Secret password is now autogenerated.
+   6. Secret password is now autogenerated.
 
 
-    6. "Plaque" is adjusted for A4 paper:)
+   7. "Plaque" is adjusted for A4 paper :-)
 
 
-    7. Phasers now tells you how much energy needed, but only if the computer 
+   8. Phasers now tells you how much energy needed, but only if the computer 
        is alive.
 
        is alive.
 
-    8. Planets are auto-scanned when you enter the quadrant.
+   9. Planets are auto-scanned when you enter the quadrant.
 
 
-    9. Mining or using crystals in presense of enemy now yields an attack.
+   10. Mining or using crystals in presense of enemy now yields an attack.
        There are other minor adjustments to what yields an attack
        and what does not.
 
        There are other minor adjustments to what yields an attack
        and what does not.
 
-    10. Ramming a black hole is no longer instant death.  There is a
-        chance you might get timewarped instead.
+   11. Ramming a black hole is no longer instant death.  There is a
+       chance you might get timewarped instead.
+
+   12. "freeze" command reverts to "save", most people will understand this
+        better anyway.
+
+   13. Screen-oriented interface, with sensor scans always up.
+
+Eric Raymond's changes:
+
+   1. "sos" and "call" becomes "mayday", "freeze" and "save" are both good.
 
    */
 
 
    */
 
-static char *commands[] = {
-#ifdef SERGEEV
-        "--",
-        "---",
-#else
-       "srscan",
-       "lrscan",
-#endif /* SERGEEV */
-       "phasers",
-#ifdef SERGEEV
-        "torpedo",
-#else
-       "photons",
-#endif /* SERGEEV */
-       "move",
-       "shields",
-       "dock",
-       "damages",
-       "chart",
-       "impulse",
-       "rest",
-       "warp",
-#ifdef SERGEEV
-        "score",
-        "----",
-#else
-       "status",
-       "sensors",
-#endif /* SERGEEV */
-       "orbit",
-       "transport",
-       "mine",
-       "crystals",
-       "shuttle",
-       "planets",
-#ifdef SERGEEV
-        "-----",
-#else
-       "request",
-#endif /* SERGEEV */
-       "report",
-       "computer",
-       "commands",
-       "emexit",
-       "probe",
-       "abandon",
-       "destruct",
-#ifdef SERGEEV
-        "save",
-#else
-       "freeze",
-#endif /* SERGEEV */
-       "deathray",
-       "debug",
-#ifdef SERGEEV
-        "sos",
-#else
-       "call",
-#endif /* SERGEEV */
-       "quit",
-       "help"
-};
+/* the input queue */
+static char line[128], *linep = line;
 
 
-#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 */
+static struct 
+{
+    char *name;
+    int value;
+}
+commands[] = {
+#define SRSCAN 1
+       {"SRSCAN",      SRSCAN},
+#define STATUS 2
+       {"STATUS",      STATUS},
+#define REQUEST        3
+       {"REQUEST",     REQUEST},
+#define LRSCAN 4
+       {"LRSCAN",      LRSCAN},
+#define PHASERS        5
+       {"PHASERS",     PHASERS},
+#define TORPEDO        6
+        {"TORPEDO",    TORPEDO},
+       {"PHOTONS",     TORPEDO},
+#define MOVE   7
+       {"MOVE",        MOVE},
+#define SHIELDS        8
+       {"SHIELDS",     SHIELDS},
+#define DOCK   9
+       {"DOCK",        DOCK},
+#define DAMAGES        10
+       {"DAMAGES",     DAMAGES},
+#define CHART  11
+       {"CHART",       CHART},
+#define IMPULSE        12
+       {"IMPULSE",     IMPULSE},
+#define REST   13
+       {"REST",        REST},
+#define WARP   14
+       {"WARP",        WARP},
+#define SCORE  15
+       {"SCORE",       SCORE},
+#define SENSORS        16
+       {"SENSORS",     SENSORS},
+#define ORBIT  17
+       {"ORBIT",       ORBIT},
+#define TRANSPORT      18
+       {"TRANSPORT",   TRANSPORT},
+#define MINE   19
+       {"MINE",        MINE},
+#define CRYSTALS       20
+       {"CRYSTALS",    CRYSTALS},
+#define SHUTTLE        21
+       {"SHUTTLE",     SHUTTLE},
+#define PLANETS        22
+       {"PLANETS",     PLANETS},
+#define REPORT 23
+       {"REPORT",      REPORT},
+#define COMPUTER       24
+       {"COMPUTER",    COMPUTER},
+#define COMMANDS       25
+       {"COMMANDS",    COMMANDS},
+#define EMEXIT 26
+       {"EMEXIT",      EMEXIT},
+#define PROBE  27
+       {"PROBE",       PROBE},
+#define SAVE   28
+       {"SAVE",        SAVE},
+       {"FREEZE",      SAVE},
+#define ABANDON        29
+       {"ABANDON",     ABANDON},
+#define DESTRUCT       30
+       {"DESTRUCT",    DESTRUCT},
+#define DEATHRAY       31
+       {"DEATHRAY",    DEATHRAY},
+#define DEBUGCMD       32
+       {"DEBUG",       DEBUGCMD},
+#define MAYDAY 33
+       {"MAYDAY",      MAYDAY},
+       {"SOS",         MAYDAY},
+       {"CALL",        MAYDAY},
+#define QUIT   34
+       {"QUIT",        QUIT},
+#define HELP   35
+       {"HELP",        HELP},
+};
 
 #define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])
 
 static void listCommands(int x) {
 
 #define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])
 
 static void listCommands(int x) {
-        proutn   ("LEGAL COMMANDS ARE:\n\r"
-                  "   MOVE      PHASERS   SOS       PROBE\n\r"
-                  "   COMPUTER  IMPULSE   TORPEDO   ABANDON\n\r"
-                  "   EMEXIT    WARP      SHIELDS   DESTRUCT\n\r"
-                  "   CHART     REST      DOCK      QUIT\n\r"
-                  "   DAMAGES   REPORT    SCORE     ORBIT\n\r"
-                  "   TRANSPORT MINE      CRYSTALS  SHUTTLE\n\r"
-                  "   PLANETS   DEATHRAY  SAVE      COMMANDS\n\r");
-       if (x) prout("   HELP");
-}
-
-#ifdef SERGEEV
-void setwnd(short wndnum){
-     int cury;
-     cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
-     if ((curwnd==0)&&(wndnum!=0)) clrscr();
-     window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
-     if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
-        gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
-       skip(1);
-     }
-     curwnd=wndnum;
-     gotoxy(1,cury);
+    int i;
+    prout("LEGAL COMMANDS ARE:");
+    for (i = 0; i < NUMCOMMANDS; i++) {
+       proutn("%-12s ", commands[i].name);
+       if (i % 5 == 4)
+           skip(1);
+    }
+    skip(1);
 }
 }
-#endif /* SERGEEV */
 
 static void helpme(void) {
        int i, j;
 
 static void helpme(void) {
        int i, j;
@@ -195,18 +199,17 @@ static void helpme(void) {
        key = scan();
        while (TRUE) {
                if (key == IHEOL) {
        key = scan();
        while (TRUE) {
                if (key == IHEOL) {
-#ifdef SERGEEV
-                        setwnd(5);
-#endif /* SERGEEV */
+                        setwnd(BOTTOM_WINDOW);
                         proutn("Help on what command? ");
                        key = scan();
                }
                         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 (key == IHEOL) return;
                for (i = 0; i < NUMCOMMANDS; i++) {
-                       if (strcmp(commands[i], citem)==0) break;
+                   if (strcasecmp(commands[i].name, citem)==0) {
+                       i = commands[i].value;
+                       break;
+                   }
                }
                if (i != NUMCOMMANDS) break;
                skip(1);
                }
                if (i != NUMCOMMANDS) break;
                skip(1);
@@ -216,12 +219,12 @@ static void helpme(void) {
                chew();
                skip(1);
        }
                chew();
                skip(1);
        }
-       if (i == 23) {
+       if (i == COMMANDS) {
                strcpy(cmdbuf, " ABBREV");
        }
        else {
                strcpy(cmdbuf, " ABBREV");
        }
        else {
-           for (j = 0; commands[i][j]; j++)
-               cmdbuf[j] = toupper(commands[i][j]);
+           for (j = 0; commands[i].name[j]; j++)
+               cmdbuf[j] = toupper(commands[i].name[j]);
            cmdbuf[j] = '\0';
        }
        fp = fopen(SSTDOC, "r");
            cmdbuf[j] = '\0';
        }
        fp = fopen(SSTDOC, "r");
@@ -244,7 +247,7 @@ static void helpme(void) {
                for (cp = linebuf+3; isspace(*cp); cp++)
                        continue;
                linebuf[strlen(linebuf)-1] = '\0';
                for (cp = linebuf+3; isspace(*cp); cp++)
                        continue;
                linebuf[strlen(linebuf)-1] = '\0';
-               if (strcmp(cp, cmdbuf) == 0)
+               if (strcasecmp(cp, cmdbuf) == 0)
                    break;
            }
        }
                    break;
            }
        }
@@ -256,39 +259,19 @@ static void helpme(void) {
        while (fgets(linebuf, sizeof(linebuf),fp)) {
                if (strstr(linebuf, "******"))
                        break;
        while (fgets(linebuf, sizeof(linebuf),fp)) {
                if (strstr(linebuf, "******"))
                        break;
-               proutc(linebuf);
+               proutn(linebuf);
        }
        fclose(fp);
 }
 
        }
        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 */
+void enqueue(char *s) {
+    strcpy(line, s);
 }
 
 static void makemoves(void) {
        int i, hitme;
 }
 
 static void makemoves(void) {
        int i, hitme;
-#ifdef SERGEEV
         clrscr();
         clrscr();
-        setwnd(4);
-#endif /* SERGEEV */
+        setwnd(LOWER_WINDOW);
        while (TRUE) { /* command loop */
                 drawmaps(1);
                 while (TRUE)  { /* get a command */
        while (TRUE) { /* command loop */
                 drawmaps(1);
                 while (TRUE)  { /* get a command */
@@ -297,176 +280,166 @@ static void makemoves(void) {
                        Time = 0.0;
                        i = -1;
                        chew();
                        Time = 0.0;
                        i = -1;
                        chew();
-#ifdef SERGEEV
-                        setwnd(5);
+                        setwnd(BOTTOM_WINDOW);
                         clrscr();
                         clrscr();
-#endif /* SERGEEV */
                        proutn("COMMAND> ");
                         if (scan() == IHEOL) {
                        proutn("COMMAND> ");
                         if (scan() == IHEOL) {
-#ifdef SERGEEV
-                            _setcursortype(_NOCURSOR);
-                            setwnd(4);
-                            clrscr();
-                            chart(0);
-                            _setcursortype(_NORMALCURSOR);
-#endif /* SERGEEV */
+                           makechart();
                             continue;
                         }
                             continue;
                         }
-#ifdef SERGEEV
                         ididit=0;
                         clrscr();
                         ididit=0;
                         clrscr();
-                        setwnd(4);
+                        setwnd(LOWER_WINDOW);
                         clrscr();
                         clrscr();
-#endif /* SERGEEV */
-                       for (i=0; i < 26; i++)
-                               if (isit(commands[i]))
-                                       break;
-                       if (i < 26) break;
+                       for (i=0; i < ABANDON; i++)
+                           if (isit(commands[i].name)) {
+                               i = commands[i].value;
+                               break;
+                           }
+                       if (i < ABANDON) break;
                        for (; i < NUMCOMMANDS; i++)
                        for (; i < NUMCOMMANDS; i++)
-                               if (strcmp(commands[i], citem) == 0) break;
+                           if (strcasecmp(commands[i].name, citem) == 0) {
+                                   i = commands[i].value;
+                                   break;
+                           }
                        if (i < NUMCOMMANDS) break;
 
                        listCommands(TRUE);
                }
                        if (i < NUMCOMMANDS) break;
 
                        listCommands(TRUE);
                }
-               commandhook(commands[i], TRUE);
+               commandhook(commands[i].name, TRUE);
                switch (i) { /* command switch */
                switch (i) { /* command switch */
-#ifndef SERGEEV
-                        case 0:                 // srscan
-                               srscan(1);
+                        case SRSCAN:                 // srscan
+                               srscan(SCAN_FULL);
                                break;
                                break;
-                       case 1:                 // lrscan
+                        case STATUS:                 // status
+                               srscan(SCAN_STATUS);
+                               break;
+                       case REQUEST:                   // status request 
+                               srscan(SCAN_REQUEST);
+                               break;
+                       case LRSCAN:                    // lrscan
                                lrscan();
                                 break;
                                lrscan();
                                 break;
-#endif /* SERGEEV */
-                       case 2:                 // phasers
+                       case PHASERS:                   // phasers
                                phasers();
                                if (ididit) hitme = TRUE;
                                break;
                                phasers();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 3:                 // photons
+                       case TORPEDO:                   // photons
                                photon();
                                if (ididit) hitme = TRUE;
                                break;
                                photon();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 4:                 // move
+                       case MOVE:                      // move
                                warp(1);
                                break;
                                warp(1);
                                break;
-                       case 5:                 // shields
+                       case SHIELDS:                   // shields
                                doshield(1);
                                if (ididit) {
                                        hitme=TRUE;
                                        shldchg = 0;
                                }
                                break;
                                doshield(1);
                                if (ididit) {
                                        hitme=TRUE;
                                        shldchg = 0;
                                }
                                break;
-                       case 6:                 // dock
+                       case DOCK:                      // dock
                                 dock(1);
                                 if (ididit) attack(0);
                                break;
                                 dock(1);
                                 if (ididit) attack(0);
                                break;
-                       case 7:                 // damages
+                       case DAMAGES:                   // damages
                                dreprt();
                                break;
                                dreprt();
                                break;
-                       case 8:                 // chart
+                       case CHART:                     // chart
                                chart(0);
                                break;
                                chart(0);
                                break;
-                       case 9:                 // impulse
+                       case IMPULSE:                   // impulse
                                impuls();
                                break;
                                impuls();
                                break;
-                       case 10:                // rest
+                       case REST:              // rest
                                wait();
                                if (ididit) hitme = TRUE;
                                break;
                                wait();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 11:                // warp
+                       case WARP:              // warp
                                setwrp();
                                break;
                                setwrp();
                                break;
-                        case 12:                // score
+                        case SCORE:                // score
                                 score();
                                break;
                                 score();
                                break;
-#ifndef SERGEEV
-                       case 13:                        // sensors
+                       case SENSORS:                   // sensors
                                sensor();
                                break;
                                sensor();
                                break;
-#endif /* SERGEEV */
-                       case 14:                        // orbit
+                       case ORBIT:                     // orbit
                                orbit();
                                if (ididit) hitme = TRUE;
                                break;
                                orbit();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 15:                        // transport "beam"
+                       case TRANSPORT:                 // transport "beam"
                                beam();
                                break;
                                beam();
                                break;
-                       case 16:                        // mine
+                       case MINE:                      // mine
                                mine();
                                if (ididit) hitme = TRUE;
                                break;
                                mine();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 17:                        // crystals
+                       case CRYSTALS:                  // crystals
                                usecrystals();
                                 if (ididit) hitme = TRUE;
                                break;
                                usecrystals();
                                 if (ididit) hitme = TRUE;
                                break;
-                       case 18:                        // shuttle
+                       case SHUTTLE:                   // shuttle
                                shuttle();
                                if (ididit) hitme = TRUE;
                                break;
                                shuttle();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 19:                        // Planet list
+                       case PLANETS:                   // Planet list
                                preport();
                                break;
                                preport();
                                break;
-                       case 20:                        // Status information
-                               srscan(2);
-                               break;
-                       case 21:                        // Game Report 
+                       case REPORT:                    // Game Report 
                                report();
                                break;
                                report();
                                break;
-                       case 22:                        // use COMPUTER!
+                       case COMPUTER:                  // use COMPUTER!
                                eta();
                                break;
                                eta();
                                break;
-                       case 23:
+                       case COMMANDS:
                                listCommands(TRUE);
                                break;
                                listCommands(TRUE);
                                break;
-                       case 24:                // Emergency exit
-#ifdef SERGEEV
+                       case EMEXIT:            // Emergency exit
                                clrscr();       // Hide screen
                                clrscr();       // Hide screen
-#endif /* SERGEEV */
                                freeze(TRUE);   // forced save
                                exit(1);                // And quick exit
                                break;
                                freeze(TRUE);   // forced save
                                exit(1);                // And quick exit
                                break;
-                       case 25:
+                       case PROBE:
                                probe();                // Launch probe
                                 if (ididit) hitme = TRUE;
                                break;
                                probe();                // Launch probe
                                 if (ididit) hitme = TRUE;
                                break;
-                       case 26:                        // Abandon Ship
+                       case ABANDON:                   // Abandon Ship
                                abandn();
                                break;
                                abandn();
                                break;
-                       case 27:                        // Self Destruct
+                       case DESTRUCT:                  // Self Destruct
                                dstrct();
                                break;
                                dstrct();
                                break;
-                       case 28:                        // Save Game
+                       case SAVE:                      // Save Game
                                freeze(FALSE);
                                freeze(FALSE);
-#ifdef SERGEEV
                                 clrscr();
                                 clrscr();
-#endif /* SERGEEV */
                                if (skill > 3)
                                         prout("WARNING--Saved games produce no plaques!");
                                break;
                                if (skill > 3)
                                         prout("WARNING--Saved games produce no plaques!");
                                break;
-                       case 29:                        // Try a desparation measure
+                       case DEATHRAY:          // Try a desparation measure
                                deathray();
                                if (ididit) hitme = TRUE;
                                break;
                                deathray();
                                if (ididit) hitme = TRUE;
                                break;
-                       case 30:                        // What do we want for debug???
+                       case DEBUGCMD:          // What do we want for debug???
 #ifdef DEBUG
                                debugme();
 #endif
                                break;
 #ifdef DEBUG
                                debugme();
 #endif
                                break;
-                       case 31:                // Call for help
+                       case MAYDAY:            // Call for help
                                help();
                                 if (ididit) hitme = TRUE;
                                break;
                                help();
                                 if (ididit) hitme = TRUE;
                                break;
-                       case 32:
+                       case QUIT:
                                alldone = 1;    // quit the game
 #ifdef DEBUG
                                if (idebug) score();
 #endif
                                break;
                                alldone = 1;    // quit the game
 #ifdef DEBUG
                                if (idebug) score();
 #endif
                                break;
-                       case 33:
+                       case HELP:
                                helpme();       // get help
                                break;
                }
                                helpme();       // get help
                                break;
                }
-               commandhook(commands[i], FALSE);
+               commandhook(commands[i].name, FALSE);
                for (;;) {
                        if (alldone) break;             // Game has ended
 #ifdef DEBUG
                for (;;) {
                        if (alldone) break;             // Game has ended
 #ifdef DEBUG
@@ -510,20 +483,17 @@ int main(int argc, char **argv) {
            }
        }
 
            }
        }
 
-#ifndef SERGEEV
-       iostart(usecurses);
-#else
        randomize();
        randomize();
-        textattr(7);
-        clrscr();
-        setwnd(0);
-#endif /* SERGEEV */
+       iostart(usecurses);
+
        line[0] = '\0';
        for (i = optind; i < argc;  i++) {
                strcat(line, argv[i]);
                strcat(line, " ");
        }
        while (TRUE) { /* Play a game */
        line[0] = '\0';
        for (i = optind; i < argc;  i++) {
                strcat(line, argv[i]);
                strcat(line, " ");
        }
        while (TRUE) { /* Play a game */
+               setwnd(FULLSCREEN_WINDOW);
+               clrscr();
                prelim();
                setup(line[0] == '\0');
                if (alldone) {
                prelim();
                setup(line[0] == '\0');
                if (alldone) {
@@ -544,15 +514,8 @@ int main(int argc, char **argv) {
                }
                proutn("Do you want to play again? ");
                if (!ja()) break;
                }
                proutn("Do you want to play again? ");
                if (!ja()) break;
-#ifdef SERGEEV
-               setwnd(0);
-               clrscr();
-#endif /* SERGEEV */
        }
        skip(1);
        }
        skip(1);
-#ifndef SERGEEV
-       ioend();
-#endif /* SERGEEV */
        prout("May the Great Bird of the Galaxy roost upon your home planet.");
        return 0;
 }
        prout("May the Great Bird of the Galaxy roost upon your home planet.");
        return 0;
 }
@@ -653,15 +616,13 @@ int scan(void) {
                        chew();
                        return IHEOL;
                }
                        chew();
                        return IHEOL;
                }
-               getline(line, sizeof(line));
-#ifdef SERGEEV
+               cgetline(line, sizeof(line));
                 fflush(stdin);
                 fflush(stdin);
-                if (curwnd==5){
+                if (curwnd==BOTTOM_WINDOW){
                    clrscr();
                    clrscr();
-                   setwnd(4);
+                   setwnd(LOWER_WINDOW);
                    clrscr();
                 }
                    clrscr();
                 }
-#endif /* SERGEEV */
                linep = line;
        }
        // Skip leading white space
                linep = line;
        }
        // Skip leading white space
@@ -716,7 +677,7 @@ int isit(char *s) {
        /* New function -- compares s to scaned citem and returns true if it
           matches to the length of s */
 
        /* New function -- compares s to scaned citem and returns true if it
           matches to the length of s */
 
-       return strncmp(s, citem, max(1, strlen(citem))) == 0;
+       return strncasecmp(s, citem, max(1, strlen(citem))) == 0;
 
 }
 
 
 }