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);
}