From: Holger Schemel Date: Fri, 18 Sep 2020 17:18:29 +0000 (+0200) Subject: moved variables for network server thread to network structure X-Git-Tag: 4.2.0.3~24 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7f8f5498ebbb9cbfd0857dce7e53b64bf6603aa4;p=rocksndiamonds.git moved variables for network server thread to network structure --- diff --git a/src/init.c b/src/init.c index d126103a..5c795f4c 100644 --- a/src/init.c +++ b/src/init.c @@ -6302,8 +6302,8 @@ void CloseAllAndExit(int exit_value) // using SDL_WaitThread() // // Code used with SDL 1.2: - // if (network_server) // terminate network server - // SDL_KillThread(server_thread); + // if (network.server_thread) // terminate network server + // SDL_KillThread(network.server_thread); CloseVideoDisplay(); ClosePlatformDependentStuff(); diff --git a/src/libgame/system.c b/src/libgame/system.c index b0b8d477..076ea586 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -114,6 +114,9 @@ void InitNetworkInfo(boolean enabled, boolean connected, boolean serveronly, network.server_host = server_host; network.server_port = server_port; + + network.server_thread = NULL; + network.is_server_thread = FALSE; } void InitRuntimeInfo() diff --git a/src/libgame/system.h b/src/libgame/system.h index d18f0f27..44f97e07 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -977,6 +977,8 @@ struct NetworkInfo char *server_host; int server_port; + SDL_Thread *server_thread; + boolean is_server_thread; }; struct RuntimeInfo diff --git a/src/main.c b/src/main.c index 86cd3099..1a4243f9 100644 --- a/src/main.c +++ b/src/main.c @@ -33,8 +33,6 @@ int game_status = -1; boolean game_status_last_screen = -1; boolean level_editor_test_game = FALSE; boolean network_playing = FALSE; -boolean network_server = FALSE; -SDL_Thread *server_thread; int key_joystick_mapping = 0; diff --git a/src/main.h b/src/main.h index c412801a..0ab4907d 100644 --- a/src/main.h +++ b/src/main.h @@ -3639,8 +3639,6 @@ extern int game_status; extern boolean game_status_last_screen; extern boolean level_editor_test_game; extern boolean network_playing; -extern boolean network_server; -extern SDL_Thread *server_thread; extern int key_joystick_mapping; diff --git a/src/netserv.c b/src/netserv.c index e94304d2..9ed0291c 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -819,6 +819,8 @@ static void ExitNetworkServer(int exit_value) // the pointer points to an integer containing the port-number int NetworkServerThread(void *ptr) { + network.is_server_thread = TRUE; + NetworkServer(*((int *) ptr), 0); // should never be reached diff --git a/src/network.c b/src/network.c index b61f861a..a21c16e7 100644 --- a/src/network.c +++ b/src/network.c @@ -189,9 +189,8 @@ static void StartNetworkServer(int port) p = port; - server_thread = SDL_CreateThread(NetworkServerThread, - "NetworkServerThread", &p); - network_server = TRUE; + network.server_thread = SDL_CreateThread(NetworkServerThread, + "NetworkServerThread", &p); } boolean ConnectToServer(char *hostname, int port)