From 9e4d41cce49ab4b9abba07cf80119b0968c9a56b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 15 Oct 2023 19:40:14 +0300 Subject: [PATCH 30/30] Split Techs manuals creation to separate source file See osdn #48674 Signed-off-by: Marko Lindqvist --- meson.build | 1 + tools/manual/Makefile.am | 1 + tools/manual/fc_manual.c | 44 +-------------------- tools/manual/fc_manual.h | 1 + tools/manual/manual_techs.c | 72 +++++++++++++++++++++++++++++++++++ translations/core/POTFILES.in | 1 + 6 files changed, 78 insertions(+), 42 deletions(-) create mode 100644 tools/manual/manual_techs.c diff --git a/meson.build b/meson.build index 1ee100452f..6081c0e06c 100644 --- a/meson.build +++ b/meson.build @@ -4300,6 +4300,7 @@ executable('freeciv-manual', 'tools/manual/manual_commands.c', 'tools/manual/manual_governments.c', 'tools/manual/manual_settings.c', + 'tools/manual/manual_techs.c', 'tools/manual/manual_terrain.c', 'tools/manual/manual_units.c', 'client/helpdata.c', diff --git a/tools/manual/Makefile.am b/tools/manual/Makefile.am index bc7c41c4d8..eb7ebeee39 100644 --- a/tools/manual/Makefile.am +++ b/tools/manual/Makefile.am @@ -24,6 +24,7 @@ freeciv_manual_SOURCES = \ manual_commands.c \ manual_governments.c \ manual_settings.c \ + manual_techs.c \ manual_terrain.c \ manual_units.c diff --git a/tools/manual/fc_manual.c b/tools/manual/fc_manual.c index 0f7fef7b3a..299f4ae953 100644 --- a/tools/manual/fc_manual.c +++ b/tools/manual/fc_manual.c @@ -47,13 +47,6 @@ #include "tilespec.h" /* server */ -#include "citytools.h" -#include "connecthand.h" -#include "console.h" -#include "diplhand.h" -#include "gamehand.h" -#include "plrhand.h" -#include "report.h" #include "ruleset.h" #include "settings.h" #include "sernet.h" @@ -347,44 +340,11 @@ static bool manual_command(struct tag_types *tag_info) || !manual_terrain(tag_info) || !manual_buildings(tag_info) || !manual_governments(tag_info) - || !manual_units(tag_info)) { + || !manual_units(tag_info) + || !manual_techs(tag_info)) { return FALSE; } - { - FILE *doc; - - doc = manual_start(tag_info, MANUAL_TECHS); - - if (doc == NULL) { - return FALSE; - } - - /* FIXME: this doesn't resemble the wiki manual at all. */ - /* TRANS: markup ... Freeciv version ... ruleset name ... markup */ - fprintf(doc, _("%sFreeciv %s tech help (%s)%s\n\n"), - tag_info->title_begin, VERSION_STRING, game.control.name, - tag_info->title_end); - advance_iterate(ptech) { - if (valid_advance(ptech)) { - char buf[64000]; - - fprintf(doc, tag_info->item_begin, "tech", ptech->item_number); - fprintf(doc, "%s%s%s\n\n", tag_info->sect_title_begin, - advance_name_translation(ptech), tag_info->sect_title_end); - - fprintf(doc, tag_info->subitem_begin, "helptext"); - helptext_advance(buf, sizeof(buf), NULL, "", ptech->item_number); - fprintf(doc, "%s", buf); - fprintf(doc, "%s", tag_info->subitem_end); - - fprintf(doc, "%s", tag_info->item_end); - } - } advance_iterate_end; - - manual_finalize(tag_info, doc, MANUAL_TECHS); - } - return TRUE; } diff --git a/tools/manual/fc_manual.h b/tools/manual/fc_manual.h index 7dce80dffb..5bce2608c9 100644 --- a/tools/manual/fc_manual.h +++ b/tools/manual/fc_manual.h @@ -55,6 +55,7 @@ bool manual_terrain(struct tag_types *tag_info); bool manual_buildings(struct tag_types *tag_info); bool manual_governments(struct tag_types *tag_info); bool manual_units(struct tag_types *tag_info); +bool manual_techs(struct tag_types *tag_info); #ifdef __cplusplus } diff --git a/tools/manual/manual_techs.c b/tools/manual/manual_techs.c new file mode 100644 index 0000000000..e734042026 --- /dev/null +++ b/tools/manual/manual_techs.c @@ -0,0 +1,72 @@ +/*********************************************************************** + 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 "tech.h" + +/* client */ +#include "helpdata.h" + +/* tools/manual */ +#include "fc_manual.h" + +/**********************************************************************//** + Write techs manual page + + @param tag_info Tag set to use + @return Success +**************************************************************************/ +bool manual_techs(struct tag_types *tag_info) +{ + FILE *doc; + + doc = manual_start(tag_info, MANUAL_TECHS); + + if (doc == NULL) { + return FALSE; + } + + /* FIXME: this doesn't resemble the wiki manual at all. */ + /* TRANS: markup ... Freeciv version ... ruleset name ... markup */ + fprintf(doc, _("%sFreeciv %s tech help (%s)%s\n\n"), + tag_info->title_begin, VERSION_STRING, game.control.name, + tag_info->title_end); + advance_iterate(ptech) { + if (valid_advance(ptech)) { + char buf[64000]; + + fprintf(doc, tag_info->item_begin, "tech", ptech->item_number); + fprintf(doc, "%s%s%s\n\n", tag_info->sect_title_begin, + advance_name_translation(ptech), tag_info->sect_title_end); + + fprintf(doc, tag_info->subitem_begin, "helptext"); + helptext_advance(buf, sizeof(buf), NULL, "", ptech->item_number); + fprintf(doc, "%s", buf); + fprintf(doc, "%s", tag_info->subitem_end); + + fprintf(doc, "%s", tag_info->item_end); + } + } advance_iterate_end; + + manual_finalize(tag_info, doc, MANUAL_TECHS); + + return TRUE; +} diff --git a/translations/core/POTFILES.in b/translations/core/POTFILES.in index 68247a3963..ff2cd8d94a 100644 --- a/translations/core/POTFILES.in +++ b/translations/core/POTFILES.in @@ -397,6 +397,7 @@ tools/manual/manual_buildings.c tools/manual/manual_commands.c tools/manual/manual_governments.c tools/manual/manual_settings.c +tools/manual/manual_techs.c tools/manual/manual_terrain.c tools/manual/manual_units.c tools/ruleutil/rulesave.c -- 2.42.0