network.c
changeset 2915 c59cbb76b5b2
parent 2881 1ffbbdbf1685
child 2944 7c392e7b51c6
equal deleted inserted replaced
2914:04ce2485f05f 2915:c59cbb76b5b2
   865 void NetworkRebuildHostList(void)
   865 void NetworkRebuildHostList(void)
   866 {
   866 {
   867 	uint i = 0;
   867 	uint i = 0;
   868 	NetworkGameList *item = _network_game_list;
   868 	NetworkGameList *item = _network_game_list;
   869 	while (item != NULL && i != lengthof(_network_host_list)) {
   869 	while (item != NULL && i != lengthof(_network_host_list)) {
   870 		if (item->manually)
   870 		if (item->manually) {
       
   871 			free(_network_host_list[i]);
   871 			_network_host_list[i++] = str_fmt("%s:%i", item->info.hostname, item->port);
   872 			_network_host_list[i++] = str_fmt("%s:%i", item->info.hostname, item->port);
       
   873 		}
   872 		item = item->next;
   874 		item = item->next;
   873 	}
   875 	}
   874 
   876 
   875 	for (; i < lengthof(_network_host_list); i++) {
   877 	for (; i < lengthof(_network_host_list); i++) {
   876 		_network_host_list[i] = strdup("");
   878 		free(_network_host_list[i]);
       
   879 		_network_host_list[i] = NULL;
   877 	}
   880 	}
   878 }
   881 }
   879 
   882 
   880 // Used by clients, to connect to a server
   883 // Used by clients, to connect to a server
   881 bool NetworkClientConnectGame(const char* host, unsigned short port)
   884 bool NetworkClientConnectGame(const char* host, unsigned short port)