transmit handleInput dt
authorterom
Mon, 08 Dec 2008 23:52:08 +0000
changeset 334 0cf3f2be51eb
parent 333 50ec1ab32d2d
child 335 47dc65c8df71
transmit handleInput dt
src/Network/Client.cc
src/Network/Protocol.hh
src/Network/Server.cc
--- a/src/Network/Client.cc	Mon Dec 08 23:49:48 2008 +0000
+++ b/src/Network/Client.cc	Mon Dec 08 23:52:08 2008 +0000
@@ -295,12 +295,13 @@
 }
         
 void NetworkClientLocalPlayer::handleInput (PlayerInput input, TimeMS dt) {
-    (void) dt;
+    NetworkPacket pkt;
 
-    // always send move, in all cases
-    NetworkPacket pkt;
+    // write packet
     pkt.write_uint16(input);
-
+    pkt.write_uint32(dt);
+    
+    // send
     send(NETMSG_CLIENT_INPUT, pkt, false);
     
     // do not handle locally
--- a/src/Network/Protocol.hh	Mon Dec 08 23:49:48 2008 +0000
+++ b/src/Network/Protocol.hh	Mon Dec 08 23:52:08 2008 +0000
@@ -57,6 +57,7 @@
      * Client has input to process
      *
      *  uint16_t    PlayerInput
+     *  uint32_t    dt
      */
     NETMSG_CLIENT_INPUT         = 0x0201,
     
--- a/src/Network/Server.cc	Mon Dec 08 23:49:48 2008 +0000
+++ b/src/Network/Server.cc	Mon Dec 08 23:52:08 2008 +0000
@@ -216,11 +216,12 @@
     
     // read packet 
     PlayerInput input = pkt.read_uint16();
+    TimeMS dt = pkt.read_uint32();
 
 //    Engine::log(INFO, "server_player.on_input") << "player=" << obj << ", old_pos=" << position << ", input=" << input;
     
     // apply input
-    handleInput(input, 10);  
+    handleInput(input, dt);
 
     // send position update
     send_position_update();