test network 4
[carveJwlIkooP6JGAAIwe30JlM.git] / network.c
index 4042ef4ef3dd1f5882617141c63f15a555e00b22..a35ead4ef3a6004403c9c78d139ef345f426e127 100644 (file)
--- a/network.c
+++ b/network.c
@@ -157,6 +157,16 @@ static void network_send_username(void){
          k_nSteamNetworkingSend_Reliable, NULL );
 }
 
+static void network_disconnect(void){
+   SteamAPI_ISteamNetworkingSockets_CloseConnection( 
+         hSteamNetworkingSockets, network_client.remote, 0, NULL, 0 );
+   network_client.remote = 0;
+
+   for( int i=0; i<vg_list_size(netplayers.list); i++ ){
+      netplayers.list[i].active = 0;
+   }
+}
+
 static void on_server_connect_status( CallbackMsg_t *msg ){
    SteamNetConnectionStatusChangedCallback_t *info = (void *)msg->m_pubParam;
    vg_info( "  Connection status changed for %lu\n", info->m_hConn );
@@ -193,16 +203,11 @@ static void on_server_connect_status( CallbackMsg_t *msg ){
                k_ESteamNetConnectionEnd_Remote_Max ){
             network_client.retries = 40;
          }
-
-         SteamAPI_ISteamNetworkingSockets_CloseConnection( 
-               hSteamNetworkingSockets, info->m_hConn, 0, NULL, 0 );
-         network_client.remote = 0;
+         network_disconnect();
       }
       else if( info->m_info.m_eState == 
             k_ESteamNetworkingConnectionState_ProblemDetectedLocally ){
-         SteamAPI_ISteamNetworkingSockets_CloseConnection( 
-               hSteamNetworkingSockets, info->m_hConn, 0, NULL, 0 );
-         network_client.remote = 0;
+         network_disconnect();
       }
    }
    else{