summaryrefslogtreecommitdiff
path: root/src/net_sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/net_sdl.c')
-rw-r--r--src/net_sdl.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/net_sdl.c b/src/net_sdl.c
index 7de61cb7..da667ff7 100644
--- a/src/net_sdl.c
+++ b/src/net_sdl.c
@@ -302,15 +302,27 @@ static boolean NET_SDL_RecvPacket(net_addr_t **addr, net_packet_t **packet)
void NET_SDL_AddrToString(net_addr_t *addr, char *buffer, int buffer_len)
{
IPaddress *ip;
+ uint32_t host;
+ uint16_t port;
ip = (IPaddress *) addr->handle;
-
- M_snprintf(buffer, buffer_len,
- "%i.%i.%i.%i",
- ip->host & 0xff,
- (ip->host >> 8) & 0xff,
- (ip->host >> 16) & 0xff,
- (ip->host >> 24) & 0xff);
+ host = SDLNet_Read32(&ip->host);
+ port = SDLNet_Read16(&ip->port);
+
+ M_snprintf(buffer, buffer_len, "%i.%i.%i.%i",
+ (host >> 24) & 0xff, (host >> 16) & 0xff,
+ (host >> 8) & 0xff, host & 0xff);
+
+ // If we are using the default port we just need to show the IP address,
+ // but otherwise we need to include the port. This is important because
+ // we use the string representation in the setup tool to provided an
+ // address to connect to.
+ if (port != DEFAULT_PORT)
+ {
+ char portbuf[10];
+ M_snprintf(portbuf, sizeof(portbuf), ":%i", port);
+ M_StringConcat(buffer, portbuf, buffer_len);
+ }
}
net_addr_t *NET_SDL_ResolveAddress(char *address)