diff options
author | rubidium <rubidium@openttd.org> | 2007-02-02 21:04:50 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-02-02 21:04:50 +0000 |
commit | fe996cb13d80eb79b5c9de1f0eb2c9b99ee82ad6 (patch) | |
tree | 6afcca18aefaacfe113a8dc1b2d985a26e852f12 | |
parent | 6fd39ebb7ca14b50124c699693cc060f1453a217 (diff) | |
download | openttd-fe996cb13d80eb79b5c9de1f0eb2c9b99ee82ad6.tar.xz |
(svn r8543) -Codechange: make a real difference between querying the server via UDP and TCP.
-rw-r--r-- | src/network/network.cpp | 12 | ||||
-rw-r--r-- | src/network/network.h | 2 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 10 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 8 | ||||
-rw-r--r-- | src/network/network_udp.h | 2 |
5 files changed, 14 insertions, 20 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index cfeef9ed1..76a29f3af 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -851,14 +851,12 @@ static void NetworkInitialize(void) // Query a server to fetch his game-info // If game_info is true, only the gameinfo is fetched, // else only the client_info is fetched -NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info) +void NetworkTCPQueryServer(const char* host, unsigned short port) { - if (!_network_available) return NULL; + if (!_network_available) return; NetworkDisconnect(); - if (game_info) return NetworkUDPQueryServer(host, port); - NetworkInitialize(); _network_server = false; @@ -872,8 +870,6 @@ NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool } else { // No networking, close everything down again NetworkDisconnect(); } - - return NULL; } /* Validates an address entered as a string and adds the server to @@ -882,7 +878,6 @@ NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool void NetworkAddServer(const char *b) { if (*b != '\0') { - NetworkGameList *item; const char *port = NULL; const char *player = NULL; char host[NETWORK_HOSTNAME_LENGTH]; @@ -896,8 +891,7 @@ void NetworkAddServer(const char *b) ParseConnectionString(&player, &port, host); if (port != NULL) rport = atoi(port); - item = NetworkQueryServer(host, rport, true); - item->manually = true; + NetworkUDPQueryServer(host, rport, true); } } diff --git a/src/network/network.h b/src/network/network.h index 58af8e304..b091cab86 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -163,7 +163,7 @@ VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X mont VARDEF Year _network_restart_game_year; // If this year is reached, the server automaticly restarts VARDEF uint8 _network_min_players; // Minimum number of players for game to unpause -NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info); +void NetworkTCPQueryServer(const char* host, unsigned short port); byte NetworkSpectatorCount(void); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e0bd94205..4457d5b6e 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -446,7 +446,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) break; case 17: // Refresh if (nd->server != NULL) - NetworkQueryServer(nd->server->info.hostname, nd->server->port, true); + NetworkUDPQueryServer(nd->server->info.hostname, nd->server->port); break; case 18: // NewGRF Settings if (nd->server != NULL) ShowNewGRFSettings(false, false, false, &nd->server->info.grfconfig); @@ -945,8 +945,8 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) NetworkClientConnectGame(_network_last_host, _network_last_port); break; case 10: /* Refresh */ - NetworkQueryServer(_network_last_host, _network_last_port, false); // company info - NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data + NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info + NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data break; } break; @@ -994,8 +994,8 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl) Window *w; DeleteWindowById(WC_NETWORK_WINDOW, 0); - NetworkQueryServer(_network_last_host, _network_last_port, false); // company info - NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data + NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info + NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data w = AllocateWindowDesc(&_network_lobby_window_desc); if (w != NULL) { diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index b7e8b6f94..3517b4918 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -481,14 +481,14 @@ void NetworkUDPSearchGame(void) _network_udp_broadcast = 300; // Stay searching for 300 ticks } -NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port) +void NetworkUDPQueryServer(const char* host, unsigned short port, bool manually) { struct sockaddr_in out_addr; NetworkGameList *item; // No UDP-socket yet.. if (!_udp_client_socket->IsConnected()) { - if (!_udp_client_socket->Listen(0, 0, true)) return NULL; + if (!_udp_client_socket->Listen(0, 0, true)) return; } out_addr.sin_family = AF_INET; @@ -500,14 +500,14 @@ NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port) memset(&item->info, 0, sizeof(item->info)); ttd_strlcpy(item->info.server_name, host, lengthof(item->info.server_name)); ttd_strlcpy(item->info.hostname, host, lengthof(item->info.hostname)); - item->online = false; + item->online = false; + item->manually = manually; // Init the packet Packet p(PACKET_UDP_CLIENT_FIND_SERVER); _udp_client_socket->SendPacket(&p, &out_addr); UpdateNetworkGameWindow(false); - return item; } /* Remove our advertise from the master-server */ diff --git a/src/network/network_udp.h b/src/network/network_udp.h index c8b34a49d..ed9f5b952 100644 --- a/src/network/network_udp.h +++ b/src/network/network_udp.h @@ -8,7 +8,7 @@ void NetworkUDPInitialize(void); void NetworkUDPSearchGame(void); void NetworkUDPQueryMasterServer(void); -NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port); +void NetworkUDPQueryServer(const char* host, unsigned short port, bool manually = false); void NetworkUDPAdvertise(void); void NetworkUDPRemoveAdvertise(void); void NetworkUDPShutdown(void); |