Skip to content

Commit

Permalink
engine: common: net_ws: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Oct 2, 2024
1 parent a1060b0 commit 2ecae44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
22 changes: 10 additions & 12 deletions engine/common/net_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ static CVAR_DEFINE( net_ip6hostport, "ip6_hostport", "0", FCVAR_READ_ONLY, "netw
static CVAR_DEFINE( net_ip6clientport, "ip6_clientport", "0", FCVAR_READ_ONLY, "network ip6 client port" );
static CVAR_DEFINE_AUTO( net6_address, "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "contain local IPv6 address of current client" );

static void NET_ClearLagData( qboolean bClient, qboolean bServer );

/*
====================
NET_ErrorString
Expand Down Expand Up @@ -197,7 +199,7 @@ static char *NET_ErrorString( void )
#endif
}

_inline socklen_t NET_SockAddrLen( const struct sockaddr_storage *addr )
static inline socklen_t NET_SockAddrLen( const struct sockaddr_storage *addr )
{
switch ( addr->ss_family )
{
Expand All @@ -210,7 +212,7 @@ _inline socklen_t NET_SockAddrLen( const struct sockaddr_storage *addr )
}
}

_inline qboolean NET_IsSocketError( int retval )
static inline qboolean NET_IsSocketError( int retval )
{
#if XASH_WIN32 || XASH_DOS4GW
return retval == SOCKET_ERROR ? true : false;
Expand All @@ -219,7 +221,7 @@ _inline qboolean NET_IsSocketError( int retval )
#endif
}

_inline qboolean NET_IsSocketValid( int socket )
static inline qboolean NET_IsSocketValid( int socket )
{
#if XASH_WIN32 || XASH_DOS4GW
return socket != INVALID_SOCKET;
Expand Down Expand Up @@ -460,7 +462,7 @@ static void NET_DeleteCriticalSections( void )
memset( &nsthread, 0, sizeof( nsthread ));
}

void NET_ResolveThread( void )
static void NET_ResolveThread( void )
{
struct sockaddr_storage addr;
qboolean res;
Expand Down Expand Up @@ -579,21 +581,17 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
asyncfailed = false;
return NET_EAI_AGAIN;
}
else // failed to create thread
{
Con_Reportf( S_ERROR "%s: failed to create thread!\n", __func__ );
nsthread.busy = false;
}

Con_Reportf( S_ERROR "%s: failed to create thread!\n", __func__ );
nsthread.busy = false;
}

mutex_unlock( nsthread.mutexres );
}
#endif // CAN_ASYNC_NS_RESOLVE

if( asyncfailed )
{
ret = NET_GetHostByName( copy, family, &temp );
}

if( !ret )
{
Expand Down Expand Up @@ -2106,7 +2104,7 @@ NET_ClearLagData
clear fakelag list
====================
*/
void NET_ClearLagData( qboolean bClient, qboolean bServer )
static void NET_ClearLagData( qboolean bClient, qboolean bServer )
{
if( bClient ) NET_ClearLaggedList( &net.lagdata[NS_CLIENT] );
if( bServer ) NET_ClearLaggedList( &net.lagdata[NS_SERVER] );
Expand Down
1 change: 0 additions & 1 deletion engine/common/net_ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ qboolean NET_CompareAdrByMask( const netadr_t a, const netadr_t b, uint prefixle
qboolean NET_GetPacket( netsrc_t sock, netadr_t *from, byte *data, size_t *length );
void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to );
void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t to, size_t splitsize );
void NET_ClearLagData( qboolean bClient, qboolean bServer );
void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 );
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr );

Expand Down

0 comments on commit 2ecae44

Please sign in to comment.