From 1a07df371a8d0c7defad55b7c11f868b1bcbca56 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 27 Jun 2018 23:20:11 +0200 Subject: [PATCH] replaced delay functions with new one that continues updating toons --- src/init.c | 2 +- src/network.c | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/init.c b/src/init.c index dd7e5a17..71cc90db 100644 --- a/src/init.c +++ b/src/init.c @@ -5637,7 +5637,7 @@ void InitNetworkServer() } /* short time to recognize result of network initialization */ - Delay(1000); + Delay_WithScreenUpdates(1000); } static boolean CheckArtworkConfigForCustomElements(char *filename) diff --git a/src/network.c b/src/network.c index fcd757d4..b7c753b4 100644 --- a/src/network.c +++ b/src/network.c @@ -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); } -- 2.34.1