From: Holger Schemel Date: Sat, 30 Jan 2021 22:45:40 +0000 (+0100) Subject: moved code to remove tree info node to separate function X-Git-Tag: 4.2.3.0~37 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=076afecb45e19998ef5f8995774bc35ea0f1b4fc;p=rocksndiamonds.git moved code to remove tree info node to separate function --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index aca52f7d..4a630aa6 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1163,6 +1163,16 @@ void pushTreeInfo(TreeInfo **node_first, TreeInfo *node_new) *node_first = node_new; } +void removeTreeInfo(TreeInfo **node_first) +{ + TreeInfo *node_old = *node_first; + + *node_first = node_old->next; + node_old->next = NULL; + + freeTreeInfo(node_old); +} + int numTreeInfo(TreeInfo *node) { int num = 0; @@ -3989,12 +3999,7 @@ static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, // if sub-tree has no custom artwork at all, remove it if (artwork_new->node_group->next == NULL) - { - *artwork_node = artwork_new->next; - artwork_new->next = NULL; - - freeTreeInfo(artwork_new); - } + removeTreeInfo(artwork_node); } level_node = level_node->next; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 116ab776..7877ccb2 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -262,6 +262,7 @@ void InitLevelSetupDirectory(char *); TreeInfo *newTreeInfo(void); TreeInfo *newTreeInfo_setDefaults(int); void pushTreeInfo(TreeInfo **, TreeInfo *); +void removeTreeInfo(TreeInfo **); int numTreeInfo(TreeInfo *); boolean validLevelSeries(TreeInfo *); TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *);