From 91effb6e25573555acf9df6ff9b8c776c8169b50 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 20 May 2021 17:09:17 +0300 Subject: [PATCH 42/42] validity.c: Use ..._active_iterate() macros where appropriate It was erroneously considering even removed items (those that the regular iterator goes through) blockers for removal of dependant items. See osdn #42173 Signed-off-by: Marko Lindqvist --- tools/ruledit/validity.c | 42 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/ruledit/validity.c b/tools/ruledit/validity.c index a24ea4227f..09e5adf049 100644 --- a/tools/ruledit/validity.c +++ b/tools/ruledit/validity.c @@ -73,48 +73,46 @@ static bool is_universal_needed(struct universal *uni, requirers_cb cb, } } disaster_type_iterate_end; - improvement_iterate(pimprove) { + improvement_active_iterate(pimprove) { if (universal_is_mentioned_by_requirements(&pimprove->reqs, uni) || universal_is_mentioned_by_requirements(&pimprove->obsolete_by, uni)) { cb(improvement_rule_name(pimprove), data); needed = TRUE; } - } improvement_iterate_end; + } improvement_active_iterate_end; - governments_iterate(pgov) { + governments_active_iterate(pgov) { if (universal_is_mentioned_by_requirements(&pgov->reqs, uni)) { cb(government_rule_name(pgov), data); needed = TRUE; } - } governments_iterate_end; - - specialist_type_iterate(sp) { - struct specialist *psp = specialist_by_number(sp); + } governments_active_iterate_end; + specialist_active_type_iterate(psp) { if (universal_is_mentioned_by_requirements(&psp->reqs, uni)) { cb(specialist_rule_name(psp), data); needed = TRUE; } - } specialist_type_iterate_end; + } specialist_active_type_iterate_end; - extra_type_iterate(pextra) { + extra_active_type_iterate(pextra) { if (universal_is_mentioned_by_requirements(&pextra->reqs, uni) || universal_is_mentioned_by_requirements(&pextra->rmreqs, uni)) { cb(extra_rule_name(pextra), data); needed = TRUE; } - } extra_type_iterate_end; + } extra_active_type_iterate_end; - goods_type_iterate(pgood) { + goods_active_type_iterate(pgood) { if (universal_is_mentioned_by_requirements(&pgood->reqs, uni)) { cb(goods_rule_name(pgood), data); needed = TRUE; } - } goods_type_iterate_end; + } goods_active_type_iterate_end; action_iterate(act) { - action_enabler_list_iterate(action_enablers_for_action(act), enabler) { + action_enabler_list_re_iterate(action_enablers_for_action(act), enabler) { if (universal_is_mentioned_by_requirements(&(enabler->actor_reqs), uni) || universal_is_mentioned_by_requirements(&(enabler->target_reqs), @@ -122,7 +120,7 @@ static bool is_universal_needed(struct universal *uni, requirers_cb cb, cb(R__("Action Enabler"), data); needed = TRUE; } - } action_enabler_list_iterate_end; + } action_enabler_list_re_iterate_end; } action_iterate_end; for (i = 0; i < game.control.styles_count; i++) { @@ -162,23 +160,23 @@ bool is_tech_needed(struct advance *padv, requirers_cb cb, void *data) struct universal uni = { .value.advance = padv, .kind = VUT_ADVANCE }; bool needed = FALSE; - advance_iterate(A_FIRST, pdependant) { + advance_active_iterate(pdependant) { if (pdependant->require[AR_ONE] == padv || pdependant->require[AR_TWO] == padv || pdependant->require[AR_ROOT] == padv) { cb(advance_rule_name(pdependant), data); needed = TRUE; } - } advance_iterate_end; + } advance_active_iterate_end; - unit_type_iterate(ptype) { + unit_active_type_iterate(ptype) { if (ptype->require_advance == padv) { cb(utype_rule_name(ptype), data); needed = TRUE; } - } unit_type_iterate_end; + } unit_active_type_iterate_end; - extra_type_iterate(pextra) { + extra_active_type_iterate(pextra) { if (pextra->visibility_req == advance_number(padv)) { char buf[512]; @@ -186,7 +184,7 @@ bool is_tech_needed(struct advance *padv, requirers_cb cb, void *data) extra_rule_name(pextra)); cb(buf, data); } - } extra_type_iterate_end; + } extra_active_type_iterate_end; needed |= is_universal_needed(&uni, cb, data); @@ -247,10 +245,10 @@ bool is_extra_needed(struct extra_type *pextra, requirers_cb cb, bool hides = FALSE; int id = extra_index(pextra); - extra_type_iterate(requirer) { + extra_active_type_iterate(requirer) { conflicts |= BV_ISSET(requirer->conflicts, id); hides |= BV_ISSET(requirer->hidden_by, id); - } extra_type_iterate_end; + } extra_active_type_iterate_end; if (conflicts) { cb(R__("Conflicting extra"), data); -- 2.30.2