ref: 1baca76aaf266a2d071af4a173aee5b85efeffd6
parent: d2c0ab7a62b7a2c99c4c491ce55466859429571b
author: rodri <rgl@antares-labs.eu>
date: Sun May 14 11:54:05 EDT 2023
cleanup and comment improvements.
--- a/dat.h
+++ b/dat.h
@@ -32,18 +32,18 @@
NShi, /* S accepts. sends P and G for DHX */
NCdhx = 12, /* C shares pubkey */
NSdhx, /* S shares pubkey */
- NCnudge = 16, /* nudge ACK */
- NSnudge, /* check the pulse of the line */
+ NCnudge = 16, /* C ACKs nudge */
+ NSnudge, /* S checks the pulse of the line */
NCinput = 20, /* C sends player input state */
NSsimstate, /* S sends current simulation state */
- NCawol = 22, /* AWOL ACK */
- NSawol, /* notify the adversary flew away */
+ NCawol = 22, /* C ACKs AWOL */
+ NSawol, /* S notifies the adversary flew away */
- NCbuhbye = 30,
- NSbuhbye,
+ NCbuhbye = 30, /* C quits gracefully */
+ NSbuhbye, /* S kicks the player out */
- NSerror = 66 /* report an error */
+ NSerror = 66 /* S reports an error */
};
enum {
--- a/musw.c
+++ b/musw.c
@@ -737,7 +737,11 @@
frametime = now - then;
then = now;
- if(gamestate != &gamestates[GSIntro]){
+ switch(gamestate-gamestates){
+ case GSPlaying:
+ universe->star.spr->step(universe->star.spr, frametime/1e6);
+ /* fallthrough */
+ default:
if(netconn.state == NCSConnecting)
lastpktsent += frametime/1e6;
@@ -746,11 +750,12 @@
initconn();
lastpktsent = 0;
}
+ break;
+ case GSIntro:
+ intro->step(intro, frametime/1e6);
+ break;
}
-
gamestate = gamestate->δ(gamestate, &frametime);
- universe->star.spr->step(universe->star.spr, frametime/1e6);
- intro->step(intro, frametime/1e6);
redraw();
--- a/muswd.c
+++ b/muswd.c
@@ -67,9 +67,9 @@
signframe(f, adv->conn->dh.priv);
sendp(egress, f);
- return;
+ goto kickplayer;
}
-
+kickplayer:
/*
* make sure to free the player even if there's no
* party going on.
--- a/todo
+++ b/todo
@@ -1,7 +1,7 @@
[ ] collision detection
[✓] toroidal warping
[✓] respect bullets's ttl
- [ ] communicate this event to the clients
+ [✓] communicate this event to the clients (δ: fired 1 → 0)
[ ] explode when the time comes
[ ] fuel consumption
[ ] hyperjump
--- a/universe.c
+++ b/universe.c
@@ -95,7 +95,7 @@
p->p.y = r.min.y;
}
-/* collision resolution */
+/* collision detection and resolution */
static void
universe_collide(Universe *u)
{