aboutsummaryrefslogtreecommitdiff
path: root/musw.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-04-23 14:33:14 +0000
committerrodri <rgl@antares-labs.eu>2023-04-23 14:33:14 +0000
commit826fce49c5319d0965c603dc950623cc07996376 (patch)
treeb32f1a46ce48c8d6007586bb263be0d75d6052eb /musw.c
parent00f7d8dd3dc47ed3cfa951325e809a92c37341b7 (diff)
downloadmusw-826fce49c5319d0965c603dc950623cc07996376.tar.gz
musw-826fce49c5319d0965c603dc950623cc07996376.tar.bz2
musw-826fce49c5319d0965c603dc950623cc07996376.zip
only send/recv the fired bullets on simstate packets.
Diffstat (limited to 'musw.c')
-rw-r--r--musw.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/musw.c b/musw.c
index 75dea1a..8d428c0 100644
--- a/musw.c
+++ b/musw.c
@@ -327,6 +327,7 @@ void
threadnetppu(void *)
{
int i, j;
+ int nfired[2], bi;
uchar *bufp;
Frame *frame, *newf;
@@ -384,11 +385,20 @@ threadnetppu(void *)
&universe->ships[1].p, &universe->ships[1].θ,
&universe->star.p);
- /* TODO: only recv the fired ones */
- for(i = 0; i < nelem(universe->ships); i++)
- for(j = 0; j < nelem(universe->ships[i].rounds); j++)
- bufp += unpack(bufp, frame->len - (bufp-frame->data), "Pd",
- &universe->ships[i].rounds[j].p, &universe->ships[i].rounds[j].θ);
+ bufp += unpack(bufp, frame->len - (bufp-frame->data), "bb", &nfired[0], &nfired[1]);
+
+ if(debug)
+ fprint(2, "nfired0 %d nfired1 %d\n", nfired[0], nfired[1]);
+
+ for(i = 0; i < nelem(universe->ships); i++)
+ for(j = 0; j < nfired[i]; j++){
+ bufp += unpack(bufp, frame->len - (bufp-frame->data), "b",
+ &bi);
+ if(debug)
+ fprint(2, "bi %d\n", bi);
+ bufp += unpack(bufp, frame->len - (bufp-frame->data), "Pd",
+ &universe->ships[i].rounds[bi].p, &universe->ships[i].rounds[bi].θ);
+ }
break;
case NSnudge:
newf = newframe(nil, NCnudge, frame->seq+1, frame->seq, 0, nil);