Opened 9 years ago
Last modified 8 years ago
#3309 closed defect
[PATCH] Disappearing lag makes the game fast forward for all players — at Version 5
Reported by: | elexis | Owned by: | |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 19 |
Component: | Network | Keywords: | |
Cc: | Philip Taylor | Patch: |
Description (last modified by )
Disappearing lag As noted by sanderd17 in comment 3, the issue described below appears always when lag disappears: http://wildfiregames.com/forum/index.php?showtopic=18797 By doing fast forward the game tries to compensate the previous slow motion caused by lag. However the game should never exceed the defined game speed, so that players can always issue commands.
Fast Forwarding Replays
If you change the game_speeds.json
file to support 20x speed, you will observe the following bug when doing a visual replay. If you try to set the gamespeed back to 1x and the replay has been playing for a while with 20x speed with bad performance, then the units are still walking in 20x speed over the screen while the simulation is only updated with 1x speed. So you basically can't set it back to regular speed instantaneously, but have to wait until all simulation updates were rendered.
See Game.cpp
line 389:
// At the normal sim rate, we currently want to render at least one // frame per simulation turn, so let maxTurns be 1. But for fast-forward // sim rates we want to allow more, so it's not bounded by framerate, // so just use the sim rate itself as the number of turns per frame. size_t maxTurns = (size_t)m_SimRate;
The function CGame::Update
or one of its assets must be changed somehow to fix this, so that people can replay with arbitrary game speeds.
Maybe the game can also skip the rendering of frames, so that you can actually fast forward with 20x speed if your CPU but not the graphics card supports it.
Change History (8)
comment:1 by , 9 years ago
by , 9 years ago
Attachment: | commands_tradelag.txt added |
---|
An example replay file to reproduce the issue (produces lag by spamming trade carts). Edit game_speeds.json
to support 20x speed. Enable time warp mode in the develoeprs overlay, hit backspace and change the gamespeed to fix the described bug.
by , 9 years ago
Attachment: | t3309_fix_very_fast_forward_v1.patch added |
---|
Resets m_DeltaSimTime
to zero when changing the game speed and also sets back the next turn to currentTurn + 1. Works.
comment:2 by , 9 years ago
Keywords: | patch review added |
---|---|
Milestone: | Backlog → Alpha 19 |
Summary: | Very Fast Forward doesn't return to regular speed instantaneously → [PATCH] Very Fast Forward doesn't return to regular speed instantaneously |
comment:3 by , 9 years ago
This problem ought to be solved on a more general level. It happens whenever there's lag, followed by turns without lag. See http://wildfiregames.com/forum/index.php?showtopic=18797 as example.
So the deltaSimTime should probably be capped in some way. On one side, it's nice to catch up the lag when a turn took just a bit more time than it was given, but it's not nice if the catchup accumulates to a level where it will take multiple turns at full speed to catch up.
by , 9 years ago
Attachment: | t3309_cap_expected_simTime_v2.patch added |
---|
comment:4 by , 9 years ago
In multiplayer mode m_DeltaSimTime
also increases over time. However if the lag is gone, then the variable is set back to zero and the game continues in the desired speed instantaneously.
Reproduce:
- Start a multiplayer game with debug output for
m_DeltaSimTime
, 20x speed and a second client. - Create hundreds of units and move them somewhere.
- Notice that it lags and that
m_DeltaSimTime
increases. - Alt + doubleclick on a unit to select and delete all of them.
- Notice that the lag has gone and that
m_DeltaSimTime
is set back to zero that moment..
If you do the same with only one client, then the effect doesn't happen.
If there is lag in multiplayer that disappears at a later point and if all clients have perfect performance, then all players will try to catch up with the expected simulation time and thus will go in fast forward mode.
But as noted on the forum thread above, this doesn't make sense at all, since the user can't issue any more orders.
Therefore the simulation speed must be reset as soon as the user can issue commands, i.e. the next turn. This can be achieved by just caping the expected simulation time (defined relatively in m_DeltaSimTime
).
We speculated on IRC that multiplayer games will always lag in situations of disappearing lag (as described above). But in case where lag disappears, there won't be any lagging. The only thing that won't happen anymore is that the clients won't try to fast forward to compensate. Rather it will always go with the currently defined game speed, which is expected (contrary to fast forwarding).
comment:5 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | [PATCH] Very Fast Forward doesn't return to regular speed instantaneously → [PATCH] Disappearing lag makes the game fast forward for all players |
The
m_DeltaSimTime
variable will become bigger and bigger over time (when replaying with high speed when its 'laggy'). Its value is increased in the beginning ofCNetTurnManager::Update
and then reduced afterwards:
but if it can't keep up with the selected speed, then the value is not reduced sufficiently. It won't reach zero anymore as it ought to be but grows instead.
This problem is reproducible in singleplayer mode too, where you can change the speed live and make the game laggy by producing many units with cheats.
Possible solution: If you have reproduced the issue, enabled time warp mode, hit backspace for rewinding a bit, and select the game speed again, then the issue is fixed!
That time warp mode however can cause the game to crash:
(experienced on r16797).