From 80c0beff89958ea959a22cbafd3a18512ff7731d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 27 Oct 2022 19:46:28 +0900 Subject: [PATCH] [ecs] Support adding null hierarchies to non-root As an implementation detail, inserting null hierarchies (src hierarchy is null) is supported for ease of hierarchy construction from data. No component data is copied, only the child and parent indices and counts are updated. --- libs/ecs/hierarchy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ecs/hierarchy.c b/libs/ecs/hierarchy.c index 4d8786fe7..38fd4523b 100644 --- a/libs/ecs/hierarchy.c +++ b/libs/ecs/hierarchy.c @@ -271,7 +271,9 @@ Hierarchy_InsertHierarchy (hierarchy_t *dst, const hierarchy_t *src, Sys_Error ("attempt to insert root in non-empty hierarchy"); } hierarchy_open (dst, 0, 1); - hierarchy_move (dst, src, 0, srcRoot, 1); + if (src) { + hierarchy_move (dst, src, 0, srcRoot, 1); + } dst->parentIndex[0] = nullent; dst->childIndex[0] = 1; dst->childCount[0] = 0;