From: Holger Schemel Date: Tue, 2 Feb 2021 16:49:30 +0000 (+0100) Subject: added function to set all parent links in tree X-Git-Tag: 4.2.3.0~28 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=31dcabc4f4e981a616b0e0d5fda7c32eef1c0596;p=rocksndiamonds.git added function to set all parent links in tree --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 1298d927..192e2ce6 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -2934,6 +2934,19 @@ static TreeInfo *createTopTreeInfoNode(TreeInfo *node_first) return ti_new; } +static void setTreeInfoParentNodes(TreeInfo *node, TreeInfo *node_parent) +{ + while (node) + { + if (node->node_group) + setTreeInfoParentNodes(node->node_group, node); + + node->node_parent = node_parent; + + node = node->next; + } +} + // ---------------------------------------------------------------------------- // functions for handling level and custom artwork info cache @@ -4048,10 +4061,15 @@ static void LoadArtworkInfoFromLevelInfoExt(ArtworkDirTree **artwork_node, static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node) { + // move peviously loaded artwork tree into separate sub-tree MoveArtworkInfoIntoSubTree(artwork_node); + // load artwork from level sets into separate sub-trees LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, TRUE); LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, FALSE); + + // set all parent links (back links) in complete artwork tree + setTreeInfoParentNodes(*artwork_node, NULL); } void LoadLevelArtworkInfo(void)