Example #1
0
void CPedRPCs::SetPedFightingStyle ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned char ucStyle;
    if ( bitStream.Read ( ucStyle ) )
    {
        CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            pPed->SetFightingStyle ( ( eFightingStyle ) ucStyle );
        }
    }
}
Example #2
0
void CElementRPCs::AttachElements ( NetBitStreamInterface& bitStream )
{
    ElementID ID, usAttachedToID;
    CVector vecPosition, vecRotation;
    if ( bitStream.Read ( ID ) && bitStream.Read ( usAttachedToID ) &&
        bitStream.Read ( vecPosition.fX ) &&
        bitStream.Read ( vecPosition.fY ) &&
        bitStream.Read ( vecPosition.fZ ) &&
        bitStream.Read ( vecRotation.fX ) &&
        bitStream.Read ( vecRotation.fY ) &&
        bitStream.Read ( vecRotation.fZ ) )
    {
        CClientEntity* pEntity = CElementIDs::GetElement ( ID );
        CClientEntity* pAttachedToEntity = CElementIDs::GetElement ( usAttachedToID );
        if ( pEntity && pAttachedToEntity )
        {
            pEntity->SetAttachedOffsets ( vecPosition, vecRotation );
            pEntity->AttachTo ( pAttachedToEntity );
        }
    }
}
Example #3
0
void CPedRPCs::SetPedMoveAnim ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned int uiMoveAnim;
    if ( bitStream.ReadCompressed ( uiMoveAnim ) )
    {
        CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            pPed->SetMoveAnim ( (eMoveAnim)uiMoveAnim );
        }
    }
}
Example #4
0
void CPlayerRPCs::SetPlayerNametagShowing ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned char ucShowing;
    if ( bitStream.Read ( ucShowing ) )
    {
        CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () );
        if ( pPlayer )
        {
            pPlayer->SetNametagShowing ( ( ucShowing == 1 ) );
        }
    }
}
Example #5
0
void CPedRPCs::SetPedChoking ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    bool bChoking;
    if ( bitStream.ReadBit ( bChoking ) )
    {
        CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            pPed->SetChoking ( bChoking );
        }
    }
}
Example #6
0
void CObjectSync::Packet_ObjectSync ( NetBitStreamInterface& BitStream )
{
    // While we're not out of bytes
    while ( BitStream.GetNumberOfUnreadBits () > 8 )
    {
        // Read out the ID
        ElementID ID;
        if ( !BitStream.Read ( ID ) )
            return;

        // Read out the sync time context. See CClientEntity for documentation on that.
        unsigned char ucSyncTimeContext;
        if ( !BitStream.Read ( ucSyncTimeContext ) )
            return;
            
        // Read out flags
        SIntegerSync < unsigned char, 3 > flags ( 0 );
        if ( !BitStream.Read ( &flags ) )
            return;
                    
        // Read out the position if we need
        SPositionSync position;
        if ( flags & 0x1 )
        {
            if ( !BitStream.Read ( &position ) )
                return;
        }

        // Read out the rotation
        SRotationRadiansSync rotation;
        if ( flags & 0x2 )
        {
            if ( !BitStream.Read ( &rotation ) )
                return;
        }

        // Read out the health
        SObjectHealthSync health;
        if ( flags & 0x4 )
        {
            if ( !BitStream.Read ( &health ) )
                return;
        }

        // Grab the object
        CDeathmatchObject* pObject = static_cast < CDeathmatchObject* > ( m_pObjectManager->Get ( ID ) );
        // Only update the sync if this packet is from the same context
        if ( pObject && pObject->CanUpdateSync ( ucSyncTimeContext ) )
        {
            if ( flags & 0x1 ) pObject->SetPosition ( position.data.vecPosition );
            if ( flags & 0x2 ) pObject->SetRotationRadians ( rotation.data.vecRotation );
            if ( flags & 0x4 ) pObject->SetHealth ( health.data.fValue );
        }
    }
}
Example #7
0
void CWeaponRPCs::SetWeaponAmmo ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    SWeaponTypeSync weaponType;
    if ( bitStream.ReadCompressed ( ID ) &&
         bitStream.Read ( &weaponType ) )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;
        SWeaponAmmoSync ammo ( ucWeaponID, true, true );

        if ( bitStream.Read ( &ammo ) )
        {
            unsigned short usAmmo = ammo.data.usTotalAmmo;
            unsigned short usAmmoInClip = ammo.data.usAmmoInClip;

            CClientPed * pPed = m_pPedManager->Get ( ID, true );
            if ( pPed )
            {
                // Valid weapon id?
                if ( !CClientPickupManager::IsValidWeaponID ( ucWeaponID ) ) return;

                // Do we have it?
                CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                if ( pPlayerWeapon == NULL ) return;

                unsigned char ucAmmoInClip = static_cast < unsigned char > ( pPlayerWeapon->GetAmmoInClip () );
                pPlayerWeapon->SetAmmoInClip ( usAmmoInClip );
                pPlayerWeapon->SetAmmoTotal ( usAmmo );

                if ( !usAmmoInClip )
                {
                    if ( usAmmo > ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( ucAmmoInClip );
                    else if ( usAmmo <= ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( usAmmo );
                }
            }
        }
    }
}
bool CResourceClientScriptsPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_vecItems.size() == 0 )
        return false;

    BitStream.Write ( m_pResource->GetNetID() );

    unsigned short usItemCount = m_vecItems.size();
    BitStream.Write ( usItemCount );

    for ( std::vector<CResourceClientScriptItem*>::const_iterator iter = m_vecItems.begin ();
          iter != m_vecItems.end();
          ++iter )
    {
        if ( BitStream.Version() >= 0x50 )
            BitStream.WriteString( (*iter)->GetName() );

        const SString& data = (*iter)->GetSourceCode ();
        unsigned int len = data.length ();
        BitStream.Write ( len );
        BitStream.Write ( data.c_str(), len );
    }

    return true;
}
Example #9
0
void CCameraRPCs::SetCameraMatrix ( NetBitStreamInterface& bitStream )
{
    CVector vecPosition, vecLookAt;
    float fRoll = 0.0f;
    float fFOV = 70.0f;
    if ( bitStream.Read ( vecPosition.fX ) &&
         bitStream.Read ( vecPosition.fY ) &&
         bitStream.Read ( vecPosition.fZ ) &&
         bitStream.Read ( vecLookAt.fX ) &&
         bitStream.Read ( vecLookAt.fY ) &&
         bitStream.Read ( vecLookAt.fZ ) )
    {
        bitStream.Read ( fRoll );
        bitStream.Read ( fFOV );

        if ( !m_pCamera->IsInFixedMode () )
            m_pCamera->ToggleCameraFixedMode ( true );

        // Put the camera there
        m_pCamera->SetPosition ( vecPosition );
        m_pCamera->SetTarget ( vecLookAt );
        m_pCamera->SetRoll ( fRoll );
        m_pCamera->SetFOV ( fFOV );
    }
}
Example #10
0
void CWeaponRPCs::TakeAllWeapons ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    if ( bitStream.ReadCompressed ( ID ) )
    {
        CClientPed * pPed = m_pPedManager->Get ( ID, true );
        if ( pPed )
        {
            // Remove all our weapons
            pPed->RemoveAllWeapons ();
        }
    }
}
Example #11
0
void CWeaponRPCs::SetWeaponSlot ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    SWeaponSlotSync slot;

    if ( bitStream.Read ( &slot ) )
    {
        CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            pPed->SetCurrentWeaponSlot ( (eWeaponSlot) slot.data.uiSlot );
        }
    }
}
Example #12
0
bool CPlayerModInfoPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Read type
    if ( !BitStream.ReadString ( m_strInfoType ) )
        return false;

    // Read amount of items
    uint uiCount;
    if ( !BitStream.Read ( uiCount ) )
        return false;

    // Read each item
    for ( uint i = 0 ; i < uiCount ; i++ )
    {
        SModInfoItem item;

        if ( !BitStream.Read ( item.usId ) )
            return false;

        if ( !BitStream.Read ( item.uiHash ) )
            return false;

        if ( !BitStream.ReadString ( item.strName ) )
            return false;

        int iHasSize;
        if ( !BitStream.Read ( iHasSize ) )
            return false;
        item.bHasSize = iHasSize != 0;

        if ( !BitStream.Read ( item.vecSize.fX ) )
            return false;

        if ( !BitStream.Read ( item.vecSize.fY ) )
            return false;

        if ( !BitStream.Read ( item.vecSize.fZ ) )
            return false;

        m_ModInfoItemList.push_back ( item );
    }

    return true;
}
Example #13
0
bool CLuaArguments::ReadFromBitStream(NetBitStreamInterface& bitStream, std::vector<CLuaArguments*>* pKnownTables)
{
    bool bKnownTablesCreated = false;
    if (!pKnownTables)
    {
        pKnownTables = new std::vector<CLuaArguments*>();
        bKnownTablesCreated = true;
    }

    unsigned int uiNumArgs;
    bool         bResult;
#if MTA_DM_VERSION >= 0x150
    bResult = bitStream.ReadCompressed(uiNumArgs);
#else
    if (bitStream.Version() < 0x05B)
    {
        unsigned short usNumArgs;
        bResult = bitStream.ReadCompressed(usNumArgs);
        uiNumArgs = usNumArgs;
    }
    else
        bResult = bitStream.ReadCompressed(uiNumArgs);
#endif

    if (bResult)
    {
        pKnownTables->push_back(this);
        for (unsigned int ui = 0; ui < uiNumArgs; ++ui)
        {
            CLuaArgument* pArgument = new CLuaArgument(bitStream, pKnownTables);
            m_Arguments.push_back(pArgument);
        }
    }

    if (bKnownTablesCreated)
        delete pKnownTables;

    return true;
}
Example #14
0
void CKeysyncPacket::WriteVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream ) const
{
    // Turret states
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) )
    {
        // Grab the turret position
        SVehicleSpecific vehicle;
        pVehicle->GetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );

        BitStream.Write ( &vehicle );
    }
}
Example #15
0
void CWorldRPCs::SetWeather(NetBitStreamInterface& bitStream)
{
    // Read out the weather to apply
    unsigned char ucWeather;
    if (bitStream.Read(ucWeather))
    {
        // Check that its within range
        if (ucWeather <= MAX_VALID_WEATHER)
        {
            m_pBlendedWeather->SetWeather(ucWeather);
        }
    }
}
Example #16
0
void CElementRPCs::SetElementHealth ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    float fHealth;
    unsigned char ucTimeContext;
    if ( bitStream.Read ( fHealth ) &&
         bitStream.Read ( ucTimeContext ) )
    {
        pSource->SetSyncTimeContext ( ucTimeContext );

        switch ( pSource->GetType () )
        {
            case CCLIENTPED:
            case CCLIENTPLAYER:
            {
                CClientPed* pPed = static_cast < CClientPed * > ( pSource );
                if ( pPed->IsHealthLocked() )
                    pPed->LockHealth ( fHealth );
                else
                    pPed->SetHealth ( fHealth );
                break;
            }

            case CCLIENTVEHICLE:
            {
                CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
                pVehicle->SetHealth ( fHealth );
                break;
            }

            case CCLIENTOBJECT:
            case CCLIENTWEAPON:
            {
                CClientObject* pObject = static_cast < CClientObject * > ( pSource );
                pObject->SetHealth ( fHealth );
                break;
            }
        }
    }
}
Example #17
0
void CPedRPCs::SetPedAnimation ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    // Read out the player and vehicle id
    char szBlockName [ 64 ], szAnimName [ 64 ];
    unsigned char ucBlockSize, ucAnimSize;
    int iTime;
    bool bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame;

    if ( bitStream.Read ( ucBlockSize ) )
    {
        // Grab the ped
        CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            if ( ucBlockSize > 0 )
            {
                if ( bitStream.Read ( szBlockName, ucBlockSize ) &&
                    bitStream.Read ( ucAnimSize ) )
                {
                    szBlockName [ ucBlockSize ] = 0;
                    if ( bitStream.Read ( szAnimName, ucAnimSize ) &&
                         bitStream.Read ( iTime ) &&
                         bitStream.ReadBit ( bLoop ) &&
                         bitStream.ReadBit ( bUpdatePosition ) &&
                         bitStream.ReadBit ( bInterruptable ) &&
                         bitStream.ReadBit ( bFreezeLastFrame ) )
                    {
                        szAnimName [ ucAnimSize ] = 0;

                        CAnimBlock * pBlock = g_pGame->GetAnimManager ()->GetAnimationBlock ( szBlockName );
                        if ( pBlock )
                        {
                            pPed->RunNamedAnimation ( pBlock, szAnimName, iTime, bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame );
                        }
                    }
                }
            }
            else
            {
                pPed->KillAnimation ();
            }
        }
    }
}
Example #18
0
void CWorldRPCs::SetSyncIntervals(NetBitStreamInterface& bitStream)
{
    bitStream.Read(g_TickRateSettings.iPureSync);
    bitStream.Read(g_TickRateSettings.iLightSync);
    bitStream.Read(g_TickRateSettings.iCamSync);
    bitStream.Read(g_TickRateSettings.iPedSync);
    bitStream.Read(g_TickRateSettings.iUnoccupiedVehicle);
    bitStream.Read(g_TickRateSettings.iObjectSync);
    bitStream.Read(g_TickRateSettings.iKeySyncRotation);
    bitStream.Read(g_TickRateSettings.iKeySyncAnalogMove);
}
Example #19
0
void CPlayerRPCs::SetPlayerTeam ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    ElementID TeamID;
    if ( bitStream.Read ( TeamID ) )
    {
        CClientTeam* pTeam = m_pTeamManager->GetTeam ( TeamID );
        CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () );
        if ( pPlayer )
        {
            pPlayer->SetTeam ( pTeam, true );
        }
    }
}
Example #20
0
void CElementRPCs::SetElementParent ( NetBitStreamInterface& bitStream )
{
    // Read out the entity id and parent id
    ElementID ID, ParentID;
    if ( bitStream.Read ( ID ) && bitStream.Read ( ParentID ) )
    {
        CClientEntity* pEntity = CElementIDs::GetElement ( ID );
        CClientEntity* pParent = CElementIDs::GetElement ( ParentID );
        if ( pEntity && pParent )
        {
            pEntity->SetParent ( pParent );
        }
        else
        {
            // TODO: raise an error
        }
    }
    else
    {
        // TODO: raise an error
    }
}
Example #21
0
void CPedSync::Packet_PedStartSync ( NetBitStreamInterface& BitStream )
{
    // Read out the element id
    ElementID ID;
    if ( BitStream.Read ( ID ) )
    {
        // Grab the ped
        CClientPed* pPed = static_cast < CClientPed* > ( m_pPedManager->Get ( ID ) );
        if ( pPed )
        {
            // Read out the position
            CVector vecPosition;
            BitStream.Read ( vecPosition.fX );
            BitStream.Read ( vecPosition.fY );
            BitStream.Read ( vecPosition.fZ );

            // And rotation
            float fRotation;
            BitStream.Read ( fRotation );

            // And the velocity
            CVector vecVelocity;
            BitStream.Read ( vecVelocity.fX );
            BitStream.Read ( vecVelocity.fY );
            BitStream.Read ( vecVelocity.fZ );

            // And health/armor
            float fHealth, fArmor;
            BitStream.Read ( fHealth );
            BitStream.Read ( fArmor );

            // Set data
            pPed->SetPosition ( vecPosition );
            pPed->SetCurrentRotation ( fRotation );
            pPed->SetMoveSpeed ( vecVelocity );

            // Set the new health
            pPed->SetHealth ( fHealth );
            pPed->SetArmor ( fArmor );

            // Unlock health and armour for the syncer
            pPed->UnlockHealth ();
            pPed->UnlockArmor ();

            AddPed ( pPed );
        }
    }
}
bool CPlayerWastedPacket::Read ( NetBitStreamInterface& BitStream )
{
    return BitStream.Read ( m_AnimGroup ) &&
           BitStream.Read ( m_AnimID ) &&
           BitStream.Read ( m_Killer ) &&
           BitStream.Read ( m_ucKillerWeapon ) &&
           BitStream.Read ( m_ucBodyPart ) &&
           BitStream.Read ( m_vecPosition.fX ) &&
           BitStream.Read ( m_vecPosition.fY ) &&
           BitStream.Read ( m_vecPosition.fZ ) &&
           BitStream.Read ( m_usAmmo );
}
bool CVehicleResyncPacket::Write ( NetBitStreamInterface& BitStream ) const 
{
    if ( !m_pVehicle )
        return false;

    BitStream.Write ( m_pVehicle->GetID() );

    // Write vehicle position and rotation
    SPositionSync position ( false );
    position.data.vecPosition = m_pVehicle->GetPosition();
    BitStream.Write ( &position );

    SRotationDegreesSync rotation;
    m_pVehicle->GetRotationDegrees ( rotation.data.vecRotation );
    BitStream.Write ( &rotation );

    // Write the movespeed
    SVelocitySync velocity;
    velocity.data.vecVelocity = m_pVehicle->GetVelocity ();
    BitStream.Write ( &velocity );

    // Write the turnspeed
    SVelocitySync turnSpeed;
    turnSpeed.data.vecVelocity = m_pVehicle->GetTurnSpeed ();
    BitStream.Write ( &turnSpeed );

    // Write the vehicle health
    SVehicleHealthSync health;
    health.data.fValue = m_pVehicle->GetHealth ();
    BitStream.Write ( &health );

    // Write parts state
    if ( BitStream.Version() >= 0x5D )
    {
        SVehicleDamageSyncMethodeB damage;
        damage.data.bSyncDoors = true;
        damage.data.bSyncWheels = true;
        damage.data.bSyncPanels = true;
        damage.data.bSyncLights = true;
        damage.data.doors.data.ucStates = m_pVehicle->m_ucDoorStates;
        damage.data.wheels.data.ucStates = m_pVehicle->m_ucWheelStates;
        damage.data.panels.data.ucStates = m_pVehicle->m_ucPanelStates;
        damage.data.lights.data.ucStates = m_pVehicle->m_ucLightStates;
        BitStream.Write ( &damage );
    }

    return true;
}
Example #24
0
void CElementRPCs::SetElementModel ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned short usModel;
    if ( bitStream.Read ( usModel ) )
    {
        switch ( pSource->GetType () )
        {
            case CCLIENTPED:
            case CCLIENTPLAYER:
            {
                CClientPed* pPed = static_cast < CClientPed * > ( pSource );
                pPed->SetModel ( usModel );
                break;
            }

            case CCLIENTVEHICLE:
            {
                uchar ucVariant = 255, ucVariant2 = 255;
                if ( bitStream.GetNumberOfUnreadBits () >= sizeof ( ucVariant ) + sizeof ( ucVariant2 ) )
                {
                    bitStream.Read ( ucVariant );
                    bitStream.Read ( ucVariant2 );
                }
                CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
                pVehicle->SetModelBlocking ( usModel, ucVariant, ucVariant2 );
                break;
            }

            case CCLIENTOBJECT:
            case CCLIENTWEAPON:
            {
                CClientObject* pObject = static_cast < CClientObject * > ( pSource );
                pObject->SetModel ( usModel );
                break;
            }
        }
    }
}
Example #25
0
void CVehiclePuresyncPacket::ReadVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream )
{
    // Turret data
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) ) 
    {
        // Read out the turret position
        SVehicleTurretSync vehicle;
        if ( !BitStream.Read ( &vehicle ) )
            return;

        // Set the data
        pVehicle->SetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );
    }

    // Adjustable property value
    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
    {
        unsigned short usAdjustableProperty;
        if ( BitStream.Read ( usAdjustableProperty ) )
        {
            pVehicle->SetAdjustableProperty ( usAdjustableProperty );
        }
    }

    // Door angles.
    if ( CVehicleManager::HasDoors ( usModel ) )
    {
        SDoorOpenRatioSync door;

        for ( unsigned int i = 2; i < 6; ++i )
        {
            if ( !BitStream.Read ( &door ) )
                return;
            pVehicle->SetDoorOpenRatio ( i, door.data.fRatio );
        }
    }
}
bool CUnoccupiedVehicleSyncPacket::Read ( NetBitStreamInterface& BitStream )
{
    // While we're not out of bytes
    while ( BitStream.GetNumberOfUnreadBits () >= 8 )
    {
        // Read out the sync data
        SyncData data;
        data.bSend = false;

        SUnoccupiedVehicleSync vehicle;
        if ( BitStream.Read ( &vehicle ) )
        {
            data.syncStructure = vehicle;

            // Add it to our list. We no longer check if it's valid here
            // because CUnoccupiedVehicleSync does and it won't write bad ID's
            // back to clients.
            m_Syncs.push_back ( data );
        }
    }

    return m_Syncs.size () > 0;
}
Example #27
0
void CElementRPCs::SetElementAttachedOffsets ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    SPositionSync position ( true );
    SRotationDegreesSync rotation ( true );
    if ( bitStream.Read ( ID ) && position.Read ( bitStream ) && rotation.Read ( bitStream ) )
    {
        CClientEntity* pEntity = CElementIDs::GetElement ( ID );
        if ( pEntity )
        {
            pEntity->SetAttachedOffsets ( position.data.vecPosition, rotation.data.vecRotation );
        }
    }
}
Example #28
0
void CElementRPCs::DetachElements ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    unsigned char ucTimeContext;
    if ( bitStream.Read ( ID ) &&
         bitStream.Read ( ucTimeContext ) )
    {
        CClientEntity* pEntity = CElementIDs::GetElement ( ID );
        if ( pEntity )
        {
            pEntity->SetSyncTimeContext ( ucTimeContext );
            pEntity->AttachTo ( NULL );

            CVector vecPosition;
            if ( bitStream.Read ( vecPosition.fX ) &&
                 bitStream.Read ( vecPosition.fY ) &&
                 bitStream.Read ( vecPosition.fZ ) )
            {
                pEntity->SetPosition ( vecPosition );
            }
        }
    }
}
Example #29
0
void CWaterRPCs::SetElementWaterLevel ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    float fLevel;

    if ( bitStream.Read ( fLevel ) )
    {
        // (water, level)
        CClientWater* pWater = m_pWaterManager->Get ( pSource->GetID () );
        if ( pWater )
        {
            m_pWaterManager->SetElementWaterLevel ( pWater, fLevel, NULL );
        }
    }
}
Example #30
0
void CObjectRPCs::StopObject ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    // Grab the object
    CDeathmatchObject* pObject = static_cast < CDeathmatchObject* > ( m_pObjectManager->Get ( pSource->GetID () ) );
    if ( pObject )
    {
        // Read out the position and rotation
        CVector vecSourcePosition;
        CVector vecSourceRotation;
        if ( bitStream.Read ( vecSourcePosition.fX ) &&
             bitStream.Read ( vecSourcePosition.fY ) &&
             bitStream.Read ( vecSourcePosition.fZ ) &&
             bitStream.Read ( vecSourceRotation.fX ) &&
             bitStream.Read ( vecSourceRotation.fY ) &&
             bitStream.Read ( vecSourceRotation.fZ ) )
        {
            // Stop the movement
            pObject->StopMovement ();
            // Set it to the source position and rotation
            pObject->SetOrientation ( vecSourcePosition, vecSourceRotation );
        }
    }
}