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
- gather command inputs from player1
- send to the server turn number and commands
- end turn, increment turn number
The server receives the commands, runs pathfinding and sends the paths to all clients.
Next turn
- receive paths from server, as well as confirmation that all clients completed previous turn, otherwise pause and wait for that confirmation
- move units
- gather new inputs
- 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.