From 61f66ae55458f25a8b28faae3206677a51d9a8ae Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Sat, 24 May 2025 01:57:10 +0100 Subject: [PATCH] Fix entity id size to fit the entity count --- dod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dod.c b/dod.c index 3d62f98..362c14b 100644 --- a/dod.c +++ b/dod.c @@ -21,7 +21,7 @@ enum EntityTag { typedef struct Entity Entity; struct Entity { - u16 id; + u32 id; }; typedef struct Position Position; @@ -137,7 +137,7 @@ void init_manager(const Allocator *allocator, Manager *manager) { assert(allocator != NULL && manager != NULL); u64 total_count = (u64)WANDERER_COUNT + (u64)ZONE_COUNT; - total_count += 4 - (total_count % 4); + assert(total_count < (1lu << 32)); // Ensure we're not exceeding the maximum limit of entities u64 entities_size = sizeof(Entity) * total_count; u64 rects_size = sizeof(Rect) * total_count;