From: Holger Schemel Date: Tue, 15 Feb 2022 16:50:36 +0000 (+0100) Subject: added function to add top tree node with back link X-Git-Tag: 4.3.2.0~126 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0105036fde3897cfe82618a09f440e4c973596f8;p=rocksndiamonds.git added function to add top tree node with back link --- 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);