示例#1
0
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();
}
示例#2
0
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 );
        }
    }
}
示例#3
0
// 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 );
}
示例#5
0
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;
}
示例#6
0
bool CVehicle::IsIdleTimerFinished ( void )
{
    return IsIdleTimerRunning () && CTickCount::Now () > m_llIdleTime + CTickCount ( (long long)m_ulIdleRespawnInterval );
}
示例#7
0
void CVehicle::StopIdleTimer ( void )
{
    m_llIdleTime = CTickCount ( 0LL );
}
示例#8
0
bool CVehicle::IsBlowTimerFinished ( void )
{
    return GetIsBlown () && CTickCount::Now () > m_llBlowTime + CTickCount ( (long long)m_ulBlowRespawnInterval );
}
示例#9
0
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;
}