View Single Post
Author Message
hebusletroll
Senior Member
Join Date: Apr 2006
Old 09-20-2008 , 11:13   [BUG - RESOLVED] Infinite loop EngFunc_FindEntityInSphere for some maps
Reply With Quote #1

Hi Friends,

Since some days i've noticed a bug by using Find Entity In Sphere method that work fine on "basics" maps (that contain few entities), but make an infinite loop for maps like de_torn, de_airstrip, cs_manoir, etc.

After logging entity list, it appears that same entities are processed, when the count is over 32 entities in the sphere.

The loop will appears when the radius reach a certain ammount (approximatively 700.0 for de_airstrip).

Please note that the loop appears too when using engine method !!!!

I will provide my plugin test (use "dotest" command to spawn a entity) : when the entity is touching certains obstacle, the game is freezed.

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "TryIt"
#define VERSION "1.0"
#define AUTHOR "Hebusletroll"

#define modeltype "models/boid.mdl"

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("dotest","cmd_dotest")
	register_forward(FM_Touch,"try_touch")
}

public plugin_precache()
{
	precache_model(modeltype)
}

public cmd_dotest(id)
{
	static Float:origin[3],Float:velocity[3],Float:angles[3]
	if(is_user_alive(id))
	{
		new entity = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
		if(entity)
		{
			pev(id,pev_origin,origin)
			pev(id,pev_angles,angles)
			velocity_by_aim(id,750,velocity)
			set_pev(entity,pev_classname,"try")
			set_pev(entity,pev_model,modeltype)
			engfunc(EngFunc_SetModel, entity, modeltype)
			set_pev(entity,pev_velocity,velocity)
			set_pev(entity,pev_solid,SOLID_BBOX)
			set_pev(entity,pev_movetype,MOVETYPE_FLY)
			set_pev(entity,pev_owner,id)
			set_pev(entity,pev_origin,origin)
			set_pev(entity,pev_angles,angles)
		}
	}
	return FMRES_HANDLED
}

public try_touch(ptr,ptd)
{
	static ptrClassName[64],Float:origin[3],victim
	if(ptd!=pev(ptr,pev_owner))
	{
		pev(ptr,pev_classname,ptrClassName,sizeof(ptrClassName))
		if(equali(ptrClassName,"try"))
		{
			victim = -1
			pev(ptr,pev_origin,origin)
			while((victim=engfunc(EngFunc_FindEntityInSphere,victim,origin,700.0))!=0)
			{
				client_print(pev(ptr,pev_owner),print_chat,"Entity ID = %d",victim)
			}
			engfunc(EngFunc_RemoveEntity,ptr)
		}
	}
}
Here, you can find some screenshots where the game will freeze.





Any body has find an issue ?

Best regards.
__________________
Boring about playing same weapons ? PowerWeapons is available !
PowerWeapon v1.0 released !
Play up to 70 new weapons and create your own weapons !
Tested on Windows Server 2003, 2008/R2, 2012 and Linux Ubuntu 10.x and CentOs 6.x

Last edited by hebusletroll; 09-20-2008 at 12:08.
hebusletroll is offline