From 9b1937aa1fba3bb37ef0a25e2409e195363dd54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sat, 4 Mar 2023 14:29:01 +0100 Subject: [PATCH] - Base diff --git a/client/packhand.c b/client/packhand.c index abc2c4bf93..f4e02fa130 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -5556,3 +5556,32 @@ void handle_ruleset_counter(const struct packet_ruleset_counter *packet) attach_city_counter(curr); } + +/**********************************************************************//** +Handle updating city's counter, when server request +**************************************************************************/ +void handle_city_update_counters(const struct packet_city_update_counters *packet) +{ + uint8_t i; + uint8_t counters_count = counters_get_city_counters_count(); + + struct city *pcity = game_city_by_number(packet->city); + + if (NULL == pcity) { + + return; + } + + if (counters_count != packet->count) { + + return; + } + + counters_count = counters_get_city_counters_count(); + for (i = 0; i < counters_count; i++) { + pcity->counter_values[i] = packet->counters[i]; + } + + update_city_description(pcity); + city_report_dialog_update_city(pcity); +} diff --git a/common/fc_types.h b/common/fc_types.h index a406c53da0..5042a51cde 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -105,6 +105,10 @@ enum output_type_id { O_FOOD, O_SHIELD, O_TRADE, O_GOLD, O_LUXURY, O_SCIENCE, O_LAST }; +/* Counters related definitions. See common/counters.h */ +/* Used in the network protocol. */ +#define MAX_COUNTERS 20 + /* Counters related types. See common/counters.h */ /* Used in the network protocol. */ #define SPECENUM_NAME counter_behaviour diff --git a/common/networking/packets.def b/common/networking/packets.def index c1f8e6da7d..48daa07777 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -3,7 +3,7 @@ Max used id: ============ -Max id: 513 +Max id: 514 Packets are not ordered by their id, but by their category. New packet with higher id may get added to existing category, and not to the end of file. @@ -304,6 +304,7 @@ type ACTION_ID = uint8(action_id) type ACTION_TGT = SINT32 type ACTION_SUB_TGT = SINT16 type BASE = sint8(Base_type_id) +type COUNTER = UINT32 type ROAD = sint8(Road_type_id) type CITY = UINT16 # city id, with space for special values @@ -777,6 +778,12 @@ PACKET_CITY_NATIONALITIES = 46; sc, lsend, is-game-info, force CITIZENS nation_citizens[MAX_CITY_NATIONALITIES:nationalities_count]; end +PACKET_CITY_UPDATE_COUNTERS = 514; sc, lsend, is-game-info + CITY city; key + UINT8 count; # MAX_COUNTERS is set to 20 currently + COUNTER counters[MAX_COUNTERS:count]; +end + PACKET_CITY_SHORT_INFO = 32; sc, lsend, is-game-info, cancel(PACKET_CITY_INFO), cancel(PACKET_WEB_CITY_INFO_ADDITION) CITY id; key TILE tile; diff --git a/server/citytools.c b/server/citytools.c index c628c1253d..51885ce722 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -2343,11 +2343,6 @@ void send_city_info(struct player *dest, struct city *pcity) send_city_info_at_tile(dest, dest->connections, pcity, pcity->tile); } - /* Sending counters */ - city_counters_iterate(pcount) { - city_counter_refresh(pcity, pcount->index); - } city_counters_iterate_end; - if (game.info.team_pooled_research && player_list_size(team_members(powner->team)) > 1) { /* We want to send the new total bulbs production of the team. */ -- 2.39.2