summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-11-07 03:53:00 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-11-07 03:53:00 +0000
commit5c3dba0a64f0fd0865f1c6550a3a97ad69439011 (patch)
treeb91d403d4236fe81f563d39d7b31c990a7b351a7 /games
parentc6f3d5ea7e9137fd7f62a5d6b79bb00f3c665b26 (diff)
make delayed turn commands not become immediate when there is a
request to go to the same altitude as already at. pr 3448
Diffstat (limited to 'games')
-rw-r--r--games/atc/input.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/games/atc/input.c b/games/atc/input.c
index b4a57e2219d..a188d17fc58 100644
--- a/games/atc/input.c
+++ b/games/atc/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.10 2004/11/29 08:52:28 jsg Exp $ */
+/* $OpenBSD: input.c,v 1.11 2006/11/07 03:52:59 deraadt Exp $ */
/* $NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $ */
/*-
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: input.c,v 1.10 2004/11/29 08:52:28 jsg Exp $";
+static char rcsid[] = "$OpenBSD: input.c,v 1.11 2006/11/07 03:52:59 deraadt Exp $";
#endif
#endif /* not lint */
@@ -462,6 +462,8 @@ setalt(char c)
{
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
return ("Already at that altitude");
+ if (p.new_altitude == c - '0')
+ return ("Already going to that altitude");
p.new_altitude = c - '0';
return (NULL);
}
@@ -469,24 +471,30 @@ setalt(char c)
const char *
setrelalt(char c)
{
+ int new_altitude;
+
if (c == 0)
return ("altitude not changed");
switch (dir) {
case D_UP:
- p.new_altitude = p.altitude + c - '0';
+ new_altitude = p.altitude + c - '0';
break;
case D_DOWN:
- p.new_altitude = p.altitude - (c - '0');
+ new_altitude = p.altitude - (c - '0');
break;
default:
return ("Unknown case in setrelalt! Get help!");
break;
}
- if (p.new_altitude < 0)
+ if (new_altitude < 0)
return ("Altitude would be too low");
- else if (p.new_altitude > 9)
+ else if (new_altitude > 9)
return ("Altitude would be too high");
+ else if (new_altitude == p.new_altitude)
+ return ("Already going to that altitude");
+
+ p.new_altitude = new_altitude;
return (NULL);
}