ref: fcc06b383c3490d105b527849dcf0b9d7af8481f
parent: 826fce49c5319d0965c603dc950623cc07996376
author: rodri <rgl@antares-labs.eu>
date: Mon Apr 24 21:40:32 EDT 2023
bullets aren't fired unless the server says otherwise. also don't draw bullets that weren't fired.
--- a/musw.c
+++ b/musw.c
@@ -166,6 +166,9 @@
Point2 v;
for(i = 0; i < nelem(ship->rounds); i++){
+ if(!ship->rounds[i].fired)
+ continue;
+
b = &ship->rounds[i];
v = Vec2(-1,0); /* it's pointing backwards to paint the tail */
Matrix R = {
@@ -391,13 +394,18 @@
fprint(2, "nfired0 %d nfired1 %d\n", nfired[0], nfired[1]);
for(i = 0; i < nelem(universe->ships); i++)
+ for(j = 0; j < nelem(universe->ships[i].rounds); j++)
+ universe->ships[i].rounds[j].fired = 0;
+
+ 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);
+ fprint(2, "si %d bi %d\n", i, bi);
bufp += unpack(bufp, frame->len - (bufp-frame->data), "Pd",
&universe->ships[i].rounds[bi].p, &universe->ships[i].rounds[bi].θ);
+ universe->ships[i].rounds[bi].fired++;
}
break;
case NSnudge:
--- a/muswd.c
+++ b/muswd.c
@@ -106,7 +106,7 @@
f = newframe(&(*ncp)->udp, NSnudge, (*ncp)->lastseq+1, 0, 0, nil);
signframe(f, (*ncp)->dh.priv);
sendp(egress, f);
-
+
(*ncp)->lastnudgets = curts;
}
break;
--- a/todo
+++ b/todo
@@ -14,6 +14,7 @@
[✓] main game
[ ] reduce the amount of data sent on every NSsimstate packet
[✓] only send the fired bullets
+ [ ] bit packing
[?] the client must try to connect continously
> there's an error in the udp stack that doesn't allow the client to receive packets if run before the server is up.
[ ] more realistic DEC Type 30 CRT emulation