moved variables for network server thread to network structure
authorHolger Schemel <info@artsoft.org>
Fri, 18 Sep 2020 17:18:29 +0000 (19:18 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 18 Sep 2020 17:18:29 +0000 (19:18 +0200)
src/init.c
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/netserv.c
src/network.c

index d126103a47d662fa6b7c4ece63852b4aa142632d..5c795f4c32daa9e473fd624190dd972a2d71cfd5 100644 (file)
@@ -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();
index b0b8d4775236b8005ed1a5cae12ee39cb411be46..076ea586309c008e3332e9eb4fa49602c89fc6bb 100644 (file)
@@ -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()
index d18f0f271df43dc9d20661cfbbd5201133d52f82..44f97e073fa671c08a677b0b92648b2cdc9dccde 100644 (file)
@@ -977,6 +977,8 @@ struct NetworkInfo
   char *server_host;
   int server_port;
 
+  SDL_Thread *server_thread;
+  boolean is_server_thread;
 };
 
 struct RuntimeInfo
index 86cd30994d89fcc6ee0545fb13d726bd2f147478..1a4243f98dae958e5ddf865d0e50399c01a7a229 100644 (file)
@@ -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;
 
index c412801a2607b2e667710e9a6f7fc06ac2ecc9de..0ab4907d5db570a8e3cb73b3255d77aba0f54ce9 100644 (file)
@@ -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;
 
index e94304d29cc9e14adb5f19d3ab460931413b0791..9ed0291c5d43745741b974c46fa08d915e1e1208 100644 (file)
@@ -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
index b61f861abd857a1299770e340eeed16b0b9010b1..a21c16e71062308923e551b7dd5962b0d8f05020 100644 (file)
@@ -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)