src/network/network.cpp
changeset 6167 1475cf991e66
parent 6153 2ecdbf81caa7
child 6210 717cc12ac0a9
equal deleted inserted replaced
6166:053fd8482b7d 6167:1475cf991e66
   849 }
   849 }
   850 
   850 
   851 // Query a server to fetch his game-info
   851 // Query a server to fetch his game-info
   852 //  If game_info is true, only the gameinfo is fetched,
   852 //  If game_info is true, only the gameinfo is fetched,
   853 //   else only the client_info is fetched
   853 //   else only the client_info is fetched
   854 NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info)
   854 void NetworkTCPQueryServer(const char* host, unsigned short port)
   855 {
   855 {
   856 	if (!_network_available) return NULL;
   856 	if (!_network_available) return;
   857 
   857 
   858 	NetworkDisconnect();
   858 	NetworkDisconnect();
   859 
       
   860 	if (game_info) return NetworkUDPQueryServer(host, port);
       
   861 
   859 
   862 	NetworkInitialize();
   860 	NetworkInitialize();
   863 
   861 
   864 	_network_server = false;
   862 	_network_server = false;
   865 
   863 
   870 	if (_networking) {
   868 	if (_networking) {
   871 		SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)();
   869 		SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)();
   872 	} else { // No networking, close everything down again
   870 	} else { // No networking, close everything down again
   873 		NetworkDisconnect();
   871 		NetworkDisconnect();
   874 	}
   872 	}
   875 
       
   876 	return NULL;
       
   877 }
   873 }
   878 
   874 
   879 /* Validates an address entered as a string and adds the server to
   875 /* Validates an address entered as a string and adds the server to
   880  * the list. If you use this function, the games will be marked
   876  * the list. If you use this function, the games will be marked
   881  * as manually added. */
   877  * as manually added. */
   882 void NetworkAddServer(const char *b)
   878 void NetworkAddServer(const char *b)
   883 {
   879 {
   884 	if (*b != '\0') {
   880 	if (*b != '\0') {
   885 		NetworkGameList *item;
       
   886 		const char *port = NULL;
   881 		const char *port = NULL;
   887 		const char *player = NULL;
   882 		const char *player = NULL;
   888 		char host[NETWORK_HOSTNAME_LENGTH];
   883 		char host[NETWORK_HOSTNAME_LENGTH];
   889 		uint16 rport;
   884 		uint16 rport;
   890 
   885 
   894 		rport = NETWORK_DEFAULT_PORT;
   889 		rport = NETWORK_DEFAULT_PORT;
   895 
   890 
   896 		ParseConnectionString(&player, &port, host);
   891 		ParseConnectionString(&player, &port, host);
   897 		if (port != NULL) rport = atoi(port);
   892 		if (port != NULL) rport = atoi(port);
   898 
   893 
   899 		item = NetworkQueryServer(host, rport, true);
   894 		NetworkUDPQueryServer(host, rport, true);
   900 		item->manually = true;
       
   901 	}
   895 	}
   902 }
   896 }
   903 
   897 
   904 /* Generates the list of manually added hosts from NetworkGameList and
   898 /* Generates the list of manually added hosts from NetworkGameList and
   905  * dumps them into the array _network_host_list. This array is needed
   899  * dumps them into the array _network_host_list. This array is needed