private static int GenerateAuthID( NetState state )
{
if ( m_AuthIDWindow.Count == m_AuthIDWindowSize ) {
int oldestID = 0;
DateTime oldest = DateTime.MaxValue;
foreach ( KeyValuePair<int, AuthIDPersistence> kvp in m_AuthIDWindow ) {
if ( kvp.Value.Age < oldest ) {
oldestID = kvp.Key;
oldest = kvp.Value.Age;
}
}
m_AuthIDWindow.Remove( oldestID );
}
int authID;
do {
authID = Utility.Random( 1, int.MaxValue - 1 );
if ( Utility.RandomBool() )
authID |= 1<<31;
} while ( m_AuthIDWindow.ContainsKey( authID ) );
m_AuthIDWindow[authID] = new AuthIDPersistence( state.Version );
return authID;
}