From: Holger Schemel Date: Fri, 3 Sep 2021 13:40:34 +0000 (+0200) Subject: added function to get next valid tree node X-Git-Tag: 4.3.0.0~83 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e3eb198296f9af373fa51c7a30f3a9ae27870808;p=rocksndiamonds.git added function to get next valid tree node --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 403d0dae..60ec59f3 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1290,7 +1290,7 @@ TreeInfo *getValidLevelSeries(TreeInfo *node, TreeInfo *default_node) return getFirstValidTreeInfoEntry(default_node); } -TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) +static TreeInfo *getValidTreeInfoEntryExt(TreeInfo *node, boolean get_next_node) { if (node == NULL) return NULL; @@ -1299,6 +1299,9 @@ TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) return getFirstValidTreeInfoEntry(node->node_group); if (node->parent_link) // skip first node (back link) of node group + get_next_node = TRUE; + + if (get_next_node) { // get next regular tree node, or step up until one is found while (node->next == NULL && node->node_parent != NULL) @@ -1311,6 +1314,16 @@ TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) return node; } +TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) +{ + return getValidTreeInfoEntryExt(node, FALSE); +} + +TreeInfo *getNextValidTreeInfoEntry(TreeInfo *node) +{ + return getValidTreeInfoEntryExt(node, TRUE); +} + TreeInfo *getTreeInfoFirstGroupEntry(TreeInfo *node) { if (node == NULL) diff --git a/src/libgame/setup.h b/src/libgame/setup.h index b312caac..1a79b558 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -304,6 +304,7 @@ int numTreeInfo(TreeInfo *); boolean validLevelSeries(TreeInfo *); TreeInfo *getValidLevelSeries(TreeInfo *, TreeInfo *); TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *); +TreeInfo *getNextValidTreeInfoEntry(TreeInfo *); TreeInfo *getTreeInfoFirstGroupEntry(TreeInfo *); int numTreeInfoInGroup(TreeInfo *); int getPosFromTreeInfo(TreeInfo *);