From e93e09371811b9370848c0a69195005f227830c7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 5 Jan 2024 14:56:46 +0200 Subject: [PATCH 30/30] Make real_embassy a bitvector in network protocol See osdn #48224 Signed-off-by: Marko Lindqvist --- client/packhand.c | 11 +---------- common/networking/packets.def | 2 +- server/plrhand.c | 10 +++------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 43afb553a9..0065fd10a4 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -2522,16 +2522,7 @@ void handle_player_info(const struct packet_player_info *pinfo) pplayer->client.tech_upkeep = pinfo->tech_upkeep; pplayer->government = pgov; pplayer->target_government = ptarget_gov; - /* Don't use player_iterate here, because we ignore the real number - * of players and we want to read all the datas. */ - BV_CLR_ALL(pplayer->real_embassy); - fc_assert(8 * sizeof(pplayer->real_embassy) - >= ARRAY_SIZE(pinfo->real_embassy)); - for (i = 0; i < ARRAY_SIZE(pinfo->real_embassy); i++) { - if (pinfo->real_embassy[i]) { - BV_SET(pplayer->real_embassy, i); - } - } + pplayer->real_embassy = pinfo->real_embassy; pplayer->gives_shared_vision = pinfo->gives_shared_vision; pplayer->gives_shared_tiles = pinfo->gives_shared_tiles; pplayer->style = style_by_number(pinfo->style); diff --git a/common/networking/packets.def b/common/networking/packets.def index 2c90e7f8c3..25e57f26b4 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -930,7 +930,7 @@ PACKET_PLAYER_INFO = 51; sc, is-info BOOL was_created; GOVERNMENT government; GOVERNMENT target_government; - BOOL real_embassy[MAX_NUM_PLAYER_SLOTS]; + BV_PLAYER real_embassy; MOOD mood; UINT8 style; SINT8 music_style; diff --git a/server/plrhand.c b/server/plrhand.c index 76b91d346b..8b796b3f43 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1421,16 +1421,12 @@ static void package_player_info(struct player *plr, packet->target_government = plr->target_government ? government_number(plr->target_government) : government_count(); - memset(&packet->real_embassy, 0, sizeof(packet->real_embassy)); - players_iterate(pother) { - packet->real_embassy[player_index(pother)] = - player_has_real_embassy(plr, pother); - } players_iterate_end; + packet->real_embassy = plr->real_embassy; packet->gives_shared_vision = plr->gives_shared_vision; packet->gives_shared_tiles = plr->gives_shared_tiles; } else { packet->target_government = packet->government; - memset(&packet->real_embassy, 0, sizeof(packet->real_embassy)); + BV_CLR_ALL(packet->real_embassy); BV_CLR_ALL(packet->gives_shared_vision); BV_CLR_ALL(packet->gives_shared_tiles); @@ -1438,7 +1434,7 @@ static void package_player_info(struct player *plr, int ridx = player_index(receiver); if (player_has_real_embassy(plr, receiver)) { - packet->real_embassy[ridx] = TRUE; + BV_SET(packet->real_embassy, ridx); } if (gives_shared_vision(plr, receiver)) { -- 2.43.0