void CGameSA::SuspendASyncLoading ( bool bSuspend, uint uiAutoUnsuspendDelay ) { m_bASyncLoadingSuspended = bSuspend; // Setup auto unsuspend time if required if ( uiAutoUnsuspendDelay && bSuspend ) m_llASyncLoadingAutoUnsuspendTime = CTickCount::Now() + CTickCount( (long long)uiAutoUnsuspendDelay ); else m_llASyncLoadingAutoUnsuspendTime = CTickCount(); }
void CMapManager::DoPickupRespawning ( void ) { // Grab the current time CTickCount currentTime = CTickCount::Now(); // Loop through each pickup looking for respawnable ones CPickup* pPickup; list < CPickup* > ::const_iterator iterPickups = m_pPickupManager->IterBegin (); for ( ; iterPickups != m_pPickupManager->IterEnd (); iterPickups++ ) { pPickup = *iterPickups; // Do we have to respawn this one and is it time to? const CTickCount lastUsedTime = pPickup->GetLastUsedTime (); const CTickCount creationTime = pPickup->GetCreationTime (); if ( pPickup->IsEnabled () == false ) { // Allow time for the element to be at least sent client side before allowing collisions otherwise it's possible to get a collision before the pickup is created. DO NOT WANT! - Caz if ( currentTime >= ( creationTime + CTickCount( 100LL ) ) && pPickup->HasDoneDelayHack() == false ) { // make sure we only happen once. pPickup->SetDoneDelayHack ( true ); pPickup->SetEnabled ( true ); } } if ( !pPickup->IsSpawned () && lastUsedTime != CTickCount( 0LL ) && currentTime >= ( lastUsedTime + CTickCount( (long long)pPickup->GetRespawnIntervals() ) ) ) { // Set it as spawned pPickup->SetSpawned ( true ); // Eventually randomize the random stuff in the pickup pPickup->Randomize (); // Tell everyone to show it CPickupHideShowPacket Packet ( true ); Packet.Add ( pPickup ); m_pPlayerManager->BroadcastOnlyJoined ( Packet ); // Mark it visible pPickup->SetVisible ( true ); // Call the on pickup spawn event CLuaArguments Arguments; pPickup->CallEvent ( "onPickupSpawn", Arguments ); } } }
// For blow respawn timer void CVehicle::SetIsBlown ( bool bBlown ) { if ( !bBlown ) m_llBlowTime = CTickCount ( 0LL ); else m_llBlowTime = CTickCount::Now (); }
/////////////////////////////////////////////////////////////// // // CPerfStatDebugTableImpl::UpdateLine // // Add/update a line by a string key. // /////////////////////////////////////////////////////////////// void CPerfStatDebugTableImpl::UpdateLine ( const SString& strKey, int iLifeTimeMs, ... ) { LOCK_SCOPE ( m_CS ); SLineInfo& info = MapGet( m_LineMap, strKey ); info.strCellList.clear (); // Get cells va_list vl; va_start ( vl, iLifeTimeMs ); while ( true ) { char* szText = va_arg ( vl, char* ); if ( !szText ) break; info.strCellList.push_back ( szText ); } va_end ( vl ); if ( info.strCellList.empty () ) info.strCellList.push_back ( "" ); // Update end time info.bHasEndTime = ( iLifeTimeMs > 0 ); if ( info.bHasEndTime ) info.endTickCount = CTickCount::Now ( true ) + CTickCount ( (long long)iLifeTimeMs ); }
bool CGameSA::IsASyncLoadingEnabled ( bool bIgnoreSuspend ) { // Process auto unsuspend time if set if ( m_llASyncLoadingAutoUnsuspendTime.ToLongLong() != 0 ) { if ( CTickCount::Now() > m_llASyncLoadingAutoUnsuspendTime ) { m_llASyncLoadingAutoUnsuspendTime = CTickCount(); m_bASyncLoadingSuspended = false; } } if ( m_bASyncLoadingSuspended && !bIgnoreSuspend ) return false; if ( m_bAsyncScriptForced ) return m_bAsyncScriptEnabled; return true; }
bool CVehicle::IsIdleTimerFinished ( void ) { return IsIdleTimerRunning () && CTickCount::Now () > m_llIdleTime + CTickCount ( (long long)m_ulIdleRespawnInterval ); }
void CVehicle::StopIdleTimer ( void ) { m_llIdleTime = CTickCount ( 0LL ); }
bool CVehicle::IsBlowTimerFinished ( void ) { return GetIsBlown () && CTickCount::Now () > m_llBlowTime + CTickCount ( (long long)m_ulBlowRespawnInterval ); }
int CLuaTimerDefs::SetTimer ( lua_State* luaVM ) { // timer setTimer ( function theFunction, int timeInterval, int timesToExecute, [ var arguments... ] ) CLuaFunctionRef iLuaFunction; double dTimeInterval; uint uiTimesToExecute; CLuaArguments Arguments; CScriptArgReader argStream ( luaVM ); argStream.ReadFunction ( iLuaFunction ); argStream.ReadNumber ( dTimeInterval ); argStream.ReadNumber ( uiTimesToExecute ); argStream.ReadLuaArguments ( Arguments ); argStream.ReadFunctionComplete (); if ( !argStream.HasErrors () ) { CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( luaMain ) { // Check for the minimum interval if ( dTimeInterval < LUA_TIMER_MIN_INTERVAL ) { argStream.SetCustomError ( "Interval is below 50" ); } else { CLuaTimer* pLuaTimer = luaMain->GetTimerManager ()->AddTimer ( iLuaFunction, CTickCount ( dTimeInterval ), uiTimesToExecute, Arguments ); if ( pLuaTimer ) { // Set our timer debug info (in case we don't have any debug info which is usually when you do setTimer(destroyElement, 50, 1) or such) pLuaTimer->SetLuaDebugInfo ( g_pClientGame->GetScriptDebugging ()->GetLuaDebugInfo ( luaVM ) ); lua_pushtimer ( luaVM, pLuaTimer ); return 1; } } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }