From 08ca8ca428f4483af4877a32a2704b1154cfb8bf Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 4 Feb 2023 05:19:41 +0200 Subject: [PATCH 13/13] 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 | 66 +++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/tools/civmanual.c b/tools/civmanual.c index 6e83627d69..2fcdc836ba 100644 --- a/tools/civmanual.c +++ b/tools/civmanual.c @@ -104,6 +104,7 @@ enum manuals { #define SUBITEM_BEGIN "
"
 #define SUBITEM_END "
\n" #define TAIL "" +#define HLINE "
" #else /* MANUAL_USE_HTML */ #define FILE_EXT "mediawiki" #define HEADER " " @@ -118,6 +119,7 @@ enum manuals { #define SUBITEM_BEGIN "\n" #define SUBITEM_END "\n" #define TAIL " " +#define HLINE "----" #endif /* MANUAL_USE_HTML */ void insert_client_build_info(char *outbuf, size_t outlen); @@ -515,7 +517,6 @@ static bool manual_command(void) improvement_iterate(pimprove) { char buf[64000]; - struct advance *obs_tech = NULL; if (!valid_improvement(pimprove) || is_great_wonder(pimprove) == (manuals == MANUAL_BUILDINGS)) { @@ -531,32 +532,47 @@ static bool manual_command(void) 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, "\n%s\n", HLINE); - fprintf(doc, "%s\n", - obs_tech != NULL - ? advance_name_translation(obs_tech) - : Q_("?tech:None")); - fprintf(doc, "%s\n\n\n", buf); + 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