Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into gl
  • Loading branch information
jamesbrq committed Jul 31, 2024
2 parents 1dd5b0b + 6ab9963 commit bdb072e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
24 changes: 22 additions & 2 deletions worlds/gl/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def patch_items(caller: APProcedurePatch, rom: bytes):
for i in range(len(level_locations)):
level: Dict[str, Tuple] = json.loads(caller.get_file(f"level_{i}.json").decode("utf-8"))
stream.seek(level_address[i], 0)
stream, data = get_level_data(stream, level_size[i])
stream, data = get_level_data(stream, level_size[i], i)
for j, (location_name, item) in enumerate(level.items()):
if item[0] == 0:
continue
Expand Down Expand Up @@ -233,6 +233,22 @@ def locations_to_dict(locations: List[Location]) -> Dict[str, Tuple]:
return {location.name: (location.item.code, location.item.player) if location.item is not None else (0, 0) for location in locations}


def patch_docks(data: LevelData) -> LevelData:
data.stream.seek(0x19AC, 0)
data.stream.write(bytes([0x2, 0xF0, 0x0, 0x18, 0x1, 0x6F]))
data.stream.seek(0x80, 0)
data.stream.write(bytes([0x3, 0x4E, 0x0, 0x1A, 0x1, 0x32]))
return data


def patch_camp(data: LevelData) -> LevelData:
data.stream.seek(0x1B74, 0)
data.stream.write(bytes([0xFF, 0x2, 0x0, 0x3B, 0xFF, 0xF9]))
data.stream.seek(0x1B64, 0)
data.stream.write(bytes([0xFE, 0x6B, 0x0, 0x3D, 0xFF, 0xEE]))
return data


# Zlib decompression with wbits set to -15
def zdec(data):
"""
Expand Down Expand Up @@ -262,9 +278,13 @@ def zenc(data):


# Create a LevelData object from raw decompressed bytes of a level
def get_level_data(stream: io.BytesIO, size: int) -> (io.BytesIO, LevelData):
def get_level_data(stream: io.BytesIO, size: int, level=0) -> (io.BytesIO, LevelData):
data = LevelData()
data.stream = io.BytesIO(zdec(stream.read(size)))
if level == 17:
data = patch_docks(data)
if level == 18:
data = patch_camp(data)
data.header = data.stream.read(0x5C)
data.stream.seek(0)
data.item_addr = int.from_bytes(data.stream.read(4), "big")
Expand Down
5 changes: 2 additions & 3 deletions worlds/gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import typing

import settings
from BaseClasses import ItemClassification, Tutorial, Item
from BaseClasses import ItemClassification, Tutorial
from Fill import fast_fill

from worlds.AutoWorld import WebWorld, World
Expand Down Expand Up @@ -73,7 +73,6 @@ class GauntletLegendsWorld(World):
item_name_to_id = {name: data.code for name, data in item_table.items()}
location_name_to_id = {loc_data.name: loc_data.id for loc_data in all_locations}
required_client_version = (0, 5, 0)
death: typing.List[Item] = []
crc32: str = None

disabled_locations: typing.List[LocationData]
Expand Down Expand Up @@ -162,7 +161,7 @@ def fill_slot_data(self) -> dict:
"characters": characters,
"max": (self.options.max_difficulty_value.value if self.options.max_difficulty_toggle else 4),
"instant_max": self.options.instant_max.value,
"death_link": self.options.death_link.value == 1
"death_link": bool((self.options.death_link.value == 1))
}

def create_items(self) -> None:
Expand Down

0 comments on commit bdb072e

Please sign in to comment.