ref: 3241d4b8c80f9424a3f725b5905def22916fc854
parent: 9942eb201a657640cf244b261008b850352a29f3
author: rodri <rgl@antares-labs.eu>
date: Thu Jul 29 10:56:10 EDT 2021
made the client window size immutable. added some dev notes to a file. renamed Lobby.healthcheck to Lobby.purge, which makes more sense.
--- a/dat.h
+++ b/dat.h
@@ -16,6 +16,13 @@
WEDGE
} Kind;
+enum {
+ SCRW = 640,
+ SCRH = 480,
+ SCRWB = SCRW+2*Borderwidth,
+ SCRHB = SCRH+2*Borderwidth
+};
+
typedef struct Vector Vector;
typedef struct VModel VModel;
typedef struct Sprite Sprite;
@@ -126,7 +133,7 @@
int (*takeseat)(Lobby*, char*, int, int);
int (*leaveseat)(Lobby*, ulong);
int (*getcouple)(Lobby*, Player*);
- void (*healthcheck)(Lobby*);
+ void (*purge)(Lobby*);
};
struct Party
--- a/lobby.c
+++ b/lobby.c
@@ -51,7 +51,7 @@
}
static void
-lobby_healthcheck(Lobby *l)
+lobby_purge(Lobby *l)
{
char status[48], buf[16];
int i, fd;
@@ -86,7 +86,7 @@
l->takeseat = lobby_takeseat;
l->getcouple = lobby_getcouple;
l->leaveseat = lobby_leaveseat;
- l->healthcheck = lobby_healthcheck;
+ l->purge = lobby_purge;
return l;
}
--- a/musw.c
+++ b/musw.c
@@ -35,6 +35,7 @@
};
Ball bouncer;
+char winspec[32];
int debug;
@@ -142,6 +143,8 @@
void
resize(void)
{
+ int fd;
+
if(debug)
fprint(2, "resizing\n");
@@ -149,6 +152,15 @@
if(getwindow(display, Refnone) < 0)
sysfatal("resize failed");
unlockdisplay(display);
+
+ if(Dx(screen->r) != SCRW || Dy(screen->r) != SCRH){
+ fd = open("/dev/wctl", OWRITE);
+ if(fd >= 0){
+ fprint(fd, "resize %s", winspec);
+ close(fd);
+ }
+ }
+
redraw();
}
@@ -178,7 +190,8 @@
usage();
server = argv[0];
- if(newwindow("-dx 640 -dy 480") < 0)
+ snprint(winspec, sizeof winspec, "-dx %d -dy %d", SCRWB, SCRHB);
+ if(newwindow(winspec) < 0)
sysfatal("newwindow: %r");
if(initdraw(nil, nil, nil) < 0)
sysfatal("initdraw: %r");
--- a/muswd.c
+++ b/muswd.c
@@ -107,7 +107,7 @@
io = ioproc();
for(;;){
- lobby->healthcheck(lobby);
+ lobby->purge(lobby);
if(lobby->getcouple(lobby, couple) != -1){
newparty(couple);
--- /dev/null
+++ b/notes
@@ -1,0 +1,17 @@
+• there's, at most, two players waiting in the lobby at a given time.
+it makes no sense to allocate more than two seats since the threadsim
+will consume them whenever they are ready to join the party. i'm
+thinking of using channels to synchronize the two threads, so
+threadsim doesn't loop doing nothing (but sleeping) until at least a
+couple of players join.
+
+• the integrator has to operate with vectors and the different objects
+in the universe, some of which may require their own governing laws.
+
+• think of a way to pack the bullets efficiently. will they be part
+of the global state broadcast? what does the client need to know to
+render and manage them?
+
+• it could be beneficial to do dynamics in the client as well, which
+means sending more data, and probably require a tighter sync, but a
+smoother user experience.
--- a/physics.c
+++ b/physics.c
@@ -4,6 +4,8 @@
#include "dat.h"
#include "fns.h"
+static double G = 6.674e-11;
+
/*
* Dynamics stepper
*/