]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - atc/input.c
don't install in /usr/share if NOSHARE is defined
[bsdgames-darwin.git] / atc / input.c
index 95ada1336c2192fcf76fb15ec3f4367961ccf955..eb0fa9e6955aa4a802e74ff203984f8de55d71c9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: input.c,v 1.6 1997/10/10 02:07:18 lukem Exp $  */
+/*     $NetBSD: input.c,v 1.10 1998/09/13 15:20:31 hubertf Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -50,7 +50,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: input.c,v 1.6 1997/10/10 02:07:18 lukem Exp $");
+__RCSID("$NetBSD: input.c,v 1.10 1998/09/13 15:20:31 hubertf Exp $");
 #endif
 #endif not lint
 
@@ -61,9 +61,6 @@ __RCSID("$NetBSD: input.c,v 1.6 1997/10/10 02:07:18 lukem Exp $");
 #define MAXDEPTH       15
 
 #define RETTOKEN       '\n'
-#ifdef SYSV
-#define CRTOKEN                '\r'
-#endif
 #define REDRAWTOKEN    '\014'  /* CTRL(L) */
 #define        SHELLTOKEN      '!'
 #define HELPTOKEN      '?'
@@ -103,9 +100,6 @@ typedef struct {
 
 RULE   state0[] = {    { ALPHATOKEN,   1,      "%c:",          setplane},
                        { RETTOKEN,     -1,     "",             NULL    },
-#ifdef SYSV
-                       { CRTOKEN,      -1,     "",             NULL    },
-#endif
                        { HELPTOKEN,    12,     " [a-z]<ret>",  NULL    }},
        state1[] = {    { 't',          2,      " turn",        turn    },      
                        { 'a',          3,      " altitude:",   NULL    },      
@@ -137,9 +131,6 @@ RULE        state0[] = {    { ALPHATOKEN,   1,      "%c:",          setplane},
        state4[] = {    { '@',          9,      " at",          NULL    },      
                        { 'a',          9,      " at",          NULL    },      
                        { RETTOKEN,     -1,     "",             NULL    },
-#ifdef SYSV
-                       { CRTOKEN,      -1,     "",             NULL    },
-#endif
                        { HELPTOKEN,    12,     " @a<ret>",     NULL    }},
        state5[] = {    { NUMTOKEN,     7,      "%c",           delayb  },
                        { HELPTOKEN,    12,     " [0-9]",       NULL    }},
@@ -154,14 +145,8 @@ RULE       state0[] = {    { ALPHATOKEN,   1,      "%c:",          setplane},
                        { 'a',          4,      " 270",         rel_dir },
                        { 'q',          4,      " 315",         rel_dir },
                        { RETTOKEN,     -1,     "",             NULL    },      
-#ifdef SYSV
-                       { CRTOKEN,      -1,     "",             NULL    },      
-#endif
                        { HELPTOKEN,    12,     " @a<dir><ret>",NULL    }},
        state7[] = {    { RETTOKEN,     -1,     "",             NULL    },
-#ifdef SYSV
-                       { CRTOKEN,      -1,     "",             NULL    },
-#endif
                        { HELPTOKEN,    12,     " <ret>",       NULL    }},
        state8[] = {    { NUMTOKEN,     4,      "%c",           benum   },
                        { HELPTOKEN,    12,     " [0-9]",       NULL    }},
@@ -424,7 +409,7 @@ right(c)
 {
        dir = D_RIGHT;
        p.new_dir = p.dir + 1;
-       if (p.new_dir > MAXDIR)
+       if (p.new_dir >= MAXDIR)
                p.new_dir -= MAXDIR;
        return (NULL);
 }
@@ -444,7 +429,7 @@ Right(c)
        char c;
 {
        p.new_dir = p.dir + 2;
-       if (p.new_dir > MAXDIR)
+       if (p.new_dir >= MAXDIR)
                p.new_dir -= MAXDIR;
        return (NULL);
 }
@@ -459,9 +444,9 @@ delayb(c)
 
        if (c >= sp->num_beacons)
                return ("Unknown beacon");
-       xdiff = sp->beacon[c].x - p.xpos;
+       xdiff = sp->beacon[(int)c].x - p.xpos;
        xdiff = SGN(xdiff);
-       ydiff = sp->beacon[c].y - p.ypos;
+       ydiff = sp->beacon[(int)c].y - p.ypos;
        ydiff = SGN(ydiff);
        if (xdiff != displacement[p.dir].dx || ydiff != displacement[p.dir].dy)
                return ("Beacon is not in flight path");
@@ -471,16 +456,16 @@ delayb(c)
        if (dest_type != T_NODEST) {
                switch (dest_type) {
                case T_BEACON:
-                       xdiff = sp->beacon[dest_no].x - sp->beacon[c].x;
-                       ydiff = sp->beacon[dest_no].y - sp->beacon[c].y;
+                       xdiff = sp->beacon[dest_no].x - sp->beacon[(int)c].x;
+                       ydiff = sp->beacon[dest_no].y - sp->beacon[(int)c].y;
                        break;
                case T_EXIT:
-                       xdiff = sp->exit[dest_no].x - sp->beacon[c].x;
-                       ydiff = sp->exit[dest_no].y - sp->beacon[c].y;
+                       xdiff = sp->exit[dest_no].x - sp->beacon[(int)c].x;
+                       ydiff = sp->exit[dest_no].y - sp->beacon[(int)c].y;
                        break;
                case T_AIRPORT:
-                       xdiff = sp->airport[dest_no].x - sp->beacon[c].x;
-                       ydiff = sp->airport[dest_no].y - sp->beacon[c].y;
+                       xdiff = sp->airport[dest_no].x - sp->beacon[(int)c].x;
+                       ydiff = sp->airport[dest_no].y - sp->beacon[(int)c].y;
                        break;
                default:
                        return ("Bad case in delayb!  Get help!");
@@ -580,20 +565,20 @@ benum(c)
        case T_BEACON:
                if (c >= sp->num_beacons)
                        return ("Unknown beacon");
-               p.new_dir = DIR_FROM_DXDY(sp->beacon[c].x - p.xpos,
-                       sp->beacon[c].y - p.ypos);
+               p.new_dir = DIR_FROM_DXDY(sp->beacon[(int)c].x - p.xpos,
+                       sp->beacon[(int)c].y - p.ypos);
                break;
        case T_EXIT:
                if (c >= sp->num_exits)
                        return ("Unknown exit");
-               p.new_dir = DIR_FROM_DXDY(sp->exit[c].x - p.xpos,
-                       sp->exit[c].y - p.ypos);
+               p.new_dir = DIR_FROM_DXDY(sp->exit[(int)c].x - p.xpos,
+                       sp->exit[(int)c].y - p.ypos);
                break;
        case T_AIRPORT:
                if (c >= sp->num_airports)
                        return ("Unknown airport");
-               p.new_dir = DIR_FROM_DXDY(sp->airport[c].x - p.xpos,
-                       sp->airport[c].y - p.ypos);
+               p.new_dir = DIR_FROM_DXDY(sp->airport[(int)c].x - p.xpos,
+                       sp->airport[(int)c].y - p.ypos);
                break;
        default:
                return ("Unknown case in benum!  Get help!");