From f890fe7cdc37d4dd3e72501f97d1548331dcb7d6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 21 Nov 2022 22:14:29 +0200 Subject: [PATCH 9/9] Protocol: Make city culture values UINT32 See osdn #46014 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/editprop.c | 6 ++++-- client/gui-gtk-3.0/editprop.c | 6 ++++-- client/gui-gtk-3.22/editprop.c | 6 ++++-- client/packhand.c | 9 +++++++-- common/networking/packets.def | 9 ++++++--- fc_version | 2 +- server/citytools.c | 6 ++++-- server/edithand.c | 11 +++++++++-- 8 files changed, 39 insertions(+), 16 deletions(-) diff --git a/client/gui-gtk-2.0/editprop.c b/client/gui-gtk-2.0/editprop.c index 64ee3f027a..8398997edc 100644 --- a/client/gui-gtk-2.0/editprop.c +++ b/client/gui-gtk-2.0/editprop.c @@ -2278,7 +2278,8 @@ static void objbind_pack_current_values(struct objbind *ob, packet->id = pcity->id; sz_strlcpy(packet->name, pcity->name); packet->size = city_size_get(pcity); - packet->history = pcity->history; + packet->history32 = pcity->history; + packet->history16 = pcity->history; for (i = 0; i < B_LAST; i++) { packet->built[i] = pcity->built[i].turn; } @@ -2494,7 +2495,8 @@ static void objbind_pack_modified_value(struct objbind *ob, packet->size = pv->data.v_int; return; case OPID_CITY_HISTORY: - packet->history = pv->data.v_int; + packet->history32 = pv->data.v_int; + packet->history16 = pv->data.v_int; return; case OPID_CITY_FOOD_STOCK: packet->food_stock = pv->data.v_int; diff --git a/client/gui-gtk-3.0/editprop.c b/client/gui-gtk-3.0/editprop.c index 1bde141b62..f858161e74 100644 --- a/client/gui-gtk-3.0/editprop.c +++ b/client/gui-gtk-3.0/editprop.c @@ -2282,7 +2282,8 @@ static void objbind_pack_current_values(struct objbind *ob, packet->id = pcity->id; sz_strlcpy(packet->name, pcity->name); packet->size = city_size_get(pcity); - packet->history = pcity->history; + packet->history32 = pcity->history; + packet->history16 = pcity->history; for (i = 0; i < B_LAST; i++) { packet->built[i] = pcity->built[i].turn; } @@ -2498,7 +2499,8 @@ static void objbind_pack_modified_value(struct objbind *ob, packet->size = pv->data.v_int; return; case OPID_CITY_HISTORY: - packet->history = pv->data.v_int; + packet->history32 = pv->data.v_int; + packet->history16 = pv->data.v_int; return; case OPID_CITY_FOOD_STOCK: packet->food_stock = pv->data.v_int; diff --git a/client/gui-gtk-3.22/editprop.c b/client/gui-gtk-3.22/editprop.c index 7db4dc336f..1b261a9f32 100644 --- a/client/gui-gtk-3.22/editprop.c +++ b/client/gui-gtk-3.22/editprop.c @@ -2282,7 +2282,8 @@ static void objbind_pack_current_values(struct objbind *ob, packet->id = pcity->id; sz_strlcpy(packet->name, pcity->name); packet->size = city_size_get(pcity); - packet->history = pcity->history; + packet->history32 = pcity->history; + packet->history16 = pcity->history; for (i = 0; i < B_LAST; i++) { packet->built[i] = pcity->built[i].turn; } @@ -2498,7 +2499,8 @@ static void objbind_pack_modified_value(struct objbind *ob, packet->size = pv->data.v_int; return; case OPID_CITY_HISTORY: - packet->history = pv->data.v_int; + packet->history32 = pv->data.v_int; + packet->history16 = pv->data.v_int; return; case OPID_CITY_FOOD_STOCK: packet->food_stock = pv->data.v_int; diff --git a/client/packhand.c b/client/packhand.c index 9c6ce63f2e..36f59aabcd 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -716,8 +716,13 @@ void handle_city_info(const struct packet_city_info *packet) fc_assert(citizens_count(pcity) == city_size_get(pcity)); } - pcity->history = packet->history; - pcity->client.culture = packet->culture; + if (has_capability("cityculture32", client.conn.capability)) { + pcity->history = packet->history32; + pcity->client.culture = packet->culture32; + } else { + pcity->history = packet->history16; + pcity->client.culture = packet->culture16; + } pcity->client.buy_cost = packet->buy_cost; pcity->city_radius_sq = packet->city_radius_sq; diff --git a/common/networking/packets.def b/common/networking/packets.def index 880a8fda58..fff4f85d09 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -682,8 +682,10 @@ PACKET_CITY_INFO = 31; sc, lsend, is-game-info, force, cancel(PACKET_CITY_SHORT_ PLAYER nation_id[MAX_NUM_PLAYER_SLOTS:nationalities_count]; CITIZENS nation_citizens[MAX_NUM_PLAYER_SLOTS:nationalities_count]; - UINT16 history; - UINT16 culture; + UINT16 history16; remove-cap(cityculture32) + UINT16 culture16; remove-cap(cityculture32) + UINT32 history32; add-cap(cityculture32) + UINT32 culture32; add-cap(cityculture32) UINT16 buy_cost; SINT16 surplus[O_LAST]; @@ -2184,7 +2186,8 @@ PACKET_EDIT_CITY = 213; cs, handle-per-conn, handle-via-packet PLAYER owner; PLAYER original; UINT8 size; - UINT16 history; + UINT16 history16; remove-cap(cityculture32) + UINT32 history32; add-cap(cityculture32) UINT8 ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5]; UINT8 specialists_size; UINT8 specialists[SP_MAX:specialists_size]; diff --git a/fc_version b/fc_version index 571977df91..c7569e3a29 100755 --- a/fc_version +++ b/fc_version @@ -69,7 +69,7 @@ DEFAULT_FOLLOW_TAG=stable # 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 plrculture32 pingfix researchclr" +NETWORK_CAPSTRING_OPTIONAL="year32 plrculture32 pingfix researchclr cityculture32" FREECIV_DISTRIBUTOR="" diff --git a/server/citytools.c b/server/citytools.c index 7399a6c6eb..4df06b2050 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -2442,8 +2442,10 @@ void package_city(struct city *pcity, struct packet_city_info *packet, fc_assert(cit == packet->size); } - packet->history = pcity->history; - packet->culture = city_culture(pcity); + packet->history32 = pcity->history; + packet->history16 = pcity->history; + packet->culture32 = city_culture(pcity); + packet->culture16 = packet->culture32; packet->buy_cost = city_production_buy_gold_cost(pcity); if (packet->size != ppl) { diff --git a/server/edithand.c b/server/edithand.c index 5c8dc4b3d3..71cbaa1c42 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -19,6 +19,7 @@ /* utility */ #include "bitvector.h" +#include "capability.h" #include "fcintl.h" #include "log.h" #include "shared.h" @@ -738,6 +739,7 @@ void handle_edit_city(struct connection *pc, bool changed = FALSE; bool need_game_info = FALSE; bv_player need_player_info; + int history; pcity = game_city_by_number(packet->id); if (!pcity) { @@ -775,8 +777,13 @@ void handle_edit_city(struct connection *pc, } } - if (packet->history != pcity->history) { - pcity->history = packet->history; + if (has_capability("cityculture32", pc->capability)) { + history = packet->history32; + } else { + history = packet->history16; + } + if (history != pcity->history) { + pcity->history = history; changed = TRUE; } -- 2.35.1