From 8d2e9e21529dc319434b41ef95ecc6364c806fb5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 3 Sep 2021 15:22:48 +0200 Subject: [PATCH] fixed tree node navigation bug (when stepping up empty sub-trees) --- src/libgame/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index dfd9ac61..403d0dae 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1300,10 +1300,11 @@ TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) if (node->parent_link) // skip first node (back link) of node group { - if (node->next) // get next regular node - return getFirstValidTreeInfoEntry(node->next); - else // leave empty node group and go on - return getFirstValidTreeInfoEntry(node->node_parent->next); + // get next regular tree node, or step up until one is found + while (node->next == NULL && node->node_parent != NULL) + node = node->node_parent; + + return getFirstValidTreeInfoEntry(node->next); } // this is a regular tree node -- 2.34.1