-/* $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
#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
#define MAXDEPTH 15
#define RETTOKEN '\n'
-#ifdef SYSV
-#define CRTOKEN '\r'
-#endif
#define REDRAWTOKEN '\014' /* CTRL(L) */
#define SHELLTOKEN '!'
#define HELPTOKEN '?'
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 },
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 }},
{ '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 }},
{
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);
}
char c;
{
p.new_dir = p.dir + 2;
- if (p.new_dir > MAXDIR)
+ if (p.new_dir >= MAXDIR)
p.new_dir -= MAXDIR;
return (NULL);
}
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");
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!");
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!");