Ejemplo n.º 1
0
    patcher = Patcher(rom, get_ppmdu_config_for_rom(rom))
    assert not patcher.is_applied('ActorAndLevelLoader')

    patcher.apply('ActorAndLevelLoader')

    bin_before = rom.getFileByName('BALANCE/actor_list.bin')
    # noinspection PyTypeChecker
    # - Bug in PyCharm with bound TypeVars
    actor_list_before: ActorListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_before), ActorListBin)
    # This only works with unmodified ROMs!
    assert actor_list_before.list == Pmd2XmlReader.load_default(
        'EoS_NA').script_data.level_entities
    assert len(
        Sir0Handler.deserialize(bin_before).content_pointer_offsets) == len(
            Sir0Handler.wrap_obj(actor_list_before).content_pointer_offsets)

    bin_after = Sir0Handler.serialize(Sir0Handler.wrap_obj(actor_list_before))
    # noinspection PyTypeChecker
    actor_list_after: ActorListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_after), ActorListBin)

    with open('/tmp/before.bin', 'wb') as f:
        f.write(bin_before)

    with open('/tmp/after.bin', 'wb') as f:
        f.write(bin_after)

    assert actor_list_before.list == actor_list_after.list

    for entry in actor_list_after.list:
Ejemplo n.º 2
0
        assert item_spawn_pnt in content_pointer_offsets
        item_shop_spawn_pnt = item_spawn_list_index_start + 4 * read_uintle(
            data, pnt_floor_index_entry + 0x08, 2)
        assert item_shop_spawn_pnt in content_pointer_offsets
        item_mhouse_spawn_pnt = item_spawn_list_index_start + 4 * read_uintle(
            data, pnt_floor_index_entry + 0x0A, 2)
        assert item_mhouse_spawn_pnt in content_pointer_offsets
        item_buried_spawn_pnt = item_spawn_list_index_start + 4 * read_uintle(
            data, pnt_floor_index_entry + 0x0C, 2)
        assert item_buried_spawn_pnt in content_pointer_offsets
        item_unk1_spawn_pnt = item_spawn_list_index_start + 4 * read_uintle(
            data, pnt_floor_index_entry + 0x0E, 2)
        assert item_unk1_spawn_pnt in content_pointer_offsets
        item_unk2_spawn_pnt = item_spawn_list_index_start + 4 * read_uintle(
            data, pnt_floor_index_entry + 0x10, 2)
        assert item_unk2_spawn_pnt in content_pointer_offsets
    return dungeons


mappa_bin = rom.getFileByName('BALANCE/mappa_s.bin')
mappa_sir0 = Sir0Handler.deserialize(mappa_bin)
mappa = MappaBinHandler.deserialize(mappa_bin)

validate_mappa_sir0(mappa_sir0.content, mappa_sir0.data_pointer,
                    mappa_sir0.content_pointer_offsets)
rewrapped = Sir0Handler.wrap_obj(mappa)
validate_mappa_sir0(rewrapped.content, rewrapped.data_pointer,
                    rewrapped.content_pointer_offsets)

#assert len(mappa_sir0.content_pointer_offsets) == len(rewrapped.content_pointer_offsets)