Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/atc Make the list of place types an enumeration. Use u...



details:   https://anonhg.NetBSD.org/src/rev/325af3e52445
branches:  trunk
changeset: 327983:325af3e52445
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Mar 22 22:58:56 2014 +0000

description:
Make the list of place types an enumeration. Use unsigned values for
place numbers.

diffstat:

 games/atc/def.h    |   7 +------
 games/atc/extern.h |   4 ++--
 games/atc/input.c  |   7 ++++---
 games/atc/main.c   |   6 +++---
 games/atc/struct.h |  17 ++++++++++++-----
 games/atc/update.c |  18 ++++++++----------
 6 files changed, 30 insertions(+), 29 deletions(-)

diffs (205 lines):

diff -r 5a5848ba4553 -r 325af3e52445 games/atc/def.h
--- a/games/atc/def.h   Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/def.h   Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: def.h,v 1.6 2003/08/07 09:36:53 agc Exp $      */
+/*     $NetBSD: def.h,v 1.7 2014/03/22 22:58:56 dholland Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -65,11 +65,6 @@
 #define D_UP           3
 #define D_DOWN         4
 
-#define T_NODEST       0
-#define T_BEACON       1
-#define T_EXIT         2
-#define T_AIRPORT      3
-
 #undef S_NONE
 #undef S_GONE
 #undef S_MARKED
diff -r 5a5848ba4553 -r 325af3e52445 games/atc/extern.h
--- a/games/atc/extern.h        Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/extern.h        Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.16 2009/08/12 04:48:03 dholland Exp $     */
+/*     $NetBSD: extern.h,v 1.17 2014/03/22 22:58:56 dholland Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -61,7 +61,7 @@
 
 extern DISPLACEMENT    displacement[MAXDIR];
 
-int            addplane(void);
+void           addplane(void);
 void           append(LIST *, PLANE *);
 void           check_adir(int, int, int);
 void           delete(LIST *, PLANE *);
diff -r 5a5848ba4553 -r 325af3e52445 games/atc/input.c
--- a/games/atc/input.c Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/input.c Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: input.c,v 1.27 2014/03/22 22:47:07 dholland Exp $      */
+/*     $NetBSD: input.c,v 1.28 2014/03/22 22:58:56 dholland Exp $      */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: input.c,v 1.27 2014/03/22 22:47:07 dholland Exp $");
+__RCSID("$NetBSD: input.c,v 1.28 2014/03/22 22:58:56 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -199,7 +199,8 @@
 static STACK stack[MAXDEPTH];
 static int level;
 static int tval;
-static int dest_type, dir;
+static int dir;
+static enum places dest_type;
 static unsigned dest_no;
 
 static int
diff -r 5a5848ba4553 -r 325af3e52445 games/atc/main.c
--- a/games/atc/main.c  Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/main.c  Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.21 2012/10/12 10:44:20 dholland Exp $       */
+/*     $NetBSD: main.c,v 1.22 2014/03/22 22:58:56 dholland Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -51,7 +51,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: main.c,v 1.21 2012/10/12 10:44:20 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.22 2014/03/22 22:58:56 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -144,7 +144,7 @@
        init_gr();
        setup_screen(sp);
 
-       (void)addplane();
+       addplane();
 
        (void)signal(SIGINT, quit);
        (void)signal(SIGQUIT, quit);
diff -r 5a5848ba4553 -r 325af3e52445 games/atc/struct.h
--- a/games/atc/struct.h        Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/struct.h        Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: struct.h,v 1.9 2014/03/22 22:45:05 dholland Exp $      */
+/*     $NetBSD: struct.h,v 1.10 2014/03/22 22:58:56 dholland Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -72,15 +72,22 @@
        AIRPORT *airport;
 } C_SCREEN;
 
+enum places {
+       T_NODEST = 0,
+       T_BEACON = 1,
+       T_EXIT = 2,
+       T_AIRPORT = 3
+};
+
 typedef struct plane {
        struct plane    *next, *prev;
        int             status;
        int             plane_no;
        int             plane_type;
-       int             orig_no;
-       int             orig_type;
-       int             dest_no;
-       int             dest_type;
+       unsigned orig_no;
+       enum places orig_type;
+       unsigned dest_no;
+       enum places dest_type;
        int             altitude;
        int             new_altitude;
        int             dir;
diff -r 5a5848ba4553 -r 325af3e52445 games/atc/update.c
--- a/games/atc/update.c        Sat Mar 22 22:47:07 2014 +0000
+++ b/games/atc/update.c        Sat Mar 22 22:58:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: update.c,v 1.24 2014/03/22 22:45:05 dholland Exp $     */
+/*     $NetBSD: update.c,v 1.25 2014/03/22 22:58:56 dholland Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)update.c   8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: update.c,v 1.24 2014/03/22 22:45:05 dholland Exp $");
+__RCSID("$NetBSD: update.c,v 1.25 2014/03/22 22:58:56 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -217,7 +217,7 @@
         * we don't update props on odd updates.
         */
        if ((rand() % sp->newplane_time) == 0)
-               (void)addplane();
+               addplane();
 
 #ifdef SYSV
        alarm(sp->update_secs);
@@ -233,14 +233,14 @@
        buf[0] = '\0';
        bp = buf;
        bpsize = sizeof(buf);
-       (void)snprintf(bp, bpsize, "%c%d%c%c%d: ", name(pp), pp->altitude, 
+       (void)snprintf(bp, bpsize, "%c%d%c%c%u: ", name(pp), pp->altitude, 
                (pp->fuel < LOWFUEL) ? '*' : ' ',
                (pp->dest_type == T_AIRPORT) ? 'A' : 'E', pp->dest_no);
 
        comm_start = bp = strchr(buf, '\0');
        bpsize = buf + sizeof(buf) - bp;
        if (pp->altitude == 0)
-               (void)snprintf(bp, bpsize, "Holding @ A%d", pp->orig_no);
+               (void)snprintf(bp, bpsize, "Holding @ A%u", pp->orig_no);
        else if (pp->new_dir >= MAXDIR || pp->new_dir < 0)
                (void)snprintf(bp, bpsize, "Circle");
        else if (pp->new_dir != pp->dir)
@@ -308,7 +308,7 @@
        return (last_plane);
 }
 
-int
+void
 addplane(void)
 {
        PLANE   p, *pp, *p1;
@@ -363,10 +363,10 @@
                break;
        }
        if (i >= num_starts)
-               return (-1);
+               return;
        pnum = next_plane();
        if (pnum < 0)
-               return (-1);
+               return;
        p.plane_no = pnum;
 
        pp = newplane();
@@ -378,8 +378,6 @@
                append(&ground, pp);
        else
                append(&air, pp);
-
-       return (pp->dest_type);
 }
 
 PLANE *



Home | Main Index | Thread Index | Old Index