SpComb wrote:
eis_os wrote:
* only if we can't gurantee the order, a timestamp, counter order...
Sending packets in the same order to all the clients shouldn't be a problem, as long as the relative ordering of packets from different clients doesn't matter.
If the package of one player come into a stream, and not like mixed between Player 1 3 4 2 1 3 then this should be ok.
SpComb wrote:
eis_os wrote:
0x30 = heartbeat
0x41 = random gen value
0x42 = setplayer
0x43 = newgrfmap with md5sums
0x44 = get sync package
0x45 = sync package (whole savegame data)
0x60 = change setting that affect others, like the gamespeed
These need more details, I know the heartbeat is what tells the client what frame to advance to, but the others need more clarification, I gather they are related to what happens when a new client connects?
For the beginning only really the heartbeat and randomgen values are really needed. To advance the game and to look if the games run out of sync. Currently. As we transfer all actions as old TTD we should have a synced game after we connect two players. We should start with some small steps and do the highlevel error fixing later. (We assume that both TTD(Patch) are the same, and that we keep the player settings until the TTDPatch core works async enough-
SpComb wrote:
eis_os wrote:
When TTD normally would wait 27ms,
a framecounter is increased and waits on the network to recieve the next heartbeat (service) package,
Server creates every 27ms a heartbeat package, all clients wait for it so they can progress to the next frame,
From what I've understood, the clients buffer the DoActions, and when they get a hearbeat packet for a frame, they execute all DoActions up to and including that frame?
The hearbeat package is the clock signal. As OTTD do, we still think both games work in sync when there is no userinteraction. The userinteraction is passed to the network completly and not stored. Some frame later it will return on all machines the same frametime. (The differene here, we don't wait for the player action to really happen as TTD does, but the result will be somewhere in the future)
Yes, this still has some latency problem. Actually I assume that the latency doesn't change much between packages, so I assume if package needs 100ms to travel, the next won't be that different and need aswell 100ms +-27ms.
Then you have have a steady time offset to your server and the UI keeps responsive. Only all players work with a past TTD Version. To be exact their client will be always one traveltime of the heartbeat package away. And their actions, (build an rail as example) will need exactly transmit time x 2 to do really something in the game. But aswell OTTD can't change physic. A player action (you build something) have to be reached all clients before the timestamp to really do the action has been reached. This means a OTTD action needs to be [traveltime to server] + [slowest possible time to send from client to server] + [fixed value to compensate latency issues] in the future.
SpComb wrote:
We discussed latency issues a long time ago on #tycoon, will the server still perform some magic to help with those?
The game runs clocked by the server. While you will see latency differency changes outside the 27ms the game should run normally.
(As I said, it works by assumeing that your connection isn't highly changeing the latency.)
Code:
Heartbeat at Client 1: <##latency 1##> 1 2 3 4 5 6
>------------------------------------- Timeline
Heartbeat at Client 2: <###latency 2###> 1 2 3 4 5 6
As soon as latency changes, say Client 2 gets a lower latency, you will have one frame or more that are shorter as usally, until it has resolved the latency difference. Say the latency drops from 181 ms to 100, then you client has to fix 81ms, if we say a frame in TTD has a minium of 10ms we have synced again in around 9 frames.
If the latency gets higher, we have a problem, then we can only wait until the next heartbeat package (with maybe new player created actions) arrive. If the latency changes from 100ms to 181ms, the player has a stop of 81ms unresponsive UI.
(This can be little bit compensated if we cache say 2 frames always on the client side before TTD really starts doing something, a bit like a audio stream, you don't hear something really until the cache is full) If the cache gets empty, we need to throttle the client a bit, and say, we change the frame time to 30ms, so in 81 frames, we get an extra one in our cache)
Hmm, to make it for all people understandable, TTDPatch Multiplayer would work like a music or video stream, you have to wait a bit on start to get a cache, then if something bad happens on the line, you will eat the cache, But if the cache gets smaller, your TTD will get abit slower,a) you don't have something in the cache, you get a fullstop or b) your cache gets filled again, and your TTD will run in normal speed.
*edit*
Trying fixing the Broken quotes...