Jak and Daxter: fix checks getting lost if player disconnects. (#5280)

This commit is contained in:
massimilianodelliubaldini
2025-08-19 12:08:39 -04:00
committed by GitHub
parent 9a64b8c5ce
commit 48906de873

View File

@@ -135,6 +135,10 @@ class JakAndDaxterContext(CommonContext):
self.tags = set() self.tags = set()
await self.send_connect() await self.send_connect()
async def disconnect(self, allow_autoreconnect: bool = False):
self.locations_checked = set() # Clear this set to gracefully handle server disconnects.
await super(JakAndDaxterContext, self).disconnect(allow_autoreconnect)
def on_package(self, cmd: str, args: dict): def on_package(self, cmd: str, args: dict):
if cmd == "RoomInfo": if cmd == "RoomInfo":
@@ -177,6 +181,10 @@ class JakAndDaxterContext(CommonContext):
create_task_log_exception(get_orb_balance()) create_task_log_exception(get_orb_balance())
# If there were any locations checked while the client wasn't connected, we want to make sure the server
# knows about them. To do that, replay the whole location_outbox (no duplicates will be sent).
self.memr.outbox_index = 0
# Tell the server if Deathlink is enabled or disabled in the in-game options. # Tell the server if Deathlink is enabled or disabled in the in-game options.
# This allows us to "remember" the user's choice. # This allows us to "remember" the user's choice.
self.on_deathlink_toggle() self.on_deathlink_toggle()
@@ -254,6 +262,7 @@ class JakAndDaxterContext(CommonContext):
# We don't need an ap_inform function because check_locations solves that need. # We don't need an ap_inform function because check_locations solves that need.
def on_location_check(self, location_ids: list[int]): def on_location_check(self, location_ids: list[int]):
self.locations_checked.update(location_ids) # Populate this set to gracefully handle server disconnects.
create_task_log_exception(self.check_locations(location_ids)) create_task_log_exception(self.check_locations(location_ids))
# CommonClient has no finished_game function, so we will have to craft our own. TODO - Update if that changes. # CommonClient has no finished_game function, so we will have to craft our own. TODO - Update if that changes.