From 6dffe35585d0b05a31fe89057116c03061068066 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.
---
 data/alien/game.ruleset         | 16 ++++++++++++++++
 data/civ1/game.ruleset          | 16 ++++++++++++++++
 data/civ2/game.ruleset          | 16 ++++++++++++++++
 data/civ2civ3/game.ruleset      | 16 ++++++++++++++++
 data/classic/game.ruleset       | 16 ++++++++++++++++
 data/goldkeep/game.ruleset      | 17 +++++++++++++++++
 data/granularity/game.ruleset   | 17 +++++++++++++++++
 data/ruledit/comments-3.2.txt   | 20 ++++++++++++++++++++
 data/sandbox/game.ruleset       | 17 +++++++++++++++++
 data/stub/game.ruleset          | 17 +++++++++++++++++
 data/webperimental/game.ruleset | 16 ++++++++++++++++
 tools/ruleutil/comments.c       | 12 ++++++++++++
 tools/ruleutil/comments.h       |  1 +
 tools/ruleutil/rulesave.c       |  3 +++
 14 files changed, 200 insertions(+)

diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset
index 24d033d0e9..ad04ccd090 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 eebb8e619e..eaaa4593da 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 c1d69cecad..481864dd9b 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 1b47d723d2..2553224835 100644
--- a/data/civ2civ3/game.ruleset
+++ b/data/civ2civ3/game.ruleset
@@ -2197,3 +2197,19 @@ set =
       "tradeworldrelpct", 100
     }
 
+
+;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/classic/game.ruleset b/data/classic/game.ruleset
index f890989511..2f3c19532f 100644
--- a/data/classic/game.ruleset
+++ b/data/classic/game.ruleset
@@ -1976,3 +1976,19 @@ colorlist =
 ;       "int_set", 123, FALSE
 ;       "str_set", "test", 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/goldkeep/game.ruleset b/data/goldkeep/game.ruleset
index 2128e81baf..4121b2cd3c 100644
--- a/data/goldkeep/game.ruleset
+++ b/data/goldkeep/game.ruleset
@@ -2078,3 +2078,20 @@ set =
       "traitdistribution", "EVEN", FALSE
       "victories", "SPACERACE|ALLIED|CULTURE", 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/granularity/game.ruleset b/data/granularity/game.ruleset
index 8b2fdc2db8..9a85d938fd 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 7aa232f4bd..17d28a8277 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/data/sandbox/game.ruleset b/data/sandbox/game.ruleset
index 073e32f1c4..cf7657f6c6 100644
--- a/data/sandbox/game.ruleset
+++ b/data/sandbox/game.ruleset
@@ -3638,3 +3638,20 @@ set =
       "multiresearch", "ENABLED"
       "tradeworldrelpct", 100
     }
+
+
+;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/stub/game.ruleset b/data/stub/game.ruleset
index 3f8576b06f..a15d374cd7 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/data/webperimental/game.ruleset b/data/webperimental/game.ruleset
index 4f794c36a8..a251563ec7 100644
--- a/data/webperimental/game.ruleset
+++ b/data/webperimental/game.ruleset
@@ -2237,3 +2237,19 @@ set =
     "airliftingstyle", "FROM_ALLIES|TO_ALLIES", FALSE
     "restrictinfra", "enabled", 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/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 8947fbd904..14c67c5930 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -1738,6 +1738,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.2

