From 689bd912f33226fe0b1640a72db62a429bf86616 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 24d033d0e9..189a886a38 100644
--- a/data/alien/game.ruleset
+++ b/data/alien/game.ruleset
@@ -1680,3 +1680,21 @@ set =
       ; no effect anyway
      "traitdistribution", "FIXED",              TRUE
    }
+
+[counters]
+
+;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..61648a57ce 100644
--- a/data/civ1/game.ruleset
+++ b/data/civ1/game.ruleset
@@ -1499,3 +1499,21 @@ set =
       "topology", "ISO", FALSE
       "wrap", "WRAPX", FALSE
     }
+
+[counters]
+
+;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..30c2e862b1 100644
--- a/data/civ2/game.ruleset
+++ b/data/civ2/game.ruleset
@@ -1743,3 +1743,21 @@ set =
       "topology", "ISO", FALSE
       "wrap", "WRAPX", FALSE
     }
+
+[counters]
+
+;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 4f5d76bd22..2e54416456 100644
--- a/data/civ2civ3/game.ruleset
+++ b/data/civ2civ3/game.ruleset
@@ -2197,6 +2197,23 @@ set =
       "tradeworldrelpct", 100
     }
 
+[counters]
+
+;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
 [counter_owned1]
 name = "Owned"
 def = 0
diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset
index f890989511..6dd077bfb5 100644
--- a/data/classic/game.ruleset
+++ b/data/classic/game.ruleset
@@ -1976,3 +1976,21 @@ colorlist =
 ;       "int_set", 123, FALSE
 ;       "str_set", "test", FALSE
 ;     }
+
+[counters]
+
+;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..ab2594f6b5 100644
--- a/data/goldkeep/game.ruleset
+++ b/data/goldkeep/game.ruleset
@@ -2078,3 +2078,21 @@ set =
       "traitdistribution", "EVEN", FALSE
       "victories", "SPACERACE|ALLIED|CULTURE", FALSE
     }
+
+[counters]
+
+;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..a42c323b0d 100644
--- a/data/granularity/game.ruleset
+++ b/data/granularity/game.ruleset
@@ -904,3 +904,21 @@ set =
     { "name", "value", "lock"
       "startunits", "c", TRUE
     }
+
+[counters]
+
+;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..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/data/sandbox/game.ruleset b/data/sandbox/game.ruleset
index 073e32f1c4..6c6cee12a1 100644
--- a/data/sandbox/game.ruleset
+++ b/data/sandbox/game.ruleset
@@ -3638,3 +3638,21 @@ set =
       "multiresearch", "ENABLED"
       "tradeworldrelpct", 100
     }
+
+[counters]
+
+;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..6a523c3821 100644
--- a/data/stub/game.ruleset
+++ b/data/stub/game.ruleset
@@ -765,3 +765,21 @@ set =
     { "name", "value", "lock"
       "startunits", "c", TRUE
     }
+
+[counters]
+
+;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..01f04e89a0 100644
--- a/data/webperimental/game.ruleset
+++ b/data/webperimental/game.ruleset
@@ -2237,3 +2237,21 @@ set =
     "airliftingstyle", "FROM_ALLIES|TO_ALLIES", FALSE
     "restrictinfra", "enabled", FALSE
   }
+
+[counters]
+
+;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

