Skip to content

Commit ae6c16b

Browse files
authored
MultiServer: send new read_hints datastore values on change (#2558)
1 parent c795c72 commit ae6c16b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

MultiServer.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -707,15 +707,18 @@ def on_goal_achieved(self, client: Client):
707707
self.save() # save goal completion flag
708708

709709
def on_new_hint(self, team: int, slot: int):
710-
key: str = f"_read_hints_{team}_{slot}"
711-
targets: typing.Set[Client] = set(self.stored_data_notification_clients[key])
712-
if targets:
713-
self.broadcast(targets, [{"cmd": "SetReply", "key": key, "value": self.hints[team, slot]}])
710+
self.on_changed_hints(team, slot)
714711
self.broadcast(self.clients[team][slot], [{
715712
"cmd": "RoomUpdate",
716713
"hint_points": get_slot_points(self, team, slot)
717714
}])
718715

716+
def on_changed_hints(self, team: int, slot: int):
717+
key: str = f"_read_hints_{team}_{slot}"
718+
targets: typing.Set[Client] = set(self.stored_data_notification_clients[key])
719+
if targets:
720+
self.broadcast(targets, [{"cmd": "SetReply", "key": key, "value": self.hints[team, slot]}])
721+
719722
def on_client_status_change(self, team: int, slot: int):
720723
key: str = f"_read_client_status_{team}_{slot}"
721724
targets: typing.Set[Client] = set(self.stored_data_notification_clients[key])
@@ -975,7 +978,10 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations: typi
975978
"hint_points": get_slot_points(ctx, team, slot),
976979
"checked_locations": new_locations, # send back new checks only
977980
}])
978-
981+
old_hints = ctx.hints[team, slot].copy()
982+
ctx.recheck_hints(team, slot)
983+
if old_hints != ctx.hints[team, slot]:
984+
ctx.on_changed_hints(team, slot)
979985
ctx.save()
980986

981987

0 commit comments

Comments
 (0)