How to implement lockstep model for RTS game?

Posted by user11177 on Game Development See other posts from Game Development or by user11177
Published on 2013-04-25T14:53:21Z Indexed on 2013/11/01 22:13 UTC
Read the original article Hit count: 388

Filed under:
|

In my effort to learn programming I'm trying to make a small RTS style game. I've googled and read a lot of articles and gamedev q&a's on the topic of lockstep synchronization in multiplayer RTS games, but am still having trouble wrapping my head around how to implement it in my own game.

I currently have a simple server/client system. For example if player1 selects a unit and gives the command to move it, the client sends the command [move, unit, coordinates] to the server, the server runs the pathfinding function and sends [move, unit, path] to all clients which then moves the unit and run animations. So far so good, but not synchronized for clients with latency or lower/higher FPS. How can I turn this into a true lockstep system?

Is the right methodology supposed to be something like the following, using the example from above:

Turn 1 start

  1. gather command inputs from player1
  2. send to the server turn number and commands
  3. end turn, increment turn number

The server receives the commands, runs pathfinding and sends the paths to all clients.

Next turn

  1. receive paths from server, as well as confirmation that all clients completed previous turn, otherwise pause and wait for that confirmation
  2. move units
  3. gather new inputs
  4. end turn

Is that the gist of it? Should perhaps pathfinding and other game logic be done client side instead of on the server, if so why? Is there anything else I'm missing? I hope someone can break down the concept, so I understand it better.

© Game Development or respective owner

Related posts about networking

Related posts about rts