diff options
author | rodri <rgl@antares-labs.eu> | 2023-06-05 21:21:56 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-06-05 21:21:56 +0000 |
commit | 650a361f5a04e4fc39ade90459d280d227875cb1 (patch) | |
tree | 2d97defc243ce642522acd6a2f388574e1d66e24 /muswd.c | |
parent | 9c20abc1ab976cab00040a32299896dc8ea71e6c (diff) | |
download | musw-650a361f5a04e4fc39ade90459d280d227875cb1.tar.gz musw-650a361f5a04e4fc39ade90459d280d227875cb1.tar.bz2 musw-650a361f5a04e4fc39ade90459d280d227875cb1.zip |
use a queue for player input to dampen race conditions between the netcode and the sims.
Diffstat (limited to 'muswd.c')
-rw-r--r-- | muswd.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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); |