From 4db0a383bae3b8f0a3d75f92c38e0f7fc80da1d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Thu, 30 Mar 2023 18:43:35 +0200
Subject: [PATCH 2/3] =?UTF-8?q?!OSDN:=20TICKET=2047697:=20S=C5=82awomir=20?=
 =?UTF-8?q?Lach=20<s=C5=82awek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Helptext for counter are loaded by server.
No visible changes are done by this patch.

diff --git a/client/packhand.c b/client/packhand.c
index a4713baa6e..712e6bbb08 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -5554,6 +5554,7 @@ void handle_ruleset_counter(const struct packet_ruleset_counter *packet)
     return;
   }
 
+  PACKET_STRVEC_EXTRACT(curr->helptext, packet->helptext);
   attach_city_counter(curr);
 }
 
diff --git a/common/counters.h b/common/counters.h
index bf43e32b84..f253fe15e8 100644
--- a/common/counters.h
+++ b/common/counters.h
@@ -26,6 +26,7 @@ extern "C" {
 struct counter
 {
   struct name_translation name;
+  struct strvec *helptext;
   bool ruledit_disabled;
   enum counter_behaviour type;
   enum counter_target target;
diff --git a/common/networking/packets.def b/common/networking/packets.def
index cd9d5d48b7..5def095edd 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -1899,6 +1899,7 @@ end
 PACKET_RULESET_COUNTER = 513; sc, lsend
   STRING name[MAX_LEN_NAME];
   STRING rule_name[MAX_LEN_NAME];
+  STRVEC helptext[MAX_LEN_PACKET];
   UINT32 def;
   UINT32 checkpoint;
   COUNTER_TARGET type;
diff --git a/server/ruleset.c b/server/ruleset.c
index 80df66b92e..f3f54c5640 100644
--- a/server/ruleset.c
+++ b/server/ruleset.c
@@ -7501,6 +7501,14 @@ static bool load_ruleset_game(struct section_file *file, bool act,
           break;
         }
 
+        pcount->helptext = lookup_strvec(file, sec_name, "helptext");
+        if (NULL == pcount->helptext) {
+          ruleset_error(NULL, LOG_ERROR,
+                        "\"%s\": No helptext for this counter",
+                        filename);
+          ok = FALSE;
+          break;
+        }
         pcount->type = cb;
         if (!secfile_lookup_int(file, &pcount->checkpoint,
                                 "%s.checkpoint", sec_name)) {
@@ -8167,6 +8175,7 @@ static void send_ruleset_counters(struct conn_list *dest)
     packet.type = pcount->target;
     packet.def = pcount->def;
 
+    PACKET_STRVEC_COMPUTE(packet.helptext, pcount->helptext);
     lsend_packet_ruleset_counter(dest, &packet);
   } city_counters_iterate_end;
 }
-- 
2.40.0

