added function to set all parent links in tree
authorHolger Schemel <info@artsoft.org>
Tue, 2 Feb 2021 16:49:30 +0000 (17:49 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 2 Feb 2021 16:49:30 +0000 (17:49 +0100)
src/libgame/setup.c

index 1298d9271e8108147d0b1e3fd97f9cf3b5a27169..192e2ce67e4d2b5307bdccf257e5ac9a4421563c 100644 (file)
@@ -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)