X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=403d0dae558baa641d5ebf618fb45a8e514fe9c3;hp=dfd9ac612eb4127d6a0c4496bc1f9ee552f5c42e;hb=8d2e9e21529dc319434b41ef95ecc6364c806fb5;hpb=767fdb2a9a16a0e09c3b8f724ef81e6f512fcaf3 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