From 8954cf31a0e90bbe4fe784cd8fbfc4d4089d0d6d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 7 Oct 2023 21:51:32 +0300 Subject: [PATCH 62/63] Split Governments manuals creation to separate source file See osdn #48814 Signed-off-by: Marko Lindqvist --- meson.build | 1 + tools/manual/Makefile.am | 1 + tools/manual/fc_manual.c | 34 ++------------- tools/manual/fc_manual.h | 1 + tools/manual/manual_governments.c | 69 +++++++++++++++++++++++++++++++ translations/core/POTFILES.in | 1 + 6 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 tools/manual/manual_governments.c diff --git a/meson.build b/meson.build index e7b7cfdae4..f399822d29 100644 --- a/meson.build +++ b/meson.build @@ -4272,6 +4272,7 @@ executable('freeciv-manual', 'tools/manual/fc_manual.c', 'tools/manual/manual_buildings.c', 'tools/manual/manual_commands.c', + 'tools/manual/manual_governments.c', 'tools/manual/manual_settings.c', 'tools/manual/manual_terrain.c', 'client/helpdata.c', diff --git a/tools/manual/Makefile.am b/tools/manual/Makefile.am index d2ec327156..72ade631f4 100644 --- a/tools/manual/Makefile.am +++ b/tools/manual/Makefile.am @@ -22,6 +22,7 @@ freeciv_manual_SOURCES = \ fc_manual.h \ manual_buildings.c \ manual_commands.c \ + manual_governments.c \ manual_settings.c \ manual_terrain.c diff --git a/tools/manual/fc_manual.c b/tools/manual/fc_manual.c index 9ae48f5824..bc2d182459 100644 --- a/tools/manual/fc_manual.c +++ b/tools/manual/fc_manual.c @@ -35,28 +35,20 @@ /* common */ #include "capstr.h" #include "connection.h" -#include "events.h" #include "fc_cmdhelp.h" #include "fc_interface.h" -#include "fc_types.h" /* LINE_BREAK */ -#include "government.h" -#include "improvement.h" -#include "map.h" #include "movement.h" -#include "player.h" #include "version.h" /* client */ #include "client_main.h" #include "climisc.h" #include "helpdata.h" -#include "helpdlg_g.h" #include "music.h" #include "tilespec.h" /* server */ #include "citytools.h" -#include "commands.h" #include "connecthand.h" #include "console.h" #include "diplhand.h" @@ -356,11 +348,12 @@ static bool manual_command(struct tag_types *tag_info) if (!manual_settings(tag_info) || !manual_commands(tag_info) || !manual_terrain(tag_info) - || !manual_buildings(tag_info)) { + || !manual_buildings(tag_info) + || !manual_governments(tag_info)) { return FALSE; } - for (manuals = MANUAL_GOVS; manuals < MANUAL_COUNT; manuals++) { + for (manuals = MANUAL_UNITS; manuals < MANUAL_COUNT; manuals++) { FILE *doc; doc = manual_start(tag_info, manuals); @@ -375,30 +368,11 @@ static bool manual_command(struct tag_types *tag_info) case MANUAL_TERRAIN: case MANUAL_BUILDINGS: case MANUAL_WONDERS: + case MANUAL_GOVS: /* Should be handled in separate functions */ fc_assert(FALSE); break; - case MANUAL_GOVS: - /* Freeciv-web uses (parts of) the government HTML output in its own - * manual pages. */ - /* FIXME: this doesn't resemble the wiki manual at all. */ - /* TRANS: markup ... Freeciv version ... ruleset name ... markup */ - fprintf(doc, _("%sFreeciv %s governments help (%s)%s\n\n"), tag_info->title_begin, - VERSION_STRING, game.control.name, tag_info->title_end); - governments_iterate(pgov) { - char buf[64000]; - fprintf(doc, tag_info->item_begin, "gov", pgov->item_number); - fprintf(doc, "%s%s%s\n\n", tag_info->sect_title_begin, - government_name_translation(pgov), tag_info->sect_title_end); - fprintf(doc, tag_info->subitem_begin, "helptext"); - helptext_government(buf, sizeof(buf), NULL, NULL, pgov); - fprintf(doc, "%s\n\n", buf); - fprintf(doc, "%s", tag_info->subitem_end); - fprintf(doc, "%s", tag_info->item_end); - } governments_iterate_end; - break; - case MANUAL_UNITS: /* Freeciv-web uses (parts of) the unit type HTML output in its own * manual pages. */ diff --git a/tools/manual/fc_manual.h b/tools/manual/fc_manual.h index 2af7171b7b..a3ba1dd99a 100644 --- a/tools/manual/fc_manual.h +++ b/tools/manual/fc_manual.h @@ -53,6 +53,7 @@ bool manual_settings(struct tag_types *tag_info); bool manual_commands(struct tag_types *tag_info); bool manual_terrain(struct tag_types *tag_info); bool manual_buildings(struct tag_types *tag_info); +bool manual_governments(struct tag_types *tag_info); #ifdef __cplusplus } diff --git a/tools/manual/manual_governments.c b/tools/manual/manual_governments.c new file mode 100644 index 0000000000..4e76259f69 --- /dev/null +++ b/tools/manual/manual_governments.c @@ -0,0 +1,69 @@ +/*********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* utility */ +#include "fcintl.h" + +/* common */ +#include "game.h" +#include "government.h" + +/* client */ +#include "helpdata.h" + +/* tools/manual */ +#include "fc_manual.h" + +/**********************************************************************//** + Write governments manual page + + @param tag_info Tag set to use + @return Success +**************************************************************************/ +bool manual_governments(struct tag_types *tag_info) +{ + FILE *doc; + + doc = manual_start(tag_info, MANUAL_GOVS); + + if (doc == NULL) { + return FALSE; + } + + /* Freeciv-web uses (parts of) the government HTML output in its own + * manual pages. */ + /* FIXME: this doesn't resemble the wiki manual at all. */ + /* TRANS: markup ... Freeciv version ... ruleset name ... markup */ + fprintf(doc, _("%sFreeciv %s governments help (%s)%s\n\n"), tag_info->title_begin, + VERSION_STRING, game.control.name, tag_info->title_end); + governments_iterate(pgov) { + char buf[64000]; + + fprintf(doc, tag_info->item_begin, "gov", pgov->item_number); + fprintf(doc, "%s%s%s\n\n", tag_info->sect_title_begin, + government_name_translation(pgov), tag_info->sect_title_end); + fprintf(doc, tag_info->subitem_begin, "helptext"); + helptext_government(buf, sizeof(buf), NULL, NULL, pgov); + fprintf(doc, "%s\n\n", buf); + fprintf(doc, "%s", tag_info->subitem_end); + fprintf(doc, "%s", tag_info->item_end); + } governments_iterate_end; + + manual_finalize(tag_info, doc, MANUAL_GOVS); + + return TRUE; +} diff --git a/translations/core/POTFILES.in b/translations/core/POTFILES.in index dc1b72c990..b6c251545b 100644 --- a/translations/core/POTFILES.in +++ b/translations/core/POTFILES.in @@ -395,6 +395,7 @@ tools/fcmp/mpgui_qt_worker.cpp tools/manual/fc_manual.c tools/manual/manual_buildings.c tools/manual/manual_commands.c +tools/manual/manual_governments.c tools/manual/manual_settings.c tools/manual/manual_terrain.c tools/ruleutil/rulesave.c -- 2.40.1