- Debug symbols
authorMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 30 Jun 2014 18:45:31 +0000 (18:45 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 30 Jun 2014 18:45:31 +0000 (18:45 +0000)
- client_marked() instead of ad-hoc checks
- Update README

mmsoftware/mystic_ships/server/GNUmakefile
mmsoftware/mystic_ships/server/src/client.c
mmsoftware/mystic_ships/server/src/client.h
mmsoftware/mystic_ships/server/src/kqueue.c
mmsoftware/mystic_ships/server/src/packets.c
mmsoftware/mystic_ships/server/src/torp.c

index f52821d..86dfba8 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.3 2014/06/25 14:25:42 mmondor Exp $
+# $Id: GNUmakefile,v 1.4 2014/06/30 18:45:31 mmondor Exp $
 
 MMLIB_PATH := ../../mmlib
 
@@ -9,6 +9,7 @@ OBJS := $(addprefix src/,main.o trigonometry.o net.o kqueue.o sendq.o recvq.o \
        $(addprefix ../common/,hmac_sha1.o hmac_rmd160.o sha1.o rmd160.o \
        mmenc.o)
 CFLAGS += -Wall -g
+LDFLAGS += -g
 BINS := tms-server
 
 all: $(BINS)
@@ -18,7 +19,7 @@ all: $(BINS)
 
 
 tms-server: $(MMLIBS) $(LIBS) $(OBJS)
-       cc -o $@ $(MMLIBS) $(OBJS) $(LIBS)
+       cc -o $@ $(MMLIBS) $(OBJS) $(LIBS) $(CFLAGS) $(LDFLAGS)
 
 
 clean:
index 6307917..79602d1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.6 2014/06/25 12:53:14 mmondor Exp $ */
+/* $Id: client.c,v 1.7 2014/06/30 18:45:31 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -132,6 +132,13 @@ client_destroy_mark(client_t *c)
        DLIST_SWAP(&clients_gc_list, &clients_list, (node_t *)c, FALSE);
 }
 
+inline bool
+client_marked(client_t *c)
+{
+
+       return (c->todestroy || c->toclose);
+}
+
 void
 client_destroy_marked(void)
 {
index c13b869..4d3fbed 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: client.h,v 1.2 2007/12/05 23:47:57 mmondor Exp $ */
+/* $Id: client.h,v 1.3 2014/06/30 18:45:31 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -14,6 +14,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <time.h>
 
@@ -51,6 +52,7 @@ inline int    client_write(client_t *, uint8_t *, size_t, int);
 
 client_t       *client_create(int, struct sockaddr *);
 void           client_destroy_mark(client_t *);
+inline bool    client_marked(client_t *);
 void           client_destroy_marked(void);
 
 void           client_timeout(void);
index 0ea9d70..fd894a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kqueue.c,v 1.3 2014/06/22 10:24:29 mmondor Exp $ */
+/* $Id: kqueue.c,v 1.4 2014/06/30 18:45:31 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -222,7 +222,7 @@ kqueue_main(void)
                         * for this purpose.
                         */
                        if ((c = (client_t *)kev->udata) == NULL ||
-                           c->todestroy)
+                           client_marked(c))
                                continue;
 
                        if ((kev->flags & EV_EOF) != 0) {
index 83e181f..f561a51 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: packets.c,v 1.7 2014/06/26 03:46:37 mmondor Exp $ */
+/* $Id: packets.c,v 1.8 2014/06/30 18:45:31 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -104,13 +104,16 @@ packets_update(void)
        for (c = (client_t *)DLIST_TOP(&clients_list); c != NULL; c = next) {
                next = DLIST_NEXT((node_t *)c);
 
-               if (c->todestroy || c->toclose)
+               if (client_marked(c))
                        continue;
 
                /* Check for ship/ship collisions */
                for (c2 = (client_t *)DLIST_TOP(&clients_list); c2 != NULL;
                     c2 = next2) {
                        next2 = DLIST_NEXT((node_t *)c2);
+
+                       if (client_marked(c2))
+                               continue;
                        if (c2 != c) {
                                ship_t  *s1 = &c->ship, *s2 = &c2->ship;
                                int     x1 = s1->x, y1 = s1->y,
@@ -132,8 +135,6 @@ packets_update(void)
                                }
                        }
                }
-               if (c->todestroy)
-                       continue;
 
                /* Reset ping request throttling flag */
                c->askedping = 0;
index c08d8f1..6347363 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: torp.c,v 1.6 2014/06/30 03:37:35 mmondor Exp $ */
+/* $Id: torp.c,v 1.7 2014/06/30 18:45:31 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -112,7 +112,7 @@ torps_update(void)
                        ship_t  *s = &c->ship;
                        int     sx = s->x, sy = s->y, sr = s->ship->radius;
 
-                       if (c->todestroy || c->toclose)
+                       if (client_marked(c))
                                continue;
 
                        if (square_intersect(tx, ty, tr, sx, sy, sr) &&