aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-01-31 23:46:58 +0000
committerrodri <rgl@antares-labs.eu>2023-01-31 23:46:58 +0000
commit06f817044e7b2ec0bf63ed37a1cadd9f3818a787 (patch)
treee3f677987e50eaffddfd7c29745ceb090d1c991f
parent1ee28cd5ece6c035af2ab445ec774d7e0cc054ec (diff)
downloadmusw-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.h3
-rw-r--r--fns.h6
-rw-r--r--lobby.c2
-rw-r--r--mkfile10
-rw-r--r--musw.c2
-rw-r--r--musw.man28
-rw-r--r--muswd.c7
-rw-r--r--pack.c2
-rw-r--r--party.c43
-rw-r--r--physics.c4
-rw-r--r--sprite.c2
-rw-r--r--universe.c2
-rw-r--r--vmodeled/main.c2
-rw-r--r--vmodeled/mkfile18
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 <libc.h>
#include <ip.h>
#include <draw.h>
-#include "libgeometry/geometry.h"
+#include <geometry.h>
#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\
-
</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:
diff --git a/musw.c b/musw.c
index 106a83a..accdd2c 100644
--- a/musw.c
+++ b/musw.c
@@ -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"
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 <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);
diff --git a/pack.c b/pack.c
index 85d71ac..3b61a66 100644
--- a/pack.c
+++ b/pack.c
@@ -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/party.c b/party.c
index cacf2e4..ad3cd9b 100644
--- a/party.c
+++ b/party.c
@@ -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;
}
diff --git a/physics.c b/physics.c
index f7fd284..0fafea4 100644
--- a/physics.c
+++ b/physics.c
@@ -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);
diff --git a/sprite.c b/sprite.c
index c857a85..aceceed 100644
--- a/sprite.c
+++ b/sprite.c
@@ -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/universe.c b/universe.c
index 5a4ea82..7a17b56 100644
--- a/universe.c
+++ b/universe.c
@@ -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}