- Log connections/disconnections with address and fd/id
authorMatthew Mondor <mmondor@pulsar-zone.net>
Sun, 22 Jun 2014 10:24:30 +0000 (10:24 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Sun, 22 Jun 2014 10:24:30 +0000 (10:24 +0000)
- Position entering ships randomly (should ideally make sure not to place
  it over another ship)

mmsoftware/mystic_ships/server/src/client.c
mmsoftware/mystic_ships/server/src/kqueue.c
mmsoftware/mystic_ships/server/src/ships.c

index cabf623..ed87534 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.4 2014/06/19 19:53:34 mmondor Exp $ */
+/* $Id: client.c,v 1.5 2014/06/22 10:24:29 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <arpa/inet.h>
 
 #include <client.h>
 #include <kqueue.h>
@@ -147,6 +148,10 @@ client_destroy_marked(void)
                if (c->ship.torps > 0)
                        continue;
 
+               syslog(LOG_NOTICE, "Disconnect [%s], id %d",
+                   inet_ntoa(((struct sockaddr_in *)(&c->saddr))->sin_addr),
+                   c->fd);
+
                /* Closing descriptor automatically deletes its kevents */
                (void) close(c->fd);
 
index deec56c..0ea9d70 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kqueue.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
+/* $Id: kqueue.c,v 1.3 2014/06/22 10:24:29 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -21,6 +21,7 @@
 #include <packets_common.h>
 #include <packets.h>
 #include <net.h>
+#include <arpa/inet.h>
 #include <conf.h>
 
 
@@ -183,6 +184,10 @@ kqueue_main(void)
                                            &saddrl)) == -1)
                                                continue;
 
+                                       syslog(LOG_NOTICE,
+                                           "Connection from [%s], id %d",
+                                           inet_ntoa(((struct sockaddr_in *)
+                                           &saddr)->sin_addr), fd);
                                        if ((c = client_create(fd, &saddr))
                                            == NULL) {
                                                (void) close(fd);
index ac33956..ff8e3ba 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ships.c,v 1.2 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: ships.c,v 1.3 2014/06/22 10:24:30 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -104,13 +104,12 @@ ship_init(ship_t *s, int type)
 
        /* XXX Random position/angle for now */
        s->angle = s->i_angle = (random() % 255);
+       s->x = d->radius + (random() % (int)(WORLD_X_MAX - (d->radius * 2) - 1));
+       s->y = d->radius + (random() % (int)(WORLD_Y_MAX - (d->radius * 2) - 1));
        /*
-       s->x = d->radius + (random() % (WORLD_X_MAX - (d->radius * 2) - 1));
-       s->y = d->radius + (random() % (WORLD_Y_MAX - (d->radius * 2) - 1));
-       XXX
-       */
        s->x = WORLD_X_MAX / 2;
        s->y = WORLD_Y_MAX / 2;
+       */
 }
 
 void