From 58fc8734edd43baff7c8db5af4dab24af454694e Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 28 Feb 2021 15:04:26 +0200
Subject: [PATCH 11/11] Make player culture values 32bit value in network
 protocol

Reported by mortmann

See osdn #41654

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

diff --git a/client/packhand.c b/client/packhand.c
index 48a0ff10d9..5fb3caacc6 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -2352,8 +2352,13 @@ void handle_player_info(const struct packet_player_info *pinfo)
     }
   }
 
-  pplayer->history = pinfo->history;
-  pplayer->client.culture = pinfo->culture;
+  if (has_capability("plrculture32", client.conn.capability)) {
+    pplayer->history = pinfo->history32;
+    pplayer->client.culture = pinfo->culture32;
+  } else {
+    pplayer->history = pinfo->history16;
+    pplayer->client.culture = pinfo->culture16;
+  }
 
   /* Don't use player_iterate or player_slot_count here, because we ignore
    * the real number of players and we want to read all the datas. */
diff --git a/common/networking/packets.def b/common/networking/packets.def
index f7b4d3fa0d..7cec131cc3 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -878,8 +878,10 @@ PACKET_PLAYER_INFO = 51; sc, is-info
   UINT8 ai_skill_level;
   BARBARIAN_TYPE barbarian_type;
   BV_PLAYER gives_shared_vision;
-  UINT16 history;
-  UINT16 culture;
+  UINT16 history16; remove-cap(plrculture32)
+  UINT16 culture16; remove-cap(plrculture32)
+  UINT32 history32; add-cap(plrculture32)
+  UINT32 culture32; add-cap(plrculture32)
   SINT16 love[MAX_NUM_PLAYER_SLOTS];
 
   BOOL color_valid;
diff --git a/fc_version b/fc_version
index a5dc905152..df609bcb5f 100755
--- a/fc_version
+++ b/fc_version
@@ -60,7 +60,7 @@ DEFAULT_FOLLOW_TAG=S3_0
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
 NETWORK_CAPSTRING_MANDATORY="+Freeciv-3.0-network"
-NETWORK_CAPSTRING_OPTIONAL="year32"
+NETWORK_CAPSTRING_OPTIONAL="year32 plrculture32"
 
 FREECIV_DISTRIBUTOR=""
 
diff --git a/server/plrhand.c b/server/plrhand.c
index 988eb374a5..904348288c 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -1225,15 +1225,17 @@ static void package_player_info(struct player *plr,
     packet->science         = plr->economic.science;
     packet->luxury          = plr->economic.luxury;
     packet->revolution_finishes = plr->revolution_finishes;
-    packet->culture         = player_culture(plr);
+    packet->culture32       = player_culture(plr);
   } else {
     packet->tax             = 0;
     packet->science         = 0;
     packet->luxury          = 0;
     packet->revolution_finishes = -1;
-    packet->culture         = 0;
+    packet->culture32       = 0;
   }
 
+  packet->culture16 = packet->culture32;
+
   if (info_level >= INFO_FULL
       || (receiver
           && player_diplstate_get(plr, receiver)->type == DS_TEAM)) {
@@ -1243,10 +1245,12 @@ static void package_player_info(struct player *plr,
   }
 
   if (info_level >= INFO_FULL) {
-    packet->history         = plr->history;
+    packet->history32       = plr->history;
   } else {
-    packet->history         = 0;
+    packet->history32       = 0;
   }
+
+  packet->history16 = packet->history32;
 }
 
 /**************************************************************************
-- 
2.30.1