From: Holger Schemel Date: Fri, 3 Sep 2021 12:55:32 +0000 (+0200) Subject: added leaf node count to level/artwork tree info dump X-Git-Tag: 4.3.0.0~87 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d6481c93d4463ebaf584d390101fb191eb531665;p=rocksndiamonds.git added leaf node count to level/artwork tree info dump --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index bda89ee3..9c6ddfe6 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1491,9 +1491,10 @@ static boolean adjustTreeSoundsForEMC(TreeInfo *node) return settings_changed; } -void dumpTreeInfo(TreeInfo *node, int depth) +int dumpTreeInfo(TreeInfo *node, int depth) { char bullet_list[] = { '-', '*', 'o' }; + int num_leaf_nodes = 0; int i; if (depth == 0) @@ -1511,6 +1512,9 @@ void dumpTreeInfo(TreeInfo *node, int depth) (node->node_parent ? node->node_parent->identifier : "-"), (node->node_group ? "[GROUP]" : "")); + if (!node->node_group && !node->parent_link) + num_leaf_nodes++; + /* // use for dumping artwork info tree Debug("tree", "subdir == '%s' ['%s', '%s'] [%d])", @@ -1518,10 +1522,15 @@ void dumpTreeInfo(TreeInfo *node, int depth) */ if (node->node_group != NULL) - dumpTreeInfo(node->node_group, depth + 1); + num_leaf_nodes += dumpTreeInfo(node->node_group, depth + 1); node = node->next; } + + if (depth == 0) + Debug("tree", "Summary: %d leaf nodes found", num_leaf_nodes); + + return num_leaf_nodes; } void sortTreeInfoBySortFunction(TreeInfo **node_first, diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 4e68c596..b312caac 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -309,7 +309,7 @@ int numTreeInfoInGroup(TreeInfo *); int getPosFromTreeInfo(TreeInfo *); TreeInfo *getTreeInfoFromPos(TreeInfo *, int); TreeInfo *getTreeInfoFromIdentifier(TreeInfo *, char *); -void dumpTreeInfo(TreeInfo *, int); +int dumpTreeInfo(TreeInfo *, int); void sortTreeInfoBySortFunction(TreeInfo **, int (*compare_function)(const void *, const void *));