2424)
2525from NetUtils import ClientStatus , NetworkItem , NetworkPlayer
2626
27- from .items import wsr_items
27+ from .items import wsr_items , WSRItem
28+ from .LocationList import location_table
2829
2930if TYPE_CHECKING :
3031 import kvui
@@ -86,7 +87,7 @@ class CommandRequest:
8687 def __init__ (self , command : bytes , timeout : float = 10.0 ):
8788 self .command = command
8889 self .timeout = timeout
89- self .future = asyncio .get_running_loop (). create_future () # asyncio. Future()
90+ self .future = asyncio .Future ()
9091 self .timestamp = time .time ()
9192
9293# =============================================================================#
@@ -467,9 +468,6 @@ async def server_auth(self, password_requested: bool = False) -> None:
467468
468469 @param password_requested: Whether the server requires a password. Defaults to `False`.
469470 """
470-
471- self .log ("Authenticating with the Archipelago server..." )
472-
473471 if password_requested and not self .password :
474472 await super ().server_auth (password_requested )
475473
@@ -495,7 +493,7 @@ def on_package(self, cmd: str, args: dict[str, Any]) -> None:
495493 self .last_rcvd_index = args ["index" ]
496494
497495 for item in args ["items" ]:
498- self .items_rcvd .append (item , self .last_rcvd_index )
496+ self .items_rcvd .append (( item , self .last_rcvd_index ) )
499497 self .last_rcvd_index += 1
500498
501499 self .items_rcvd .sort (key = lambda v : v [1 ])
@@ -534,7 +532,26 @@ async def check_locations(self) -> None:
534532
535533 response = await self .wii_client .send_packet (bytes (), packet_type_id = CommandID .LOCATION )
536534
537- logger .info (f"Location Data in bytes: { self .wii_client .most_recent_packet_data } " )
535+ p_data = self .wii_client .most_recent_packet_data
536+
537+ if (int .from_bytes ((p_data ), byteorder = "big" ) == 4294967295 ):
538+ return
539+
540+ locations_checked = []
541+ location = None
542+
543+ for i in range (0 , len (p_data ), 4 ):
544+ location = int .from_bytes (p_data [i :i + 4 ], byteorder = "big" )
545+ for l in self .missing_locations :
546+ logger .info (l )
547+ if location in self .missing_locations :
548+ self .locations_checked .add (WSRItem .get_apid (location ))
549+ locations_checked .append (location )
550+
551+ if locations_checked :
552+ logger .info (f"Sending new check: { p_data } " )
553+ await self .send_msgs ([{"cmd" : "LocationsChecks" , "locations" : locations_checked }])
554+
538555
539556
540557
@@ -593,7 +610,6 @@ async def sync_loop(ctx: WSRContext) -> None:
593610 if ctx .is_hooked ():
594611 await ctx .give_items ()
595612 await ctx .check_locations ()
596-
597613 if ctx .awaiting_rom :
598614 await ctx .server_auth ()
599615
0 commit comments