added setting network connection flag for network games
authorHolger Schemel <info@artsoft.org>
Fri, 22 Jun 2018 19:29:50 +0000 (21:29 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 22 Jun 2018 19:29:50 +0000 (21:29 +0200)
src/init.c
src/network.c

index 9c9af0e90144197a94d2253ad0d38d50cb9e9c7d..7413cd52e53f5b9695e02e3697c8f57a46d4ccde 100644 (file)
@@ -5616,7 +5616,7 @@ void InitNetworkSettings()
 
 void InitNetworkServer()
 {
-  if (!network.enabled)
+  if (!network.enabled || network.connected)
     return;
 
   if (!ConnectToServer(network.server_host, network.server_port))
@@ -5625,12 +5625,16 @@ void InitNetworkServer()
 
     network.enabled = FALSE;
 
+    setup.network_mode = FALSE;
+
     return;
   }
 
   SendToServer_PlayerName(setup.player_name);
   SendToServer_ProtocolVersion();
   SendToServer_NrWanted(setup.network_player_nr + 1);
+
+  network.connected = TRUE;
 }
 
 static boolean CheckArtworkConfigForCustomElements(char *filename)
index 2bbdf6b18b1277c576258cee3982775f379e858b..55e43e12207ad6e54094ba7b6dc685924ca4aa53 100644 (file)
@@ -704,9 +704,13 @@ static void HandleNetworkingDisconnect()
   SDLNet_TCP_DelSocket(rfds, sfd);
   SDLNet_TCP_Close(sfd);
 
-  network.enabled = FALSE;
   network_playing = FALSE;
 
+  network.enabled = FALSE;
+  network.connected = FALSE;
+
+  setup.network_mode = FALSE;
+
   for (i = 0; i < MAX_PLAYERS; i++)
     stored_player[i].connected_network = FALSE;
 }