l0b0 / mian

Mine analysis - Graph blocks to height in a Minecraft save game
https://github.com/l0b0/mian/wiki
GNU General Public License v3.0
14 stars 4 forks source link

Beta 1.3 support #6

Closed l0b0 closed 13 years ago

l0b0 commented 13 years ago

ASAP ZULU SAMBA

Fenixin commented 13 years ago

Just and idea for this... in the last version we tried to read one chunk per time, so the memory usage was constant. This has the problem of being really slower than everything-in-memory method. Now, with region files, we can read them one by one. This can be a solution with the best of both methods. What do you think?

l0b0 commented 13 years ago

I think this makes sense, and that's what I'm trying to do ATM. I should probably just upload the current (broken) implementation so you can get an idea of what's cooking, and someone with more binary-fu can tell me exactly why my "solution" isn't getting anywhere :)

Fenixin commented 13 years ago

hahah... my binary-fu isn't as big as you think :P... but I can try to help if you upload it :)

l0b0 commented 13 years ago

I'll do it ASAP. In the meantime, what do you think of instead of going for a full-fledged parser like NBT, we do something like this: for file in .mcr: offsets, sector_counts = split_and_convert_to_int(file.read(4096)) for index in range(len(offsets)): if sector_counts[index] == 0: break chunk_length = struct.unpack('>L', file.read(4)) # I assume they are unsigned longs compression = file.read(1) chunk_raw = file.read(int(sector_counts[index] \ 4096)) chunk = inflate(chunk_raw) blocks = to_int_list(chunk) for block_hex, count in enumerate(block_counts): block_counts[block_hex] += count(block_hex, blocks) ? I'll try to develop + test this on the way to the machine with the more experimental code.

Fenixin commented 13 years ago

It looks ok to me. Which one is going to be faster? We can test both, NBT and this, and then choose.

l0b0 commented 13 years ago

Alright, it's up: 05e69ff8806429921a37019abe270010c76c87fb

Fenixin commented 13 years ago

Giving a try and coding a bit, I don't expect results now, though.

Fenixin commented 13 years ago

Well... it's working now. I've done some copy&paste job from the old mian, but works now. Almost all the job was done!

I've just pushed the working commit to my branch of beta-format, and I'm going to make a pull request, but I want to try to improve the looking of the code, so expect more commits (maybe not now, but tomorrow).

l0b0 commented 13 years ago

Awesome! Eagerly awaiting the code here. You could run it through make python-check for some low-hanging code prettifying fruit.

Fenixin commented 13 years ago

The code is in the pull request!

Fenixin commented 13 years ago

Just pushed another commit to the same pull request with some corrections according to make python-check.

l0b0 commented 13 years ago

Finished - Thanks Fenixin! Note that future versions will only support the Beta format (or newer formats) since it's much less work and it's converted automatically by the Beta client.