From 9a1d3956df6a499dfc2512b6e1fea8e3c0dd488a Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 16 Oct 2024 04:54:57 +0300
Subject: [PATCH 43/43] Rename Martial_Law_Each as Martial_Law_By_Unit

See RM #972

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daieffects.c             |  2 +-
 ai/default/daimilitary.c            |  2 +-
 ai/default/daiunit.c                |  2 +-
 client/helpdata.c                   |  2 +-
 client/text.c                       |  3 ++-
 common/city.c                       |  2 +-
 data/alien/effects.ruleset          |  4 ++--
 data/civ1/effects.ruleset           | 24 ++++++++++++------------
 data/civ2/effects.ruleset           | 24 ++++++++++++------------
 data/civ2civ3/effects.ruleset       | 24 ++++++++++++------------
 data/classic/effects.ruleset        | 24 ++++++++++++------------
 data/goldkeep/effects.ruleset       | 24 ++++++++++++------------
 data/multiplayer/effects.ruleset    | 24 ++++++++++++------------
 data/sandbox/effects.ruleset        | 24 ++++++++++++------------
 data/webperimental/effects.ruleset  | 24 ++++++++++++------------
 doc/README.effects                  |  4 ++--
 gen_headers/enums/effects_enums.def |  2 +-
 server/ruleset/rscompat.c           | 12 ++++++++++++
 server/ruleset/rscompat.h           |  1 +
 server/ruleset/ruleload.c           |  4 ++++
 20 files changed, 125 insertions(+), 107 deletions(-)

diff --git a/ai/default/daieffects.c b/ai/default/daieffects.c
index bdfd55b400..192af1fe17 100644
--- a/ai/default/daieffects.c
+++ b/ai/default/daieffects.c
@@ -588,7 +588,7 @@ adv_want dai_effect_value(struct player *pplayer,
   case EFT_EMPIRE_SIZE_BASE:
   case EFT_EMPIRE_SIZE_STEP:
   case EFT_MAX_RATES:
-  case EFT_MARTIAL_LAW_EACH:
+  case EFT_MARTIAL_LAW_BY_UNIT:
   case EFT_MARTIAL_LAW_MAX:
   case EFT_RAPTURE_GROW:
   case EFT_REVOLUTION_UNHAPPINESS:
diff --git a/ai/default/daimilitary.c b/ai/default/daimilitary.c
index 0bcd6d6ad3..def431ff35 100644
--- a/ai/default/daimilitary.c
+++ b/ai/default/daimilitary.c
@@ -1820,7 +1820,7 @@ struct adv_choice *military_advisor_choose_build(struct ai_type *ait,
   if (martial_need
       && unit_list_size(pcity->tile->units) < get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX)) {
     martial_value = dai_content_effect_value(pplayer, pcity,
-                                             get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH),
+                                             get_city_bonus(pcity, EFT_MARTIAL_LAW_BY_UNIT),
                                              1, FEELING_FINAL);
   }
 
diff --git a/ai/default/daiunit.c b/ai/default/daiunit.c
index 3179e5cdc1..51dd7b118f 100644
--- a/ai/default/daiunit.c
+++ b/ai/default/daiunit.c
@@ -2779,7 +2779,7 @@ static void dai_set_defenders(struct ai_type *ait, struct player *pplayer)
     bool emergency = FALSE;
     int count = 0;
     int mart_max = get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX);
-    int mart_each = get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH);
+    int mart_each = get_city_bonus(pcity, EFT_MARTIAL_LAW_BY_UNIT);
     int martless_unhappy = pcity->feel[CITIZEN_UNHAPPY][FEELING_NATIONALITY]
       + pcity->feel[CITIZEN_ANGRY][FEELING_NATIONALITY];
     int entertainers = 0;
diff --git a/client/helpdata.c b/client/helpdata.c
index 23f86b989b..418a43da83 100644
--- a/client/helpdata.c
+++ b/client/helpdata.c
@@ -4672,7 +4672,7 @@ void helptext_government(char *buf, size_t bufsz, struct player *pplayer,
           }
         }
         break;
-      case EFT_MARTIAL_LAW_EACH:
+      case EFT_MARTIAL_LAW_BY_UNIT:
         if (playerwide) {
           cat_snprintf(buf, bufsz,
                        PL_("%s Your units may impose martial law."
diff --git a/client/text.c b/client/text.c
index 99ec8cb673..f73caf7030 100644
--- a/client/text.c
+++ b/client/text.c
@@ -2087,7 +2087,8 @@ const char *text_happiness_units(const struct city *pcity)
   astr_clear(&str);
 
   if (mlmax > 0) {
-    int mleach = get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH);
+    int mleach = get_city_bonus(pcity, EFT_MARTIAL_LAW_BY_UNIT);
+
     if (mlmax == 100) {
       astr_add_line(&str, "%s", _("Unlimited martial law in effect."));
     } else {
diff --git a/common/city.c b/common/city.c
index 30d8092a78..04ecec9155 100644
--- a/common/city.c
+++ b/common/city.c
@@ -3153,7 +3153,7 @@ static inline void city_support(struct city *pcity)
                                                  .unit = punit,
                                                  .unittype = unit_type_get(punit)
                                                },
-                                               NULL, EFT_MARTIAL_LAW_EACH);
+                                               NULL, EFT_MARTIAL_LAW_BY_UNIT);
         if (current > 0) {
           if (sel_count < max_mart_units) {
             best_units[sel_count++] = current;
diff --git a/data/alien/effects.ruleset b/data/alien/effects.ruleset
index 19ea392aaa..d2a3e119a4 100644
--- a/data/alien/effects.ruleset
+++ b/data/alien/effects.ruleset
@@ -859,10 +859,10 @@ reqs    =
     }
 
 [effect_martial_law]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range"
+    { "type",     "name",          "range"
       "Building", "Secret Police", "City"
     }
 
diff --git a/data/civ1/effects.ruleset b/data/civ1/effects.ruleset
index 8e598427e6..205b415081 100644
--- a/data/civ1/effects.ruleset
+++ b/data/civ1/effects.ruleset
@@ -427,35 +427,35 @@ type    = "Empire_Size_Step"
 value   = 10
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/data/civ2/effects.ruleset b/data/civ2/effects.ruleset
index ce5608c6c3..bcd187720a 100644
--- a/data/civ2/effects.ruleset
+++ b/data/civ2/effects.ruleset
@@ -744,35 +744,35 @@ reqs    =
     }
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs    =
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/data/civ2civ3/effects.ruleset b/data/civ2civ3/effects.ruleset
index f21562b195..317e9c21a5 100644
--- a/data/civ2civ3/effects.ruleset
+++ b/data/civ2civ3/effects.ruleset
@@ -1407,35 +1407,35 @@ reqs    =
     }
 
 [effect_martial_law_each_anarchy]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Anarchy", "Player", TRUE
+    { "type", "name",    "range",  "quiet"
+      "Gov",  "Anarchy", "Player", TRUE
     }
 
 [effect_martial_law_each_despotism]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Despotism", "Player", TRUE
+    { "type", "name",      "range",  "quiet"
+      "Gov",  "Despotism", "Player", TRUE
     }
 
 [effect_martial_law_each_monarchy]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Monarchy", "Player", TRUE
+    { "type", "name",     "range",  "quiet"
+      "Gov",  "Monarchy", "Player", TRUE
     }
 
 [effect_martial_law_each_communism]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Communism", "Player", TRUE
+    { "type", "name",      "range",  "quiet"
+      "Gov",  "Communism", "Player", TRUE
     }
 
 [effect_martial_law_max]
diff --git a/data/classic/effects.ruleset b/data/classic/effects.ruleset
index 5249e5bd14..218f1bdceb 100644
--- a/data/classic/effects.ruleset
+++ b/data/classic/effects.ruleset
@@ -601,35 +601,35 @@ reqs	=
     }
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/data/goldkeep/effects.ruleset b/data/goldkeep/effects.ruleset
index c83e52903c..a866aceb73 100644
--- a/data/goldkeep/effects.ruleset
+++ b/data/goldkeep/effects.ruleset
@@ -678,35 +678,35 @@ reqs	=
     }
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/data/multiplayer/effects.ruleset b/data/multiplayer/effects.ruleset
index 83aa69d0a1..e892b2df03 100644
--- a/data/multiplayer/effects.ruleset
+++ b/data/multiplayer/effects.ruleset
@@ -597,35 +597,35 @@ reqs	=
     }
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/data/sandbox/effects.ruleset b/data/sandbox/effects.ruleset
index 60f0b7b753..07c6528f03 100644
--- a/data/sandbox/effects.ruleset
+++ b/data/sandbox/effects.ruleset
@@ -1590,35 +1590,35 @@ reqs    =
     }
 
 [effect_martial_law_each_anarchy]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Anarchy", "Player", TRUE
+    { "type", "name",    "range",  "quiet"
+      "Gov",  "Anarchy", "Player", TRUE
     }
 
 [effect_martial_law_each_despotism]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Despotism", "Player", TRUE
+    { "type", "name",      "range",  "quiet"
+      "Gov",  "Despotism", "Player", TRUE
     }
 
 [effect_martial_law_each_monarchy]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Monarchy", "Player", TRUE
+    { "type", "name",     "range",  "quiet"
+      "Gov",  "Monarchy", "Player", TRUE
     }
 
 [effect_martial_law_each_communism]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs    =
-    { "type", "name", "range", "quiet"
-      "Gov", "Communism", "Player", TRUE
+    { "type", "name",      "range",  "quiet"
+      "Gov",  "Communism", "Player", TRUE
     }
 
 [effect_martial_law_max]
diff --git a/data/webperimental/effects.ruleset b/data/webperimental/effects.ruleset
index 4bc1ecfb46..766b39a888 100644
--- a/data/webperimental/effects.ruleset
+++ b/data/webperimental/effects.ruleset
@@ -601,35 +601,35 @@ reqs	=
     }
 
 [effect_martial_law_each_0]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Anarchy",   "Player"
+    { "type", "name",    "range"
+      "Gov",  "Anarchy", "Player"
     }
 
 [effect_martial_law_each_1]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Despotism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Despotism", "Player"
     }
 
 [effect_martial_law_each_2]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 1
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Monarchy",  "Player"
+    { "type", "name",     "range"
+      "Gov",  "Monarchy", "Player"
     }
 
 [effect_martial_law_each_3]
-type    = "Martial_Law_Each"
+type    = "Martial_Law_By_Unit"
 value   = 2
 reqs	=
-    { "type",       "name",      "range"
-      "Gov", "Communism", "Player"
+    { "type", "name",      "range"
+      "Gov",  "Communism", "Player"
     }
 
 [effect_martial_law_max_0]
diff --git a/doc/README.effects b/doc/README.effects
index 876605f3f5..151dc847c7 100644
--- a/doc/README.effects
+++ b/doc/README.effects
@@ -495,11 +495,11 @@ Maps_Stolen_Pct
     Requirements evaluated against tile or city not supported.
     Default value: 100%
 
-Martial_Law_Each
+Martial_Law_By_Unit
     The amount of citizens pacified by each military unit giving martial law.
 
 Martial_Law_Max
-    The maximum amount of units that will give martial law in city.
+    The maximum amount of units that will give martial law in the city.
 
 Max_Rates
     The maximum setting for each tax rate is amount.
diff --git a/gen_headers/enums/effects_enums.def b/gen_headers/enums/effects_enums.def
index 0197096d49..6dfe14c59e 100644
--- a/gen_headers/enums/effects_enums.def
+++ b/gen_headers/enums/effects_enums.def
@@ -68,7 +68,7 @@ values
   EMPIRE_SIZE_BASE                  "Empire_Size_Base"
   EMPIRE_SIZE_STEP                  "Empire_Size_Step"
   MAX_RATES                         "Max_Rates"
-  MARTIAL_LAW_EACH                  "Martial_Law_Each"
+  MARTIAL_LAW_BY_UNIT               "Martial_Law_By_Unit"
   MARTIAL_LAW_MAX                   "Martial_Law_Max"
   RAPTURE_GROW                      "Rapture_Grow"
   REVOLUTION_UNHAPPINESS            "Revolution_Unhappiness"
diff --git a/server/ruleset/rscompat.c b/server/ruleset/rscompat.c
index ac8f7a5e5d..bfe695946f 100644
--- a/server/ruleset/rscompat.c
+++ b/server/ruleset/rscompat.c
@@ -647,6 +647,18 @@ const char *rscompat_universal_name_3_3(const char *old_name)
   return old_name;
 }
 
+/**********************************************************************//**
+  Convert 3.2 effect name to a 3.3 one.
+**************************************************************************/
+const char *rscompat_effect_name_3_3(const char *old_name)
+{
+  if (!fc_strcasecmp("Martial_Law_Each", old_name)) {
+    return "Martial_Law_By_Unit";
+  }
+
+  return old_name;
+}
+
 /**********************************************************************//**
   Tell 3.2 blocked_by name matching 3.3 one
 **************************************************************************/
diff --git a/server/ruleset/rscompat.h b/server/ruleset/rscompat.h
index c6fb6a4f7f..2eaf3bd768 100644
--- a/server/ruleset/rscompat.h
+++ b/server/ruleset/rscompat.h
@@ -59,6 +59,7 @@ struct requirement_vector *lookup_req_list(struct section_file *file,
 /* Functions specific to 3.2 -> 3.3 transition */
 const char *rscompat_utype_flag_name_3_3(const char *old_name);
 const char *rscompat_universal_name_3_3(const char *old_name);
+const char *rscompat_effect_name_3_3(const char *old_name);
 
 const char *blocked_by_old_name_3_3(const char *new_name);
 const char *ui_name_old_name_3_3(const char *new_name);
diff --git a/server/ruleset/ruleload.c b/server/ruleset/ruleload.c
index ffeb1f0082..3ff7d60893 100644
--- a/server/ruleset/ruleload.c
+++ b/server/ruleset/ruleload.c
@@ -6149,6 +6149,10 @@ static bool load_ruleset_effects(struct section_file *file,
       break;
     }
 
+    if (compat->compat_mode && compat->version < RSFORMAT_3_3) {
+      type = rscompat_effect_name_3_3(type);
+    }
+
     eff = effect_type_by_name(type, fc_strcasecmp);
     if (!effect_type_is_valid(eff)) {
       ruleset_error(NULL, LOG_ERROR,
-- 
2.45.2

