Fixed get component error handling.
This commit is contained in:
parent
dc0a1f3656
commit
af46238076
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue