Source-Changes-HG archive

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

[src/trunk]: src/games/hunt/hunt use fewer globals



details:   https://anonhg.NetBSD.org/src/rev/4128990441ac
branches:  trunk
changeset: 328280:4128990441ac
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Mar 30 03:35:26 2014 +0000

description:
use fewer globals

diffstat:

 games/hunt/hunt/hunt.c         |  20 +++++++++++++-------
 games/hunt/hunt/hunt_private.h |  13 +------------
 2 files changed, 14 insertions(+), 19 deletions(-)

diffs (97 lines):

diff -r 97d953e3244f -r 4128990441ac games/hunt/hunt/hunt.c
--- a/games/hunt/hunt/hunt.c    Sun Mar 30 03:26:19 2014 +0000
+++ b/games/hunt/hunt/hunt.c    Sun Mar 30 03:35:26 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hunt.c,v 1.49 2014/03/30 02:58:25 dholland Exp $       */
+/*     $NetBSD: hunt.c,v 1.50 2014/03/30 03:35:26 dholland Exp $       */
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: hunt.c,v 1.49 2014/03/30 02:58:25 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.50 2014/03/30 03:35:26 dholland Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -81,9 +81,7 @@
 #ifdef INTERNET
 char *Sock_host;
 static char *use_port;
-static bool Query_driver = false;
 char *Send_message = NULL;
-static bool Show_scores = false;
 #endif
 
 SOCKET Daemon;
@@ -124,6 +122,8 @@
        char *term;
        int c;
        long enter_status;
+       bool Query_driver = false;
+       bool Show_scores = false;
 
        enter_status = env_init((long) Q_CLOAK);
        while ((c = getopt(ac, av, "Sbcfh:l:mn:op:qst:w:")) != -1) {
@@ -217,7 +217,7 @@
 #ifdef INTERNET
        if (Show_scores) {
                SOCKET *hosts;
-               u_short msg = C_TESTMSG();
+               u_short msg = C_SCORES;
 
                for (hosts = list_drivers(msg); hosts->sin_port != 0; hosts += 1)
                        dump_scores(*hosts);
@@ -225,7 +225,7 @@
        }
        if (Query_driver) {
                SOCKET *hosts;
-               u_short msg = C_TESTMSG();
+               u_short msg = C_MESSAGE;
 
                for (hosts = list_drivers(msg); hosts->sin_port != 0; hosts += 1) {
                        struct hostent *hp;
@@ -351,7 +351,13 @@
 find_driver(bool do_startup)
 {
        SOCKET *hosts;
-       u_short msg = C_TESTMSG();
+       u_short msg = C_PLAYER;
+
+#ifdef MONITOR
+       if (Am_monitor) {
+               msg = C_MONITOR;
+       }
+#endif
 
        hosts = list_drivers(msg);
        if (hosts[0].sin_port != htons(0)) {
diff -r 97d953e3244f -r 4128990441ac games/hunt/hunt/hunt_private.h
--- a/games/hunt/hunt/hunt_private.h    Sun Mar 30 03:26:19 2014 +0000
+++ b/games/hunt/hunt/hunt_private.h    Sun Mar 30 03:35:26 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hunt_private.h,v 1.5 2014/03/30 02:58:25 dholland Exp $        */
+/*     $NetBSD: hunt_private.h,v 1.6 2014/03/30 03:35:26 dholland Exp $        */
 
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
@@ -43,17 +43,6 @@
 #include <sys/un.h>
 #endif
 
-#ifdef MONITOR
-#define C_TESTMSG()    (Query_driver ? C_MESSAGE :\
-                       (Show_scores ? C_SCORES :\
-                       (Am_monitor ? C_MONITOR :\
-                       C_PLAYER)))
-#else
-#define        C_TESTMSG()     (Show_scores ? C_SCORES :\
-                       (Query_driver ? C_MESSAGE :\
-                       C_PLAYER))
-#endif
-
 /*
  * external variables
  */



Home | Main Index | Thread Index | Old Index