From 2108aef8c6dfb7fcad9f55442813769a3d412313 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 6 Mar 2010 14:10:37 +0000 Subject: [PATCH] det_dgrm.c (Strip_Port): New proc stripping off port from the given host name and assining the new port number to net_hostport. based on ProQuake code. This makes a command line like "+connect ip:port" work. (Test_f): Call Strip_Port(). (Test2_f): Likewise. (Datagram_Connect): Likewise. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@103 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/net_dgrm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Quake/net_dgrm.c b/Quake/net_dgrm.c index 4a4e5e28..c4b9285a 100644 --- a/Quake/net_dgrm.c +++ b/Quake/net_dgrm.c @@ -511,6 +511,24 @@ void NET_Stats_f (void) } +// recognize ip:port (based on ProQuake) +static void Strip_Port (char *host) +{ + if (!host || !*host) + return; + if ((host = Q_strrchr(host, ':')) != NULL) + { + int port; + *host++ = '\0'; + port = Q_atoi(host); + if (port > 0 && port < 65536 && port != net_hostport) + { + net_hostport = port; + Con_Printf("Port set to %d\n", net_hostport); + } + } +} + static qboolean testInProgress = false; static int testPollCount; static int testDriver; @@ -587,6 +605,7 @@ static void Net_Test_f (void) return; host = Cmd_Argv (1); + Strip_Port (host); if (host && hostCacheCount) { @@ -715,6 +734,7 @@ static void Test2_f (void) return; host = Cmd_Argv (1); + Strip_Port (host); if (host && hostCacheCount) { @@ -1377,6 +1397,7 @@ qsocket_t *Datagram_Connect (char *host) { qsocket_t *ret = NULL; + Strip_Port (host); for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) if (net_landrivers[net_landriverlevel].initialized) if ((ret = _Datagram_Connect (host)) != NULL)