diff options
author | rodri <rgl@antares-labs.eu> | 2023-06-05 20:23:26 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-06-05 20:23:26 +0000 |
commit | 9c20abc1ab976cab00040a32299896dc8ea71e6c (patch) | |
tree | 5037406ea18c55dc0be2001c1d27e2d89edc16f7 /muswd.c | |
parent | 0625897dd0194986b02988eb5a9c2969e24adf0c (diff) | |
download | musw-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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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(); |