-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improved block serialization format #3946
Comments
Sure that all sounds good, but this is a longer-term enhancement that should probably come below getting other PRs merged in terms of priority. |
|
EDIT: |
I think you should consider merkle-tree-like structures first. Basically the hash of subsets of the map/data are hashed together in a tree. If a branch has the wrong hash, you ask for the sub-branch hashes, and then there must be at least one wrong there. You go down finding all the changes upto some granularity that is convenient and efficient. Could prioritize keeping/not keeping chunks on hard disk by how long the player spends near those areas. Then when (s)he logs in, very little has to be sent. (edit: as a next step)In case of changes nearby, could try for a synchronized simulation in that case, sending across events by users/server and using the hash to catch when the synchronization fails. That could be due to floating point differences or "edge of what users simulate" difference. (If floating points "diverge in small amounts too quickly" can use for the hash Lua tables/object data can also be hashed that way. Got something sortah for that, but not quite.. Edit: simplest, is to simply have hashes calculated with each chunk. Main disadvantage is that you have to iterate and hash the whole thing for each change. So it is likely better to have a bunch of sub-chunks with hashes. If one block changes, that 4³ blocks + 4³ subhashes = 128 instead of 16³ = 4096 blocks. Also can just hash occasionally, for instance when changes start, wait 5ms until hashing it, so not every change triggers rehashing. Also note that users can put whatever nodes they want. Malicious ones try find collisions causing desynchronizations. Probably not an issue though. Also springrts, had desync problems until they had this. At least, how i understand it. |
@o-jasper: What are you talking about? It doesn't sound like what you're saying has anything to do with MapBlock serialization. |
Not if you're serializing to disk, but if you're serializing for sending across the network to players, it might be premature optimization? |
The mapblock data is similar to a 3D image with colour palette, so I think that compression algorithms for image formats could be used for mapblock compression, too. |
This should either be accepted and implemented or closed |
This isn't true btw. |
Recently, while writing a utility that serializes MapBlocks and writes then to a database I noticed that there was some room for improvement for the format:
Map<SlotID, Item>
.u16
, however, this allows up to (216) nodes per block, and only different ids are actually (212) possible, wasting at least 4 bits. Also, most blocks won't have anywhere near 212 different nodes. Many will have less than 8. To reduce this waste, the content could be serialized as an array ofu8
, with an optional array ofu4
(conceptually) included if there are more than 256 distinct nodes in a block. This might be pointless if compression does a good job though.content_width
/params_width
these are set to constants and ignored. Changing then would break the format anyways.The text was updated successfully, but these errors were encountered: