From 54744343e9fb865e1b8954cef5b31328b86efb85 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 23 Jun 2023 18:46:56 +0300 Subject: [PATCH 17/17] Cleanup create_dummy_reqtree() a bit Sync with bits of changes going to older branches. See osdn #48274 Signed-off-by: Marko Lindqvist --- client/reqtree.c | 10 +++++----- common/tech.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/reqtree.c b/client/reqtree.c index ae0b3ad637..7e1156904e 100644 --- a/client/reqtree.c +++ b/client/reqtree.c @@ -389,7 +389,7 @@ static void calculate_diagram_layout(struct reqtree *tree) /*********************************************************************//** Create a "dummy" tech tree from current ruleset. This tree is then - fleshed out further (see create_reqtree). This tree doesn't include + fleshed out further (see create_reqtree() ). This tree doesn't include dummy edges. Layering and ordering isn't done also. If pplayer is given, add only techs reachable by that player to tree. @@ -400,8 +400,8 @@ static struct reqtree *create_dummy_reqtree(struct player *pplayer, const struct research *presearch = research_get(pplayer); struct reqtree *tree = fc_malloc(sizeof(*tree)); int j; - struct tree_node *nodes[advance_count()]; Tech_type_id ac = advance_count(); + struct tree_node *nodes[ac]; nodes[A_NONE] = NULL; advance_index_iterate_max(A_FIRST, tech, ac) { @@ -443,8 +443,8 @@ static struct reqtree *create_dummy_reqtree(struct player *pplayer, continue; } - /* Formerly, we used to remove the redundant requirement nodes (the - * technologies already included in the requirements of the other + /* Formerly, we used to remove the redundant requirement nodes + * (the technologies already included in the requirements of the other * requirement). However, it doesn't look like a good idea, because * a player can steal any technology independently of the technology * tree. */ @@ -458,7 +458,7 @@ static struct reqtree *create_dummy_reqtree(struct player *pplayer, /* Copy nodes from local array to dynamically allocated one. * Skip non-existing entries */ - tree->nodes = fc_calloc(advance_count(), sizeof(*tree->nodes)); + tree->nodes = fc_calloc(ac, sizeof(*tree->nodes)); j = 0; advance_index_iterate_max(A_FIRST, tech, ac) { if (nodes[tech]) { diff --git a/common/tech.h b/common/tech.h index 45ee87a7b9..f45aaac056 100644 --- a/common/tech.h +++ b/common/tech.h @@ -240,7 +240,7 @@ void techs_precalc_data(void); /* This iterates over almost all technologies. It includes non-existent * technologies, but not A_FUTURE. */ -#define advance_index_iterate(_start, _index) \ +#define advance_index_iterate(_start, _index) \ { \ advance_index_iterate_max(_start, _index, advance_count()) @@ -321,4 +321,4 @@ struct iterator *advance_root_req_iter_init(struct advance_root_req_iter *it, } #endif /* __cplusplus */ -#endif /* FC__TECH_H */ +#endif /* FC__TECH_H */ -- 2.40.1