From 3241d4b8c80f9424a3f725b5905def22916fc854 Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 29 Jul 2021 14:56:10 +0000 Subject: made the client window size immutable. added some dev notes to a file. renamed Lobby.healthcheck to Lobby.purge, which makes more sense. --- dat.h | 9 ++++++++- lobby.c | 4 ++-- musw.c | 15 ++++++++++++++- muswd.c | 2 +- notes | 17 +++++++++++++++++ physics.c | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 notes diff --git a/dat.h b/dat.h index 33c4607..9290562 100644 --- a/dat.h +++ b/dat.h @@ -16,6 +16,13 @@ typedef enum 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 @@ struct Lobby int (*takeseat)(Lobby*, char*, int, int); int (*leaveseat)(Lobby*, ulong); int (*getcouple)(Lobby*, Player*); - void (*healthcheck)(Lobby*); + void (*purge)(Lobby*); }; struct Party diff --git a/lobby.c b/lobby.c index 4211639..8ed5789 100644 --- a/lobby.c +++ b/lobby.c @@ -51,7 +51,7 @@ lobby_getcouple(Lobby *l, Player *couple) } static void -lobby_healthcheck(Lobby *l) +lobby_purge(Lobby *l) { char status[48], buf[16]; int i, fd; @@ -86,7 +86,7 @@ newlobby(void) l->takeseat = lobby_takeseat; l->getcouple = lobby_getcouple; l->leaveseat = lobby_leaveseat; - l->healthcheck = lobby_healthcheck; + l->purge = lobby_purge; return l; } diff --git a/musw.c b/musw.c index 39c707a..fddec50 100644 --- a/musw.c +++ b/musw.c @@ -35,6 +35,7 @@ struct Ball }; Ball bouncer; +char winspec[32]; int debug; @@ -142,6 +143,8 @@ redraw(void) void resize(void) { + int fd; + if(debug) fprint(2, "resizing\n"); @@ -149,6 +152,15 @@ resize(void) 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 @@ threadmain(int argc, char *argv[]) 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"); diff --git a/muswd.c b/muswd.c index 4c1c7ca..d23f906 100644 --- a/muswd.c +++ b/muswd.c @@ -107,7 +107,7 @@ threadsim(void *) io = ioproc(); for(;;){ - lobby->healthcheck(lobby); + lobby->purge(lobby); if(lobby->getcouple(lobby, couple) != -1){ newparty(couple); diff --git a/notes b/notes new file mode 100644 index 0000000..26e05fb --- /dev/null +++ b/notes @@ -0,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. diff --git a/physics.c b/physics.c index 5bc2e5b..d0c6ae8 100644 --- a/physics.c +++ b/physics.c @@ -4,6 +4,8 @@ #include "dat.h" #include "fns.h" +static double G = 6.674e-11; + /* * Dynamics stepper */ -- cgit v1.2.3