From 17474583d2d8d2b39a8bc3e828502913dbe2ca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= 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 eb14a48a06..e3b36bbb51 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -5555,6 +5555,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.c b/common/counters.c index b18334009f..43c21bb244 100644 --- a/common/counters.c +++ b/common/counters.c @@ -39,7 +39,8 @@ static int number_city_counters; ****************************************************************************/ void counters_init(void) { - game.control.num_counters = 0; + fc_assert(game.control.num_counters == 0); + number_city_counters = 0; } @@ -53,6 +54,16 @@ void counters_free(void) * code here */ + int i; + + for (i = 0; i < game.control.num_counters; i++) { + + if (NULL != counters[i].helptext) { + strvec_destroy(counters[i].helptext); + counters[i].helptext = NULL; + } + } + game.control.num_counters = 0; number_city_counters = 0; } 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 7048ce4a77..af70925eb0 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -1900,6 +1900,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 d88f0d4521..42e4c8a4fe 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -7504,6 +7504,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)) { @@ -8171,6 +8172,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 430741c83f..eccfcadcb9 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1812,6 +1812,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)) { + save_strvec(sfile, pcounter->helptext, "%s.helptext", path); + } } counters_re_iterate_end; -- 2.40.0