From: hgn Date: Wed, 31 May 2023 16:58:34 +0000 (+0100) Subject: server changes X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=9fb26bfce5b8130703a8c31818783912c2b3dfac;p=carveJwlIkooP6JGAAIwe30JlM.git server changes --- diff --git a/highscores.h b/highscores.h index 817a503..b096714 100644 --- a/highscores.h +++ b/highscores.h @@ -164,8 +164,7 @@ VG_STATIC int highscores_read(void) struct highscore_system *sys = &highscore_system; FILE *fp = fopen( ".aadb", "rb" ); - if( fp ) - { + if( fp ){ vg_info( "Loading existing database\n" ); u64 count = fread( &sys->dbheader, sizeof(highscore_database), 1, fp ); diff --git a/network.h b/network.h index 3a49d63..38fc903 100644 --- a/network.h +++ b/network.h @@ -243,13 +243,11 @@ VG_STATIC void on_inet_scoreboard( SteamNetworkingMessage_t *msg ) sizeof(struct netmsg_board)*vg_list_size(track_infos), expected = base_size+sizeof(struct netmsg_board)*sb->board_count; - if( msg->m_cbSize != expected ) - { + if( msg->m_cbSize != expected ){ vg_error( "Server scoreboard was corrupted. Size: %u != %u\n", msg->m_cbSize, expected ); } - else - { + else{ if( vg_list_size(track_infos) > sb->board_count ) vg_warn( "Server is out of date, not enough boards recieved\n"); else if( vg_list_size(track_infos) < sb->board_count ) @@ -257,8 +255,7 @@ VG_STATIC void on_inet_scoreboard( SteamNetworkingMessage_t *msg ) else vg_success( "Recieved new scoreboards from server\n" ); - for( int i=0; i < vg_min(sb->board_count,vg_list_size(track_infos)); i++) - { + for( int i=0; i < vg_min(sb->board_count,vg_list_size(track_infos)); i++){ scoreboard_client_data.boards[i] = sb->boards[i]; highscores_board_printf( stdout, sb->boards[i].data, 10 ); } @@ -276,20 +273,17 @@ VG_STATIC void poll_connection(void) SteamNetworkingMessage_t *messages[32]; int len; - while(1) - { + while(1){ len = SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnConnection( hSteamNetworkingSockets, cremote, messages, vg_list_size(messages)); if( len <= 0 ) return; - for( int i=0; im_cbSize < sizeof(netmsg_blank) ) - { + if( msg->m_cbSize < sizeof(netmsg_blank) ){ vg_warn( "Discarding message (too small: %d)\n", msg->m_cbSize ); continue; } @@ -309,21 +303,17 @@ VG_STATIC void poll_connection(void) */ VG_STATIC void network_update(void) { - if( steam_ready ) - { + if( steam_ready ){ static double last_update = 0.0; poll_connection(); - if( vg.time > (last_update + 60.0) ) - { + if( vg.time > (last_update + 60.0) ){ last_update = vg.time; - if( steam_app_ticket_length ) - { + if( steam_app_ticket_length ){ network_connect_gc(); } - else - { + else{ vg_low( "Not making remote connection; app ticket not gotten\n" ); } } @@ -340,8 +330,7 @@ VG_STATIC void network_update(void) VG_STATIC void network_init(void) { - if( steam_ready ) - { + if( steam_ready ){ steam_register_callback( k_iSteamNetConnectionStatusChangedCallBack, on_server_connect_status ); request_auth_ticket(); diff --git a/network_msg.h b/network_msg.h index 5f1bc41..1df9434 100644 --- a/network_msg.h +++ b/network_msg.h @@ -49,7 +49,9 @@ struct netmsg_set_score } records[]; }; -enum{ k_inetmsg_set_score = 3 }; +enum{ k_inetmsg_set_score = 6 }; +/* 31.05.23: k_inetmsg_set_score id changed from ID 3 to ID 6, + * 3 is now INVALID */ typedef struct netmsg_set_nickname netmsg_set_nickname; struct netmsg_set_nickname diff --git a/server.c b/server.c index be3f2a9..5e13355 100644 --- a/server.c +++ b/server.c @@ -275,8 +275,7 @@ static void poll_connections(void) SteamNetworkingMessage_t *messages[32]; int len; - while(1) - { + while(1){ len = SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnPollGroup( hSteamNetworkingSockets, client_pollgroup, messages, vg_list_size(messages) ); @@ -284,12 +283,10 @@ static void poll_connections(void) if( len <= 0 ) return; - for( int i=0; im_cbSize < sizeof(netmsg_blank) ) - { + if( msg->m_cbSize < sizeof(netmsg_blank) ){ vg_warn( "Discarding message (too small: %d)\n", msg->m_cbSize ); continue; @@ -305,6 +302,10 @@ static void poll_connections(void) on_inet_set_nickname( msg ); else if( tmp->inetmsg_id == k_inetmsg_set_score ) on_inet_set_score( msg ); + else { + vg_warn( "Unknown inetmsg_id recieved from client. (%u)\n", + temp->inetmsg_id ); + } SteamAPI_SteamNetworkingMessage_t_Release( msg ); } diff --git a/skaterift.c b/skaterift.c index 50e780f..74e360b 100644 --- a/skaterift.c +++ b/skaterift.c @@ -57,10 +57,12 @@ int main( int argc, char *argv[] ) return 0; } +#if 0 VG_STATIC void highscores_save_at_exit(void) { highscores_serialize_all(); } +#endif VG_STATIC void vg_launch_opt(void) { @@ -78,11 +80,13 @@ vg_info(" | \\/ | | / | | \\ | / | \n" ); vg_info(" ' ' '--' [] '----- '----- ' ' '---' " "SOFTWARE\n" ); + /* 31.05.23 (hgn): this is only a server feature now */ +#if 0 highscores_init( 2000, 50 ); if( !highscores_read() ) highscores_create_db(); - vg_loader_step( NULL, highscores_save_at_exit ); +#endif steam_init(); vg_loader_step( NULL, steam_end ); diff --git a/world_routes.c b/world_routes.c index efde364..d366a12 100644 --- a/world_routes.c +++ b/world_routes.c @@ -22,7 +22,7 @@ VG_STATIC void world_routes_local_set_record( world_instance *world, ent_route *route, - double lap_time ) + f64 lap_time ) { vg_success( " NEW LAP TIME: %f\n", lap_time ); @@ -37,7 +37,6 @@ void world_routes_local_set_record( world_instance *world, ent_route *route, temp.playerid = 0; temp.points = 0; temp.time = time_centiseconds; - #if 0 highscores_push_record( &temp ); #endif