From 1dfcffcf3259f6be3c1b74d865cf18a27095616f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 4 Feb 2023 05:15:21 +0200 Subject: [PATCH 26/26] freeciv-manual: Improve listing of buildings' build/obsoleting reqs - Show "None" for an empty build requirement list - Have a separator between build and obsoletion requirements - List all obsoletion requirements, not just single tech See osdn #47297 Signed-off-by: Marko Lindqvist --- tools/civmanual.c | 75 ++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/tools/civmanual.c b/tools/civmanual.c index 621cc20420..f1a4b7b187 100644 --- a/tools/civmanual.c +++ b/tools/civmanual.c @@ -100,6 +100,7 @@ struct tag_types { const char *subitem_begin; const char *subitem_end; const char *tail; + const char *hline; }; struct tag_types html_tags = { @@ -142,7 +143,10 @@ struct tag_types html_tags = { "\n", /* tail */ - "" + "", + + /* horizontal line */ + "
" }; struct tag_types wiki_tags = { @@ -183,7 +187,10 @@ struct tag_types wiki_tags = { "\n", /* tail */ - " " + " ", + + /* horizontal line */ + "----" }; @@ -594,7 +601,6 @@ static bool manual_command(struct tag_types *tag_info) improvement_iterate(pimprove) { char buf[64000]; - struct advance *obs_tech = NULL; if (!valid_improvement(pimprove) || is_great_wonder(pimprove) == (manuals == MANUAL_BUILDINGS)) { @@ -610,32 +616,47 @@ static bool manual_command(struct tag_types *tag_info) pimprove->build_cost, pimprove->upkeep); - requirement_vector_iterate(&pimprove->reqs, req) { - char text[512], text2[512]; - - fc_snprintf(text2, sizeof(text2), - /* TRANS: improvement requires a feature to be absent. */ - req->present ? "%s" : _("no %s"), - VUT_NONE != req->source.kind - ? universal_name_translation(&req->source, - text, sizeof(text)) - : Q_("?req:None")); - fprintf(doc, "%s
", text2); - } requirement_vector_iterate_end; - - requirement_vector_iterate(&pimprove->obsolete_by, pobs) { - if (pobs->source.kind == VUT_ADVANCE && pobs->present) { - obs_tech = pobs->source.value.advance; - break; - } - } requirement_vector_iterate_end; + if (requirement_vector_size(&pimprove->reqs) == 0) { + char text[512]; + + strncpy(text, Q_("?req:None"), sizeof(text) - 1); + fprintf(doc, "%s
", text); + } else { + requirement_vector_iterate(&pimprove->reqs, req) { + char text[512], text2[512]; + + fc_snprintf(text2, sizeof(text2), + /* TRANS: Feature required to be absent. */ + req->present ? "%s" : _("no %s"), + universal_name_translation(&req->source, + text, sizeof(text))); + fprintf(doc, "%s
", text2); + } requirement_vector_iterate_end; + } - fprintf(doc, "%s\n", - obs_tech != NULL - ? advance_name_translation(obs_tech) - : Q_("?tech:None")); - fprintf(doc, "%s\n\n\n", buf); + fprintf(doc, "\n%s\n", tag_info->hline); + + if (requirement_vector_size(&pimprove->obsolete_by) == 0) { + char text[512]; + + strncpy(text, Q_("?req:None"), sizeof(text) - 1); + fprintf(doc, "%s
", text); + } else { + requirement_vector_iterate(&pimprove->obsolete_by, pobs) { + char text[512], text2[512]; + + fc_snprintf(text2, sizeof(text2), + /* TRANS: Feature required to be absent. */ + pobs->present ? "%s" : _("no %s"), + universal_name_translation(&pobs->source, + text, sizeof(text))); + fprintf(doc, "%s
", text2); + } requirement_vector_iterate_end; + } + + fprintf(doc, "\n%s\n\n\n", buf); } improvement_iterate_end; + fprintf(doc, ""); break; -- 2.39.1