test network 4
[carveJwlIkooP6JGAAIwe30JlM.git] / network.c
index 8b34fb092a9668a820dc662e2d20846769af77e7..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{
@@ -233,6 +238,8 @@ static void network_connect(void){
    const char *server_lon1 = "46.101.34.155:27402";
    SteamAPI_SteamNetworkingIPAddr_ParseString( &remoteAddr, server_lon1 );
 #endif
+   const char *server_lan = "192.168.1.32:27402";
+   SteamAPI_SteamNetworkingIPAddr_ParseString( &remoteAddr, server_lan );
 
    char buf[256];
    SteamAPI_SteamNetworkingIPAddr_ToString( &remoteAddr, buf, 256, 1 );