]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - hunt/huntd/driver.c
avoid unnecessary floating point ops
[bsdgames-darwin.git] / hunt / huntd / driver.c
index f1d79297e066c8a7640a6eb7a0a129a7e9ded316..ff5411d9f393355000d05a9b198308e434f288a5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: driver.c,v 1.17 2009/07/04 04:29:54 dholland Exp $     */
+/*     $NetBSD: driver.c,v 1.22 2013/10/19 17:23:08 christos Exp $     */
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
  * All rights reserved.
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: driver.c,v 1.17 2009/07/04 04:29:54 dholland Exp $");
+__RCSID("$NetBSD: driver.c,v 1.22 2013/10/19 17:23:08 christos Exp $");
 #endif /* not lint */
 
 #include <sys/ioctl.h>
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -51,19 +51,19 @@ __RCSID("$NetBSD: driver.c,v 1.17 2009/07/04 04:29:54 dholland Exp $");
 #define RN     ((Seed = Seed * 11109 + 13849) & 0x7fff)
 #endif
 
 #define RN     ((Seed = Seed * 11109 + 13849) & 0x7fff)
 #endif
 
-int Seed = 0;
+static int Seed = 0;
 
 
 
 
-SOCKET Daemon;
-char *First_arg;               /* pointer to argv[0] */
-char *Last_arg;                        /* pointer to end of argv/environ */
+static SOCKET Daemon;
+static char *First_arg;                        /* pointer to argv[0] */
+static char *Last_arg;                 /* pointer to end of argv/environ */
 
 #ifdef INTERNET
 
 #ifdef INTERNET
-int Test_socket;               /* test socket to answer datagrams */
-FLAG inetd_spawned;            /* invoked via inetd */
-FLAG standard_port = TRUE;     /* true if listening on standard port */
-u_short        sock_port;              /* port # of tcp listen socket */
-u_short        stat_port;              /* port # of statistics tcp socket */
+static int Test_socket;                        /* test socket to answer datagrams */
+static FLAG inetd_spawned;             /* invoked via inetd */
+static FLAG standard_port = TRUE;      /* true if listening on standard port */
+static u_short sock_port;              /* port # of tcp listen socket */
+static u_short stat_port;              /* port # of statistics tcp socket */
 #define DAEMON_SIZE    (sizeof Daemon)
 #else
 #define DAEMON_SIZE    (sizeof Daemon - 1)
 #define DAEMON_SIZE    (sizeof Daemon)
 #else
 #define DAEMON_SIZE    (sizeof Daemon - 1)
@@ -88,7 +88,7 @@ main(int ac, char **av, char **ep)
        PLAYER *pp;
 #ifdef INTERNET
        u_short msg;
        PLAYER *pp;
 #ifdef INTERNET
        u_short msg;
-       short port_num, reply;
+       short reply;
        socklen_t namelen;
        SOCKET test;
 #endif
        socklen_t namelen;
        SOCKET test;
 #endif
@@ -143,7 +143,6 @@ again:
 #ifdef INTERNET
                if (fdset[2].revents & POLLIN) {
                        namelen = DAEMON_SIZE;
 #ifdef INTERNET
                if (fdset[2].revents & POLLIN) {
                        namelen = DAEMON_SIZE;
-                       port_num = htons(sock_port);
                        (void) recvfrom(Test_socket, &msg, sizeof msg,
                                0, (struct sockaddr *) &test, &namelen);
                        switch (ntohs(msg)) {
                        (void) recvfrom(Test_socket, &msg, sizeof msg,
                                0, (struct sockaddr *) &test, &namelen);
                        switch (ntohs(msg)) {
@@ -279,12 +278,7 @@ init(void)
        (void) signal(SIGPIPE, SIG_IGN);
 
 #ifdef LOG
        (void) signal(SIGPIPE, SIG_IGN);
 
 #ifdef LOG
-#ifdef SYSLOG_43
        openlog("huntd", LOG_PID, LOG_DAEMON);
        openlog("huntd", LOG_PID, LOG_DAEMON);
-#endif
-#ifdef SYSLOG_42
-       openlog("huntd", LOG_PID);
-#endif
 #endif
 
        /*
 #endif
 
        /*
@@ -417,7 +411,7 @@ init(void)
        fdset[2].fd = -1;
 #endif
 
        fdset[2].fd = -1;
 #endif
 
-       Seed = getpid() + time((time_t *) NULL);
+       Seed = getpid() + time(NULL);
        makemaze();
 #ifdef BOOTS
        makeboots();
        makemaze();
 #ifdef BOOTS
        makeboots();
@@ -604,7 +598,6 @@ zap(PLAYER *pp, FLAG was_player, int i)
        BULLET *bp;
        PLAYER *np;
        int x, y;
        BULLET *bp;
        PLAYER *np;
        int x, y;
-       int savefd;
 
        if (was_player) {
                if (pp->p_undershot)
 
        if (was_player) {
                if (pp->p_undershot)
@@ -627,8 +620,6 @@ zap(PLAYER *pp, FLAG was_player, int i)
        outstr(pp, pp->p_death, len);
        cgoto(pp, HEIGHT, 0);
 
        outstr(pp, pp->p_death, len);
        cgoto(pp, HEIGHT, 0);
 
-       savefd = pp->p_fd;
-
 #ifdef MONITOR
        if (was_player) {
 #endif
 #ifdef MONITOR
        if (was_player) {
 #endif
@@ -667,7 +658,7 @@ zap(PLAYER *pp, FLAG was_player, int i)
                }
                if (x > 0) {
                        (void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x,
                }
                if (x > 0) {
                        (void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x,
-                               (PLAYER *) NULL, TRUE, SPACE);
+                               NULL, TRUE, SPACE);
                        (void) snprintf(Buf, sizeof(Buf), "%s detonated.",
                                pp->p_ident->i_name);
                        for (np = Player; np < End_player; np++)
                        (void) snprintf(Buf, sizeof(Buf), "%s detonated.",
                                pp->p_ident->i_name);
                        for (np = Player; np < End_player; np++)
@@ -715,7 +706,7 @@ zap(PLAYER *pp, FLAG was_player, int i)
                                y = rand_num(HEIGHT / 2) + HEIGHT / 4;
                        } while (Maze[y][x] != SPACE);
                        (void) add_shot(LAVA, y, x, LEFTS, volcano,
                                y = rand_num(HEIGHT / 2) + HEIGHT / 4;
                        } while (Maze[y][x] != SPACE);
                        (void) add_shot(LAVA, y, x, LEFTS, volcano,
-                               (PLAYER *) NULL, TRUE, SPACE);
+                               NULL, TRUE, SPACE);
                        for (np = Player; np < End_player; np++)
                                message(np, "Volcano eruption.");
                        volcano = 0;
                        for (np = Player; np < End_player; np++)
                                message(np, "Volcano eruption.");
                        volcano = 0;
@@ -731,7 +722,7 @@ zap(PLAYER *pp, FLAG was_player, int i)
                        add_shot(DSHOT, y, x, rand_dir(),
                                shot_req[MINDSHOT +
                                rand_num(MAXBOMB - MINDSHOT)],
                        add_shot(DSHOT, y, x, rand_dir(),
                                shot_req[MINDSHOT +
                                rand_num(MAXBOMB - MINDSHOT)],
-                               (PLAYER *) NULL, FALSE, SPACE);
+                               NULL, FALSE, SPACE);
                }
 #endif
 
                }
 #endif
 
@@ -852,7 +843,7 @@ check_again:
  * cleanup:
  *     Exit with the given value, cleaning up any droppings lying around
  */
  * cleanup:
  *     Exit with the given value, cleaning up any droppings lying around
  */
-SIGNAL_TYPE
+void
 cleanup(int eval)
 {
        PLAYER *pp;
 cleanup(int eval)
 {
        PLAYER *pp;