aboutsummaryrefslogtreecommitdiff
path: root/musw.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-07-25 20:59:58 +0000
committerrodri <rgl@antares-labs.eu>2021-07-25 20:59:58 +0000
commitbdaa63a1a4604ada3539aeb50e4af144da3ba6f0 (patch)
tree6aa3d68f94d7756d45f78cce10af1796bdb744d2 /musw.c
parentf54a8666413d80db3bda3de6e17f795faf7790eb (diff)
downloadmusw-bdaa63a1a4604ada3539aeb50e4af144da3ba6f0.tar.gz
musw-bdaa63a1a4604ada3539aeb50e4af144da3ba6f0.tar.bz2
musw-bdaa63a1a4604ada3539aeb50e4af144da3ba6f0.zip
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.
Diffstat (limited to 'musw.c')
-rw-r--r--musw.c18
1 files changed, 14 insertions, 4 deletions
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;