Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python approach for 1.4.3.6 #10

Open
franktreppromo65 opened this issue Aug 19, 2022 · 3 comments
Open

python approach for 1.4.3.6 #10

franktreppromo65 opened this issue Aug 19, 2022 · 3 comments
Labels

Comments

@franktreppromo65
Copy link

franktreppromo65 commented Aug 19, 2022

hi, i am currently doing this decoding for myself in a python language. my goal is to merge two friends files but currently i am stuck at the part where you do :

int8[] |For each tile ID with multiple options, in sequence, the number of options is recorded.

int8[] | For each wall ID with multiple options, in sequence, the number of options is recorded.

@franktreppromo65
Copy link
Author

MapMerger.zip
so far i have this done

@TruePikachu
Copy link
Owner

I actually had ported it all over to Python+numpy, though it isn't in a format ready for any sort of release, and I don't quite plan to do more development on it unless I have a good reason to do so. This is the line which does that particular part of the reading.

def iter_bits(bytes_obj):
    for byte in bytes_obj:
        for n in (0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80):
            yield byte&n==n

# tile_has_multiple_options is the raw byte array read from that position in the header
tile_option_count = [
    (f.read(1)[0] if has_mo else 1)
    for i,has_mo in zip(range(n_tiles),iter_bits(tile_has_multiple_options))
]

In a nutshell, the array of int8 that's at that point of the map file is a variable-length array, with length equal to the number of bits set in the prior bit arrays.

@franktreppromo65
Copy link
Author

that is perfect ! i sure will get a look around and it will debug my code. if you want to callab with me, i want to merge two friends file of a same map so we can see what other have discovered in a world. i will be working on this repo:https://github.com/franktreppromo65/TerrariaMapMerging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants