@@ -13,7 +13,10 @@ namespace Lockstep.Network.Server
1313 /// </summary>
1414 public class Room
1515 {
16- private const int TargetFps = 20 ;
16+ /// <summary>
17+ /// Server determines the default speed of the simulation measured in FPS
18+ /// </summary>
19+ private const int SimulationSpeed = 20 ;
1720
1821 private byte _nextPlayerId ;
1922 private readonly int _size ;
@@ -70,7 +73,12 @@ private void OnDataReceived(int clientId, byte[] data)
7073 switch ( messageTag )
7174 {
7275 case MessageTag . Input :
73- _server . Distribute ( clientId , data ) ;
76+ var clientTick = reader . GetUInt ( ) ;
77+ var commandsCount = reader . GetInt ( ) ;
78+ if ( commandsCount > 0 )
79+ {
80+ _server . Distribute ( clientId , data ) ;
81+ }
7482 break ;
7583
7684 case MessageTag . HashCode :
@@ -111,7 +119,7 @@ private void StartSimulationOnConnectedPeers()
111119 var writer = new Serializer ( ) ;
112120
113121 //Create a new seed and send it with a start-message to all clients
114- //The message also contains the respective player-id and the servers' frame rate
122+ //The message also contains the respective player-id and the initial simulation speed
115123 var seed = new Random ( ) . Next ( int . MinValue , int . MaxValue ) ;
116124
117125 foreach ( var player in _playerIds )
@@ -123,7 +131,7 @@ private void StartSimulationOnConnectedPeers()
123131 Seed = seed ,
124132 ActorID = player . Value ,
125133 AllActors = _playerIds . Values . ToArray ( ) ,
126- TargetFPS = TargetFps
134+ SimulationSpeed = SimulationSpeed
127135 } . Serialize ( writer ) ;
128136
129137 _server . Send ( player . Key , Compressor . Compress ( writer ) ) ;
0 commit comments