eClientVehicleType CClientVehicleManager::GetVehicleType ( unsigned long ulModel )
{
    // Valid vehicle id?
    if ( IsValidModel ( ulModel ) )
    {
        // Grab the model info for the current vehicle
        CModelInfo* pModelInfo = g_pGame->GetModelInfo ( ulModel );
        if ( pModelInfo )
        {
            // Return the appropriate type
            if ( pModelInfo->IsCar () ) return CLIENTVEHICLE_CAR;
            if ( pModelInfo->IsBike () ) return CLIENTVEHICLE_BIKE;
            if ( pModelInfo->IsPlane () ) return CLIENTVEHICLE_PLANE;
            if ( pModelInfo->IsHeli () ) return CLIENTVEHICLE_HELI;
            if ( pModelInfo->IsBoat () ) return CLIENTVEHICLE_BOAT;
            if ( pModelInfo->IsQuadBike () ) return CLIENTVEHICLE_QUADBIKE;
            if ( pModelInfo->IsBmx () ) return CLIENTVEHICLE_BMX;
            if ( pModelInfo->IsMonsterTruck () ) return CLIENTVEHICLE_MONSTERTRUCK;
            if ( pModelInfo->IsTrailer () ) return CLIENTVEHICLE_TRAILER;
            if ( pModelInfo->IsTrain () ) return CLIENTVEHICLE_TRAIN;
        }
    }

    // Invalid vehicle id or some other error
    return CLIENTVEHICLE_NONE;
}
Esempio n. 2
0
////////////////////////////////////////////////////
//
//  CMouseControl::ProcessMouseMove
//
//  Process a windows mouse movement message and turn it into control
//
////////////////////////////////////////////////////
bool CMouseControl::ProcessMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if (uMsg != WM_MOUSEMOVE)
        return false;

    if (g_pCore->GetGame()->GetSystemState() != 9)
        return false;

    // HACK:  Grab our local player, and check his vehicle
    CPed* pPed = g_pCore->GetGame()->GetPools()->GetPedFromRef((DWORD)1);
    if (!pPed)
        return false;

    CVehicle* pVehicle = pPed->GetVehicle();
    if (!pVehicle)
        return false;

    CModelInfo* pModelInfo = g_pCore->GetGame()->GetModelInfo(pVehicle->GetModelIndex());

    bool bVar;
    CVARS_GET("fly_with_mouse", bVar);
    if (pModelInfo->IsPlane() || pModelInfo->IsHeli() && !bVar)            // Are we in a plane, but not have mouse flight enabled?
        return false;

    CVARS_GET("steer_with_mouse", bVar);
    if (!bVar)            // Are we in another type of vehicle, but not have mouse steering enabled?
        return false;

    // Let's calculate our mouse movement directions
    CVector2D resolution = g_pCore->GetGUI()->GetResolution();
    int       iX = GET_X_LPARAM(lParam), iY = GET_Y_LPARAM(lParam);
    float     fX = (iX - resolution.fX * 0.5f) / resolution.fX;

    fX *= MOUSE_CONTROL_MULTIPLIER;

    float fMouseSensitivity = g_pCore->GetGame()->GetSettings()->GetMouseSensitivity();
    fX *= fMouseSensitivity;

    m_usLeftStickX += fX * 128;
    m_usLeftStickX = Clamp<const short>(-128, m_usLeftStickX, 128);

    // Only process Y input if we're in a vehicle that requires it
    if (pModelInfo->IsPlane() || pModelInfo->IsHeli() || pModelInfo->IsBike() || pModelInfo->IsBmx() || pModelInfo->IsQuadBike())
    {
        float fY = (resolution.fY * 0.5f - iY) / resolution.fY;
        fY *= MOUSE_CONTROL_MULTIPLIER;
        fY *= fMouseSensitivity;

        CVARS_GET("invert_mouse", bVar);
        fY = bVar ? -fY : fY;

        m_usLeftStickY += fY * 128;
        m_usLeftStickY = Clamp<const short>(-128, m_usLeftStickY, 128);
    }

    return true;
}