From 0105036fde3897cfe82618a09f440e4c973596f8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 15 Feb 2022 17:50:36 +0100 Subject: [PATCH] added function to add top tree node with back link --- src/libgame/setup.c | 18 +++++++++++++----- src/libgame/setup.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index d81cb8b5..88762de4 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3080,6 +3080,17 @@ static void setTreeInfoParentNodes(TreeInfo *node, TreeInfo *node_parent) } } +TreeInfo *addTopTreeInfoNode(TreeInfo *node_first) +{ + // add top tree node with back link node in previous tree + node_first = createTopTreeInfoNode(node_first); + + // set all parent links (back links) in complete tree + setTreeInfoParentNodes(node_first, NULL); + + return node_first; +} + // ---------------------------------------------------------------------------- // functions for handling level and custom artwork info cache @@ -4214,11 +4225,8 @@ static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node) LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, TRUE); LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, FALSE); - // add top tree node over all three separate sub-trees - *artwork_node = createTopTreeInfoNode(*artwork_node); - - // set all parent links (back links) in complete artwork tree - setTreeInfoParentNodes(*artwork_node, NULL); + // add top tree node over all sub-trees and set parent links + *artwork_node = addTopTreeInfoNode(*artwork_node); } void LoadLevelArtworkInfo(void) diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 4a779440..36df605e 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -320,6 +320,7 @@ void sortTreeInfoBySortFunction(TreeInfo **, const void *)); void sortTreeInfo(TreeInfo **); void freeTreeInfo(TreeInfo *); +TreeInfo *addTopTreeInfoNode(TreeInfo *); char *getHomeDir(void); char *getPersonalDataDir(void); -- 2.34.1