diff options
author | rodri <rgl@antares-labs.eu> | 2023-02-23 16:31:16 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-02-23 16:31:16 +0000 |
commit | 5052a27ece26976e3bec769896bbdc65d9e5ede2 (patch) | |
tree | 173b7afa030d48c22186dee89eb26bb83b84e5b4 /muswd.c | |
parent | d40305baf8a0722cf6128520a5b792fc173c5a93 (diff) | |
download | musw-5052a27ece26976e3bec769896bbdc65d9e5ede2.tar.gz musw-5052a27ece26976e3bec769896bbdc65d9e5ede2.tar.bz2 musw-5052a27ece26976e3bec769896bbdc65d9e5ede2.zip |
(inefficiently) send bullets state and paint them.
Diffstat (limited to 'muswd.c')
-rw-r--r-- | muswd.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -271,7 +271,8 @@ threadnetsend(void *arg) void broadcaststate(void) { - int i; + int i, j, k; + uchar *bufp; Frame *frame; NetConn *pnc; Party *p; @@ -280,11 +281,20 @@ broadcaststate(void) for(i = 0; i < nelem(p->players); i++){ pnc = p->players[i]->conn; - frame = newframe(&pnc->udp, NSsimstate, pnc->lastseq+1, 0, 2*(3*8+8)+3*8, nil); - pack(frame->data, frame->len, "PdPdP", + frame = newframe(&pnc->udp, NSsimstate, pnc->lastseq+1, 0, 2*(3*8+8)+3*8+20*(3*8+8), nil); + + bufp = frame->data; + bufp += pack(bufp, frame->len, "PdPdP", p->u->ships[0].p, p->u->ships[0].θ, p->u->ships[1].p, p->u->ships[1].θ, p->u->star.p); + + /* TODO: only send the fired ones */ + for(j = 0; j < nelem(p->u->ships); j++) + for(k = 0; k < nelem(p->u->ships[j].rounds); k++) + bufp += pack(bufp, frame->len - (bufp-frame->data), "Pd", + p->u->ships[j].rounds[k].p, p->u->ships[j].rounds[k].θ); + signframe(frame, pnc->dh.priv); sendp(egress, frame); @@ -488,5 +498,5 @@ threadmain(int argc, char *argv[]) threadcreate(threadnetppu, nil, mainstacksize); threadcreate(threadnetsend, &adfd, mainstacksize); threadcreate(threadsim, nil, mainstacksize); - threadexits(nil); + yield(); } |