X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=network.c;h=777fab46b9852e72c1ab8568653a807208ce03e4;hb=46f4e9ee87dc67402166e4c6b05efbe922cd7574;hp=63b70c3903feea369c927fae63b7eef9c7f92741;hpb=22f62f001f21d1b91fefd9fc495c122d9ddf205a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/network.c b/network.c index 63b70c3..777fab4 100644 --- a/network.c +++ b/network.c @@ -1,5 +1,7 @@ #include "player.h" #include "network.h" +#include "network_msg.h" +#include "player_remote.h" static void scores_update(void); @@ -151,13 +153,33 @@ static void on_server_connect_status( CallbackMsg_t *msg ){ if( info->m_hConn == network_client.remote ){ network_client.state = info->m_info.m_eState; - if( info->m_info.m_eState == k_ESteamNetworkingConnectionState_Connected ){ + + if( info->m_info.m_eState == + k_ESteamNetworkingConnectionState_Connected ){ vg_success(" Connected to remote server.. authenticating\n"); send_auth_ticket(); } + else if( info->m_info.m_eState == + k_ESteamNetworkingConnectionState_ClosedByPeer ){ + + if( info->m_info.m_eEndReason == + k_ESteamNetConnectionEnd_Remote_Max ){ + network_client.retries = 40; + } + + SteamAPI_ISteamNetworkingSockets_CloseConnection( + hSteamNetworkingSockets, info->m_hConn, 0, NULL, 0 ); + network_client.remote = 0; + } + else if( info->m_info.m_eState == + k_ESteamNetworkingConnectionState_ProblemDetectedLocally ){ + SteamAPI_ISteamNetworkingSockets_CloseConnection( + hSteamNetworkingSockets, info->m_hConn, 0, NULL, 0 ); + network_client.remote = 0; + } } else{ - vg_warn( " Recieved signal from unknown connection\n" ); + //vg_warn( " Recieved signal from unknown connection\n" ); } } @@ -205,9 +227,11 @@ static void on_inet_scoreboard( SteamNetworkingMessage_t *msg ){ } } +#if 0 /* We dont need to stay on the server currently */ SteamAPI_ISteamNetworkingSockets_CloseConnection( hSteamNetworkingSockets, network_client.remote, 0, NULL, 1 ); +#endif network_scores_updated = 1; } @@ -237,6 +261,10 @@ static void poll_remote_connection(void){ if( tmp->inetmsg_id == k_inetmsg_scoreboard ) on_inet_scoreboard( msg ); + if( (tmp->inetmsg_id >= 200) && (tmp->inetmsg_id < 300) ){ + player_remote_packet( msg ); + } + SteamAPI_SteamNetworkingMessage_t_Release( msg ); } } @@ -280,6 +308,8 @@ static void network_update(void){ } static void network_init(void){ + vg_console_reg_var( "network_info", &network_client.network_info, + k_var_dtype_i32, VG_VAR_PERSISTENT ); if( steam_ready ){ steam_register_callback( k_iSteamNetConnectionStatusChangedCallBack, on_server_connect_status );