MultiServer: filter new locations via sets, instead of if and only echo new checks
This commit is contained in:
parent
39ff471772
commit
c381df6563
|
@ -654,10 +654,10 @@ 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]):
|
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 = set(locations) - ctx.location_checks[team, slot]
|
||||||
|
new_locations.intersection_update(ctx.locations[slot]) # ignore location IDs unknown to this multidata
|
||||||
if new_locations:
|
if new_locations:
|
||||||
ctx.client_activity_timers[team, slot] = datetime.datetime.now(datetime.timezone.utc)
|
ctx.client_activity_timers[team, slot] = datetime.datetime.now(datetime.timezone.utc)
|
||||||
for location in new_locations:
|
for location in new_locations:
|
||||||
if location in ctx.locations[slot]:
|
|
||||||
item_id, target_player = ctx.locations[slot][location]
|
item_id, target_player = ctx.locations[slot][location]
|
||||||
new_item = NetworkItem(item_id, location, slot)
|
new_item = NetworkItem(item_id, location, slot)
|
||||||
if target_player != slot or slot in ctx.remote_items:
|
if target_player != slot or slot in ctx.remote_items:
|
||||||
|
@ -674,7 +674,7 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations: typi
|
||||||
ctx.broadcast(ctx.clients[team][slot], [{
|
ctx.broadcast(ctx.clients[team][slot], [{
|
||||||
"cmd": "RoomUpdate",
|
"cmd": "RoomUpdate",
|
||||||
"hint_points": get_slot_points(ctx, team, slot),
|
"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()
|
ctx.save()
|
||||||
|
|
|
@ -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. |
|
| hint_points | int | New argument. The client's current hint points. |
|
||||||
| players | list\[NetworkPlayer\] | Changed argument. Always sends all players, whether connected or not. |
|
| 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. |
|
| 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.
|
All arguments for this packet are optional, only changes are sent.
|
||||||
|
|
Loading…
Reference in New Issue