Beispiel #1
0
void CVehicleUpgrades::ForceAddUpgrade ( unsigned short usUpgrade )
{
    unsigned char ucSlot;
    if ( GetSlotFromUpgrade ( usUpgrade, ucSlot ) )
    {
        CVehicle* pVehicle = m_pVehicle->GetGameVehicle ();
        if ( pVehicle )
        {
            // Grab the upgrade model
            CModelInfo* pModelInfo = g_pGame->GetModelInfo ( usUpgrade );
            if ( pModelInfo )
            {
                if ( !g_pGame->IsASyncLoadingEnabled () || !pModelInfo->IsLoaded () )
                {
                    // Request and load now
                    pModelInfo->RequestVehicleUpgrade ();

                    g_pGame->GetStreaming()->LoadAllRequestedModels ();
                }
                // Add the upgrade
                pVehicle->AddVehicleUpgrade ( usUpgrade );
            }
        }

        // Add it to the slot
        m_SlotStates [ ucSlot ] = usUpgrade;
    }
}
Beispiel #2
0
bool CClientModelRequestManager::IsLoaded ( unsigned short usModelID )
{
    // Grab the model info
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        return pInfo->IsLoaded () ? true:false;
    }

    return false;
}
bool CClientModelRequestManager::RequestBlocking ( unsigned short usModelID, const char* szTag )
{
    // Grab the model info
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        pInfo->Request ( BLOCKING, szTag );
        if ( pInfo->IsLoaded () )
        {
            pInfo->MakeCustomModel ();
            return true;
        }
        OutputDebugLine ( SString ( "[Models] RequestBlocking failed for id %d", usModelID ) );
    }

    // Bad model ID probably.
    return false;
}
Beispiel #4
0
void DumpPlayer ( CClientPlayer* pPlayer, CFile *file )
{
    unsigned int uiIndex = 0;

    // Player
    file->Printf( "%s\n", "*** START OF PLAYER ***" );

    // Write the data
    file->Printf( "Nick: %s\n", pPlayer->GetNick () );
    
    CVector vecTemp;
    pPlayer->GetPosition ( vecTemp );
    file->Printf( "Position: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    file->Printf( "Nametag text: %s\n", pPlayer->GetNametagText () );

    unsigned char ucR, ucG, ucB;
    pPlayer->GetNametagColor ( ucR, ucG, ucB );
    file->Printf( "Nametag color: %u %u %u\n", ucR, ucG, ucB );

    file->Printf( "Nametag show: %u\n", pPlayer->IsNametagShowing () );

    file->Printf( "Local player: %u\n", pPlayer->IsLocalPlayer () );
    file->Printf( "Dead: %u\n", pPlayer->IsDead () );

    file->Printf( "Exp aim: %u\n", pPlayer->IsExtrapolatingAim () );
    file->Printf( "Latency: %u\n", pPlayer->GetLatency () );

    file->Printf( "Last psync time: %u\n", pPlayer->GetLastPuresyncTime () );
    file->Printf( "Has con trouble: %u\n\n", pPlayer->HasConnectionTrouble () );

    CClientTeam* pTeam = pPlayer->GetTeam ();
    if ( pTeam )
        file->Printf( "Team: %s\n", pTeam->GetTeamName () );

    // Get the matrix
    RwMatrix matPlayer;
    pPlayer->GetMatrix ( matPlayer );

    file->Printf( "Matrix: vecRoll: %f %f %f\n", matPlayer.vRight.fX, matPlayer.vRight.fY, matPlayer.vRight.fZ );
    file->Printf( "        vecDir:  %f %f %f\n", matPlayer.vFront.fX, matPlayer.vFront.fY, matPlayer.vFront.fZ );
    file->Printf( "        vecWas:  %f %f %f\n", matPlayer.vUp.fX, matPlayer.vUp.fY, matPlayer.vUp.fZ );
    file->Printf( "        vecPos:  %f %f %f\n\n", matPlayer.vPos.fX, matPlayer.vPos.fY, matPlayer.vPos.fZ );

    file->Printf( "Euler rot: %f\n", pPlayer->GetCurrentRotation () );
    file->Printf( "Cam rot: %f\n", pPlayer->GetCameraRotation () );

    pPlayer->GetMoveSpeed ( vecTemp );
    file->Printf( "Move speed: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    pPlayer->GetTurnSpeed ( vecTemp );
    file->Printf( "Turn speed: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    CControllerState State;
    pPlayer->GetControllerState ( State );

    signed short* pController = reinterpret_cast < signed short* > ( &State );
    file->Printf( "CContr state: \n" );
    for ( uiIndex = 0; uiIndex < 36; uiIndex++ )
    {
        file->Printf( "State [%u] = %i\n", uiIndex, pController [uiIndex] );
    }

    pPlayer->GetLastControllerState ( State );

    pController = reinterpret_cast < signed short* > ( &State );
    file->Printf( "LContr state: \n" );
    for ( uiIndex = 0; uiIndex < 36; uiIndex++ )
    {
        file->Printf( "State [%u] = %i\n", uiIndex, pController [uiIndex] );
    }

    file->Printf( "\nVeh IO state: %i\n", pPlayer->GetVehicleInOutState () );
    file->Printf( "Visible: %u\n", pPlayer->IsVisible () );
    file->Printf( "Health: %f\n", pPlayer->GetHealth () );
    file->Printf( "Armor: %f\n", pPlayer->GetArmor () );
    file->Printf( "On screen: %u\n", pPlayer->IsOnScreen () );
    file->Printf( "Frozen: %u\n", pPlayer->IsFrozen () );
    file->Printf( "Respawn state: %i\n", pPlayer->GetRespawnState () );

    file->Printf( "Cur weapon slot: %i\n", static_cast < int > ( pPlayer->GetCurrentWeaponSlot () ) );
    file->Printf( "Cur weapon type: %i\n", static_cast < int > ( pPlayer->GetCurrentWeaponType () ) );

    CWeapon* pWeapon = pPlayer->GetWeapon ();
    if ( pWeapon )
    {
        file->Printf( "Cur weapon state: %i\n", static_cast < int > ( pWeapon->GetState () ) );
        file->Printf( "Cur weapon ammo clip: %u\n", pWeapon->GetAmmoInClip () );
        file->Printf( "Cur weapon ammo total: %u\n", pWeapon->GetAmmoTotal () );
    }

    CTaskManager* pTaskMgr = pPlayer->GetTaskManager ();
    if ( pTaskMgr )
    {
        // Primary task
        CTask* pTask = pTaskMgr->GetTask ( TASK_PRIORITY_PRIMARY );
        if ( pTask )
        {
            file->Printf( "Primary task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Primary task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Primary task: none\n" );

        // Physical response task
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_PHYSICAL_RESPONSE );
        if ( pTask )
        {
            file->Printf( "Physical response task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Physical response task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Physical response task: none\n" );

        // Event response task temp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_EVENT_RESPONSE_TEMP );
        if ( pTask )
        {
            file->Printf( "Event rsp tmp task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Event rsp tmp task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Event rsp tmp task: none\n" );

        // Event response task nontemp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_EVENT_RESPONSE_NONTEMP );
        if ( pTask )
        {
            file->Printf( "Event rsp nontmp task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Event rsp nontmp task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Event rsp nontmp task: none\n" );

        // Event response task nontemp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_DEFAULT );
        if ( pTask )
        {
            file->Printf( "Default task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Default task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Default task: none\n" );

        // Secondary attack
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_ATTACK );
        if ( pTask )
        {
            file->Printf( "Secondary attack task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary attack task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary attack task task: none\n" );

        // Secondary duck
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_DUCK );
        if ( pTask )
        {
            file->Printf( "Secondary duck task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary duck task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary duck task task: none\n" );

        // Secondary say
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_SAY );
        if ( pTask )
        {
            file->Printf( "Secondary say task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary say task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary say task task: none\n" );

        // Secondary facial complex
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_FACIAL_COMPLEX );
        if ( pTask )
        {
            file->Printf( "Secondary facial task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary facial task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary facial task task: none\n" );

        // Secondary partial anim
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_PARTIAL_ANIM );
        if ( pTask )
        {
            file->Printf( "Secondary partial anim task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary partial anim task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary partial anim task task: none\n" );

        // Secondary IK
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_IK );
        if ( pTask )
        {
            file->Printf( "Secondary IK task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary IK task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary IK task task: none\n" );
    }

    float fX, fY;
    pPlayer->GetAim ( fX, fY );
    file->Printf( "Aim: %f %f\n", fX, fY );

    vecTemp = pPlayer->GetAimSource ();
    file->Printf( "Aim source: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    vecTemp = pPlayer->GetAimTarget ();
    file->Printf( "Aim target: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    file->Printf( "Veh aim anim: %u\n", pPlayer->GetVehicleAimAnim () );
    file->Printf( "Ducked: %u\n", pPlayer->IsDucked () );
    file->Printf( "Wearing googles: %u\n", pPlayer->IsWearingGoggles () );
    file->Printf( "Has jetpack: %u\n", pPlayer->HasJetPack () );
    file->Printf( "In water: %u\n", pPlayer->IsInWater () );
    file->Printf( "On ground: %u\n", pPlayer->IsOnGround () );
    file->Printf( "Is climbing: %u\n", pPlayer->IsClimbing () );
    file->Printf( "Interiour: %u\n", pPlayer->GetInterior () );
    file->Printf( "Fight style: %u\n", static_cast < int > ( pPlayer->GetFightingStyle () ) );
    file->Printf( "Satchel count: %u\n", pPlayer->CountProjectiles ( WEAPONTYPE_REMOTE_SATCHEL_CHARGE ) );

    CRemoteDataStorage* pRemote = pPlayer->GetRemoteData ();
    if ( pRemote )
    {
        vecTemp = pRemote->GetAkimboTarget ();
        file->Printf( "Akimbo target: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );
        file->Printf( "Akimbo aim up: %u\n", pRemote->GetAkimboTargetUp () );
    }
    else
        file->Printf( "Remote: no\n" );

    file->Printf( "Using gun: %u\n", pPlayer->IsUsingGun () );
    file->Printf( "Entering veh: %u\n", pPlayer->IsEnteringVehicle () );
    file->Printf( "Getting jacked: %u\n", pPlayer->IsGettingJacked () );
    file->Printf( "Alpha: %u\n", pPlayer->GetAlpha () );
    

    file->Printf( "Stats:\n" );

    for ( uiIndex = 0; uiIndex < NUM_PLAYER_STATS; uiIndex++ )
    {
        file->Printf( "Stat [%u] = %f\n", uiIndex, pPlayer->GetStat ( uiIndex ) );
    }

    file->Printf( "Streamed in: %u\n", pPlayer->IsStreamedIn () );


    file->Printf( "Model: %u\n", pPlayer->GetModel () );

    // Write model data
    CModelInfo* pInfo = g_pGame->GetModelInfo ( pPlayer->GetModel () );
    file->Printf( "Model ref count: %i\n", pInfo->GetRefCount () );
    file->Printf( "Model loaded: %u\n", pInfo->IsLoaded () );
    file->Printf( "Model valid: %u\n", pInfo->IsValid () );

    // End of player
    file->Printf( "%s", "\n*** END OF PLAYER ***\n\n\n\n" );
}
Beispiel #5
0
bool CClientModelRequestManager::Request ( unsigned short usModelID, CClientEntity* pRequester )
{
    assert ( pRequester );
    SClientModelRequest* pEntry;

    // Grab the model info for that model
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        // Has it already requested something?
        list < SClientModelRequest* > ::iterator iter;
        if ( GetRequestEntry ( pRequester, iter ) )
        {
            // Get the entry
            pEntry = *iter;

            // The same model?
            if ( pInfo == pEntry->pModel )
            {
                // He has to wait more for it
                return false;
            }
            else
            {
                // Remove the reference to the old model
                pEntry->pModel->RemoveRef ();

                // Is it loaded?
                if ( pInfo->IsLoaded () )
                {
                    // Delete it, remove the it from the list and return true.
                    delete pEntry;
                    m_Requests.erase ( iter );

                    pInfo->MakeCustomModel ();
                    return true;
                }
                else
                {
                    // If not loaded. Replace the model we're going to load.
                    // Also remember that we requested it now.
                    pEntry->pModel = pInfo;
                    pEntry->dwTimeRequested = timeGetTime ();

                    // Start loading the new model.
                    pInfo->AddRef ( false );

                    // He has to wait for it.
                    return false;
                }
            }
        }
        else
        {
            // Already loaded? Don't bother adding to the list.
            if ( pInfo->IsLoaded () )
            {
                pInfo->MakeCustomModel ();

                return true;
            }

            // Boost loading priority if the object is close to the local player
            bool bHighPriority = false;
            if ( pRequester->GetDistanceBetweenBoundingSpheres ( g_pClientGame->GetLocalPlayer () ) < 20 )
                bHighPriority = true;

            // Request it
            pInfo->AddRef ( false, bHighPriority );

            // Add him to the list over models we're waiting for.
            pEntry = new SClientModelRequest;
            pEntry->pModel = pInfo;
            pEntry->pEntity = pRequester;
            pEntry->dwTimeRequested = timeGetTime ();
            m_Requests.push_back ( pEntry );

            // Return false. Caller needs to wait.
            return false;
        }
    }

    // Error, model is bad. Caller should not do this.
    return false;
}
bool CClientModelRequestManager::Request ( unsigned short usModelID, CClientEntity* pRequester )
{
    assert ( pRequester );
    SClientModelRequest* pEntry;

    // Grab the model info for that model
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        // Has it already requested something?
        list < SClientModelRequest* > ::iterator iter;
        if ( GetRequestEntry ( pRequester, iter ) )
        {
            // Get the entry
            pEntry = *iter;

            // The same model?
            if ( pInfo == pEntry->pModel )
            {
                // He has to wait more for it
                return false;
            }
            else
            {
                // Remove the reference to the old model
                pEntry->pModel->RemoveRef ();

                // Is it loaded?
                if ( pInfo->IsLoaded () )
                {
                    // Delete it, remove the it from the list and return true.
                    delete pEntry;
                    m_Requests.erase ( iter );

                    pInfo->MakeCustomModel ();
                    return true;
                }
                else
                {
                    // If not loaded. Replace the model we're going to load.
                    // Also remember that we requested it now.
                    pEntry->pModel = pInfo;
                    pEntry->requestTimer.Reset ();

                    // Start loading the new model.
                    pInfo->ModelAddRef ( NON_BLOCKING, "CClientModelRequestManager::Request" );

                    // He has to wait for it.
                    return false;
                }
            }
        }
        else
        {
            // Already loaded? Don't bother adding to the list.
            if ( pInfo->IsLoaded () )
            {
                pInfo->MakeCustomModel ();

                return true;
            }

            // Request it
            pInfo->ModelAddRef ( NON_BLOCKING, "CClientModelRequestManager::Request #2" );

            // Add him to the list over models we're waiting for.
            pEntry = new SClientModelRequest;
            pEntry->pModel = pInfo;
            pEntry->pEntity = pRequester;
            pEntry->requestTimer.SetMaxIncrement ( 500 );
            pEntry->requestTimer.Reset ();
            m_Requests.push_back ( pEntry );

            // Return false. Caller needs to wait.
            return false;
        }
    }

    // Error, model is bad. Caller should not do this.
    return false;
}