From ec14e04239616c849d067930e4f9947a06c294a4 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 23 May 2024 05:04:40 +0300
Subject: [PATCH 87/87] Make possible to /list supported AI types

Requested by Jacob Nevins

See RM #672

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/commands.c  |  6 +++--
 server/stdinhand.c | 65 ++++++++++++++++++++++++++++++----------------
 2 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/server/commands.c b/server/commands.c
index 3f6c28f3fc..8d940c8287 100644
--- a/server/commands.c
+++ b/server/commands.c
@@ -85,8 +85,9 @@ static struct command commands[] = {
   },
 
   {"list",	ALLOW_INFO,
-   /* no translatable parameters */
+   /* No translatable parameters */
    SYN_ORIG_("list\n"
+             "list ais\n"
              "list colors\n"
              "list connections\n"
              "list delegations\n"
@@ -99,8 +100,9 @@ static struct command commands[] = {
              "list teams\n"
              "list votes\n"),
    N_("Show a list of various things."),
-   /* TRANS: don't translate text in '' */
+   /* TRANS: Don't translate text in '' */
    N_("Show a list of:\n"
+      " - AI types,\n"
       " - the player colors,\n"
       " - connections to the server,\n"
       " - all player delegations,\n"
diff --git a/server/stdinhand.c b/server/stdinhand.c
index aaba898cad..81ebc7ac5d 100644
--- a/server/stdinhand.c
+++ b/server/stdinhand.c
@@ -121,6 +121,7 @@ static bool cut_client_connection(struct connection *caller, char *name,
                                   bool check);
 static bool show_help(struct connection *caller, char *arg);
 static bool show_list(struct connection *caller, char *arg);
+static void show_ais(struct connection *caller);
 static void show_colors(struct connection *caller);
 static bool set_ai_level_named(struct connection *caller, const char *name,
                                const char *level_name, bool check);
@@ -7023,6 +7024,21 @@ static void show_mapimg(struct connection *caller, enum command_id cmd)
   }
 }
 
+/**********************************************************************//**
+  Show a list of AI types supported
+**************************************************************************/
+static void show_ais(struct connection *caller)
+{
+  cmd_reply(CMD_LIST, caller, C_COMMENT, _("List of AI types:"));
+  cmd_reply(CMD_LIST, caller, C_COMMENT, horiz_line);
+
+  ai_type_iterate(ai) {
+    cmd_reply(CMD_LIST, caller, C_COMMENT, "%s", ai->name);
+  } ai_type_iterate_end;
+
+  cmd_reply(CMD_LIST, caller, C_COMMENT, horiz_line);
+}
+
 /**********************************************************************//**
   Show a list of all players with the assigned color.
 **************************************************************************/
@@ -7046,28 +7062,30 @@ static void show_colors(struct connection *caller)
   '/list' arguments
 **************************************************************************/
 #define SPECENUM_NAME list_args
-#define SPECENUM_VALUE0      LIST_COLORS
-#define SPECENUM_VALUE0NAME  "colors"
-#define SPECENUM_VALUE1      LIST_CONNECTIONS
-#define SPECENUM_VALUE1NAME  "connections"
-#define SPECENUM_VALUE2      LIST_DELEGATIONS
-#define SPECENUM_VALUE2NAME  "delegations"
-#define SPECENUM_VALUE3      LIST_IGNORE
-#define SPECENUM_VALUE3NAME  "ignored users"
-#define SPECENUM_VALUE4      LIST_MAPIMG
-#define SPECENUM_VALUE4NAME  "map image definitions"
-#define SPECENUM_VALUE5      LIST_PLAYERS
-#define SPECENUM_VALUE5NAME  "players"
-#define SPECENUM_VALUE6      LIST_RULESETS
-#define SPECENUM_VALUE6NAME  "rulesets"
-#define SPECENUM_VALUE7      LIST_SCENARIOS
-#define SPECENUM_VALUE7NAME  "scenarios"
-#define SPECENUM_VALUE8      LIST_NATIONSETS
-#define SPECENUM_VALUE8NAME  "nationsets"
-#define SPECENUM_VALUE9      LIST_TEAMS
-#define SPECENUM_VALUE9NAME  "teams"
-#define SPECENUM_VALUE10     LIST_VOTES
-#define SPECENUM_VALUE10NAME "votes"
+#define SPECENUM_VALUE0      LIST_AIS
+#define SPECENUM_VALUE0NAME  "ais"
+#define SPECENUM_VALUE1      LIST_COLORS
+#define SPECENUM_VALUE1NAME  "colors"
+#define SPECENUM_VALUE2      LIST_CONNECTIONS
+#define SPECENUM_VALUE2NAME  "connections"
+#define SPECENUM_VALUE3      LIST_DELEGATIONS
+#define SPECENUM_VALUE3NAME  "delegations"
+#define SPECENUM_VALUE4      LIST_IGNORE
+#define SPECENUM_VALUE4NAME  "ignored users"
+#define SPECENUM_VALUE5      LIST_MAPIMG
+#define SPECENUM_VALUE5NAME  "map image definitions"
+#define SPECENUM_VALUE6      LIST_PLAYERS
+#define SPECENUM_VALUE6NAME  "players"
+#define SPECENUM_VALUE7      LIST_RULESETS
+#define SPECENUM_VALUE7NAME  "rulesets"
+#define SPECENUM_VALUE8      LIST_SCENARIOS
+#define SPECENUM_VALUE8NAME  "scenarios"
+#define SPECENUM_VALUE9      LIST_NATIONSETS
+#define SPECENUM_VALUE9NAME  "nationsets"
+#define SPECENUM_VALUE10     LIST_TEAMS
+#define SPECENUM_VALUE10NAME "teams"
+#define SPECENUM_VALUE11     LIST_VOTES
+#define SPECENUM_VALUE11NAME "votes"
 #include "specenum_gen.h"
 
 /**********************************************************************//**
@@ -7105,6 +7123,9 @@ static bool show_list(struct connection *caller, char *arg)
   }
 
   switch (ind) {
+  case LIST_AIS:
+    show_ais(caller);
+    return TRUE;
   case LIST_COLORS:
     show_colors(caller);
     return TRUE;
-- 
2.43.0

