shithub: musw

Download patch

ref: 06f817044e7b2ec0bf63ed37a1cadd9f3818a787
parent: 1ee28cd5ece6c035af2ab445ec774d7e0cc054ec
author: rodri <rgl@antares-labs.eu>
date: Tue Jan 31 18:46:58 EST 2023

use libgeometry from the system. got rid of global `theparty`. wrote a little man page draft.

--- a/dat.h
+++ b/dat.h
@@ -166,6 +166,3 @@
 	Universe *u;
 	Party *prev, *next;
 };
-
-
-extern Party theparty;
--- a/fns.h
+++ b/fns.h
@@ -32,10 +32,10 @@
 /*
  * 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
--- 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"
 
--- a/mkfile
+++ b/mkfile
@@ -20,17 +20,7 @@
 	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
 
--- 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"
 
--- a/musw.man
+++ b/musw.man
@@ -1,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
--- a/muswd.c
+++ b/muswd.c
@@ -3,7 +3,7 @@
 #include <ip.h>
 #include <thread.h>
 #include <draw.h>
-#include "libgeometry/geometry.h"
+#include <geometry.h>
 #include "dat.h"
 #include "fns.h"
 
@@ -10,6 +10,7 @@
 int debug;
 
 Lobby *lobby;
+Party theparty;
 
 
 void
@@ -89,7 +90,7 @@
 		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 @@
 		fprint(2, "listening on %s\n", addr);
 
 	lobby = newlobby();
-	inittheparty();
+	initparty(&theparty);
 
 	threadcreate(threadC2, nil, 4096);
 	threadcreate(threadlisten, &adfd, 4096);
--- 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"
 
--- 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 @@
 }
 
 void
-addparty(Party *p)
+addparty(Party *theparty, Party *p)
 {
-	p->prev = theparty.prev;
-	p->next = &theparty;
-	theparty.prev->next = p;
-	theparty.prev = p;
+	p->prev = theparty->prev;
+	p->next = theparty;
+	theparty->prev->next = p;
+	theparty->prev = p;
+}
+
+void
+initparty(Party *p)
+{
+	p->next = p->prev = p;
 }
--- 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 @@
 {
 	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);
--- 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"
 
--- 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"
 
--- 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
--- 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}