Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 10-12-2012, 08:44 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Maybe a sanity check is needed for "while(1)" ?

Code:
int16 EntityList::GetFreeID()
{
	if(last_insert_id > 1500)
		last_insert_id = 0;
	int16 getid=last_insert_id;
	while(1)
	{
		getid++;
		if (GetID(getid) == 0)
		{
			last_insert_id = getid;
			return getid;
		}
	}
}
Seems like that could easily cause an infinite loop if last_insert_id is really high to begin with. Either way, it seems like a bad idea to use "while(1)" to me.

Here is EntityList::GetID() for reference:

Code:
Entity* EntityList::GetID(int16 get_id)
{
	Entity* ent=0;
	if((ent=entity_list.GetEntityMob(get_id))!=0)
		return ent;
	else if((ent=entity_list.GetEntityDoor(get_id))!=0)
		return ent;
	else if((ent=entity_list.GetEntityCorpse(get_id))!=0)
		return ent;
//	else if((ent=entity_list.GetEntityGroup(get_id))!=0)
//		return ent;
	else if((ent=entity_list.GetEntityObject(get_id))!=0)
		return ent;
	else if((ent=entity_list.GetEntityTrap(get_id))!=0)
		return ent;
	else if((ent=entity_list.GetEntityBeacon(get_id))!=0)
		return ent;
	else
		return 0;
}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-12-2012 at 08:52 AM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:11 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3