From 06f817044e7b2ec0bf63ed37a1cadd9f3818a787 Mon Sep 17 00:00:00 2001 From: rodri Date: Tue, 31 Jan 2023 23:46:58 +0000 Subject: use libgeometry from the system. got rid of global `theparty`. wrote a little man page draft. --- dat.h | 3 --- fns.h | 6 +++--- lobby.c | 2 +- mkfile | 10 ---------- musw.c | 2 +- musw.man | 28 ++++++++++++++++++++++++++++ muswd.c | 7 ++++--- pack.c | 2 +- party.c | 43 ++++++++++++++++++++----------------------- physics.c | 4 ++-- sprite.c | 2 +- universe.c | 2 +- vmodeled/main.c | 2 +- vmodeled/mkfile | 18 +----------------- 14 files changed, 64 insertions(+), 67 deletions(-) diff --git a/dat.h b/dat.h index 6525c3c..6ee16ec 100644 --- a/dat.h +++ b/dat.h @@ -166,6 +166,3 @@ struct Party Universe *u; Party *prev, *next; }; - - -extern Party theparty; diff --git a/fns.h b/fns.h index 565b52c..0620a2f 100644 --- a/fns.h +++ b/fns.h @@ -32,10 +32,10 @@ void dellobby(Lobby*); /* * party */ -void inittheparty(void); -Party *newparty(Player[2]); +Party *newparty(Party*, Player[2]); void delparty(Party*); -void addparty(Party*); +void addparty(Party*, Party*); +void initparty(Party*); /* * universe diff --git a/lobby.c b/lobby.c index d5f56f2..7ffa969 100644 --- a/lobby.c +++ b/lobby.c @@ -2,7 +2,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" diff --git a/mkfile b/mkfile index fb747b3..38115d0 100644 --- a/mkfile +++ b/mkfile @@ -20,18 +20,8 @@ HFILES=\ dat.h\ fns.h\ -LIB=\ - libgeometry/libgeometry.a$O\ - /dev/null - install:V: man uninstall:V: diff --git a/musw.c b/musw.c index 106a83a..accdd2c 100644 --- a/musw.c +++ b/musw.c @@ -6,7 +6,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" diff --git a/musw.man b/musw.man index e69de29..d344308 100644 --- a/musw.man +++ b/musw.man @@ -0,0 +1,28 @@ +.TH MUSW 1 +.SH NAME +musw, muswd \- multi-user spacewar! +.SH SYNOPSIS +.B games/musw +[ +.B -d +] +.I dialstring +.br +.B games/muswd +[ +.B -d +] +[ +.B -a +.I addr +] +.SH DESCRIPTION +.SH EXAMPLE +.SH SOURCE +.B /sys/src/games/musw +.SH SEE ALSO +https://www.masswerk.at/spacewar/ +.br +https://www.masswerk.at/spacewar/SpacewarOrigin.html +.SH BUGS +.SH HISTORY diff --git a/muswd.c b/muswd.c index ce69c8d..b84436a 100644 --- a/muswd.c +++ b/muswd.c @@ -3,13 +3,14 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" int debug; Lobby *lobby; +Party theparty; void @@ -89,7 +90,7 @@ threadsim(void *) lobby->purge(lobby); if(lobby->getcouple(lobby, couple) != -1){ - newparty(couple); + newparty(&theparty, couple); theparty.prev->u->reset(theparty.prev->u); } @@ -232,7 +233,7 @@ threadmain(int argc, char *argv[]) fprint(2, "listening on %s\n", addr); lobby = newlobby(); - inittheparty(); + initparty(&theparty); threadcreate(threadC2, nil, 4096); threadcreate(threadlisten, &adfd, 4096); diff --git a/pack.c b/pack.c index 85d71ac..3b61a66 100644 --- a/pack.c +++ b/pack.c @@ -2,7 +2,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" diff --git a/party.c b/party.c index cacf2e4..ad3cd9b 100644 --- a/party.c +++ b/party.c @@ -2,33 +2,24 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" -Party theparty; - - -void -inittheparty(void) -{ - theparty.next = theparty.prev = &theparty; -} - Party * -newparty(Player *players) +newparty(Party *p, Player *players) { - Party *p; + Party *np; - p = emalloc(sizeof(Party)); - p->players[0] = players[0]; - p->players[1] = players[1]; + np = emalloc(sizeof(Party)); + np->players[0] = players[0]; + np->players[1] = players[1]; - p->u = newuniverse(); + np->u = newuniverse(); - addparty(p); + addparty(p, np); - return p; + return np; } void @@ -41,10 +32,16 @@ delparty(Party *p) } void -addparty(Party *p) +addparty(Party *theparty, Party *p) +{ + p->prev = theparty->prev; + p->next = theparty; + theparty->prev->next = p; + theparty->prev = p; +} + +void +initparty(Party *p) { - p->prev = theparty.prev; - p->next = &theparty; - theparty.prev->next = p; - theparty.prev = p; + p->next = p->prev = p; } diff --git a/physics.c b/physics.c index f7fd284..0fafea4 100644 --- a/physics.c +++ b/physics.c @@ -2,7 +2,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" @@ -17,7 +17,7 @@ accelship(Universe *u, Particle *p, double) { double g, d; - /* XXX: remember to take thrust into account, based on user input. */ + /* TODO: take thrust into account, based on user input. */ d = vec2len(subpt2(u->star.p, p->p)); d *= 1e5; /* scale to the 100km/px range */ g = G*u->star.mass/(d*d); diff --git a/sprite.c b/sprite.c index c857a85..aceceed 100644 --- a/sprite.c +++ b/sprite.c @@ -2,7 +2,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" diff --git a/universe.c b/universe.c index 5a4ea82..7a17b56 100644 --- a/universe.c +++ b/universe.c @@ -2,7 +2,7 @@ #include #include #include -#include "libgeometry/geometry.h" +#include #include "dat.h" #include "fns.h" diff --git a/vmodeled/main.c b/vmodeled/main.c index 254e410..54001f8 100644 --- a/vmodeled/main.c +++ b/vmodeled/main.c @@ -5,7 +5,7 @@ #include #include #include -#include "../libgeometry/geometry.h" +#include /* * Vector model - made out of lines and curves diff --git a/vmodeled/mkfile b/vmodeled/mkfile index eba7c97..9eabb0b 100644 --- a/vmodeled/mkfile +++ b/vmodeled/mkfile @@ -1,24 +1,8 @@