The IDLE link-list does more than JUST allow the action to self-terminate.
It is also an INSTANT way to grab an idle entity. Just grab the first in the list.
That way you dont need to wade through potentially dozens of active entities
when trying to find an idle one to re-use.
And (from memory) it was only like 3 lines of code to make an entity switch lists.
The IDLE list was only implemented single-directional searches. Thats all it needed.


How do you NORMALLY tell ent_create what action to use? Do the same for ent_create_2!
Code:
void action_ptr(ENTITY* ME);	//an empty function pointer

...


ENTITY* ent_create_2(STRING* filename, VECTOR* position,  EVENT my_action)
{
	ENTITY*  entity_to_reuse = something;
	...
	action_ptr=my_action;	action_ptr( entity_to_reuse );	action_ptr=NULL;
}



As for the events... have the funct/action ITSELF shut them down. Put the event-disabling
code AFTER the while loop. So when the entity recognises it is idle, and exists the loop,
it will then disable its own events...

Code:
void False_Action(ENTITY* ME)
{
   me=ME;
   my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY);
   my.event = blablabla_event;

   while(my.skill25==1)
   {
      //do whatever the action would do
      wait(1);
   }

   my.emask &= ~(ENABLE_BLOCK | ENABLE_ENTITY);  
   my.event = NULL;
}




Last edited by EvilSOB; 11/01/11 03:20. Reason: added function pointer info

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial