From 9baf732b73b0fd0ca0cf7eecf0adbb62ea592ad4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 1 Oct 2023 22:10:05 +0300 Subject: [PATCH 54/54] Make flagless units ownerless in client side See osdn #48782 Signed-off-by: Marko Lindqvist --- client/packhand.c | 4 ---- server/unittools.c | 16 +++++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 010d842e07..08b237874a 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -364,11 +364,7 @@ unpackage_short_unit(const struct packet_unit_short_info *packet) struct player *owner; if (packet->owner == OWNER_NONE) { - /* Silently ignore for now. */ - return nullptr; -/* owner = nullptr; -*/ } else { owner = player_by_number(packet->owner); } diff --git a/server/unittools.c b/server/unittools.c index a7d919b5a0..8a96dc6576 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -2629,7 +2629,7 @@ void package_unit(struct unit *punit, struct packet_unit_info *packet) } /**********************************************************************//** - Package a short_unit_info packet. This contains a limited amount of + Package a short_unit_info packet. This contains a limited amount of information about the unit, and is sent to players who shouldn't know everything (like the unit's owner's enemies). **************************************************************************/ @@ -2641,7 +2641,13 @@ void package_short_unit(struct unit *punit, packet->info_city_id = info_city_id; packet->id = punit->id; - packet->owner = player_number(unit_owner(punit)); + + if (unit_has_type_flag(punit, UTYF_FLAGLESS)) { + packet->owner = OWNER_NONE; + } else { + packet->owner = player_number(unit_owner(punit)); + } + packet->tile = tile_index(unit_tile(punit)); packet->facing = punit->facing; packet->veteran = punit->veteran; @@ -2655,15 +2661,15 @@ void package_short_unit(struct unit *punit, packet->activity = punit->activity; } - if (punit->activity_target == NULL) { + if (punit->activity_target == nullptr) { packet->activity_tgt = EXTRA_NONE; } else { packet->activity_tgt = extra_index(punit->activity_target); } /* Transported_by information is sent to the client even for units that - * aren't fully known. Note that for non-allied players, any transported - * unit can't be seen at all. For allied players we have to know if + * aren't fully known. Note that for non-allied players, any transported + * unit can't be seen at all. For allied players we have to know if * transporters have room in them so that we can load units properly. */ if (!unit_transported(punit)) { packet->transported = FALSE; -- 2.40.1