关于dota2同步方式
http://dev.dota2.com/showthread.php?t=527&page=7&p=4253&viewfull=1#post4253
Again, I don't recommend using that script. Let me explain how the networking model works in Dota 2 and where this "unit delay" people are describing is coming from.
The Source engine is an UDP based networking system that sends snapshot
of the unit state to the client at regular intervals. This is the
cl_updaterate and its currently locked at 20Hz on our servers right now.
This means that every 50ms, the game transmits the position of all the
units in the game, their states, etc. (For the curious, I worked with
John Carmack when this model was developed in Quakeworld at id
Software).
The way your client handles this is it interpolates between these
snapshots. By default, the cl_interp_ratio is 2, which means it
interpolates it between three snapshots. Let me explain with a
timeline. This assumes you have zero ping (or very low ping):
Time Server Client 0.00 Snapshot A Idle 0.05 Snapshot B Gives command for the hero to move 0.10 Snapshot C Idle 0.15 Snapshot D Idle
In this case, you first get Snapshot A and the client doesn't do anything as it has no succeeding snapshot. Snapshot B comes in and the client starts interpolating the motion between A and B. At this point the client tells his hero to start moving. The server responds immediately to this command and starts moving the hero on the server. Snapshot C comes in, but the client is still interpolating between A to C since cl_interp is 0.1, or 10Hz. D eventually comes in and now you start seeing the unit fully respond to your movement command as now you are interpolating between B and D. We interpolate at 10Hz instead of 20Hz so if you lose a packet from the server or its delayed a few microseconds, we "smooth" over it by interpolating around the missed packet.
There isn't an artificial unit delay, its due to the interpolating
between snapshots (which gives smooth motion on the client) that causes
it to feel a bit delayed. Since the interpolation time is 10Hz (100ms),
it can take roughly half that time, 50ms, before a unit starts to move
or appear to respond to its latest command.
Now this model was tuned for games that have prediction such as
Counterstrike, Left 4 Dead, Team Fortress 2, etc. Dota 2 doesn't have
prediction as you're basically giving orders to units on battlefield.
You're not directly controlling the player as you would in those games
and there isn't hitscan based weapons that need prediction and lag
compenstation in order to aim. You don't aim in Dota 2, you give
commands.
With this, I'm exploring increasing the snapshot frequency to lower the
interpolation time to 50ms. This will cause the perceived respond time
to lower to around a 25ms average.
Of course, you need to add your ping time to all of this. If your ping
is 135ms, then its going to take that much longer for the unit to
respond. I'm not sure why the ping is so high from France to our new
data center in Luxembourg. We recently relocated our servers there and
we're still tweaking and talking to ISPs around there. I'll talk to our
network administrators about it, but emailing me a traceroute would be
great.
dota2这篇论坛上的资料透露, Counterstrike, Left 4 Dead, Team Fortress 2等游戏都采用了该技术,而dota2在此技术的基础上,去掉了客户端预测,减少了拉扯现象,不过玩家的控制信息得不到立即反馈,该文章也是为了解答玩家关于控制延迟的疑问。
总体的意思是DOTA2使用udp,快照同步的方式,我从观看录像来分析,下载的文件有50M大小,不可能只存储了输入事件,肯定存了快照,而且录像可以快进倒退,拖动,切换阴影,确实牛逼