From 821a51dcdfe37a9241023b3b1f9f553625ad9cda Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 17 Aug 2025 15:08:57 +0300
Subject: [PATCH 9/9] Protocol: Make tech_upkeep a 32 bit value

Reported by Marco Schuler

See RM #1654

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/packhand.c             | 6 +++++-
 common/networking/packets.def | 3 ++-
 fc_version                    | 2 +-
 server/plrhand.c              | 5 +++--
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/client/packhand.c b/client/packhand.c
index 723520f458..b6df89230b 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -2646,7 +2646,11 @@ void handle_player_info(const struct packet_player_info *pinfo)
   pplayer->economic.tax = pinfo->tax;
   pplayer->economic.science = pinfo->science;
   pplayer->economic.luxury = pinfo->luxury;
-  pplayer->client.tech_upkeep = pinfo->tech_upkeep;
+  if (has_capability("tu32", client.conn.capability)) {
+    pplayer->client.tech_upkeep = pinfo->tech_upkeep_32;
+  } else {
+    pplayer->client.tech_upkeep = pinfo->tech_upkeep_16;
+  }
   pplayer->government = pgov;
   pplayer->target_government = ptarget_gov;
   /* Don't use player_iterate here, because we ignore the real number
diff --git a/common/networking/packets.def b/common/networking/packets.def
index a66842ff48..13526ad4e4 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -955,7 +955,8 @@ PACKET_PLAYER_INFO = 51; sc, is-info
   PERCENT tax, science,luxury;
   UINT32 infrapoints;
 
-  UINT16 tech_upkeep;
+  UINT16 tech_upkeep_16; remove-cap(tu32)
+  UINT32 tech_upkeep_32; add-cap(tu32)
   UINT16 science_cost;
 
   BOOL is_connected;
diff --git a/fc_version b/fc_version
index 2f71773351..0339c15a72 100755
--- a/fc_version
+++ b/fc_version
@@ -72,7 +72,7 @@ DEFAULT_FOLLOW_TAG=stable
 #   - No new mandatory capabilities can be added to the release branch; doing
 #     so would break network capability of supposedly "compatible" releases.
 #
-NETWORK_CAPSTRING="+Freeciv-3.1-network city-original rsdesc32 obsinv ids32 ownernull16"
+NETWORK_CAPSTRING="+Freeciv-3.1-network city-original rsdesc32 obsinv ids32 ownernull16 tu32"
 FREECIV_DISTRIBUTOR=""
 
 if test "x$FREECIV_LABEL_FORCE" != "x" ; then
diff --git a/server/plrhand.c b/server/plrhand.c
index 112b3f62b4..e99c0d0939 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -1289,10 +1289,11 @@ static void package_player_info(struct player *plr,
   if (info_level >= INFO_EMBASSY 
       || (receiver
 	  && player_diplstate_get(plr, receiver)->type == DS_TEAM)) {
-    packet->tech_upkeep = player_tech_upkeep(plr);
+    packet->tech_upkeep_32 = player_tech_upkeep(plr);
   } else {
-    packet->tech_upkeep = 0;
+    packet->tech_upkeep_32 = 0;
   }
+  packet->tech_upkeep_16 = packet->tech_upkeep_32;
 
   /* Send most civ info about the player only to players who have an
    * embassy. */
-- 
2.50.1

