diff options
author | rodri <rgl@antares-labs.eu> | 2023-03-04 23:32:47 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-03-04 23:32:47 +0000 |
commit | 941d146cea7d0c2ce872e599622a5c9e01d37fe2 (patch) | |
tree | 0fe67a2d7f4f906b1e33acee2b1d70d2e03e1fa5 /musw.c | |
parent | 9712ec712cc6a57d416ef2b1e86d15ef161016df (diff) | |
download | musw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.tar.gz musw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.tar.bz2 musw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.zip |
implemented client reconnection loop.
currently not working. there seems to be a problem with 9front's udp stack. needs investigation.
Diffstat (limited to 'musw.c')
-rw-r--r-- | musw.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -12,13 +12,6 @@ #include "dat.h" #include "fns.h" -typedef struct Keymap Keymap; -struct Keymap -{ - Rune key; - KeyOp op; -}; - Keymap kmap[] = { {.key = Kup, .op = K↑}, {.key = Kleft, .op = K↺}, @@ -38,6 +31,7 @@ Universe *universe; VModel *needlemdl, *wedgemdl; Image *screenb; Image *skymap; +Scene *curscene; Channel *ingress; Channel *egress; NetConn netconn; @@ -311,7 +305,7 @@ threadnetrecv(void *arg) if(debug){ rport = frame->udp.rport[0]<<8 | frame->udp.rport[1]; lport = frame->udp.lport[0]<<8 | frame->udp.lport[1]; - fprint(2, "%I!%ud → %I!%ud | rcvd %Φ\n", + fprint(2, "%I!%ud ← %I!%ud | rcvd %Φ\n", frame->udp.laddr, lport, frame->udp.raddr, rport, frame); } } @@ -557,7 +551,7 @@ usage(void) void threadmain(int argc, char *argv[]) { - uvlong then, now; + uvlong then, now, lastpktsent; double frametime; char *server; int fd; @@ -625,19 +619,26 @@ threadmain(int argc, char *argv[]) threadcreate(threadresize, mc, mainstacksize); then = nanosec(); + lastpktsent = 0; io = ioproc(); for(;;){ now = nanosec(); frametime = now - then; then = now; + if(netconn.state != NCSConnected) + lastpktsent += frametime/1e6; + + if(netconn.state == NCSDisconnected || + (netconn.state == NCSConnecting && lastpktsent >= 1000)){ + initconn(); + lastpktsent = 0; + } + universe->star.spr->step(universe->star.spr, frametime/1e6); redraw(); - if(netconn.state == NCSDisconnected) - initconn(); - iosleep(io, HZ2MS(30)); } } |