From 84b4314505ca74020df833d7927be45c665bb5a5 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 17 Aug 2025 15:04:33 +0300
Subject: [PATCH 10/10] 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 32b85bd2e0..94ba03cf6d 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -2507,7 +2507,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;
+  }
   gov_change = (!new_player && pgov != pplayer->government
                 && pplayer->government != NULL);
   pplayer->government = pgov;
diff --git a/common/networking/packets.def b/common/networking/packets.def
index 26d25e9c13..ecafd9df02 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -950,7 +950,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 cb8d68ee39..b13cbe2148 100755
--- a/fc_version
+++ b/fc_version
@@ -75,7 +75,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.2-network ownernull16 unignoresync"
+NETWORK_CAPSTRING="+Freeciv-3.2-network ownernull16 unignoresync tu32"
 
 # If you are distributing freeciv, and apply any patches at all,
 # patch also this field to contain your identification.
diff --git a/server/plrhand.c b/server/plrhand.c
index 6b591dc32a..a7fb72b4db 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -1453,10 +1453,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

