Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
// FrameTimer.cpp: implementation of the CFrameTimer class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "FrameTimer.h"
|
|
|
|
|
|
List<float> CFrameTimer::m_fUpdateTimeList;
|
|
List<float> CFrameTimer::m_fTimeRemainList;
|
|
List<float> CFrameTimer::m_fPerSecondUpdateList;
|
|
DWORD CFrameTimer::m_dwTickTime;
|
|
DWORD CFrameTimer::m_dwLastUpdateTime;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CFrameTimer::CFrameTimer()
|
|
{
|
|
m_dwTickTime=-1;
|
|
}
|
|
|
|
CFrameTimer::~CFrameTimer()
|
|
{
|
|
}
|
|
|
|
void CFrameTimer::Create()
|
|
{
|
|
|
|
}
|
|
|
|
void CFrameTimer::UpdateTime()
|
|
{
|
|
if(m_dwTickTime==-1)
|
|
{
|
|
m_dwTickTime=GetTickCount();
|
|
m_dwLastUpdateTime=m_dwTickTime;
|
|
}
|
|
DWORD dwOldTickTime=m_dwTickTime;
|
|
m_dwTickTime=GetTickCount();
|
|
|
|
DWORD dwIntervalPreTime=m_dwTickTime-dwOldTickTime;
|
|
for(int i=0;i<m_fUpdateTimeList.num;i++)
|
|
{
|
|
m_fUpdateTimeList[i]=(float)dwIntervalPreTime/(1000.0f/m_fPerSecondUpdateList[i]);
|
|
m_fUpdateTimeList[i]+=m_fTimeRemainList[i];
|
|
m_fTimeRemainList[i]=m_fUpdateTimeList[i]-(int)m_fUpdateTimeList[i];
|
|
}
|
|
/*
|
|
float fUpdateFrameRate=(float)(m_dwTickTime-dwOldTickTime)/(1000.0f/35.0f);
|
|
return fUpdateFrameRate;
|
|
*/
|
|
}
|
|
|
|
int CFrameTimer::Regist(float fPerSecondUpdate)
|
|
{
|
|
m_fUpdateTimeList.Add(0.0f);
|
|
m_fTimeRemainList.Add(0.0f);
|
|
m_fPerSecondUpdateList.Add(fPerSecondUpdate);
|
|
return m_fUpdateTimeList.num-1;
|
|
}
|
|
|
|
float CFrameTimer::GetUpdateTimer(int nTimer)
|
|
{
|
|
//return 0.0f;
|
|
return m_fUpdateTimeList[nTimer];
|
|
}
|