diff options
-rw-r--r-- | dat.h | 1 | ||||
-rw-r--r-- | muswd.c | 6 | ||||
-rw-r--r-- | pack.c | 1 | ||||
-rw-r--r-- | party.c | 1 | ||||
-rw-r--r-- | physics.c | 1 | ||||
-rw-r--r-- | player.c | 3 | ||||
-rw-r--r-- | universe.c | 1 |
7 files changed, 13 insertions, 1 deletions
@@ -213,6 +213,7 @@ struct Player { char *name; NetConn *conn; + Channel *inputq; ulong oldkdown, kdown; Player *next; }; @@ -233,7 +233,7 @@ threadnetppu(void *) if(debug) fprint(2, "\t%.*lub\n", sizeof(kdown)*8, kdown); - nc->player->kdown = kdown; + nbsendul(nc->player->inputq, kdown); break; case NCbuhbye: @@ -333,6 +333,7 @@ void threadsim(void *) { int i; + ulong kdown; uvlong then, now; double frametime, Δt; Ioproc *io; @@ -359,6 +360,9 @@ threadsim(void *) player = p->players[i]; ship = &p->u->ships[i]; + if(nbrecv(player->inputq, &kdown) != 0) + player->kdown = kdown; + if((player->kdown & 1<<Kquit) != 0){ np = p->next; popconn(player->conn); @@ -3,6 +3,7 @@ #include <ip.h> #include <mp.h> #include <libsec.h> +#include <thread.h> #include <draw.h> #include <geometry.h> #include "dat.h" @@ -3,6 +3,7 @@ #include <ip.h> #include <mp.h> #include <libsec.h> +#include <thread.h> #include <draw.h> #include <geometry.h> #include "dat.h" @@ -3,6 +3,7 @@ #include <ip.h> #include <mp.h> #include <libsec.h> +#include <thread.h> #include <draw.h> #include <geometry.h> #include "dat.h" @@ -3,6 +3,7 @@ #include <ip.h> #include <mp.h> #include <libsec.h> +#include <thread.h> #include <draw.h> #include <geometry.h> #include "dat.h" @@ -16,6 +17,7 @@ newplayer(char *name, NetConn *nc) p = emalloc(sizeof(Player)); p->name = name? strdup(name): nil; p->conn = nc; + p->inputq = chancreate(sizeof(ulong), 20); p->oldkdown = p->kdown = 0; p->next = nil; @@ -26,6 +28,7 @@ void delplayer(Player *p) { free(p->name); + chanclose(p->inputq); free(p); } @@ -3,6 +3,7 @@ #include <ip.h> #include <mp.h> #include <libsec.h> +#include <thread.h> #include <draw.h> #include <geometry.h> #include "dat.h" |