This function is used to get an entity from an array.
dg_entity_t *dg_get_entity(dg_array_t *entities, char *name);
dg_entity_t *entity = dg_get_entity(entities, "mouse");
dg_entity_t *dg_get_entity(dg_array_t *entities, char *name)
{
dg_entity_t *ent = 0;
if (!entities || !name)
return 0;
while (entities && entities->data) {
ent = ((dg_entity_t *)(entities->data));
if (!dg_strcmp(ent->name, name))
return ent;
entities = entities->next;
}
return 0;
}