mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-10 20:11:42 +00:00
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
This commit is contained in:
parent
610567cb8a
commit
2108aef8c6
1 changed files with 21 additions and 0 deletions
|
@ -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 qboolean testInProgress = false;
|
||||||
static int testPollCount;
|
static int testPollCount;
|
||||||
static int testDriver;
|
static int testDriver;
|
||||||
|
@ -587,6 +605,7 @@ static void Net_Test_f (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
host = Cmd_Argv (1);
|
host = Cmd_Argv (1);
|
||||||
|
Strip_Port (host);
|
||||||
|
|
||||||
if (host && hostCacheCount)
|
if (host && hostCacheCount)
|
||||||
{
|
{
|
||||||
|
@ -715,6 +734,7 @@ static void Test2_f (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
host = Cmd_Argv (1);
|
host = Cmd_Argv (1);
|
||||||
|
Strip_Port (host);
|
||||||
|
|
||||||
if (host && hostCacheCount)
|
if (host && hostCacheCount)
|
||||||
{
|
{
|
||||||
|
@ -1377,6 +1397,7 @@ qsocket_t *Datagram_Connect (char *host)
|
||||||
{
|
{
|
||||||
qsocket_t *ret = NULL;
|
qsocket_t *ret = NULL;
|
||||||
|
|
||||||
|
Strip_Port (host);
|
||||||
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++)
|
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++)
|
||||||
if (net_landrivers[net_landriverlevel].initialized)
|
if (net_landrivers[net_landriverlevel].initialized)
|
||||||
if ((ret = _Datagram_Connect (host)) != NULL)
|
if ((ret = _Datagram_Connect (host)) != NULL)
|
||||||
|
|
Loading…
Reference in a new issue