Fixed get component error handling.

This commit is contained in:
Ulysse Cura 2026-08-04 01:54:54 +02:00
parent dc0a1f3656
commit af46238076
1 changed files with 4 additions and 3 deletions

View File

@ -105,14 +105,15 @@ static inline bool condition_is_component_type(elem_t *elem, va_list args)
inline component_t *entity_get_component(entity_t *entity, component_type_t component_type)
{
elem_t *elem = linked_list_get_if(&entity->components, condition_is_component_type, component_type);
component_t *component = elem->data;
if(!component)
elem_t *component_elem = linked_list_get_if(&entity->components, condition_is_component_type, component_type);
if(!component_elem)
{
error_printf("Entity with id:%lu doesn't have componant of type : %d", entity->id, component_type);
return NULL;
}
component_t *component = component_elem->data;
return component;
}