diff options
author | rubidium <rubidium@openttd.org> | 2008-12-23 20:58:03 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-23 20:58:03 +0000 |
commit | ece37ca2c095ff672cd9f6e793da865c9029c83c (patch) | |
tree | 0d699dd79736133afb9429a4c93122cd0a8a711c | |
parent | afddfcb2b1a37358459158ce83a64535f13cd05e (diff) | |
download | openttd-ece37ca2c095ff672cd9f6e793da865c9029c83c.tar.xz |
(svn r14731) -Fix: don't initialise UDP multiple times without closing it.
-rw-r--r-- | src/network/network.cpp | 3 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index 3d854c320..fefd5cfe3 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -684,8 +684,6 @@ static void NetworkInitialize() _network_first_time = true; _network_reconnect = 0; - - NetworkUDPInitialize(); } // Query a server to fetch his game-info @@ -1189,6 +1187,7 @@ void NetworkStartUp() memset(&_network_game_info, 0, sizeof(_network_game_info)); + NetworkUDPInitialize(); NetworkInitialize(); DEBUG(net, 3, "[core] network online, multiplayer available"); NetworkFindBroadcastIPs(_broadcast_list, MAX_INTERFACES); diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 430eee925..493242bdf 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -34,9 +34,9 @@ enum { ADVERTISE_RETRY_TIMES = 3 // give up readvertising after this much failed retries }; -NetworkUDPSocketHandler *_udp_client_socket; ///< udp client socket -NetworkUDPSocketHandler *_udp_server_socket; ///< udp server socket -NetworkUDPSocketHandler *_udp_master_socket; ///< udp master socket +NetworkUDPSocketHandler *_udp_client_socket = NULL; ///< udp client socket +NetworkUDPSocketHandler *_udp_server_socket = NULL; ///< udp server socket +NetworkUDPSocketHandler *_udp_master_socket = NULL; ///< udp master socket ///*** Communication with the masterserver ***/ @@ -537,6 +537,8 @@ void NetworkUDPAdvertise() void NetworkUDPInitialize() { + assert(_udp_client_socket == NULL && _udp_server_socket == NULL && _udp_master_socket == NULL); + _udp_client_socket = new ClientNetworkUDPSocketHandler(); _udp_server_socket = new ServerNetworkUDPSocketHandler(); _udp_master_socket = new MasterNetworkUDPSocketHandler(); @@ -552,6 +554,9 @@ void NetworkUDPShutdown() delete _udp_client_socket; delete _udp_server_socket; delete _udp_master_socket; + _udp_client_socket = NULL; + _udp_server_socket = NULL; + _udp_master_socket = NULL; } #endif /* ENABLE_NETWORK */ |