(svn r15981) -Fix: don't print the address family when writing the IP+port to the config file.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 15 years ago
parent 18146572b0
commit 9d6edae94d

@ -56,18 +56,22 @@ void NetworkAddress::SetPort(uint16 port)
}
}
const char *NetworkAddress::GetAddressAsString()
const char *NetworkAddress::GetAddressAsString(bool with_family)
{
/* 6 = for the : and 5 for the decimal port number */
static char buf[NETWORK_HOSTNAME_LENGTH + 6 + 7];
char family;
switch (this->address.ss_family) {
case AF_INET: family = '4'; break;
case AF_INET6: family = '6'; break;
default: family = '?'; break;
if (with_family) {
char family;
switch (this->address.ss_family) {
case AF_INET: family = '4'; break;
case AF_INET6: family = '6'; break;
default: family = '?'; break;
}
seprintf(buf, lastof(buf), "%s:%d (IPv%c)", this->GetHostname(), this->GetPort(), family);
} else {
seprintf(buf, lastof(buf), "%s:%d", this->GetHostname(), this->GetPort());
}
seprintf(buf, lastof(buf), "%s:%d (IPv%c)", this->GetHostname(), this->GetPort(), family);
return buf;
}

@ -122,9 +122,10 @@ public:
/**
* Get the address as a string, e.g. 127.0.0.1:12345.
* @param with_family whether to add the family (e.g. IPvX).
* @return the address
*/
const char *GetAddressAsString();
const char *GetAddressAsString(bool with_family = true);
/**
* Get the address in it's internal representation.

@ -374,7 +374,7 @@ static void CheckMinActiveClients()
* occupied by connection_string. */
void ParseConnectionString(const char **company, const char **port, char *connection_string)
{
bool ipv6 = false;
bool ipv6 = (strchr(connection_string, ':') != strrchr(connection_string, ':'));
char *p;
for (p = connection_string; *p != '\0'; p++) {
switch (*p) {
@ -675,7 +675,7 @@ void NetworkRebuildHostList()
_network_host_list.Clear();
for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
if (item->manually) *_network_host_list.Append() = strdup(item->address.GetAddressAsString());
if (item->manually) *_network_host_list.Append() = strdup(item->address.GetAddressAsString(false));
}
}

Loading…
Cancel
Save