本文整理汇总了C++中common::Timer::WindBackStartingTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::WindBackStartingTime方法的具体用法?C++ Timer::WindBackStartingTime怎么用?C++ Timer::WindBackStartingTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Timer
的用法示例。
在下文中一共展示了Timer::WindBackStartingTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WindBack
/* Wind back the frame counter when a save state is loaded. Currently we don't know what that means in
time so we just guess that the time is proportional the the number of frames
Todo: There are many assumptions here: We probably want to replace the time here by the actual time
that we save together with the save state or the input recording for example. And have it adjusted
for full speed playback (whether it's 30 fps or 60 fps or some other speed that the game is natively
capped at). Also the input interrupts do not occur as often as the frame renderings, they occur more
often. So we may want to move the input recording to fram updates, or perhaps sync the input interrupts
to frame updates.
*/
void WindBack(int Counter)
{
/* Counter should be smaller than g_FrameCounter, however it currently updates faster than the
frames so currently it may not be the same. Therefore I use the abs() function. */
int AbsoluteFrameDifference = abs(g_FrameCounter - Counter);
float FractionalFrameDifference = (float) AbsoluteFrameDifference / (float) g_FrameCounter;
// Update the frame counter
g_FrameCounter = Counter;
// Approximate a time to wind back the clock to
// Get the current time
u64 CurrentTimeMs = ReRecTimer.GetTimeElapsed();
// Save the current time in seconds in a new double
double CurrentTimeSeconds = (double) (CurrentTimeMs / 1000);
// Reduce it by the same proportion as the counter was wound back
CurrentTimeSeconds = CurrentTimeSeconds * FractionalFrameDifference;
// Update the clock
ReRecTimer.WindBackStartingTime((u64)CurrentTimeSeconds * 1000);
// Logging
DEBUG_LOG(CONSOLE, "WindBack: %i %u\n", Counter, (u64)CurrentTimeSeconds);
}