diff options
author | Simon Howard | 2006-01-22 22:29:42 +0000 |
---|---|---|
committer | Simon Howard | 2006-01-22 22:29:42 +0000 |
commit | 6043f76a8a44d6900b42dcdcfe78f20a0be91431 (patch) | |
tree | bc0c8d8011978b32f4100adee8f1a2ec194bb321 /src/net_client.c | |
parent | e66fffd3202fe22a2eefbb4a3cb6a73048890de5 (diff) | |
download | chocolate-doom-6043f76a8a44d6900b42dcdcfe78f20a0be91431.tar.gz chocolate-doom-6043f76a8a44d6900b42dcdcfe78f20a0be91431.tar.bz2 chocolate-doom-6043f76a8a44d6900b42dcdcfe78f20a0be91431.zip |
Periodically request the time from clients to estimate their offset to
the server time.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 323
Diffstat (limited to 'src/net_client.c')
-rw-r--r-- | src/net_client.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/net_client.c b/src/net_client.c index ed24c239..b1f14c20 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 312 2006-01-21 14:16:49Z fraggle $ +// $Id: net_client.c 323 2006-01-22 22:29:42Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.23 2006/01/22 22:29:42 fraggle +// Periodically request the time from clients to estimate their offset to +// the server time. +// // Revision 1.22 2006/01/21 14:16:49 fraggle // Add first game data sending code. Check the client version when connecting. // @@ -373,6 +377,28 @@ static void NET_CL_ParseGameStart(net_packet_t *packet) autostart = true; } +static void NET_CL_ParseTimeRequest(net_packet_t *packet) +{ + net_packet_t *reply; + unsigned int seq; + + // Received a request from the server for our current time. + + if (!NET_ReadInt32(packet, &seq)) + { + return; + } + + // Send a response with our current time. + + reply = NET_NewPacket(10); + NET_WriteInt16(reply, NET_PACKET_TYPE_TIME_RESP); + NET_WriteInt32(reply, seq); + NET_WriteInt32(reply, I_GetTimeMS()); + NET_Conn_SendPacket(&client_connection, reply); + NET_FreePacket(reply); +} + // parse a received packet static void NET_CL_ParsePacket(net_packet_t *packet) @@ -403,6 +429,10 @@ static void NET_CL_ParsePacket(net_packet_t *packet) case NET_PACKET_TYPE_GAMEDATA: break; + case NET_PACKET_TYPE_TIME_REQ: + NET_CL_ParseTimeRequest(packet); + break; + default: break; } |