From 9d967af8925180bba7ae060404a0afb36b558bb1 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 1 May 2025 21:32:04 +0300
Subject: [PATCH 32/32] Remove homeless_gold_upkeep ruleset setting

Unit granularity Upkeep_Factor effect has made it deprecated

See RM #1336

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/game.h                      |  4 +++
 common/networking/packets.def      |  1 -
 data/alien/effects.ruleset         | 17 ++++++++--
 data/alien/game.ruleset            |  4 ---
 data/civ1/effects.ruleset          | 15 ++++++++-
 data/civ1/game.ruleset             |  4 ---
 data/civ2/effects.ruleset          | 15 ++++++++-
 data/civ2/game.ruleset             |  4 ---
 data/civ2civ3/effects.ruleset      | 52 ++++++++++++++++--------------
 data/civ2civ3/game.ruleset         |  4 ---
 data/classic/effects.ruleset       | 17 ++++++++--
 data/classic/game.ruleset          |  4 ---
 data/goldkeep/effects.ruleset      | 17 ++++++++--
 data/goldkeep/game.ruleset         |  4 ---
 data/granularity/game.ruleset      |  4 ---
 data/multiplayer/effects.ruleset   | 17 ++++++++--
 data/multiplayer/game.ruleset      |  4 ---
 data/ruledit/comments-3.4.txt      |  5 ---
 data/sandbox/effects.ruleset       | 52 ++++++++++++++++--------------
 data/sandbox/game.ruleset          |  4 ---
 data/stub/game.ruleset             |  4 ---
 data/webperimental/effects.ruleset | 17 ++++++++--
 data/webperimental/game.ruleset    |  4 ---
 server/plrhand.c                   |  5 +--
 server/ruleset/rscompat.c          | 43 ++++++++++++++++++++++++
 server/ruleset/ruleload.c          | 21 +++++++-----
 tools/ruleutil/comments.c          | 12 -------
 tools/ruleutil/comments.h          |  1 -
 tools/ruleutil/rulesave.c          |  5 ---
 29 files changed, 218 insertions(+), 142 deletions(-)

diff --git a/common/game.h b/common/game.h
index b9201fc6a0..04f0c0646d 100644
--- a/common/game.h
+++ b/common/game.h
@@ -127,6 +127,10 @@ struct civ_game {
       /* Defined in the ruleset. */
 
       /* Game settings & other data. */
+      struct {
+        bool homeless_gold_upkeep;
+      } deprecated;
+
       enum city_names_mode allowed_city_names;
       enum plrcolor_mode plrcolormode;
       int aqueductloss;
diff --git a/common/networking/packets.def b/common/networking/packets.def
index 86d8fd2bd7..b25e1ec648 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -543,7 +543,6 @@ PACKET_GAME_INFO = 16; sc, is-info
   UINT32 globalwarming;
   GOLD gold;
   GOLD_UPKEEP_STYLE gold_upkeep_style;
-  BOOL homeless_gold_upkeep;
   UINT32 infrapoints;
   REVOLENTYPE revolentype;
   GOVERNMENT default_government_id;
diff --git a/data/alien/effects.ruleset b/data/alien/effects.ruleset
index 505d1c6125..e56f602621 100644
--- a/data/alien/effects.ruleset
+++ b/data/alien/effects.ruleset
@@ -100,9 +100,22 @@ reqs    =
 type    = "City_Vision_Radius_Sq"
 value   = 5
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
-value	= 1
+value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_empire_size_base]
 type    = "Empire_Size_Base"
diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset
index a453315e35..2b8fbc420b 100644
--- a/data/alien/game.ruleset
+++ b/data/alien/game.ruleset
@@ -175,10 +175,6 @@ paradrop_to_transport   = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "Nation"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/civ1/effects.ruleset b/data/civ1/effects.ruleset
index 6618778541..df0a425c6b 100644
--- a/data/civ1/effects.ruleset
+++ b/data/civ1/effects.ruleset
@@ -268,9 +268,22 @@ value   = 100
 type    = "Max_Rates"
 value   = 100
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
 value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_republic_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset
index 32716f3576..e9985508b2 100644
--- a/data/civ1/game.ruleset
+++ b/data/civ1/game.ruleset
@@ -161,10 +161,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/civ2/effects.ruleset b/data/civ2/effects.ruleset
index 805f3fc9e8..ae555d7899 100644
--- a/data/civ2/effects.ruleset
+++ b/data/civ2/effects.ruleset
@@ -418,9 +418,22 @@ reqs    =
       "Gov", "Republic", "Player"
     }
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
 value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_communism_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset
index 1c2a74a3ea..35d1efdd72 100644
--- a/data/civ2/game.ruleset
+++ b/data/civ2/game.ruleset
@@ -157,10 +157,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/civ2civ3/effects.ruleset b/data/civ2civ3/effects.ruleset
index b9e36a2ed8..e013c36b3b 100644
--- a/data/civ2civ3/effects.ruleset
+++ b/data/civ2civ3/effects.ruleset
@@ -745,35 +745,37 @@ reqs    =
 type    = "Upkeep_Factor"
 value   = 1
 reqs    =
-    { "type", "name", "range", "present"
-      "OutputType", "Gold", "Local", TRUE
-      "Gov", "Anarchy", "Player", FALSE
-      "Gov", "Tribal", "Player", FALSE
-      "Gov", "Communism", "Player", FALSE
-;      "Gov", "Despotism", "Player", FALSE
-;      "Gov", "Monarchy", "Player", FALSE
-;      "Gov", "Fundamentalism", "Player", FALSE
-;      "Gov", "Federation", "Player", FALSE
-      "Gov", "Republic", "Player", FALSE
-;      "Gov", "Democracy", "Player", FALSE
-    }
-
-; additive with previous => x2 for Fundamentalism, Federation, Democracy
+    { "type",       "name",           "range",  "present"
+      "OutputType", "Gold",           "Local",  TRUE
+      "Gov",        "Anarchy",        "Player", FALSE
+      "Gov",        "Tribal",         "Player", FALSE
+      "Gov",        "Communism",      "Player", FALSE
+;      "Gov",        "Despotism",      "Player", FALSE
+;      "Gov",        "Monarchy",       "Player", FALSE
+;      "Gov",        "Fundamentalism", "Player", FALSE
+;      "Gov",        "Federation",     "Player", FALSE
+      "Gov",        "Republic",       "Player", FALSE
+;      "Gov",        "Democracy",      "Player", FALSE
+      "UnitState",  "HasHomeCity",    "Local",  TRUE
+    }
+
+; Additive with previous => x2 for Fundamentalism, Federation, Democracy
 [effect_base_unit_upkeep_gold_2]
 type    = "Upkeep_Factor"
 value   = 1
 reqs    =
-    { "type", "name", "range", "present"
-      "OutputType", "Gold", "Local", TRUE
-      "Gov", "Anarchy", "Player", FALSE
-      "Gov", "Tribal", "Player", FALSE
-      "Gov", "Communism", "Player", FALSE
-      "Gov", "Despotism", "Player", FALSE
-      "Gov", "Monarchy", "Player", FALSE
-;      "Gov", "Fundamentalism", "Player", FALSE
-;      "Gov", "Federation", "Player", FALSE
-      "Gov", "Republic", "Player", FALSE
-;      "Gov", "Democracy", "Player", FALSE
+    { "type",       "name",           "range",  "present"
+      "OutputType", "Gold",           "Local",  TRUE
+      "Gov",        "Anarchy",        "Player", FALSE
+      "Gov",        "Tribal",         "Player", FALSE
+      "Gov",        "Communism",      "Player", FALSE
+      "Gov",        "Despotism",      "Player", FALSE
+      "Gov",        "Monarchy",       "Player", FALSE
+;      "Gov",        "Fundamentalism", "Player", FALSE
+;      "Gov",        "Federation",     "Player", FALSE
+      "Gov",        "Republic",       "Player", FALSE
+;      "Gov",        "Democracy",     "Player", FALSE
+      "UnitState",  "HasHomeCity",    "Local",  TRUE
     }
 
 [effect_base_unit_upkeep_shield]
diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset
index 5155847e40..0020b9c2b6 100644
--- a/data/civ2civ3/game.ruleset
+++ b/data/civ2civ3/game.ruleset
@@ -178,10 +178,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "Mixed"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/classic/effects.ruleset b/data/classic/effects.ruleset
index 32dfbcda4b..6c5699e6b5 100644
--- a/data/classic/effects.ruleset
+++ b/data/classic/effects.ruleset
@@ -340,9 +340,22 @@ reqs	=
       "OutputType", "Trade", "Local"
     }
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
-value	= 1
+value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_republic_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset
index 06cc8466ff..988cb6bd3f 100644
--- a/data/classic/game.ruleset
+++ b/data/classic/game.ruleset
@@ -171,10 +171,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/goldkeep/effects.ruleset b/data/goldkeep/effects.ruleset
index ab7ed6c9ba..02890949cb 100644
--- a/data/goldkeep/effects.ruleset
+++ b/data/goldkeep/effects.ruleset
@@ -400,9 +400,22 @@ reqs	=
       "OutputType", "Trade", "Local"
     }
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
-value	= 1
+value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_republic_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset
index 8fbfcca069..cf7b4593b7 100644
--- a/data/goldkeep/game.ruleset
+++ b/data/goldkeep/game.ruleset
@@ -176,10 +176,6 @@ paradrop_to_transport    = TRUE
 ;            upkeep are disbanded.
 gold_upkeep_style = "Mixed"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset
index d99f2ebd0b..e35360ff29 100644
--- a/data/granularity/game.ruleset
+++ b/data/granularity/game.ruleset
@@ -168,10 +168,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 100
diff --git a/data/multiplayer/effects.ruleset b/data/multiplayer/effects.ruleset
index a97c582da0..3632ab2a41 100644
--- a/data/multiplayer/effects.ruleset
+++ b/data/multiplayer/effects.ruleset
@@ -320,9 +320,22 @@ reqs	=
       "OutputType", "Trade", "Local"
     }
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
-value	= 1
+value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_republic_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset
index 37422a918a..ec344521e5 100644
--- a/data/multiplayer/game.ruleset
+++ b/data/multiplayer/game.ruleset
@@ -174,10 +174,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/ruledit/comments-3.4.txt b/data/ruledit/comments-3.4.txt
index 96b4ee987e..cbe6f5ded9 100644
--- a/data/ruledit/comments-3.4.txt
+++ b/data/ruledit/comments-3.4.txt
@@ -1424,11 +1424,6 @@ gold_upkeep_style = "\n\
 ;            upkeep are disbanded.\
 "
 
-homeless_gold_upkeep = "\n\
-; Whether also homeless units pay gold upkeep. Enabling requires that\n\
-; gold_upkeep_style is not \"City\"\
-"
-
 airlift_always_enabled = "\n\
 ; Is it possible to airlift even with zero airlift capacity when\n\
 ; airliftingstyle server setting has been set to unlimited airlifts?\
diff --git a/data/sandbox/effects.ruleset b/data/sandbox/effects.ruleset
index 78429d12af..af2b8b51aa 100644
--- a/data/sandbox/effects.ruleset
+++ b/data/sandbox/effects.ruleset
@@ -836,35 +836,37 @@ reqs    =
 type    = "Upkeep_Factor"
 value   = 1
 reqs    =
-    { "type", "name", "range", "present"
-      "OutputType", "Gold", "Local", TRUE
-      "Gov", "Anarchy", "Player", FALSE
-      "Gov", "Tribal", "Player", FALSE
-      "Gov", "Communism", "Player", FALSE
-;      "Gov", "Despotism", "Player", FALSE
-;      "Gov", "Monarchy", "Player", FALSE
-;      "Gov", "Fundamentalism", "Player", FALSE
-;      "Gov", "Federation", "Player", FALSE
-      "Gov", "Republic", "Player", FALSE
-;      "Gov", "Democracy", "Player", FALSE
-    }
-
-; additive with previous => x2 for Fundamentalism, Federation, Democracy
+    { "type",       "name",           "range",  "present"
+      "OutputType", "Gold",           "Local",  TRUE
+      "Gov",        "Anarchy",        "Player", FALSE
+      "Gov",        "Tribal",         "Player", FALSE
+      "Gov",        "Communism",      "Player", FALSE
+;      "Gov",        "Despotism",      "Player", FALSE
+;      "Gov",        "Monarchy",       "Player", FALSE
+;      "Gov",        "Fundamentalism", "Player", FALSE
+;      "Gov",        "Federation",     "Player", FALSE
+      "Gov",        "Republic",       "Player", FALSE
+;      "Gov",        "Democracy",      "Player", FALSE
+      "UnitState",  "HasHomeCity",    "Local",   TRUE
+    }
+
+; Additive with previous => x2 for Fundamentalism, Federation, Democracy
 [effect_base_unit_upkeep_gold_2]
 type    = "Upkeep_Factor"
 value   = 1
 reqs    =
-    { "type", "name", "range", "present"
-      "OutputType", "Gold", "Local", TRUE
-      "Gov", "Anarchy", "Player", FALSE
-      "Gov", "Tribal", "Player", FALSE
-      "Gov", "Communism", "Player", FALSE
-      "Gov", "Despotism", "Player", FALSE
-      "Gov", "Monarchy", "Player", FALSE
-;      "Gov", "Fundamentalism", "Player", FALSE
-;      "Gov", "Federation", "Player", FALSE
-      "Gov", "Republic", "Player", FALSE
-;      "Gov", "Democracy", "Player", FALSE
+    { "type",       "name",           "range",  "present"
+      "OutputType", "Gold",           "Local",  TRUE
+      "Gov",        "Anarchy",        "Player", FALSE
+      "Gov",        "Tribal",         "Player", FALSE
+      "Gov",        "Communism",      "Player", FALSE
+      "Gov",        "Despotism",      "Player", FALSE
+      "Gov",        "Monarchy",       "Player", FALSE
+;      "Gov",        "Fundamentalism", "Player", FALSE
+;      "Gov",        "Federation",     "Player", FALSE
+      "Gov",        "Republic",       "Player", FALSE
+;      "Gov",        "Democracy",      "Player", FALSE
+      "UnitState",  "HasHomeCity",    "Local",   TRUE
     }
 
 [effect_base_unit_upkeep_shield]
diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset
index b2b7c3dce0..361ad4b0d0 100644
--- a/data/sandbox/game.ruleset
+++ b/data/sandbox/game.ruleset
@@ -176,10 +176,6 @@ paradrop_to_transport    = TRUE
 ;            upkeep are disbanded.
 gold_upkeep_style = "Mixed"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset
index 36281cc0b8..68446b52bd 100644
--- a/data/stub/game.ruleset
+++ b/data/stub/game.ruleset
@@ -159,10 +159,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/data/webperimental/effects.ruleset b/data/webperimental/effects.ruleset
index 96c91cbbd0..f1fa951099 100644
--- a/data/webperimental/effects.ruleset
+++ b/data/webperimental/effects.ruleset
@@ -340,9 +340,22 @@ reqs	=
       "OutputType", "Trade", "Local"
     }
 
-[effect_base_unit_upkeep]
+[effect_base_unit_upkeep_not_gold]
 type    = "Upkeep_Factor"
-value	= 1
+value   = 1
+reqs    =
+    { "type",       "name", "range", "present"
+      "OutputType", "Gold", "Local", FALSE
+    }
+
+[effect_base_unit_upkeep_gold]
+type    = "Upkeep_Factor"
+value   = 1
+reqs    =
+    { "type",       "name",        "range"
+      "OutputType", "Gold",        "Local"
+      "UnitState",  "HasHomeCity", "Local"
+    }
 
 [effect_republic_unit_upkeep]
 type    = "Upkeep_Factor"
diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset
index d03299ac22..597c323650 100644
--- a/data/webperimental/game.ruleset
+++ b/data/webperimental/game.ruleset
@@ -175,10 +175,6 @@ paradrop_to_transport    = FALSE
 ;            upkeep are disbanded.
 gold_upkeep_style = "City"
 
-; Whether also homeless units pay gold upkeep. Enabling requires that
-; gold_upkeep_style is not "City"
-homeless_gold_upkeep = FALSE
-
 ; How many points of output one basic unit consists of. Typically you
 ; want this to be some 10^n.
 output_granularity = 1
diff --git a/server/plrhand.c b/server/plrhand.c
index d929b67dd0..d9209a279f 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -3479,10 +3479,7 @@ void update_national_activities(struct player *pplayer, int old_gold)
 {
   char buf[200 + MAX_LEN_NAME];
 
-  /* gold_upkeep_style check currently redundant, but something we need
-   * once homeless_gold_upkeep retired. */
-  if (game.info.gold_upkeep_style != GOLD_UPKEEP_CITY
-      && game.info.homeless_gold_upkeep) {
+  if (game.info.gold_upkeep_style != GOLD_UPKEEP_CITY) {
     unit_list_iterate(pplayer->units, punit) {
       if (is_unit_homeless(punit)) {
         int gold = unit_upkeep_cost(punit, O_GOLD);
diff --git a/server/ruleset/rscompat.c b/server/ruleset/rscompat.c
index 50f3bb2040..3217aa4ae0 100644
--- a/server/ruleset/rscompat.c
+++ b/server/ruleset/rscompat.c
@@ -434,6 +434,49 @@ static bool effect_list_compat_cb(struct effect *peffect, void *data)
   struct rscompat_info *info = (struct rscompat_info *)data;
 
   if (info->version < RSFORMAT_3_4) {
+    if (!game.server.deprecated.homeless_gold_upkeep) {
+      if (peffect->type == EFT_UPKEEP_FACTOR) {
+        bool gold_included = TRUE;
+        bool only_gold = FALSE;
+
+        requirement_vector_iterate(&peffect->reqs, preq) {
+          if (preq->source.kind == VUT_OTYPE) {
+            if ((preq->source.value.outputtype != O_GOLD
+                 && preq->present)
+                || (preq->source.value.outputtype == O_GOLD
+                    && !preq->present)) {
+              gold_included = FALSE;
+            } else if (preq->source.value.outputtype == O_GOLD) {
+              only_gold = TRUE;
+            }
+          }
+        } requirement_vector_iterate_end;
+
+        if (gold_included) {
+          if (!only_gold) {
+            struct effect *copy = effect_copy(peffect, EFT_UPKEEP_FACTOR);
+
+            /* Split to gold-only and not-gold effects.
+             * Make sure the gold-only is the one we currently handle
+             * (and not the one we add), so we don't encounter it again
+             * when iterating forward. */
+            requirement_vector_append(&peffect->reqs,
+                                      req_from_str("OutputType", "Local",
+                                                   FALSE, TRUE, FALSE,
+                                                   "Gold"));
+            requirement_vector_append(&copy->reqs,
+                                      req_from_str("OutputType", "Local",
+                                                   FALSE, FALSE, FALSE,
+                                                   "Gold"));
+          }
+
+          requirement_vector_append(&peffect->reqs,
+                                    req_from_str("UnitState", "Local",
+                                                 FALSE, TRUE, FALSE,
+                                                 "HasHomeCity"));
+        }
+      }
+    }
   }
 
   /* Go to the next effect. */
diff --git a/server/ruleset/ruleload.c b/server/ruleset/ruleload.c
index e9e220408c..b9e0dcd981 100644
--- a/server/ruleset/ruleload.c
+++ b/server/ruleset/ruleload.c
@@ -6791,14 +6791,19 @@ static bool load_ruleset_game(struct section_file *file, bool act,
       ok = FALSE;
     }
 
-    game.info.homeless_gold_upkeep
-      = secfile_lookup_bool_default(file, FALSE, "civstyle.homeless_gold_upkeep");
+    if (compat->compat_mode
+        && compat->version < RSFORMAT_3_4) {
+      game.server.deprecated.homeless_gold_upkeep
+        = secfile_lookup_bool_default(file, FALSE, "civstyle.homeless_gold_upkeep");
 
-    if (game.info.homeless_gold_upkeep
-        && game.info.gold_upkeep_style == GOLD_UPKEEP_CITY) {
-      ruleset_error(NULL, LOG_ERROR,
-                    "Cannot have homeless_gold_upkeep while gold_upkeep_style \"City\".");
-      ok = FALSE;
+      if (game.server.deprecated.homeless_gold_upkeep
+          && game.info.gold_upkeep_style == GOLD_UPKEEP_CITY) {
+        ruleset_error(NULL, LOG_ERROR,
+                      "Cannot have homeless_gold_upkeep while gold_upkeep_style \"City\".");
+        ok = FALSE;
+      }
+    } else {
+      game.server.deprecated.homeless_gold_upkeep = TRUE;
     }
 
     game.info.granularity = secfile_lookup_int_default(file, 1,
@@ -6810,7 +6815,7 @@ static bool load_ruleset_game(struct section_file *file, bool act,
     game.info.airlift_to_always_enabled
       = secfile_lookup_bool_default(file, TRUE, "civstyle.airlift_to_always_enabled");
 
-    /* section: wonder_visibility */
+    /* Section: wonder_visibility */
     if (ok) {
       const char *text;
 
diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c
index d16c9f2613..f317391732 100644
--- a/tools/ruleutil/comments.c
+++ b/tools/ruleutil/comments.c
@@ -70,7 +70,6 @@ static struct {
   char *civstyle_ransom_gold;
   char *civstyle_gameloss_style;
   char *civstyle_gold_upkeep_style;
-  char *civstyle_homeless_gold_upkeep;
   char *civstyle_airlift_always;
   char *wonder_visibility_small_wonders;
   char *incite_cost;
@@ -202,8 +201,6 @@ bool comments_load(void)
                "entrydoc.gameloss_style");
   comment_load(comments_storage.civstyle_gold_upkeep_style, comment_file,
                "entrydoc.gold_upkeep_style");
-  comment_load(comments_storage.civstyle_homeless_gold_upkeep, comment_file,
-               "entrydoc.homeless_gold_upkeep");
   comment_load(comments_storage.civstyle_airlift_always, comment_file,
                "entrydoc.airlift_always_enabled");
   comment_load(comments_storage.wonder_visibility_small_wonders, comment_file,
@@ -639,15 +636,6 @@ void comment_civstyle_gold_upkeep_style(struct section_file *sfile)
                       "civstyle");
 }
 
-/**********************************************************************//**
-  Write civstyle homeless_gold_upkeep settings header.
-**************************************************************************/
-void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile)
-{
-  comment_entry_write(sfile, comments_storage.civstyle_homeless_gold_upkeep,
-                      "civstyle");
-}
-
 /**********************************************************************//**
   Write civstyle airlift always enabled settings header.
 **************************************************************************/
diff --git a/tools/ruleutil/comments.h b/tools/ruleutil/comments.h
index 19348d731b..e20e8809a8 100644
--- a/tools/ruleutil/comments.h
+++ b/tools/ruleutil/comments.h
@@ -73,7 +73,6 @@ void comment_civstyle_granary(struct section_file *sfile);
 void comment_civstyle_ransom_gold(struct section_file *sfile);
 void comment_civstyle_gameloss_style(struct section_file *sfile);
 void comment_civstyle_gold_upkeep_style(struct section_file *sfile);
-void comment_civstyle_homeless_gold_upkeep(struct section_file *sfile);
 void comment_civstyle_airlift_always(struct section_file *sfile);
 void comment_wonder_visibility_small_wonders(struct section_file *sfile);
 void comment_incite_cost(struct section_file *sfile);
diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c
index 3e7a155176..1cbe6bfbdf 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -1440,11 +1440,6 @@ static bool save_game_ruleset(const char *filename, const char *name)
                        gold_upkeep_style_name(game.info.gold_upkeep_style),
                        "civstyle.gold_upkeep_style");
   }
-  if (game.info.homeless_gold_upkeep) {
-    comment_civstyle_homeless_gold_upkeep(sfile);
-  }
-  save_default_bool(sfile, game.info.homeless_gold_upkeep, FALSE,
-                    "civstyle.homeless_gold_upkeep", nullptr);
   save_default_int(sfile, game.info.granularity,
                    1, "civstyle.output_granularity", nullptr);
 
-- 
2.47.2

