moved code to remove tree info node to separate function
authorHolger Schemel <info@artsoft.org>
Sat, 30 Jan 2021 22:45:40 +0000 (23:45 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Jan 2021 22:45:40 +0000 (23:45 +0100)
src/libgame/setup.c
src/libgame/setup.h

index aca52f7db36ab9fa5ffea8c302a6428d0dfb76e4..4a630aa60fe066abbb9fb7e5c1265223e1323772 100644 (file)
@@ -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;
index 116ab776c4860ee47f1a107379becda621824264..7877ccb23246ce42c5fff8d6ba508239359c0144 100644 (file)
@@ -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 *);