View Single Post
  #1 (permalink)  
Old 06-21-2007, 02:40 PM
SamehSpiky SamehSpiky is offline
Newbie
 
Join Date: Jun 2007
Posts: 6
Rep Power: 0
SamehSpiky is on a distinguished road
Default small help in this generator function plz

are there better way to make this function faster and more powerfull?

the GetNewClientID function generates new ids for the players or the monsters whenever they die

now, i don't want this function to get the same id as the old one for the same monster/player

Code:
// This function gets a new clientID for a player, monster
unsigned CWorldServer::GetNewClientID( )
{
	for (unsigned i=1; i<=0xffff; i++) 
    {
		if (ClientIDList[i]!=0 && time(NULL)-ClientIDList[i]>10) 
        {
			ClientIDList[i] = 0;
			return i;
		}
	}
	return 0;
}

// This function will free our clientID
void CWorldServer::ClearClientID( unsigned int id )
{
	ClientIDList[id] = (unsigned)time(NULL);
}
Reply With Quote

Sponsored Links