aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon
diff options
context:
space:
mode:
Diffstat (limited to 'code/qcommon')
-rw-r--r--code/qcommon/net_chan.c31
-rw-r--r--code/qcommon/qcommon.h2
2 files changed, 18 insertions, 15 deletions
diff --git a/code/qcommon/net_chan.c b/code/qcommon/net_chan.c
index e4b1739..8869c01 100644
--- a/code/qcommon/net_chan.c
+++ b/code/qcommon/net_chan.c
@@ -673,17 +673,19 @@ void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len
NET_StringToAdr
Traps "localhost" for loopback, passes everything else to system
+return 0 on address not found, 1 on address found with port, 2 on address found without port.
=============
*/
-qboolean NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ) {
- qboolean r;
+int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family )
+{
char base[MAX_STRING_CHARS], *search;
char *port = NULL;
if (!strcmp (s, "localhost")) {
Com_Memset (a, 0, sizeof(*a));
a->type = NA_LOOPBACK;
- return qtrue;
+// as NA_LOOPBACK doesn't require ports report port was given.
+ return 1;
}
Q_strncpyz( base, s, sizeof( base ) );
@@ -719,19 +721,20 @@ qboolean NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ) {
search = base;
}
- r = Sys_StringToAdr( search, a, family );
-
- if ( !r ) {
+ if(!Sys_StringToAdr(search, a, family))
+ {
a->type = NA_BAD;
- return qfalse;
+ return 0;
}
- if ( port ) {
- a->port = BigShort( (short)atoi( port ) );
- } else {
- a->port = BigShort( PORT_SERVER );
+ if(port)
+ {
+ a->port = BigShort((short) atoi(port));
+ return 1;
+ }
+ else
+ {
+ a->port = BigShort(PORT_SERVER);
+ return 2;
}
-
- return qtrue;
}
-
diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
index 0fe6a47..8746f3b 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -171,7 +171,7 @@ qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
qboolean NET_IsLocalAddress (netadr_t adr);
const char *NET_AdrToString (netadr_t a);
const char *NET_AdrToStringwPort (netadr_t a);
-qboolean NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family);
+int NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family);
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message);
void NET_JoinMulticast6(void);
void NET_LeaveMulticast6(void);