Synchronizing computers in a network game,
Members - Reputation: 122
Posted 22 June 2000 - 11:45 AM
Members - Reputation: 142
Posted 22 June 2000 - 04:48 PM
Read about 2-3 months down the list for a post by drone. He links to the source you could use.
The idea is simple, and independant of framerate. It all come doen to timeslices.
All you need to do is say x happened at y time then send that message to everyone. As each person recieved the message they integrate that event at the appropriate time in the past and display how the world would look should that event have happened.
It''s a VERY efficient method as all you need send is "user5 fired weapon7". It''s a little more complicated at each client end as you need to be able to have the ability to integrate things that happened say 500ms ago and forward calculate how things have changed since then.
Look up all posts by Drone about 3 months ago and any post that contains the word "Lockstep"
Drone also lists a forum on an ezboard where specific question can be asked and more info obtained.
Drone has offered his code openly, I''m still working on my code which is a little more difficult to understand as I use UDP and have to do more to make it work.
The moral of the story it, this works wonders but you have to make sure that EVERY person gets every event. This method doesn''t handle packetloss.
Good luck, it''s a good method which whips quakes ass when it comes to lag and efficiency...
Members - Reputation: 122
Posted 30 June 2000 - 05:29 PM
The first method is described by gimp: each host runs his copy of the simulation in lock step with the others. You tell everyone the exact time the missle was launched and it''s trajectory, and everyone performs collision checks every frame. As long as the hosts are perfectly in synch, then they will all see it hit the wall or not.
The biggest drawback of this method is that the networking is limited to the speed of the slowest host (since he must handle every network message before anyone else can proceed). This method may work for turn-based or RTS games, but probably not so well for action games.
The second method is to divide data into 2 categories: status updates and state changes. The first kind of data is just basic position and direction information for the player''s object (his character or ship), which can be sent quickly and unreliably -- giving pretty smooth motion at the cost of a little accuracy. It also includes other status information like current score, visible damage, or whatever.
The second kind of data, state changes, are actually negotiated with a "simulation authority". The simulation on this host has the final say -- he manages the creation, destruction, capture, and collision of objects in the world. He tracks the locations of everything, so when you have a potential collision, he confirms it. When 2 players aim for the same resource, he checks the timestamps of the requests, and picks the first one.
Finally, to put a spin on it, the simulation authority doesn''t have to be a single computer. You can divide the responsibility among several hosts (eg, each player controls his own zone), or pass the authority from host to host in order (eg, a turn-based game).