From 1c31cd8cbc046ae096626ce51bbe781d137c0ff8 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 9 Jan 2024 00:05:53 +0200
Subject: [PATCH 33/33] freeciv-manual: Add extras page

See RM #153

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 meson.build                  |  1 +
 tools/manual/Makefile.am     |  1 +
 tools/manual/fc_manual.c     |  1 +
 tools/manual/fc_manual.h     | 23 ++++++------
 tools/manual/manual_extras.c | 69 ++++++++++++++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 10 deletions(-)
 create mode 100644 tools/manual/manual_extras.c

diff --git a/meson.build b/meson.build
index 053867024a..18b2f56682 100644
--- a/meson.build
+++ b/meson.build
@@ -4192,6 +4192,7 @@ executable('freeciv-manual',
   'tools/manual/fc_manual.c',
   'tools/manual/manual_buildings.c',
   'tools/manual/manual_commands.c',
+  'tools/manual/manual_extras.c',
   'tools/manual/manual_governments.c',
   'tools/manual/manual_settings.c',
   'tools/manual/manual_techs.c',
diff --git a/tools/manual/Makefile.am b/tools/manual/Makefile.am
index ea04b1c7b6..71d8d25c6c 100644
--- a/tools/manual/Makefile.am
+++ b/tools/manual/Makefile.am
@@ -21,6 +21,7 @@ freeciv_manual_SOURCES =		\
 		fc_manual.h		\
 		manual_buildings.c	\
 		manual_commands.c	\
+		manual_extras.c		\
 		manual_governments.c	\
 		manual_settings.c	\
 		manual_techs.c		\
diff --git a/tools/manual/fc_manual.c b/tools/manual/fc_manual.c
index 299f4ae953..37f0cc7713 100644
--- a/tools/manual/fc_manual.c
+++ b/tools/manual/fc_manual.c
@@ -338,6 +338,7 @@ static bool manual_command(struct tag_types *tag_info)
   if (!manual_settings(tag_info)
       || !manual_commands(tag_info)
       || !manual_terrain(tag_info)
+      || !manual_extras(tag_info)
       || !manual_buildings(tag_info)
       || !manual_governments(tag_info)
       || !manual_units(tag_info)
diff --git a/tools/manual/fc_manual.h b/tools/manual/fc_manual.h
index 9476c208c7..245d8178e2 100644
--- a/tools/manual/fc_manual.h
+++ b/tools/manual/fc_manual.h
@@ -29,16 +29,18 @@ extern "C" {
 #define SPECENUM_VALUE1NAME N_("Commands")
 #define SPECENUM_VALUE2 MANUAL_TERRAIN
 #define SPECENUM_VALUE2NAME N_("Terrain")
-#define SPECENUM_VALUE3 MANUAL_BUILDINGS
-#define SPECENUM_VALUE3NAME N_("Buildings")
-#define SPECENUM_VALUE4 MANUAL_WONDERS
-#define SPECENUM_VALUE4NAME N_("Wonders")
-#define SPECENUM_VALUE5 MANUAL_GOVS
-#define SPECENUM_VALUE5NAME N_("Governments")
-#define SPECENUM_VALUE6 MANUAL_UNITS
-#define SPECENUM_VALUE6NAME N_("Units")
-#define SPECENUM_VALUE7 MANUAL_TECHS
-#define SPECENUM_VALUE7NAME N_("Techs")
+#define SPECENUM_VALUE3 MANUAL_EXTRAS
+#define SPECENUM_VALUE3NAME N_("Extras")
+#define SPECENUM_VALUE4 MANUAL_BUILDINGS
+#define SPECENUM_VALUE4NAME N_("Buildings")
+#define SPECENUM_VALUE5 MANUAL_WONDERS
+#define SPECENUM_VALUE5NAME N_("Wonders")
+#define SPECENUM_VALUE6 MANUAL_GOVS
+#define SPECENUM_VALUE6NAME N_("Governments")
+#define SPECENUM_VALUE7 MANUAL_UNITS
+#define SPECENUM_VALUE7NAME N_("Units")
+#define SPECENUM_VALUE8 MANUAL_TECHS
+#define SPECENUM_VALUE8NAME N_("Techs")
 #define SPECENUM_COUNT MANUAL_COUNT
 #include "specenum_gen.h"
 
@@ -69,6 +71,7 @@ char *html_special_chars(char *str, size_t *len);
 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_extras(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);
diff --git a/tools/manual/manual_extras.c b/tools/manual/manual_extras.c
new file mode 100644
index 0000000000..e86985be57
--- /dev/null
+++ b/tools/manual/manual_extras.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 <fc_config.h>
+#endif
+
+/* utility */
+#include "fcintl.h"
+
+/* common */
+#include "game.h"
+#include "tech.h"
+
+/* client */
+#include "helpdata.h"
+
+/* tools/manual */
+#include "fc_manual.h"
+
+/**********************************************************************//**
+  Write extras manual page
+
+  @param  tag_info  Tag set to use
+  @return           Success
+**************************************************************************/
+bool manual_extras(struct tag_types *tag_info)
+{
+  FILE *doc;
+
+  doc = manual_start(tag_info, MANUAL_EXTRAS);
+
+  if (doc == NULL) {
+    return FALSE;
+  }
+
+  /* TRANS: markup ... Freeciv version ... ruleset name ... markup */
+  fprintf(doc, _("%sFreeciv %s extras help (%s)%s\n\n"),
+          tag_info->title_begin, VERSION_STRING, game.control.name,
+          tag_info->title_end);
+  extra_type_iterate(pextra) {
+    char buf[64000];
+
+    fprintf(doc, tag_info->item_begin, "extra", extra_index(pextra));
+    fprintf(doc, "%s%s%s\n\n", tag_info->sect_title_begin,
+            extra_name_translation(pextra), tag_info->sect_title_end);
+
+    fprintf(doc, tag_info->subitem_begin, "helptext");
+    helptext_extra(buf, sizeof(buf), NULL, "", pextra);
+    fprintf(doc, "%s", buf);
+    fprintf(doc, "%s", tag_info->subitem_end);
+
+    fprintf(doc, "%s", tag_info->item_end);
+  } extra_type_iterate_end;
+
+  manual_finalize(tag_info, doc, MANUAL_EXTRAS);
+
+  return TRUE;
+}
-- 
2.43.0

