Skip to content

Commit

Permalink
Various Worlds: use / explicitly for pkgutil (#4232)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwint authored Dec 9, 2024
1 parent 5b4d7c7 commit 1f712d9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion worlds/kdl3/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generate_valid_level(world: "KDL3World", level: int, stage: int,

def generate_rooms(world: "KDL3World", level_regions: Dict[int, Region]) -> None:
level_names = {location_name.level_names[level]: level for level in location_name.level_names}
room_data = orjson.loads(get_data(__name__, os.path.join("data", "Rooms.json")))
room_data = orjson.loads(get_data(__name__, "data/Rooms.json"))
rooms: Dict[str, KDL3Room] = dict()
for room_entry in room_data:
room = KDL3Room(room_entry["name"], world.player, world.multiworld, None, room_entry["level"],
Expand Down
8 changes: 4 additions & 4 deletions worlds/kdl3/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def handle_level_sprites(stages: List[Tuple[int, ...]], sprites: List[bytearray]
def write_heart_star_sprites(rom: RomData) -> None:
compressed = rom.read_bytes(heart_star_address, heart_star_size)
decompressed = hal_decompress(compressed)
patch = get_data(__name__, os.path.join("data", "APHeartStar.bsdiff4"))
patch = get_data(__name__, "data/APHeartStar.bsdiff4")
patched = bytearray(bsdiff4.patch(decompressed, patch))
rom.write_bytes(0x1AF7DF, patched)
patched[0:0] = [0xE3, 0xFF]
Expand All @@ -327,10 +327,10 @@ def write_consumable_sprites(rom: RomData, consumables: bool, stars: bool) -> No
decompressed = hal_decompress(compressed)
patched = bytearray(decompressed)
if consumables:
patch = get_data(__name__, os.path.join("data", "APConsumable.bsdiff4"))
patch = get_data(__name__, "data/APConsumable.bsdiff4")
patched = bytearray(bsdiff4.patch(bytes(patched), patch))
if stars:
patch = get_data(__name__, os.path.join("data", "APStars.bsdiff4"))
patch = get_data(__name__, "data/APStars.bsdiff4")
patched = bytearray(bsdiff4.patch(bytes(patched), patch))
patched[0:0] = [0xE3, 0xFF]
patched.append(0xFF)
Expand Down Expand Up @@ -380,7 +380,7 @@ def get_source_data(cls) -> bytes:

def patch_rom(world: "KDL3World", patch: KDL3ProcedurePatch) -> None:
patch.write_file("kdl3_basepatch.bsdiff4",
get_data(__name__, os.path.join("data", "kdl3_basepatch.bsdiff4")))
get_data(__name__, "data/kdl3_basepatch.bsdiff4"))

# Write open world patch
if world.options.open_world:
Expand Down
2 changes: 1 addition & 1 deletion worlds/ladx/LADXR/patches/bank34.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def addBank34(rom, item_list):
.notCavesA:
add hl, de
ret
""" + pkgutil.get_data(__name__, os.path.join("bank3e.asm", "message.asm")).decode().replace("\r", ""), 0x4000), fill_nop=True)
""" + pkgutil.get_data(__name__, "bank3e.asm/message.asm").decode().replace("\r", ""), 0x4000), fill_nop=True)

nextItemLookup = ItemNameStringBufferStart
nameLookup = {
Expand Down
2 changes: 1 addition & 1 deletion worlds/ladx/LADXR/patches/bank3e.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def addBank3E(rom, seed, player_id, player_name_list):
"""))

def get_asm(name):
return pkgutil.get_data(__name__, os.path.join("bank3e.asm", name)).decode().replace("\r", "")
return pkgutil.get_data(__name__, "bank3e.asm/" + name).decode().replace("\r", "")

rom.patch(0x3E, 0x0000, 0x2F00, ASM("""
call MainJumpTable
Expand Down
2 changes: 1 addition & 1 deletion worlds/lingo/static_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def find_class(self, module, name):
return getattr(safe_builtins, name)
raise pickle.UnpicklingError(f"global '{module}.{name}' is forbidden")

file = pkgutil.get_data(__name__, os.path.join("data", "generated.dat"))
file = pkgutil.get_data(__name__, "data/generated.dat")
pickdata = RenameUnpickler(BytesIO(file)).load()

HASHES.update(pickdata["HASHES"])
Expand Down
2 changes: 1 addition & 1 deletion worlds/minecraft/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pkgutil

def load_data_file(*args) -> dict:
fname = os.path.join("data", *args)
fname = "/".join(["data", *args])
return json.loads(pkgutil.get_data(__name__, fname).decode())

# For historical reasons, these values are different.
Expand Down
2 changes: 1 addition & 1 deletion worlds/mm2/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def write_bytes(self, offset: int, value: Iterable[int]) -> None:


def patch_rom(world: "MM2World", patch: MM2ProcedurePatch) -> None:
patch.write_file("mm2_basepatch.bsdiff4", pkgutil.get_data(__name__, os.path.join("data", "mm2_basepatch.bsdiff4")))
patch.write_file("mm2_basepatch.bsdiff4", pkgutil.get_data(__name__, "data/mm2_basepatch.bsdiff4"))
# text writing
patch.write_bytes(0x37E2A, MM2TextEntry("FOR ", 0xCB).resolve())
patch.write_bytes(0x37EAA, MM2TextEntry("GET EQUIPPED ", 0x0B).resolve())
Expand Down
2 changes: 1 addition & 1 deletion worlds/shivers/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pkgutil

def load_data_file(*args) -> dict:
fname = os.path.join("data", *args)
fname = "/".join(["data", *args])
return json.loads(pkgutil.get_data(__name__, fname).decode())

location_id_offset: int = 27000
Expand Down

0 comments on commit 1f712d9

Please sign in to comment.