LADX: more tracker support (#4355)

* init

* oops
This commit is contained in:
threeandthreee
2025-04-05 12:39:31 -04:00
committed by GitHub
parent 4571ed7e2f
commit c2d8f2443e
3 changed files with 29 additions and 20 deletions

View File

@@ -638,6 +638,12 @@ class LinksAwakeningContext(CommonContext):
if cmd == "Connected": if cmd == "Connected":
self.game = self.slot_info[self.slot].game self.game = self.slot_info[self.slot].game
self.slot_data = args.get("slot_data", {}) self.slot_data = args.get("slot_data", {})
# This is sent to magpie over local websocket to make its own connection
self.slot_data.update({
"server_address": self.server_address,
"slot_name": self.player_names[self.slot],
"password": self.password,
})
# TODO - use watcher_event # TODO - use watcher_event
if cmd == "ReceivedItems": if cmd == "ReceivedItems":
@@ -722,7 +728,9 @@ class LinksAwakeningContext(CommonContext):
try: try:
self.magpie.set_checks(self.client.tracker.all_checks) self.magpie.set_checks(self.client.tracker.all_checks)
await self.magpie.set_item_tracker(self.client.item_tracker) await self.magpie.set_item_tracker(self.client.item_tracker)
if self.slot_data and "slot_data" in self.magpie.features and not self.magpie.has_sent_slot_data:
self.magpie.slot_data = self.slot_data self.magpie.slot_data = self.slot_data
await self.magpie.send_slot_data()
if self.client.gps_tracker.needs_found_entrances: if self.client.gps_tracker.needs_found_entrances:
await self.request_found_entrances() await self.request_found_entrances()

View File

@@ -184,6 +184,7 @@ class MagpieBridge:
ws = None ws = None
features = [] features = []
slot_data = {} slot_data = {}
has_sent_slot_data = False
def use_entrance_tracker(self): def use_entrance_tracker(self):
return "entrances" in self.features \ return "entrances" in self.features \
@@ -207,8 +208,6 @@ class MagpieBridge:
await self.send_all_inventory() await self.send_all_inventory()
if "checks" in self.features: if "checks" in self.features:
await self.send_all_checks() await self.send_all_checks()
if "slot_data" in self.features and self.slot_data:
await self.send_slot_data(self.slot_data)
if self.use_entrance_tracker(): if self.use_entrance_tracker():
await self.send_gps(diff=False) await self.send_gps(diff=False)
@@ -288,17 +287,17 @@ class MagpieBridge:
return await self.gps_tracker.send_entrances(self.ws, diff) return await self.gps_tracker.send_entrances(self.ws, diff)
async def send_slot_data(self, slot_data): async def send_slot_data(self):
if not self.ws: if not self.ws:
return return
logger.debug("Sending slot_data to magpie.") logger.debug("Sending slot_data to magpie.")
message = { message = {
"type": "slot_data", "type": "slot_data",
"slot_data": slot_data "slot_data": self.slot_data
} }
await self.ws.send(json.dumps(message)) await self.ws.send(json.dumps(message))
self.has_sent_slot_data = True
async def serve(self): async def serve(self):
async with websockets.serve(lambda w: self.handler(w), "", 17026, logger=logger): async with websockets.serve(lambda w: self.handler(w), "", 17026, logger=logger):

View File

@@ -589,4 +589,6 @@ class LinksAwakeningWorld(World):
for option, value in dataclasses.asdict(self.options).items() if option in slot_options_display_name for option, value in dataclasses.asdict(self.options).items() if option in slot_options_display_name
}) })
slot_data.update({"entrance_mapping": self.ladxr_logic.world_setup.entrance_mapping})
return slot_data return slot_data