RE: timers??
"SUPERDU¼" wrote:
> How do timers work in Multiplayer. For example, If i have a timer in
> a the game to switch turns between players. Is there anything that
> needs to be done differently that one would do localy( as in C#
Multiplayer is very different from single-player. If you have a server, you
should make sure that the server verifies all data coming from each player,
and breaks ties and enforces rules; else there will be cheating.
When it comes to synchronized timers, a typical solution is that each client
attempts to measure the round trip time between the server and the client
(RTT) and divide this by 2 to get an estimate of one-way latency. One way of
doing that is to send your current time to the server, and have the server
send it back; when you get it back, you compare your current time to the
returned value, and divide the difference by two. There are more advanced
systems, that take variance, server processing time, etc into account, too.
Once you have the server transmission latency measurement, the server can
send a message saying "time T happens in 7200 milliseconds" and you can
subtract the transmission latency (say, 100 milliseconds) to know that that
time will be about 7100 milliseconds from when you received the message.
However, you can never be 100% sure that it's accurate, so your design has
to account for the fact that someone might be late (or early). Be forgiving
of small discrepancies, and disallow large discrepancies.
date: Mon, 24 Apr 2006 22:29:01 -0700
author: Jon Watte, Microsoft DirectX MVP