Skip to main content
gamedev.net
🔒 Locked

Sync to level start

Started by XiotexStudios 6 replies 1.6k views
Original Post
XiotexStudios
XiotexStudios
Hi, Has anyone come up with a good solution to sync to level start on a peer-to-peer net connection? What I want to achieve is that when the client and server are ready to go and actually play the game they both start at exactly the same point and that on both sides the level is completely loaded. The game I am working on is an 'arcade' type game so the initial sync is important. The current mechanism I have is both client and server send a 'level ready' packet out. On reciept both sides bounce this message back, when the bounced message is recieved each side proceeds to play the game. All was fine until I turned on my 'bad network' emulator and the server never got its bounced message but the client did and it proceeded to play the game without the server... Has anyone come up with a good way of getting around this?
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
XiotexStudios
XiotexStudios
One really really really hacky way of getting around this problem I have come up with is that if I have a message that I really really want to get through then I send multiple copies off in the hope that one of them gets through. But tbh this stinks.

Oh, I forgot to mention that I am using UDP - but you should have been able to derive that :)
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
boenzlip
boenzlip

what you would need is an UDP equivalent of TCPs ACK to check if the ready packet is received correctly. Or simpler: do the initial handshake over TCP, since the sync should be reliable anyway and is not time critical
XiotexStudios
XiotexStudios
Well.. I am kind of emulating the ACK using UDP.

I would go down the TCP route except I don't want to deal with the TCP stack handling the timeout for me. By using UDP I can at least make a detirmination early.
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
XiotexStudios
XiotexStudios
That sounds like a plan!
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
Anon Mike
Anon Mike
I've always thought this problem was interesting. It's basically a version of The Byzantine Generals Problem. The fundamental issue is that you can never be 100% certain that both sides are ready. You end up in infinite loops of "does A know that B knows that A knows that B knows...".
-Mike
hplus0603
hplus0603
Typically, you'll synchronize time by sending timestamps and measuring latency in each packet, and then agree on a start time a few steps into the future; when time synchronizes to that point, you start the game. This only needs a rough agreement on the progress on time, and will give you a start synchronization that's as good as your time synchronization (which is equivalent to your movement position synchronization).

Note that if the link is so unreliable you can't even synchronize time, then you can't play over the link, and thus the issue is moot.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.