Endianess
This is an old article from 2013. I was a kid. I learned a lot since then,
so please do think twice when taking advice from me as a kid.
I recently spent 5 hours trying to figure out why my maps I write from an own made “tiled” plugin (Java) aren’t beeing read properly in my ninjarun game (C), already knowing all along it must be because of the endianess (But I’m always lazy to mess with the actual bits themselves, so I spent all my time googling for proof, before I actually start reversing byte orders).
Java stores it’s stuff as big-endian **whereas c will try to load it as **little-endian.
So, how do you cope with this problem? Simplest: Save the file in Java
as little-endian. This can be very easily accomplished by using
ByteBuffers, and setting using .order(ByteOrder.LITTLE_ENDIAN)
This post was imported from tumblr