From f88f4d4c0b629f80bfb08039cccf83f5aa62f579 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 29 Apr 2023 04:19:36 +0300
Subject: [PATCH 31/31] Client: Tell if there's no version information in
 metaserver reply

Previously client silently ignored the case where metaserver
had no version information matching client's followtag.

See osdn #47943

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/servers.c | 61 ++++++++++++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 25 deletions(-)

diff --git a/client/servers.c b/client/servers.c
index 2e68287664..9beb64f8f4 100644
--- a/client/servers.c
+++ b/client/servers.c
@@ -128,35 +128,46 @@ static struct server_list *parse_metaserver_data(fz_FILE *f)
   latest_ver = secfile_lookup_str_default(file, NULL, "versions." FOLLOWTAG);
   comment = secfile_lookup_str_default(file, NULL, "version_comments." FOLLOWTAG);
 
-  if (latest_ver != NULL) {
-    const char *my_comparable = fc_comparable_version();
+  if (latest_ver == NULL && comment == NULL) {
     char vertext[2048];
 
-    log_verbose("Metaserver says latest '" FOLLOWTAG "' version is '%s'; we have '%s'",
-                latest_ver, my_comparable);
-    if (cvercmp_greater(latest_ver, my_comparable)) {
-      const char *const followtag = "?vertag:" FOLLOWTAG;
-
-      fc_snprintf(vertext, sizeof(vertext),
-                  /* TRANS: Type is version tag name like "stable", "S3_2",
-                   * "windows" (which can also be localised -- msgids start
-                   * '?vertag:') */
-                  _("Latest %s release of Freeciv is %s, this is %s."),
-                  Q_(followtag), latest_ver, my_comparable);
-
-      version_message(vertext);
-    } else if (comment == NULL) {
-      fc_snprintf(vertext, sizeof(vertext),
-                  _("There is no newer %s release of Freeciv available."),
-                  FOLLOWTAG);
-
-      version_message(vertext);
+    fc_snprintf(vertext, sizeof(vertext),
+                /* TRANS: Type is version tag name like "stable", "S3_2",
+                 * "windows" (which can also be localised -- msgids start
+                 * '?vertag:') */
+                _("There's no %s release yet."), Q_("?vertag:" FOLLOWTAG));
+    log_verbose("%s", vertext);
+    version_message(vertext);
+  } else {
+    if (latest_ver != NULL) {
+      const char *my_comparable = fc_comparable_version();
+      char vertext[2048];
+
+      log_verbose("Metaserver says latest '" FOLLOWTAG "' version is '%s'; we have '%s'",
+                  latest_ver, my_comparable);
+      if (cvercmp_greater(latest_ver, my_comparable)) {
+
+        fc_snprintf(vertext, sizeof(vertext),
+                    /* TRANS: Type is version tag name like "stable", "S3_2",
+                     * "windows" (which can also be localised -- msgids start
+                     * '?vertag:') */
+                    _("Latest %s release of Freeciv is %s, this is %s."),
+                    Q_("?vertag:" FOLLOWTAG), latest_ver, my_comparable);
+
+        version_message(vertext);
+      } else if (comment == NULL) {
+        fc_snprintf(vertext, sizeof(vertext),
+                    _("There is no newer %s release of Freeciv available."),
+                    FOLLOWTAG);
+
+        version_message(vertext);
+      }
     }
-  }
 
-  if (comment != NULL) {
-    log_verbose("Mesaserver comment about '" FOLLOWTAG "': %s", comment);
-    version_message(comment);
+    if (comment != NULL) {
+      log_verbose("Mesaserver comment about '" FOLLOWTAG "': %s", comment);
+      version_message(comment);
+    }
   }
 
   server_list = server_list_new();
-- 
2.39.2