From bdaa63a1a4604ada3539aeb50e4af144da3ba6f0 Mon Sep 17 00:00:00 2001 From: rodri Date: Sun, 25 Jul 2021 20:59:58 +0000 Subject: implemented parties to hold PvP match info. started serializing game state through the wire. made some major changes to the Lobby struct, plus the ability to check the health of every connection. added some more debug statements, did some cleanup and put more checks. --- musw.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'musw.c') diff --git a/musw.c b/musw.c index a88f0fc..1b40264 100644 --- a/musw.c +++ b/musw.c @@ -4,19 +4,26 @@ #include "dat.h" #include "fns.h" +int debug; + + void threadnetin(void *arg) { - char buf[256]; + uchar buf[256]; int fd, n; + double x, v; Ioproc *io; fd = *((int*)arg); io = ioproc(); - while((n = ioread(io, fd, buf, sizeof buf)) > 0) + while((n = ioread(io, fd, buf, sizeof buf)) > 0){ + unpack(buf, n, "dd", &x, &v); + n = snprint((char *)buf, sizeof buf, "state: x=%g v=%g\n", x, v); if(iowrite(io, 1, buf, n) != n) - fprint(2, "netin iowrite: %r\n"); + fprint(2, "iowrite: %r\n"); + } closeioproc(io); } @@ -32,7 +39,7 @@ threadnetout(void *arg) while((n = ioread(io, 0, buf, sizeof buf)) > 0) if(iowrite(io, fd, buf, n) != n) - fprint(2, "netout iowrite: %r\n"); + fprint(2, "iowrite: %r\n"); closeioproc(io); } @@ -50,6 +57,9 @@ threadmain(int argc, char *argv[]) int fd; ARGBEGIN{ + case 'd': + debug++; + break; default: usage(); }ARGEND; -- cgit v1.2.3