本文整理汇总了C++中Plat_FloatTime函数的典型用法代码示例。如果您正苦于以下问题:C++ Plat_FloatTime函数的具体用法?C++ Plat_FloatTime怎么用?C++ Plat_FloatTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Plat_FloatTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void GhostEntity::updateStep() {
const size_t runsize = ghostData.RunData.Count();
if (step < 0 || step >= runsize) {
currentStep = nextStep = NULL;
return;
}
currentStep = &ghostData.RunData[step];
float currentTime = ((float)Plat_FloatTime() - startTime);
if (currentTime > currentStep->tim) {//catching up to a fast ghost, you came in late
unsigned int x = step + 1;
while (++x < runsize) {
if (Q_strlen(ghostData.RunData[x].map) > 0) {
Q_strcpy(currentMap, ghostData.RunData[x].map);
}
if (currentTime < ghostData.RunData[x].tim) {
break;
}
}
step = x - 1;
}
currentStep = &ghostData.RunData[step];//update it to the new step
//here's where we can get current time: currentStep->tim
GhostRun* thisrun = GhostEngine::getEngine()->getRun(this);
GhostHud::hud()->UpdateGhost((size_t)thisrun, step, currentMap);
currentTime = ((float)Plat_FloatTime() - startTime);//update to new time
if (step == (runsize - 1)) {//if it's on the last step
thisrun->EndRun();
} else {
nextStep = &ghostData.RunData[step+1];
}
}
示例2: RunThreadsOn
/*
=============
RunThreadsOn
=============
*/
void RunThreadsOn( int workcnt, qboolean showpacifier, RunThreadsFn fn, void *pUserData )
{
int start, end;
start = Plat_FloatTime();
dispatch = 0;
workcount = workcnt;
StartPacifier("");
pacifier = showpacifier;
#ifdef _PROFILE
threaded = false;
(*func)( 0 );
return;
#endif
RunThreads_Start( fn, pUserData );
RunThreads_End();
end = Plat_FloatTime();
if (pacifier)
{
EndPacifier(false);
printf (" (%i)\n", end-start);
}
}
示例3: main
//-----------------------------------------------------------------------------
// Tests the process.cpp stuff
//-----------------------------------------------------------------------------
int main( int argc, char **argv )
{
CommandLine()->CreateCmdLine( argc, argv );
InstallSpewFunction();
float flDelay = CommandLine()->ParmValue( "-delay", 0.0f );
const char *pEndMessage = CommandLine()->ParmValue( "-message", "Test Finished!\n" );
int nEndExtraBytes = CommandLine()->ParmValue( "-extrabytes", 0 );
if ( flDelay > 0.0f )
{
float t = Plat_FloatTime();
while ( Plat_FloatTime() - t < flDelay )
{
}
}
Msg( pEndMessage );
if ( nEndExtraBytes )
{
while( --nEndExtraBytes >= 0 )
{
Msg( "%c", ( nEndExtraBytes % 10 ) + '0' );
}
}
return 0;
}
示例4: FloodAreas
/*
=============
FloodAreas
Mark each leaf with an area, bounded by CONTENTS_AREAPORTAL
=============
*/
void FloodAreas (tree_t *tree)
{
int start = Plat_FloatTime();
qprintf ("--- FloodAreas ---\n");
Msg("Processing areas...");
FindAreas_r (tree->headnode);
SetAreaPortalAreas_r (tree, tree->headnode);
qprintf ("%5i areas\n", c_areas);
Msg("done (%d)\n", (int)(Plat_FloatTime() - start) );
}
示例5: DETOUR_DECL_STATIC
DETOUR_DECL_STATIC(void, S_Play, const char *pszName, bool flush)
{
std::lock_guard<std::mutex> lock(m_S_Play);
LOGMEM("[%12.7f] BEGIN S_Play\n", Plat_FloatTime());
{
SCOPED_INCREMENT(rc_S_Play);
DETOUR_STATIC_CALL(S_Play)(pszName, flush);
}
LOGMEM("[%12.7f] END S_Play\n\n", Plat_FloatTime());
}
示例6: ValidateRect
//-----------------------------------------------------------------------------
// main application
//-----------------------------------------------------------------------------
void CVsVGuiWindow::PaintWindow()
{
if ( m_nCurrentTick == m_nLastRenderedTick || !g_pVGui->IsRunning() )
{
ValidateRect( m_hWnd, NULL );
return;
}
m_nCurrentTick = m_nLastRenderedTick;
vgui::VPANEL root = g_pVGuiSurface->GetEmbeddedPanel();
g_pVGuiSurface->Invalidate( root );
RECT windowRect;
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
::GetClientRect( m_hWnd, &windowRect );
g_pMaterialSystem->SetView( m_hWnd );
pRenderContext->Viewport( 0, 0, windowRect.right, windowRect.bottom );
float flStartTime = Plat_FloatTime();
pRenderContext->ClearColor4ub( 76, 88, 68, 255 );
pRenderContext->ClearBuffers( true, true );
g_pMaterialSystem->BeginFrame( 0 );
// draw from the main panel down
if ( m_hMainPanel.Get() )
{
int w, h;
m_hMainPanel->GetSize( w, h );
if ( w != windowRect.right || h != windowRect.bottom )
{
m_hMainPanel->SetBounds( 0, 0, windowRect.right, windowRect.bottom );
m_hMainPanel->Repaint();
}
g_pVGuiSurface->RestrictPaintToSinglePanel( m_hMainPanel->GetVPanel() );
g_pVGuiSurface->PaintTraverseEx( root, true );
g_pVGuiSurface->RestrictPaintToSinglePanel( 0 );
}
g_pMaterialSystem->EndFrame();
g_pMaterialSystem->SwapBuffers();
g_pMaterialSystem->SetView( NULL );
ValidateRect( m_hWnd, NULL );
m_flRenderDelayTime = Plat_FloatTime() - flStartTime;
m_flRenderDelayTime = max( m_flRenderDelayTime, 0.015f );
}
示例7: Assert
//-----------------------------------------------------------------------------
// Runs the main loop.
//-----------------------------------------------------------------------------
void IGameManager::Start()
{
Assert( !m_bIsRunning && m_bIsInitialized );
m_bIsRunning = true;
m_bStopRequested = false;
// This option is useful when running the app twice on the same machine
// It makes the 2nd instance of the app run a lot faster
bool bPlayNice = ( CommandLine()->CheckParm( "-yieldcycles" ) != 0 );
float flStartTime = m_flCurrentTime = m_flLastTime = Plat_FloatTime();
int nFramesSimulated = 0;
int nCount = m_GameManagers.Count();
while ( !m_bStopRequested )
{
UpdateLevelStateMachine();
m_flLastTime = m_flCurrentTime;
m_flCurrentTime = Plat_FloatTime();
int nSimulationFramesNeeded = 1 + (int)( ( m_flCurrentTime - flStartTime ) / TICK_INTERVAL );
while( nSimulationFramesNeeded > nFramesSimulated )
{
for ( int i = 0; i < nCount; ++i )
{
if ( m_GameManagers[i]->PerformsSimulation() )
{
m_GameManagers[i]->Update();
}
}
++m_nFrameNumber;
++nFramesSimulated;
}
// Always do I/O related managers regardless of framerate
for ( int i = 0; i < nCount; ++i )
{
if ( !m_GameManagers[i]->PerformsSimulation() )
{
m_GameManagers[i]->Update();
}
}
if ( bPlayNice )
{
Sleep( 1 );
}
}
m_bIsRunning = false;
}
示例8: AddServicesBrowserIP
// This tracks a list
void AddServicesBrowserIP( const CIPAddr &ipFrom )
{
for ( int i=0; i < g_ServicesBrowsers.Count(); i++ )
{
if ( g_ServicesBrowsers[i].m_Addr == ipFrom )
{
g_ServicesBrowsers[i].m_flLastPingTime = Plat_FloatTime();
return;
}
}
CServicesBrowserInfo info;
info.m_Addr = ipFrom;
info.m_flLastPingTime = Plat_FloatTime();
g_ServicesBrowsers.AddToTail( info );
}
示例9: Plat_FloatTime
void BaseTimedTester::ProcessTests()
{
if((Plat_FloatTime() - m_lastTestDone) < m_jobMinPeriod) return;
m_lastTestDone = Plat_FloatTime();
PlayerHandler* h = nullptr;
for(int x = 1; x <= MAX_PLAYERS; ++x)
{
h = NczPlayerManager::GetInstance()->GetPlayerHandlerByIndex(x);
if(h->status == GetFilter())
{
ProcessPlayerTest(h->playerClass);
}
}
}
示例10: HandlePacket_KILL_PROCESS
void HandlePacket_KILL_PROCESS( const CIPAddr *ipFrom )
{
if ( Plat_FloatTime() - g_flLastKillProcessTime > 5 )
{
KillRunningProcess( "Got a KILL_PROCESS packet. Stopping the worker executable.\n", true );
if ( ipFrom )
{
AddServicesBrowserIP( *ipFrom );
SendStateToServicesBrowsers();
}
g_flLastKillProcessTime = Plat_FloatTime();
}
}
示例11: UpdateBenchmark
virtual void UpdateBenchmark()
{
// No benchmark running?
if ( m_BenchmarkState == BENCHMARKSTATE_NOT_RUNNING )
return;
// Wait a certain number of ticks to start the benchmark.
if ( m_BenchmarkState == BENCHMARKSTATE_START_WAIT )
{
if ( (Plat_FloatTime() - m_flBenchmarkStartTime) < m_flBenchmarkStartWaitTime )
{
UpdateStartWaitCounter();
return;
}
else
{
// Ok, now we're officially starting it.
Msg( "Starting benchmark!\n" );
m_flLastBenchmarkCounterUpdate = m_flBenchmarkStartTime = Plat_FloatTime();
m_fl_ValidTime_BenchmarkStartTime = Benchmark_ValidTime();
m_nBenchmarkStartTick = gpGlobals->tickcount;
m_nLastPhysicsObjectTick = m_nLastPhysicsForceTick = 0;
m_BenchmarkState = BENCHMARKSTATE_RUNNING;
StartVProfRecord();
RandomSeed( 0 );
m_RandomStream.SetSeed( 0 );
}
}
int nTicksRunSoFar = gpGlobals->tickcount - m_nBenchmarkStartTick;
UpdateBenchmarkCounter();
// Are we finished with the benchmark?
if ( nTicksRunSoFar >= sv_benchmark_numticks.GetInt() )
{
EndVProfRecord();
OutputResults();
EndBenchmark();
return;
}
// Ok, update whatever we're doing in the benchmark.
UpdatePlayerCreation();
UpdateVPhysicsObjects();
CServerBenchmarkHook::s_pBenchmarkHook->UpdateBenchmark();
}
示例12: InternalStartBenchmark
// nBenchmarkMode: 0 = no benchmark
// 1 = benchmark
// 2 = exit out afterwards and write sv_benchmark.txt
bool InternalStartBenchmark( int nBenchmarkMode, float flCountdown )
{
bool bWasRunningBenchmark = (m_BenchmarkState != BENCHMARKSTATE_NOT_RUNNING);
if ( nBenchmarkMode == 0 )
{
// Tear down the previous benchmark environment if necessary.
if ( bWasRunningBenchmark )
EndBenchmark();
return false;
}
m_nBenchmarkMode = nBenchmarkMode;
if ( !CServerBenchmarkHook::s_pBenchmarkHook )
Error( "This game doesn't support server benchmarks (no CServerBenchmarkHook found)." );
m_BenchmarkState = BENCHMARKSTATE_START_WAIT;
m_flBenchmarkStartTime = Plat_FloatTime();
m_flBenchmarkStartWaitTime = flCountdown;
m_nBotsCreated = 0;
m_nStartWaitCounter = -1;
// Setup the benchmark environment.
engine->SetDedicatedServerBenchmarkMode( true ); // Run 1 tick per frame and ignore all timing stuff.
// Tell the game-specific hook that we're starting.
CServerBenchmarkHook::s_pBenchmarkHook->StartBenchmark();
CServerBenchmarkHook::s_pBenchmarkHook->GetPhysicsModelNames( m_PhysicsModelNames );
return true;
}
示例13: DETOUR_DECL_MEMBER
DETOUR_DECL_MEMBER(void *, IMemAlloc_Realloc, void *pMem, size_t nSize)
{
std::lock_guard<std::mutex> lock(m_Realloc);
SCOPED_INCREMENT(rc_Realloc);
auto result = DETOUR_MEMBER_CALL(IMemAlloc_Realloc)(pMem, nSize);
if (mem_tracking && rc_Realloc <= 1 && nSize >= cvar_minimum.GetInt()) {
auto it = mems.find(pMem);
if (it != mems.end()) {
mems.erase(it);
if (mems.find(result) == mems.end()) {
LOGMEM("[%12.7f] Realloc %7u 0x%08x => 0x%08x\n", Plat_FloatTime(), nSize, (uintptr_t)pMem, (uintptr_t)result);
mems[result] = nSize;
} else {
Warning("IMemAlloc::Realloc: pointer already in map!\n");
}
} else {
// Warning("IMemAlloc::Realloc: reallocation of untracked pointer!\n");
}
// if (cvar_realloc.GetBool()) {
// LOGMEM("[%12.7f] Realloc %7u 0x%08x => 0x%08x\n", Plat_FloatTime(), nSize, (uintptr_t)pMem, (uintptr_t)result);
// }
}
return result;
}
示例14: Msg
//---------------------------------------------------------------------------------
// Purpose: called when a client spawns into a server (i.e as they begin to play)
//---------------------------------------------------------------------------------
void CNoCheatZPlugin::ClientActive( edict_t *pEntity )
{
Msg("%f : CNoCheatZPlugin::ClientActive\n", Plat_FloatTime());
NczPlayerManager::GetInstance()->ClientActive(pEntity);
PlayerHandler* ph = NczPlayerManager::GetInstance()->GetPlayerHandlerByEdict(pEntity);
if(ph->status > BOT) HookBasePlayer(ph->playerClass);
}
示例15: Msg
//-----------------------------------------------------------------------------
// Purpose: called when an event that counts toward an achievement occurs
//-----------------------------------------------------------------------------
void CBaseAchievement::IncrementCount()
{
if ( !IsAchieved() )
{
if ( !m_pAchievementMgr->CheckAchievementsEnabled() )
{
Msg( "Achievements disabled, ignoring achievement progress for %s\n", GetName() );
return;
}
// on client, where the count is kept, increment count
m_iCount++;
// if this achievement gets saved w/global state, flag our global state as dirty
if ( GetFlags() & ACH_SAVE_GLOBAL )
{
m_pAchievementMgr->SetDirty( true );
}
if ( cc_achievement_debug.GetInt() )
{
Msg( "Achievement count increased for %s: %d/%d\n", GetName(), m_iCount, m_iGoal );
}
// if this achievement's progress should be stored in Steam, set the steam stat for it
if ( StoreProgressInSteam() && steamapicontext->SteamUserStats() )
{
// Set the Steam stat with the same name as the achievement. Only cached locally until we upload it.
char pszProgressName[1024];
Q_snprintf( pszProgressName, 1024, "%s_STAT", GetName() );
bool bRet = steamapicontext->SteamUserStats()->SetStat( CGameID( engine->GetAppID() ), pszProgressName, m_iCount );
if ( !bRet )
{
DevMsg( "ISteamUserStats::GetStat failed to set progress value in Steam for achievement %s\n", pszProgressName );
}
// Upload user data to commit the change to Steam so if the client crashes, progress isn't lost.
// Only upload if we haven't uploaded recently, to keep us from spamming Steam with uploads. If we don't
// upload now, it will get uploaded no later than level shutdown.
if ( ( m_pAchievementMgr->GetTimeLastUpload() == 0 ) || ( Plat_FloatTime() - m_pAchievementMgr->GetTimeLastUpload() > 60 * 15 ) )
{
m_pAchievementMgr->UploadUserData();
}
}
// if we've hit goal, award the achievement
if ( m_iGoal > 0 )
{
if ( m_iCount >= m_iGoal )
{
AwardAchievement();
}
else
{
HandleProgressUpdate();
}
}
}
}