Source/ThunderBeast/QuakeToon/server/sv_main.c
void SVC_GetChallenge (void)
{
	int		i;
	int		oldest;
	int		oldestTime;

	oldest = 0;
	oldestTime = 0x7fffffff;

	// see if we already have a challenge for this ip
	for (i = 0 ; i < MAX_CHALLENGES ; i++)
	{
		if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
			break;
		if (svs.challenges[i].time < oldestTime)
		{
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}

	if (i == MAX_CHALLENGES)
	{
		// overwrite the oldest
		svs.challenges[oldest].challenge = rand() & 0x7fff;
		svs.challenges[oldest].adr = net_from;
		svs.challenges[oldest].time = curtime;
		i = oldest;
	}

	// send it back
	Netchan_OutOfBandPrint (NS_SERVER, net_from, "challenge %i", svs.challenges[i].challenge);
}
/*
=================
SVC_GetChallenge

Returns a challenge number that can be used
in a subsequent client_connect command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs.  With a
challenge, they must give a valid IP address.
=================
*/
SVC_GetChallenge
Returns a challenge number that can be used
in a subsequent client_connect command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs.  With a
challenge, they must give a valid IP address.
SVC_GetChallenge Returns a challenge number that can be used in a subsequent client_connect command . We do this to prevent denial of service attacks that flood the server with invalid connection IPs . With a challenge they must give a valid IP address .
void SVC_GetChallenge (void)
{
	int		i;
	int		oldest;
	int		oldestTime;
	oldest = 0;
	oldestTime = 0x7fffffff;
	for (i = 0 ; i < MAX_CHALLENGES ; i++)
	{
		if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
			break;
		if (svs.challenges[i].time < oldestTime)
		{
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}
	if (i == MAX_CHALLENGES)
	{
		svs.challenges[oldest].challenge = rand() & 0x7fff;
		svs.challenges[oldest].adr = net_from;
		svs.challenges[oldest].time = curtime;
		i = oldest;
	}
	Netchan_OutOfBandPrint (NS_SERVER, net_from, "challenge %i", svs.challenges[i].challenge);
}
void SVC_GetChallenge ( void ) { int i ; int oldest ; int oldestTime ; oldest = 0 ; oldestTime = 0x7fffffff ; for ( i = 0 ; i < MAX_CHALLENGES ; i ++ ) { if ( NET_CompareBaseAdr ( net_from , svs . challenges [ i ] . adr ) ) break ; if ( svs . challenges [ i ] . time < oldestTime ) { oldestTime = svs . challenges [ i ] . time ; oldest = i ; } } if ( i == MAX_CHALLENGES ) { svs . challenges [ oldest ] . challenge = rand ( ) & 0x7fff ; svs . challenges [ oldest ] . adr = net_from ; svs . challenges [ oldest ] . time = curtime ; i = oldest ; } Netchan_OutOfBandPrint ( NS_SERVER , net_from , " " , svs . challenges [ i ] . challenge ) ; }
SVC_GetChallenge
Returns a challenge number that can be used
in a subsequent client_connect command.
SVC_GetChallenge Returns a challenge number that can be used in a subsequent client_connect command .
// see if we already have a challenge for this ip // overwrite the oldest // send it back