From 0605d4dbc331e1e12e4665a2ff960c9c4375d927 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Sun, 24 Aug 2025 14:22:43 +0200 Subject: [PATCH] packed and aligned structures, might be the error for entities assignement --- src/game_data/ecs/animation_system.hpp | 2 +- src/game_data/ecs/ecs.hpp | 4 ++-- src/game_data/ecs/sprite_component.hpp | 2 +- src/game_data/ecs/transform_component.hpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game_data/ecs/animation_system.hpp b/src/game_data/ecs/animation_system.hpp index 70ec833..0708184 100644 --- a/src/game_data/ecs/animation_system.hpp +++ b/src/game_data/ecs/animation_system.hpp @@ -11,6 +11,6 @@ typedef struct animation_system_data_t { bool play; bool loop; bool reverse; -} animation_system_data_t; +} __attribute__((packed, aligned(4))) animation_system_data_t; #endif // SPRITE_COMPONENT_H \ No newline at end of file diff --git a/src/game_data/ecs/ecs.hpp b/src/game_data/ecs/ecs.hpp index d210bc0..251f3b6 100644 --- a/src/game_data/ecs/ecs.hpp +++ b/src/game_data/ecs/ecs.hpp @@ -19,12 +19,12 @@ typedef struct component_t { sprite_component_data_t *sprite_component_data; animation_system_data_t *animation_system_data; } component_data; -} component_t; +} __attribute__((packed, aligned(4))) component_t; typedef struct entity_t { uint16_t id; uint32_t nb_component; component_t *components; -} entity_t; +} __attribute__((packed, aligned(4))) entity_t; #endif // ECS_H \ No newline at end of file diff --git a/src/game_data/ecs/sprite_component.hpp b/src/game_data/ecs/sprite_component.hpp index b9826c9..3e7071b 100644 --- a/src/game_data/ecs/sprite_component.hpp +++ b/src/game_data/ecs/sprite_component.hpp @@ -3,6 +3,6 @@ typedef struct sprite_component_data_t { const char *texture_name; -} sprite_component_data_t; +} __attribute__((packed, aligned(4))) sprite_component_data_t; #endif // SPRITE_COMPONENT_H \ No newline at end of file diff --git a/src/game_data/ecs/transform_component.hpp b/src/game_data/ecs/transform_component.hpp index 92b9ca9..7fdeeef 100644 --- a/src/game_data/ecs/transform_component.hpp +++ b/src/game_data/ecs/transform_component.hpp @@ -4,7 +4,7 @@ typedef struct transform_component_data_t { uint32_t x, y; uint32_t w, h; - float speed; -} transform_component_data_t; + uint32_t speed; +} __attribute__((packed, aligned(4))) transform_component_data_t; #endif // TRANSFORM_COMPONENT_H \ No newline at end of file