From 1861d182a9d0ed8351bd4b4f8b121f4bd69d5a0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Wed, 13 Jul 2022 15:25:32 +0200
Subject: [PATCH 1/2] =?UTF-8?q?!OSDN=2045028=20-=20S=C5=82awomir=20Lach=20?=
 =?UTF-8?q?<slawek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- Added comment of counters saving into game.ruleset

!OSDN 45028 - Sławomir Lach <slawek@lach.art.pl>

Added comment telling how to setup counters

diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt
index 7aa232f4bd..ac59f18955 100644
--- a/data/ruledit/comments-3.2.txt
+++ b/data/ruledit/comments-3.2.txt
@@ -1500,3 +1500,23 @@ calendar_fragments = "\n\
 ; needed to control fragment accumulation.\n\
 ; Value 0 here disables year advancement by fragment accumulation.\
 "
+
+counters = "\n\
+\n\
+;Counter types\n\
+;\n\
+;name                    = translatable name as seen by user\n\
+;rule_name               = (optional) internal name for savegames, rulesets\n\
+;                          etc; if not present, "name" is used for this\n\
+;                          purpose too. Since the name used in savegames must\n\
+;                          not change, if you want to rename an item after a\n\
+;                          ruleset has been released, you should set\n\
+;                          "rule_name" to the original value of "name".\n\
+;checkpoint              = Trigger value of the counter. When counter's\n\
+;                          value is at least this much, the "Counter" requirement\n\
+;                          is fulfilled.\n\
+;def                     = Initial value of the counter.\n\
+;type                    = Behavior of the counter:\n\
+;                          "Owned" - Increased each turn, zeroed when city changes owner\n\
+\n\
+"
diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c
index 9b0fff6af1..6b2219892d 100644
--- a/tools/ruleutil/comments.c
+++ b/tools/ruleutil/comments.c
@@ -88,6 +88,7 @@ static struct {
   char *culture_history_interest;
   char *culture_migration_pml;
   char *calendar_fragments;
+  char *counters;
 } comments_storage;
 
 /**********************************************************************//**
@@ -229,6 +230,8 @@ bool comments_load(void)
                "entrydoc.migration_pml");
   comment_load(comments_storage.calendar_fragments, comment_file,
                "entrydoc.calendar_fragments");
+  comment_load(comments_storage.counters, comment_file,
+               "entrydoc.counters");
 
   secfile_check_unused(comment_file);
   secfile_destroy(comment_file);
@@ -789,3 +792,12 @@ void comment_calendar_fragments(struct section_file *sfile)
   comment_entry_write(sfile, comments_storage.calendar_fragments,
                       "calendar");
 }
+
+/**********************************************************************//**
+  Write counters comment header.
+**************************************************************************/
+void comment_counters(struct section_file *sfile)
+{
+  comment_entry_write(sfile, comments_storage.counters,
+                      "counters");
+}
diff --git a/tools/ruleutil/comments.h b/tools/ruleutil/comments.h
index 0a33711a8d..6f20dccb67 100644
--- a/tools/ruleutil/comments.h
+++ b/tools/ruleutil/comments.h
@@ -91,6 +91,7 @@ void comment_research_free_tech_method(struct section_file *sfile);
 void comment_culture_history_interest(struct section_file *sfile);
 void comment_culture_migration_pml(struct section_file *sfile);
 void comment_calendar_fragments(struct section_file *sfile);
+void comment_counters(struct section_file *sfile);
 
 #ifdef __cplusplus
 }
diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c
index 5c56e07061..e34e9d855a 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -1725,6 +1725,9 @@ static bool save_game_ruleset(const char *filename, const char *name)
     }
   }
 
+  /* Counters */
+  comment_counters(sfile);
+
   sect_idx = 0;
   city_counters_iterate(pcounter) {
     char path[512];
-- 
2.37.1

