aboutsummaryrefslogtreecommitdiff
path: root/muswd.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-02-23 16:31:16 +0000
committerrodri <rgl@antares-labs.eu>2023-02-23 16:31:16 +0000
commit5052a27ece26976e3bec769896bbdc65d9e5ede2 (patch)
tree173b7afa030d48c22186dee89eb26bb83b84e5b4 /muswd.c
parentd40305baf8a0722cf6128520a5b792fc173c5a93 (diff)
downloadmusw-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.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/muswd.c b/muswd.c
index cd268ca..ccaae27 100644
--- a/muswd.c
+++ b/muswd.c
@@ -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();
}