Ejemplo n.º 1
0
/*
====================
NET_Config
====================
*/
void NET_Config( qboolean enableNetworking )
{
	qboolean modified;
	qboolean stop;
	qboolean start;
	qboolean svRunning;
	qboolean svChanged;

	// get any latched changes to cvars
	modified = NET_GetCvars();
#ifndef DEDICATED
	svRunning = !!com_sv_running->integer;
	modified |= ( svRunning != serverMode );
#endif

	if ( !net_enabled->integer )
	{
		enableNetworking = 0;
	}

	// if enable state is the same and no cvars were modified, we have nothing to do
	if ( enableNetworking == networkingEnabled && !modified )
	{
		return;
	}

	if ( enableNetworking == networkingEnabled )
	{
		if ( enableNetworking )
		{
			stop = qtrue;
			start = qtrue;
		}
		else
		{
			stop = qfalse;
			start = qfalse;
		}
	}
	else
	{
		if ( enableNetworking )
		{
			stop = qfalse;
			start = qtrue;
		}
		else
		{
			stop = qtrue;
			start = qfalse;
		}
	}

#ifndef DEDICATED
	serverMode = svRunning;
#endif
	networkingEnabled = enableNetworking;

	if ( stop )
	{
		if ( ip_socket != INVALID_SOCKET )
		{
			closesocket( ip_socket );
			ip_socket = INVALID_SOCKET;
		}

		if ( multicast6_socket != INVALID_SOCKET )
		{
			if ( multicast6_socket != ip6_socket )
			{
				closesocket( multicast6_socket );
			}

			multicast6_socket = INVALID_SOCKET;
		}

		if ( ip6_socket != INVALID_SOCKET )
		{
			closesocket( ip6_socket );
			ip6_socket = INVALID_SOCKET;
		}

		if ( socks_socket != INVALID_SOCKET )
		{
			closesocket( socks_socket );
			socks_socket = INVALID_SOCKET;
		}
	}

	if ( start )
	{
		if ( net_enabled->integer )
		{
			NET_OpenIP();
			NET_SetMulticast6();
		}
	}
}
Ejemplo n.º 2
0
/*
====================
NET_Config
====================
*/
void NET_Config( qboolean enableNetworking )
{
    qboolean modified;
    qboolean stop;
    qboolean start;

    // get any latched changes to cvars
    modified = NET_GetCvars();

    if ( !net_enabled->integer )
    {
        enableNetworking = 0;
    }

    // if enable state is the same and no cvars were modified, we have nothing to do
    if ( enableNetworking == networkingEnabled && !modified )
    {
        return;
    }

    if ( enableNetworking == networkingEnabled )
    {
        if ( enableNetworking )
        {
            stop = qtrue;
            start = qtrue;
        }
        else
        {
            stop = qfalse;
            start = qfalse;
        }
    }
    else
    {
        if ( enableNetworking )
        {
            stop = qfalse;
            start = qtrue;
        }
        else
        {
            stop = qtrue;
            start = qfalse;
        }

        networkingEnabled = enableNetworking;
    }

    if ( stop )
    {
        if ( ip_socket != INVALID_SOCKET )
        {
            closesocket( ip_socket );
            ip_socket = INVALID_SOCKET;
        }

        if ( multicast6_socket )
        {
            if ( multicast6_socket != ip6_socket )
            {
                closesocket( multicast6_socket );
            }

            multicast6_socket = INVALID_SOCKET;
        }

        if ( ip6_socket != INVALID_SOCKET )
        {
            closesocket( ip6_socket );
            ip6_socket = INVALID_SOCKET;
        }

        if ( socks_socket != INVALID_SOCKET )
        {
            closesocket( socks_socket );
            socks_socket = INVALID_SOCKET;
        }
    }

    if ( start )
    {
        if ( net_enabled->integer )
        {
            NET_OpenIP();
            NET_SetMulticast6();
        }
    }
}
Ejemplo n.º 3
0
/*
====================
NET_Config
====================
*/
void NET_Config( bool enableNetworking )
{
	bool modified;
	bool stop;
	bool start;
#ifndef BUILD_SERVER
	bool svRunning;
#endif

	// get any latched changes to cvars
	modified = NET_GetCvars();
#ifndef BUILD_SERVER
	svRunning = !!com_sv_running->integer;
	modified |= ( svRunning != serverMode );
#endif

	if ( !net_enabled->integer )
	{
		enableNetworking = 0;
	}

	// if enable state is the same and no cvars were modified, we have nothing to do
	if ( enableNetworking == networkingEnabled && !modified )
	{
		return;
	}

	start = enableNetworking;
	if ( enableNetworking == networkingEnabled )
	{
		stop = enableNetworking;
	}
	else
	{
		stop = !enableNetworking;
	}

#ifndef BUILD_SERVER
	serverMode = svRunning;
#endif
	networkingEnabled = enableNetworking;

	if ( stop )
	{
		if ( ip_socket != INVALID_SOCKET )
		{
			closesocket( ip_socket );
			ip_socket = INVALID_SOCKET;
		}

		if ( multicast6_socket != INVALID_SOCKET )
		{
			if ( multicast6_socket != ip6_socket )
			{
				closesocket( multicast6_socket );
			}

			multicast6_socket = INVALID_SOCKET;
		}

		if ( ip6_socket != INVALID_SOCKET )
		{
			closesocket( ip6_socket );
			ip6_socket = INVALID_SOCKET;
		}

		if ( socks_socket != INVALID_SOCKET )
		{
			closesocket( socks_socket );
			socks_socket = INVALID_SOCKET;
		}
	}

	if ( start )
	{
		if ( net_enabled->integer )
		{
			NET_OpenIP();
			NET_SetMulticast6();
#ifdef BUILD_SERVER
			SV_NET_Config();
#endif
		}
	}
}