medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 0443f2672c462f38aa721c28f1747cbdc317e571
parent 3ab6d178dff9abbfc204eddc0336a4abd7010154
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Dec 28 22:27:39 +0200

Resend the connection request if we don't hear back after 1 second

Diffstat:
hm.cc | 23++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/hm.cc b/hm.cc @@ -81,6 +81,7 @@ static UB ub_sphere; static Socket sock; static u64 sid; +static double last_connection_attempt = -5.0; // TODO static bool connected = false; static struct sockaddr_in addr; @@ -145,15 +146,6 @@ extern "C" GAME_INIT( game_init ) { memcpy( &addr, &addrs, sizeof( addr ) ); if( addr.sin_family == AF_INET6 ) printf( "ipv6\n" ); addr.sin_port = htons( 13337 ); - - char write_buf[ 1400 ]; - WriteStream ws( write_buf ); - v3 pos( 1, 2, 3 ); - - write_u64( &ws, -1 ); - write( &ws, pos ); - - sock_send_udp( sock, ws, addr ); } static m4 camera_to_view( v3 position, v3 angles ) { @@ -382,6 +374,19 @@ extern "C" GAME_FRAME( game_frame ) { } } + if( !connected && current_time - last_connection_attempt > 1.0 ) { + char write_buf[ 1400 ]; + WriteStream ws( write_buf ); + v3 pos( 1, 2, 3 ); + + write_u64( &ws, -1 ); + write( &ws, pos ); + + sock_send_udp( sock, ws, addr ); + + last_connection_attempt = current_time; + } + ImmediateContext imm; ImmediateTriangle boxes[ 4096 ]; immediate_init( &imm, boxes, ARRAY_COUNT( boxes ) );