Pokemon Emerald: Send current map to trackers (#3726)
This commit is contained in:
parent
5c5f2ffc94
commit
d1a7fd7da1
|
@ -137,6 +137,8 @@ class PokemonEmeraldClient(BizHawkClient):
|
||||||
previous_death_link: float
|
previous_death_link: float
|
||||||
ignore_next_death_link: bool
|
ignore_next_death_link: bool
|
||||||
|
|
||||||
|
current_map: Optional[int]
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.local_checked_locations = set()
|
self.local_checked_locations = set()
|
||||||
|
@ -150,6 +152,7 @@ class PokemonEmeraldClient(BizHawkClient):
|
||||||
self.death_counter = None
|
self.death_counter = None
|
||||||
self.previous_death_link = 0
|
self.previous_death_link = 0
|
||||||
self.ignore_next_death_link = False
|
self.ignore_next_death_link = False
|
||||||
|
self.current_map = None
|
||||||
|
|
||||||
async def validate_rom(self, ctx: "BizHawkClientContext") -> bool:
|
async def validate_rom(self, ctx: "BizHawkClientContext") -> bool:
|
||||||
from CommonClient import logger
|
from CommonClient import logger
|
||||||
|
@ -243,6 +246,7 @@ class PokemonEmeraldClient(BizHawkClient):
|
||||||
sb1_address = int.from_bytes(guards["SAVE BLOCK 1"][1], "little")
|
sb1_address = int.from_bytes(guards["SAVE BLOCK 1"][1], "little")
|
||||||
sb2_address = int.from_bytes(guards["SAVE BLOCK 2"][1], "little")
|
sb2_address = int.from_bytes(guards["SAVE BLOCK 2"][1], "little")
|
||||||
|
|
||||||
|
await self.handle_tracker_info(ctx, guards)
|
||||||
await self.handle_death_link(ctx, guards)
|
await self.handle_death_link(ctx, guards)
|
||||||
await self.handle_received_items(ctx, guards)
|
await self.handle_received_items(ctx, guards)
|
||||||
await self.handle_wonder_trade(ctx, guards)
|
await self.handle_wonder_trade(ctx, guards)
|
||||||
|
@ -403,6 +407,31 @@ class PokemonEmeraldClient(BizHawkClient):
|
||||||
# Exit handler and return to main loop to reconnect
|
# Exit handler and return to main loop to reconnect
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
async def handle_tracker_info(self, ctx: "BizHawkClientContext", guards: Dict[str, Tuple[int, bytes, str]]) -> None:
|
||||||
|
# Current map
|
||||||
|
sb1_address = int.from_bytes(guards["SAVE BLOCK 1"][1], "little")
|
||||||
|
|
||||||
|
read_result = await bizhawk.guarded_read(
|
||||||
|
ctx.bizhawk_ctx,
|
||||||
|
[(sb1_address + 0x4, 2, "System Bus")],
|
||||||
|
[guards["SAVE BLOCK 1"]]
|
||||||
|
)
|
||||||
|
if read_result is None: # Save block moved
|
||||||
|
return
|
||||||
|
|
||||||
|
current_map = int.from_bytes(read_result[0], "big")
|
||||||
|
if current_map != self.current_map:
|
||||||
|
self.current_map = current_map
|
||||||
|
await ctx.send_msgs([{
|
||||||
|
"cmd": "Bounce",
|
||||||
|
"slots": [ctx.slot],
|
||||||
|
"tags": ["Tracker"],
|
||||||
|
"data": {
|
||||||
|
"type": "MapUpdate",
|
||||||
|
"mapId": current_map,
|
||||||
|
},
|
||||||
|
}])
|
||||||
|
|
||||||
async def handle_death_link(self, ctx: "BizHawkClientContext", guards: Dict[str, Tuple[int, bytes, str]]) -> None:
|
async def handle_death_link(self, ctx: "BizHawkClientContext", guards: Dict[str, Tuple[int, bytes, str]]) -> None:
|
||||||
"""
|
"""
|
||||||
Checks whether the player has died while connected and sends a death link if so. Queues a death link in the game
|
Checks whether the player has died while connected and sends a death link if so. Queues a death link in the game
|
||||||
|
|
Loading…
Reference in New Issue