(svn r13344) -Codechange: remove some code duplication.
--- a/src/network/network.cpp Fri May 30 18:20:26 2008 +0000
+++ b/src/network/network.cpp Fri May 30 20:08:32 2008 +0000
@@ -877,12 +877,22 @@
}
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 @@
_settings_client.network.last_port = port;
NetworkDisconnect();
- NetworkUDPCloseAll();
NetworkInitialize();
// Try to connect
@@ -1114,16 +1123,6 @@
}
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 @@
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
--- a/src/openttd.cpp Fri May 30 18:20:26 2008 +0000
+++ b/src/openttd.cpp Fri May 30 20:08:32 2008 +0000
@@ -810,10 +810,8 @@
if (_networking) {
if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) {
NetworkReboot();
- NetworkUDPCloseAll();
} else {
NetworkDisconnect();
- NetworkUDPCloseAll();
}
}