Hello Monkeys
I recently thought a lot about network programming and how an protocol could look like.
I started off with java’s default serialization and then dropped it quickly again as it had a huuge overhead.
I came up with the following: Each Paket has a paket_header, which is something like:
class header {
public BYTE msg_id; // 0..255 -> 256 different Messages, instead of using .hashCode() which is unreliable and too long!
public int paket_length;
public BYTE compression_type; // RLE, Huffman, etc.
}
I clearly see why it’s hard to have such highly compressed headers in general purpose (on the other hand I read that spiderMonkey only needs 2 Byte for the Classname? )
So Question Number One: Is spidermonkey roughly comparable with such a manually developped protocol or is it rather for games to provide “something” where speed is not that a matter?
Furthermore I’d also include something to only send the differences between the Class-Instances (When a Player moves, there is no need to re-broadcast it’s hp, level, name, …)
I could use Spindermonkey for it, in a way I just define several messages. Is there something premade in Spidermonkey already?
What do you think? (In General, I’d go for the own protocol, to know what’s happening and for the fun of programming. On the other hand I really like things like the already implemented voice chat and streaming files etc.)
And the last Question is about the movement and anti-cheating-mechanisms:
In general I see two options:
a) The client sends the sort of key presses and the server calculates the reaction and simply set’s the Players translation (That could get highly laggy but work)
b) The client sends the new position and the server compares it to the old position and the time between the last update. I would need raytracing and collission. If he’s gone too far, he speedhacks. This would have a really smooth movement and the server would only send new positions if the player got teleported and kick him if he’s gone too far.
Do I maybe simply care way to much about cheaters? I mean it’ll be some kind of racing game and if someone throws on CheatEngine, the Fun is gone.