From 41a7f22cb3907142b8ec196fcbdbd53e80c722a7 Mon Sep 17 00:00:00 2001 From: Mergul Date: Sat, 29 Sep 2018 11:53:22 +0200 Subject: [PATCH] -fixed optional components issue --- source/ecs/manager.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ecs/manager.d b/source/ecs/manager.d index 31334b3..576874d 100644 --- a/source/ecs/manager.d +++ b/source/ecs/manager.d @@ -150,8 +150,8 @@ class EntityManager if (isPointer!param) { ret ~= "PointerTarget!(types[" ~ i.to!string - ~ "])[] opt_array" ~ opt.to!string ~ ";"; - ret ~= "if(info.deltas[types[" ~ i.to!string ~ "].component_id] != ushort.max)opt_array" + ~ "])[] opt_array" ~ opt.to!string ~ " = null;"; + ret ~= "if(info.deltas[types[" ~ i.to!string ~ "].component_id] != 0)opt_array" ~ opt.to!string ~ " = (cast(types[" ~ i.to!string ~ "])(cast(void*)block + info.deltas[types[" ~ i.to!string ~ "].component_id]))[0..block.entities_count];"; @@ -266,7 +266,7 @@ class EntityManager foreach (i, ref pointer; optional_pointers) { uint ind = cast(uint)(i + pointers.length); - if (data.deltas[ind] != uint.max) + if (data.deltas[ind] != 0) pointer = data_pointer + data.deltas[ind]; else pointer = null;