2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-26 11:49:25 +01:00

engine: common: net_ws: more minor refactoring, avoid memcpy for same type structs

This commit is contained in:
Alibek Omarov 2024-10-02 23:30:42 +03:00
parent e2c96e62e1
commit 67af41cce8

View File

@ -587,16 +587,9 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
sadr->ss_family = temp.ss_family;
if( temp.ss_family == AF_INET )
{
((struct sockaddr_in *)sadr)->sin_addr =
((struct sockaddr_in*)&temp)->sin_addr;
}
((struct sockaddr_in *)sadr)->sin_addr = ((struct sockaddr_in*)&temp)->sin_addr;
else if( temp.ss_family == AF_INET6 )
{
memcpy(&((struct sockaddr_in6 *)sadr)->sin6_addr,
&((struct sockaddr_in6*)&temp)->sin6_addr,
sizeof( struct in6_addr ));
}
((struct sockaddr_in6 *)sadr)->sin6_addr = ((struct sockaddr_in6*)&temp)->sin6_addr;
}
return NET_EAI_OK;
@ -1753,7 +1746,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
if( COM_CheckStringEmpty( net_iface ) && Q_stricmp( net_iface, "localhost" ))
NET_StringToSockaddr( net_iface, &addr, false, AF_INET6 );
else memcpy(((struct sockaddr_in6 *)&addr)->sin6_addr.s6_addr, &in6addr_any, sizeof( struct in6_addr ));
else ((struct sockaddr_in6 *)&addr)->sin6_addr = in6addr_any;
if( port == PORT_ANY ) ((struct sockaddr_in6 *)&addr)->sin6_port = 0;
else ((struct sockaddr_in6 *)&addr)->sin6_port = htons((short)port);