From af462380762093bee9e471799c7ce31732a4b248 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Tue, 4 Aug 2026 01:54:54 +0200 Subject: [PATCH] Fixed get component error handling. --- src/ecs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ecs.c b/src/ecs.c index e4d3161..8dd2382 100644 --- a/src/ecs.c +++ b/src/ecs.c @@ -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; }