From abefaba5fe4e1df5ace2b59de69327f75e500cf6 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] =?UTF-8?q?!OSDN:=20#47697:=20S=C5=82awomir=20Lach:=20slaw?=
 =?UTF-8?q?ek@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..41fa6ed1a5 100644
--- a/server/ruleset.c
+++ b/server/ruleset.c
@@ -7501,6 +7501,7 @@ static bool load_ruleset_game(struct section_file *file, bool act,
           break;
         }
 
+        pcount->helptext = lookup_strvec(file, sec_name, "helptext");
         pcount->type = cb;
         if (!secfile_lookup_int(file, &pcount->checkpoint,
                                 "%s.checkpoint", sec_name)) {
@@ -8167,6 +8168,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;
 }
diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c
index fc954c3d7a..3588375d0e 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -1805,6 +1805,9 @@ static bool save_game_ruleset(const char *filename, const char *name)
     save_default_int(sfile, pcounter->checkpoint, 0, path, "checkpoint");
 
     secfile_insert_str(sfile, counter_behaviour_name(pcounter->type), "%s.type", path);
+    if (0 < strvec_size(pcounter->helptext)) {
+      secfile_insert_str_vec(sfile, pcounter->helptext, "%s.helptext", path);
+    }
 
   } counters_re_iterate_end;
 
-- 
2.40.0

