diff --git a/MultiServer.py b/MultiServer.py index 88a4a4f0..726a21f1 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -654,27 +654,27 @@ def get_remaining(ctx: Context, team: int, slot: int) -> typing.List[int]: def register_location_checks(ctx: Context, team: int, slot: int, locations: typing.Iterable[int]): new_locations = set(locations) - ctx.location_checks[team, slot] + new_locations.intersection_update(ctx.locations[slot]) # ignore location IDs unknown to this multidata if new_locations: ctx.client_activity_timers[team, slot] = datetime.datetime.now(datetime.timezone.utc) for location in new_locations: - if location in ctx.locations[slot]: - item_id, target_player = ctx.locations[slot][location] - new_item = NetworkItem(item_id, location, slot) - if target_player != slot or slot in ctx.remote_items: - get_received_items(ctx, team, target_player).append(new_item) + item_id, target_player = ctx.locations[slot][location] + new_item = NetworkItem(item_id, location, slot) + if target_player != slot or slot in ctx.remote_items: + get_received_items(ctx, team, target_player).append(new_item) - logging.info('(Team #%d) %s sent %s to %s (%s)' % ( - team + 1, ctx.player_names[(team, slot)], get_item_name_from_id(item_id), - ctx.player_names[(team, target_player)], get_location_name_from_id(location))) - info_text = json_format_send_event(new_item, target_player) - ctx.broadcast_team(team, [info_text]) + logging.info('(Team #%d) %s sent %s to %s (%s)' % ( + team + 1, ctx.player_names[(team, slot)], get_item_name_from_id(item_id), + ctx.player_names[(team, target_player)], get_location_name_from_id(location))) + info_text = json_format_send_event(new_item, target_player) + ctx.broadcast_team(team, [info_text]) ctx.location_checks[team, slot] |= new_locations send_new_items(ctx) ctx.broadcast(ctx.clients[team][slot], [{ "cmd": "RoomUpdate", "hint_points": get_slot_points(ctx, team, slot), - "checked_locations": locations, # duplicated data, but used for coop + "checked_locations": new_locations, # send back new checks only }]) ctx.save() diff --git a/docs/network protocol.md b/docs/network protocol.md index 42669af4..4673b5b7 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -140,7 +140,7 @@ The arguments for RoomUpdate are identical to [RoomInfo](#RoomInfo) barring: | ---- | ---- | ----- | | hint_points | int | New argument. The client's current hint points. | | players | list\[NetworkPlayer\] | Changed argument. Always sends all players, whether connected or not. | -| checked_locations | May be a partial update, containing new locations that were checked. | +| checked_locations | May be a partial update, containing new locations that were checked, especially from a coop partner in the same slot. | | missing_locations | Should never be sent as an update, if needed is the inverse of checked_locations. | All arguments for this packet are optional, only changes are sent.