As for the ent_next, I would try to avoid cycling through all entities, I think this might be slow too (on big levels). Let's say you have 1000 entities on the level (sprites, models, etc) and you only need 100 of them, so instead of cycling through all 1000 and finding those that 100 you need, you can right at the start of the level, add those 100 into ENTITY array list (don't forget to have integer counter, to register total amount of entities) and then cycle within that list.
Code
ENTITY *list[999];

int counter = 0;

action add_to_list()
{
	list[counter] = my;
	counter++;
}

void cycle_in_list()
{
	int i = 0;
	for(i = 0; i < counter - 1; i++)
	{
		if(list[i] == NULL)
		{
			continue;
		}
		
		// do something with the entity
		
	}
}


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung