aboutsummaryrefslogtreecommitdiff
path: root/muswd.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-06-05 20:23:26 +0000
committerrodri <rgl@antares-labs.eu>2023-06-05 20:23:26 +0000
commit9c20abc1ab976cab00040a32299896dc8ea71e6c (patch)
tree5037406ea18c55dc0be2001c1d27e2d89edc16f7 /muswd.c
parent0625897dd0194986b02988eb5a9c2969e24adf0c (diff)
downloadmusw-9c20abc1ab976cab00040a32299896dc8ea71e6c.tar.gz
musw-9c20abc1ab976cab00040a32299896dc8ea71e6c.tar.bz2
musw-9c20abc1ab976cab00040a32299896dc8ea71e6c.zip
put the player routines in their own unit.
fixed an issue with the threadsim routine that would cause re-stepping of all the previous parties after dissolving one of them due to one of the players quitting.
Diffstat (limited to 'muswd.c')
-rw-r--r--muswd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/muswd.c b/muswd.c
index 4f871d8..1882e59 100644
--- a/muswd.c
+++ b/muswd.c
@@ -336,7 +336,7 @@ threadsim(void *)
uvlong then, now;
double frametime, Δt;
Ioproc *io;
- Party *p;
+ Party *p, *np;
Player *player;
Ship *ship;
@@ -352,8 +352,7 @@ threadsim(void *)
if(players.len >= 2)
newparty(&theparty, players.get(&players), players.get(&players));
-partywalk:
- for(p = theparty.next; p != &theparty; p = p->next){
+ for(p = theparty.next; p != &theparty; p = np){
p->u->timeacc += frametime/1e9;
for(i = 0; i < nelem(p->players); i++){
@@ -361,8 +360,9 @@ partywalk:
ship = &p->u->ships[i];
if((player->kdown & 1<<Kquit) != 0){
+ np = p->next;
popconn(player->conn);
- goto partywalk;
+ goto partydone;
}
if((player->kdown & 1<<K↑) != 0)
ship->forward(ship, Δt);
@@ -384,6 +384,8 @@ partywalk:
p->u->step(p->u, Δt);
p->u->collide(p->u);
}
+ np = p->next;
+partydone:;
}
broadcaststate();