2 ms·
So, I'm in the middle of rewriting our game networking right now (in the huge crunch before the upcoming Steam sale), and a couple of months ago I've encountere
by golergka 8y ago
So, I'm in the middle of rewriting our game networking right now (in the huge crunch before the upcoming Steam sale), and a couple of months ago I've encountered exactly this problem. Thankfully, I've put in measuring before going and implementing the compression algorithm.
Turns out, if you have a previous version of the state, you can have an enormous results with the most basic algorithm ever: prefix + suffix. I don't even know if it has any official name. Simply put, you find a length of common prefix of the two byte arrays, a common suffix, and send only the bytes in-between with the lengths of the suffxies. Since in our entity model most changes are contained to a couple of bytes in the middle most of the time, it's not uncommon to see compression factor of 10 and more.
And, of course, after compressing any object we compare the message length to the length of uncompressed state change message, and send the shortest one.