From c844d9238d9419e746d4b951b84591be783dd02e 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] =?UTF-8?q?!OSDN=2045028=20-=20S=C5=82awomir=20Lach=20<sla?=
 =?UTF-8?q?wek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Added comment telling how to setup counters

Added information about counters in comments of game.ruleset.
This apply to each ruleset.

diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset
index 89a5b294e6..8ddb04a87d 100644
--- a/data/alien/game.ruleset
+++ b/data/alien/game.ruleset
@@ -1680,3 +1680,19 @@ set =
       ; no effect anyway
      "traitdistribution", "FIXED",              TRUE
    }
+
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset
index 04f96a356e..e842df5596 100644
--- a/data/civ1/game.ruleset
+++ b/data/civ1/game.ruleset
@@ -1499,3 +1499,19 @@ set =
       "topology", "ISO", FALSE
       "wrap", "WRAPX", FALSE
     }
+
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset
index 613f33ee5d..72eeb3e91f 100644
--- a/data/civ2/game.ruleset
+++ b/data/civ2/game.ruleset
@@ -1743,3 +1743,19 @@ set =
       "topology", "ISO", FALSE
       "wrap", "WRAPX", FALSE
     }
+
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset
index ae4467ae65..375944ea4c 100644
--- a/data/civ2civ3/game.ruleset
+++ b/data/civ2civ3/game.ruleset
@@ -2112,6 +2112,22 @@ type = "Vision"
 [clause_embassy]
 type = "Embassy"
 
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
+
 [playercolors]
 background.r = 86
 background.g = 86
@@ -2196,4 +2212,3 @@ set =
       "revolentype", "RANDQUICK"
       "tradeworldrelpct", 100
     }
-
diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset
index 57ef67f45a..ba07aefbd0 100644
--- a/data/granularity/game.ruleset
+++ b/data/granularity/game.ruleset
@@ -904,3 +904,20 @@ set =
     { "name", "value", "lock"
       "startunits", "c", TRUE
     }
+
+
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt
index 072e4d145b..feacce6fc9 100644
--- a/data/ruledit/comments-3.2.txt
+++ b/data/ruledit/comments-3.2.txt
@@ -1219,6 +1219,27 @@ clauses = "\
 ; */ <-- avoid gettext warnings\n\
 "
 
+counters = "\n\
+; /* <-- avoid gettext warnings\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\
+; */ <-- avoid gettext warnings\n\
+"
+
+
 [sectiondoc]
 ; This section has comments documenting other sections
 nations_ruledit = "\n\
diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset
index 6777db9600..bea5fb50d6 100644
--- a/data/stub/game.ruleset
+++ b/data/stub/game.ruleset
@@ -765,3 +765,20 @@ set =
     { "name", "value", "lock"
       "startunits", "c", TRUE
     }
+
+
+;Counter types
+;
+;name                    = translatable name as seen by user
+;rule_name               = (optional) internal name for savegames, rulesets
+;                          etc; if not present, "name" is used for this
+;                          purpose too. Since the name used in savegames must
+;                          not change, if you want to rename an item after a
+;                          ruleset has been released, you should set
+;                          "rule_name" to the original value of "name".
+;checkpoint              = Trigger value of the counter. When counter's
+;                          value is at least this much, the "Counter" requirement
+;                          is fulfilled.
+;def                     = Initial value of the counter.
+;type                    = Behavior of the counter:
+;                          "Owned" - Increased each turn, zeroed when city changes owner
diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c
index 9b0fff6af1..2f1e5b15d9 100644
--- a/tools/ruleutil/comments.c
+++ b/tools/ruleutil/comments.c
@@ -51,6 +51,7 @@ static struct {
   char *nationgroups;
   char *nationsets;
   char *clauses;
+  char *counters;
 
   /* Other section entries */
   char *nations_ruledit;
@@ -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,
+               "typedoc.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_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 b3bc667947..24582cf3b9 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -1722,6 +1722,9 @@ static bool save_game_ruleset(const char *filename, const char *name)
   /* Clauses */
   comment_clauses(sfile);
 
+  /* Counters */
+  comment_counters(sfile);
+
   sect_idx = 0;
   for (i = 0; i < CLAUSE_COUNT; i++) {
     struct clause_info *info = clause_info_get(i);
-- 
2.37.3

