diff options
author | rodri <rgl@antares-labs.eu> | 2023-01-31 23:46:58 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-01-31 23:46:58 +0000 |
commit | 06f817044e7b2ec0bf63ed37a1cadd9f3818a787 (patch) | |
tree | e3f677987e50eaffddfd7c29745ceb090d1c991f | |
parent | 1ee28cd5ece6c035af2ab445ec774d7e0cc054ec (diff) | |
download | musw-06f817044e7b2ec0bf63ed37a1cadd9f3818a787.tar.gz musw-06f817044e7b2ec0bf63ed37a1cadd9f3818a787.tar.bz2 musw-06f817044e7b2ec0bf63ed37a1cadd9f3818a787.zip |
use libgeometry from the system. got rid of global `theparty`. wrote a little man page draft.
-rw-r--r-- | dat.h | 3 | ||||
-rw-r--r-- | fns.h | 6 | ||||
-rw-r--r-- | lobby.c | 2 | ||||
-rw-r--r-- | mkfile | 10 | ||||
-rw-r--r-- | musw.c | 2 | ||||
-rw-r--r-- | musw.man | 28 | ||||
-rw-r--r-- | muswd.c | 7 | ||||
-rw-r--r-- | pack.c | 2 | ||||
-rw-r--r-- | party.c | 43 | ||||
-rw-r--r-- | physics.c | 4 | ||||
-rw-r--r-- | sprite.c | 2 | ||||
-rw-r--r-- | universe.c | 2 | ||||
-rw-r--r-- | vmodeled/main.c | 2 | ||||
-rw-r--r-- | vmodeled/mkfile | 18 |
14 files changed, 64 insertions, 67 deletions
@@ -166,6 +166,3 @@ struct Party Universe *u; Party *prev, *next; }; - - -extern Party theparty; @@ -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 @@ -2,7 +2,7 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #include "dat.h" #include "fns.h" @@ -20,18 +20,8 @@ HFILES=\ dat.h\ fns.h\ -LIB=\ - libgeometry/libgeometry.a$O\ - </sys/src/cmd/mkmany -libgeometry/libgeometry.a$O: pulldeps - cd libgeometry - mk install - -pulldeps:V: - ! test -d libgeometry && git/clone https://github.com/sametsisartenep/libgeometry || echo >/dev/null - install:V: man uninstall:V: @@ -6,7 +6,7 @@ #include <draw.h> #include <mouse.h> #include <keyboard.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #include "dat.h" #include "fns.h" @@ -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 @@ -3,13 +3,14 @@ #include <ip.h> #include <thread.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #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); @@ -2,7 +2,7 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #include "dat.h" #include "fns.h" @@ -2,33 +2,24 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #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; } @@ -2,7 +2,7 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #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); @@ -2,7 +2,7 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #include "dat.h" #include "fns.h" @@ -2,7 +2,7 @@ #include <libc.h> #include <ip.h> #include <draw.h> -#include "libgeometry/geometry.h" +#include <geometry.h> #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 <draw.h> #include <mouse.h> #include <keyboard.h> -#include "../libgeometry/geometry.h" +#include <geometry.h> /* * 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 @@ </$objtype/mkfile -BIN=/$objtype/bin/musw +BIN=/$objtype/bin/games TARG=vmodeled OFILES=\ main.$O\ -HFILES=\ - ../libgeometry/geometry.h\ - -LIB=\ - ../libgeometry/libgeometry.a$O\ - -CFLAGS=$CFLAGS - </sys/src/cmd/mkone - -../libgeometry/libgeometry.a$O: - cd ../libgeometry - mk install - -clean nuke:V: - rm -f *.[$OS] [$OS].??* $TARG - @{cd ../libgeometry; mk $target} |