Skip to content

Commit

Permalink
small accommodation
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 16, 2024
1 parent ea35ac4 commit dd700d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/engine/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,15 @@ void Com_Frame()

msec = com_frameTime - lastTime;

// For framerates up to 250fps, sleep until 1ms is remaining
// use extra margin of 2ms when looking for an higher framerate.
int margin = minMsec > 3 ? 1 : 2;

while ( msec < minMsec )
{
// Never sleep more than 50ms.
// Never sleep when there is 2ms or less remaining.
int sleep = std::max( std::min( minMsec - msec, 50 ) - 2, 0 );
// Never sleep when there is only “margin” left or less remaining.
int sleep = std::max( std::min( minMsec - msec, 50 ) - margin, 0 );

if ( sleep )
{
Expand Down

0 comments on commit dd700d1

Please sign in to comment.