aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-05-14 15:54:05 +0000
committerrodri <rgl@antares-labs.eu>2023-05-14 15:54:05 +0000
commit1baca76aaf266a2d071af4a173aee5b85efeffd6 (patch)
treec5bc3bffe0aa4076dbc053d10103f2125724e4f3
parentd2c0ab7a62b7a2c99c4c491ce55466859429571b (diff)
downloadmusw-1baca76aaf266a2d071af4a173aee5b85efeffd6.tar.gz
musw-1baca76aaf266a2d071af4a173aee5b85efeffd6.tar.bz2
musw-1baca76aaf266a2d071af4a173aee5b85efeffd6.zip
cleanup and comment improvements.
-rw-r--r--dat.h14
-rw-r--r--musw.c13
-rw-r--r--muswd.c4
-rw-r--r--todo2
-rw-r--r--universe.c2
5 files changed, 20 insertions, 15 deletions
diff --git a/dat.h b/dat.h
index 88f7a64..4c9e019 100644
--- a/dat.h
+++ b/dat.h
@@ -32,18 +32,18 @@ enum {
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 {
diff --git a/musw.c b/musw.c
index edd3826..836a56c 100644
--- a/musw.c
+++ b/musw.c
@@ -737,7 +737,11 @@ threadmain(int argc, char *argv[])
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 @@ threadmain(int argc, char *argv[])
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();
diff --git a/muswd.c b/muswd.c
index 472ce39..65c1af0 100644
--- a/muswd.c
+++ b/muswd.c
@@ -67,9 +67,9 @@ dissolveparty(Player *player)
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.
diff --git a/todo b/todo
index 06a3c45..093309a 100644
--- 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
diff --git a/universe.c b/universe.c
index 3984488..ceb3f1d 100644
--- a/universe.c
+++ b/universe.c
@@ -95,7 +95,7 @@ warp(Particle *p)
p->p.y = r.min.y;
}
-/* collision resolution */
+/* collision detection and resolution */
static void
universe_collide(Universe *u)
{