From 6b53941100d4bee9c0711b7149e12b4f0a765692 Mon Sep 17 00:00:00 2001 From: jamesbrq Date: Sat, 24 Aug 2024 16:44:16 -0400 Subject: [PATCH] v1.5.2 --- GauntletLegendsClient.py | 3 +- worlds/gl/GauntletLegendsClient.py | 64 +++++++++++++++--------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/GauntletLegendsClient.py b/GauntletLegendsClient.py index b3b0f2ad78a7..b076eafd36c4 100644 --- a/GauntletLegendsClient.py +++ b/GauntletLegendsClient.py @@ -1,6 +1,7 @@ -from worlds.gl.GauntletLegendsClient import launch import ModuleUpdate ModuleUpdate.update() +from worlds.gl.GauntletLegendsClient import launch + if __name__ == "__main__": launch() diff --git a/worlds/gl/GauntletLegendsClient.py b/worlds/gl/GauntletLegendsClient.py index 9cd585e994f9..09b2b7f76096 100644 --- a/worlds/gl/GauntletLegendsClient.py +++ b/worlds/gl/GauntletLegendsClient.py @@ -27,7 +27,7 @@ READ = "READ_CORE_RAM" WRITE = "WRITE_CORE_RAM" INV_ADDR = 0xC5BF0 -OBJ_ADDR = 0xC5B20 +OBJ_ADDR = 0xBC22C INV_UPDATE_ADDR = 0x56094 INV_LAST_ADDR = 0x56084 ACTIVE_POTION = 0xFD313 @@ -202,6 +202,7 @@ def __init__(self, server_address, password): self.obelisk_locations: List[LocationData] = [] self.chest_locations: List[LocationData] = [] self.extra_items: int = 0 + self.extra_spawners: int = 0 self.limbo: bool = False self.in_portal: bool = False self.scaled: bool = False @@ -273,60 +274,59 @@ async def get_obj_addr(self) -> int: # Objects are 0x3C bytes long # Modes: 0 = items, 1 = chests/barrels async def obj_read(self, mode=0): - obj_address = await self.get_obj_addr() _obj = [] - if self.offset == -1: - b = RamChunk(await self.socket.read(message_format(READ, f"0x{format(obj_address, 'x')} 3840"))) - b.iterate(0x3C) - for i, arr in enumerate(b.split): - if arr[0] != 0xFF: - self.offset = i - break b: RamChunk if mode == 0: - b = RamChunk( - await self.socket.read( - message_format( - READ, - f"0x{format(obj_address + (self.offset * 0x3C), 'x')} {(len(self.item_locations) + 2) * 0x3C}", - ), - ), - ) - b.iterate(0x3C) - count = 0 - for obj in b.split: - if obj[0] == 0xFF and obj[1] == 0xFF: - count += 1 - self.extra_items = count - else: - spawner_count = len([spawner for spawner in spawners[(self.current_level[1] << 4) + (self.current_level[0] if self.current_level[1] != 1 else castle_id.index(self.current_level[0]) + 1)] if self.difficulty >= spawner]) - count = 0 - for i in range((spawner_count + 99) // 100): + while True: b = RamChunk( await self.socket.read( message_format( READ, - f"0x{format(obj_address + ((self.offset + len(self.item_locations) + self.extra_items + (i * 100)) * 0x3C), 'x')} {min((spawner_count - (100 * i)), 100) * 0x3C}", + f"0x{format(OBJ_ADDR, 'x')} {(len(self.item_locations) + self.extra_items) * 0x3C}", ), ), ) b.iterate(0x3C) + count = 0 for obj in b.split: if obj[0] == 0xFF and obj[1] == 0xFF: count += 1 - self.extra_items += count + count -= self.extra_items + if count <= 0: + break + self.extra_items = count + else: + spawner_count = len([spawner for spawner in spawners[(self.current_level[1] << 4) + ( + self.current_level[0] if self.current_level[1] != 1 else castle_id.index(self.current_level[0]) + 1)] if + self.difficulty >= spawner]) + if self.extra_spawners == 0: + count = 0 + for i in range((spawner_count + 99) // 100): + b = RamChunk( + await self.socket.read( + message_format( + READ, + f"0x{format(OBJ_ADDR + ((len(self.item_locations) + self.extra_items + (i * 100)) * 0x3C), 'x')} {min((spawner_count - (100 * i)), 100) * 0x3C}", + ), + ), + ) + b.iterate(0x3C) + for obj in b.split: + if obj[0] == 0xFF and obj[1] == 0xFF: + count += 1 + self.extra_spawners += count b = RamChunk( await self.socket.read( message_format( READ, - f"0x{format(obj_address + ((self.offset + len(self.item_locations) + self.extra_items + spawner_count) * 0x3C), 'x')} {(len(self.chest_locations) + 2) * 0x3C}", + f"0x{format(OBJ_ADDR + ((len(self.item_locations) + self.extra_items + self.extra_spawners + spawner_count) * 0x3C), 'x')} {(len(self.chest_locations) + 2) * 0x3C}", ), ), ) b.iterate(0x3C) for arr in b.split: _obj += [ObjectEntry(arr)] - _obj = [obj for obj in _obj if obj.raw[0] != 0xFF or obj.raw[1] != 0xFF] + _obj = [obj for obj in _obj if obj.raw[0] != 0xFF and obj.raw[1] != 0xFF] if mode == 1: self.chest_objects = _obj[:len(self.chest_locations)] else: @@ -631,7 +631,7 @@ async def scout_locations(self, ctx: "GauntletLegendsContext") -> None: "cmd": "LocationScouts", "locations": [ location.id - for location in [location for location in raw_locations if min(self.difficulty, max(self.glslotdata["max"], self.players)) >= location.difficulty] + for location in [location for location in raw_locations if min(self.difficulty, self.glslotdata["max"]) >= location.difficulty] ], "create_as_hint": 0, },