OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ApplicationGameTimer Class Reference

#include <C4Application.h>

Inheritance diagram for C4ApplicationGameTimer:
[legend]
Collaboration diagram for C4ApplicationGameTimer:
[legend]

Public Member Functions

 C4ApplicationGameTimer ()
 
void SetGameTickDelay (uint32_t iDelay)
 
bool Execute (int iTimeout, pollfd *) override
 
bool IsLowPriority () override
 

Detailed Description

Definition at line 108 of file C4Application.h.

Constructor & Destructor Documentation

C4ApplicationGameTimer::C4ApplicationGameTimer ( )

Definition at line 861 of file C4Application.cpp.

864 {
865 }
#define CStdMultimediaTimerProc
Definition: StdScheduler.h:216

Member Function Documentation

bool C4ApplicationGameTimer::Execute ( int  iTimeout,
pollfd *   
)
override

Definition at line 888 of file C4Application.cpp.

References Application, C4GameParameters::AutoFrameSkip, C4Game::DoSkipFrame, C4Application::Draw(), Game, C4Game::GameGo, C4Application::GameTick(), C4TimeMilliseconds::Now(), and C4Game::Parameters.

889 {
890  // Check timer and reset
891  if (!CheckAndReset()) return true;
893  // Execute
894  if (tNow >= tLastGameTick + iExtraGameTickDelay || Game.GameGo)
895  {
896  if (iGameTickDelay)
897  tLastGameTick += iGameTickDelay;
898  else
899  tLastGameTick = tNow;
900 
901  // Compensate if things get too slow
902  if (tNow > tLastGameTick + iGameTickDelay)
903  tLastGameTick += (tNow - tLastGameTick) / 2;
904 
906  }
907  // Draw
908  if (!Game.DoSkipFrame)
909  {
911 
912  Application.Draw();
913 
914  // Automatic frame skip if graphics are slowing down the game (skip max. every 2nd frame)
915  Game.DoSkipFrame = Game.Parameters.AutoFrameSkip && (tPreGfxTime + iGameTickDelay < C4TimeMilliseconds::Now());
916  } else {
917  Game.DoSkipFrame=false;
918  }
919  return true;
920 }
C4Game Game
Definition: C4Globals.cpp:52
bool DoSkipFrame
Definition: C4Game.h:137
C4GameParameters & Parameters
Definition: C4Game.h:67
bool GameGo
Definition: C4Game.h:135
C4Application Application
Definition: C4Globals.cpp:44
static C4TimeMilliseconds Now()

Here is the call graph for this function:

bool C4ApplicationGameTimer::IsLowPriority ( )
override

Definition at line 922 of file C4Application.cpp.

922 { return true; }
void C4ApplicationGameTimer::SetGameTickDelay ( uint32_t  iDelay)

Definition at line 867 of file C4Application.cpp.

References Config, C4Config::Graphics, and C4ConfigGraphics::MaxRefreshDelay.

Referenced by C4Application::SetGameTickDelay().

868 {
869  // Remember delay
870  iGameTickDelay = iDelay;
871  // Smaller than minimum refresh delay?
872  if (iDelay < uint32_t(Config.Graphics.MaxRefreshDelay))
873  {
874  // Set critical timer
875  SetDelay(iDelay);
876  // No additional breaking needed
877  iExtraGameTickDelay = 0;
878  }
879  else
880  {
881  // Set critical timer
882  SetDelay(Config.Graphics.MaxRefreshDelay);
883  // Slow down game tick
884  iExtraGameTickDelay = iDelay;
885  }
886 }
C4Config Config
Definition: C4Config.cpp:833
C4ConfigGraphics Graphics
Definition: C4Config.h:253
int32_t MaxRefreshDelay
Definition: C4Config.h:113

Here is the caller graph for this function:


The documentation for this class was generated from the following files: