diff options
author | Simon Howard | 2015-05-31 04:29:15 -0400 |
---|---|---|
committer | Simon Howard | 2015-05-31 04:29:15 -0400 |
commit | d6556ee4b4d9d2c4c9ac48f998bd387f5416b75d (patch) | |
tree | 327e6fb430aeb47ba42de94ca7f1a7f6bc377042 /src/hexen/m_random.c | |
parent | e06b8d3e5a650a61307d644eae1269a64817c02b (diff) | |
download | chocolate-doom-d6556ee4b4d9d2c4c9ac48f998bd387f5416b75d.tar.gz chocolate-doom-d6556ee4b4d9d2c4c9ac48f998bd387f5416b75d.tar.bz2 chocolate-doom-d6556ee4b4d9d2c4c9ac48f998bd387f5416b75d.zip |
Fix bug with frames being rendered twice.
This actually (I believe) fixes three separate issues that are all
aspects of the same bug:
* Alexandre-Xavier reported that when running at full framerate, the
single -devparm dot would flash (#374);
* Linguica reported on Doomworld that Chocolate Doom appeared to be
rendering each tic twice (see:
http://www.doomworld.com/vb/post/1340374 ).
* Harha reported performance problems when running in a VM, which
may be related (http://www.doomworld.com/vb/post/1374315 ).
Chocolate Doom long ago (41cdd5785305a) changed the main loop code so
that it does not freeze in network games when tics stop being
received; the idea is that it should always be possible to activate
the menu to quit. Vanilla Doom allows this too, but only after 20 tics
of waiting in TryRunTics() for network data to be received; the menu
can be used but is deathly slow. So the loop was changed to wait for
only 1 tic instead.
However, there was an error in the logic for the check. In a single
player game, when time has advanced to the point of being ready to
execute another tic, NetUpdate() will build the new ticcmd_t;
TryRunTics() was returning immediately; according to the timer, at the
exact same time as tic generation, we had also been spinning in the
loop for a whole tic and it was time to render a new frame.
The end result was that each tic transition would trigger two frames
to be rendered: the previous frame, and the new frame. Clearly this is
not what is intended.
To fix the problem:
* Refactor the blocking loop in TryRunTics() so that we only bail out
of the function after checking that the loop's exit condition has
not just been satisfied (also to eliminate an unnecessary call to
I_Sleep() between ticcmd_t generation and execution).
* Increase the delay before we bail out to 5 tics rather than just 1.
This is still much less than the 20 used in Vanilla Doom but is
low enough to keep the menu responsive. A higher bar should ensure
that this bug can't reoccur, even in multiplayer where the clocks
can be adjusted for sync.
This fixes #374. Thanks to everyone involved in reporting the different
aspects of it.
Diffstat (limited to 'src/hexen/m_random.c')
0 files changed, 0 insertions, 0 deletions