replaced delay functions with new one that continues updating toons
authorHolger Schemel <info@artsoft.org>
Wed, 27 Jun 2018 21:20:11 +0000 (23:20 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 27 Jun 2018 21:35:12 +0000 (23:35 +0200)
src/init.c
src/network.c

index dd7e5a174b822a42aefc75fa6ac5de5dcce691d1..71cc90db93ac2befb78b0c822c054281ad3cdcc7 100644 (file)
@@ -5637,7 +5637,7 @@ void InitNetworkServer()
   }
 
   /* short time to recognize result of network initialization */
-  Delay(1000);
+  Delay_WithScreenUpdates(1000);
 }
 
 static boolean CheckArtworkConfigForCustomElements(char *filename)
index fcd757d48831d34efe78778fce6e476522c8b9f2..b7c753b45f9e429b56b07116e1b5323d9cfaa011 100644 (file)
@@ -240,25 +240,34 @@ boolean ConnectToServer(char *hostname, int port)
 
     DrawNetworkText("Looking for local network server ...");
 
-    if (SDLNet_CheckSockets(udp_socket_set, 500) == 1)
+    /* wait for any local network server to answer UDP broadcast */
+    for (i = 0; i < 5; i++)
     {
-      int num_packets = SDLNet_UDP_Recv(udp, &packet);
-
-      if (num_packets == 1)
+      if (SDLNet_CheckSockets(udp_socket_set, 0) == 1)
       {
-       DrawNetworkText_Success("Network server found!");
+       int num_packets = SDLNet_UDP_Recv(udp, &packet);
+
+       if (num_packets == 1)
+       {
+         DrawNetworkText_Success("Network server found!");
+
+         server_host = SDLNet_Read32(&packet.address.host);
+       }
+       else
+       {
+         DrawNetworkText_Failed("No answer from network server!");
+       }
 
-        server_host = SDLNet_Read32(&packet.address.host);
+       break;
       }
       else
       {
-       DrawNetworkText_Failed("No answer from network server!");
+       Delay_WithScreenUpdates(100);
       }
     }
-    else
-    {
+
+    if (server_host == 0)
       DrawNetworkText_Failed("No network server found!");
-    }
   }
 
   rfds = SDLNet_AllocSocketSet(1);
@@ -328,7 +337,7 @@ boolean ConnectToServer(char *hostname, int port)
       return TRUE;
     }
 
-    Delay(100);
+    Delay_WithScreenUpdates(100);
   }
 
   DrawNetworkText_Failed("Failed to connect to network server!");
@@ -841,5 +850,5 @@ void DisconnectFromNetworkServer()
   DrawNetworkText_Success("Successfully disconnected!");
 
   /* short time to recognize result of network initialization */
-  Delay(1000);
+  Delay_WithScreenUpdates(1000);
 }