summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-30 20:08:32 +0000
committerrubidium <rubidium@openttd.org>2008-05-30 20:08:32 +0000
commit6d90affce01ae2b882b2679bf5371da4a49dbc99 (patch)
tree8b0dc7d59c8980af5e6a802b0035efabfb9a642c /src/network
parent2f3b88ef9a217e911c897de49cc616e73a233b59 (diff)
downloadopenttd-6d90affce01ae2b882b2679bf5371da4a49dbc99.tar.xz
(svn r13344) -Codechange: remove some code duplication.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index b0ab7a612..713932927 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -877,12 +877,22 @@ static void NetworkClose()
}
if (_network_server) {
- // We are a server, also close the listensocket
+ /* We are a server, also close the listensocket */
closesocket(_listensocket);
_listensocket = INVALID_SOCKET;
DEBUG(net, 1, "Closed listener");
- NetworkUDPCloseAll();
}
+ NetworkUDPCloseAll();
+
+ /* Free all queued commands */
+ while (_local_command_queue != NULL) {
+ CommandPacket *p = _local_command_queue;
+ _local_command_queue = _local_command_queue->next;
+ free(p);
+ }
+
+ _networking = false;
+ _network_server = false;
}
// Inits the network (cleans sockets and stuff)
@@ -988,7 +998,6 @@ bool NetworkClientConnectGame(const char *host, uint16 port)
_settings_client.network.last_port = port;
NetworkDisconnect();
- NetworkUDPCloseAll();
NetworkInitialize();
// Try to connect
@@ -1114,16 +1123,6 @@ void NetworkReboot()
}
NetworkClose();
-
- // Free all queued commands
- while (_local_command_queue != NULL) {
- CommandPacket *p = _local_command_queue;
- _local_command_queue = _local_command_queue->next;
- free(p);
- }
-
- _networking = false;
- _network_server = false;
}
// We want to disconnect from the host/clients
@@ -1142,16 +1141,6 @@ void NetworkDisconnect()
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
NetworkClose();
-
- // Free all queued commands
- while (_local_command_queue != NULL) {
- CommandPacket *p = _local_command_queue;
- _local_command_queue = _local_command_queue->next;
- free(p);
- }
-
- _networking = false;
- _network_server = false;
}
// Receives something from the network