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;
}
void CVehiclePuresyncPacket::WriteVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream ) const
{
    // Turret states
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) )
    {
        SVehicleTurretSync vehicle;
        pVehicle->GetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );

        BitStream.Write ( &vehicle );
    }

    // Adjustable property value
    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
    {
        BitStream.Write ( pVehicle->GetAdjustableProperty () );
    }

    // Door angles.
    if ( CVehicleManager::HasDoors ( usModel ) )
    {
        SDoorOpenRatioSync door;
        for ( unsigned int i = 2; i < 6; ++i )
        {
            door.data.fRatio = pVehicle->GetDoorOpenRatio ( i );
            BitStream.Write ( &door );
        }
    }
}
bool CPlayerStatsPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player.
    if ( m_pSourceElement )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the stats
        unsigned short usNumStats = static_cast < unsigned short  >( m_List.size () );
        BitStream.WriteCompressed ( usNumStats );

        map < unsigned short, sPlayerStat > ::const_iterator iter = m_List.begin ();
        for ( ; iter != m_List.end () ; ++iter )
        {
            const sPlayerStat& playerStat = (*iter).second;
            BitStream.Write ( playerStat.id );
            BitStream.Write ( playerStat.value );
        }

        return true;
    }

    return false;
}
bool CUpdateInfoPacket::Write(NetBitStreamInterface& BitStream) const
{
    BitStream.Write((unsigned short)m_strType.length());
    BitStream.Write(m_strType.c_str(), m_strType.length());

    BitStream.Write((unsigned short)m_strData.length());
    BitStream.Write(m_strData.c_str(), m_strData.length());

    return true;
}
bool CPlayerJoinCompletePacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_PlayerID );
    BitStream.Write ( m_ucNumberOfPlayers );
    BitStream.Write ( m_RootElementID );

    // Transmit server requirement for the client to check settings
    BitStream.Write ( m_iEnableClientChecks );

    // Transmit whether or not the Voice is enabled
    BitStream.WriteBit ( m_bVoiceEnabled );

    // Transmit the sample rate for voice
    SIntegerSync < unsigned char, 2 > sampleRate ( m_ucSampleRate );
    BitStream.Write ( &sampleRate );

    // Transmit the quality for voice
    SIntegerSync < unsigned char, 4 > voiceQuality ( m_ucQuality );
    BitStream.Write ( &voiceQuality );

    // Transmit the max bitrate for voice
    BitStream.WriteCompressed ( m_uiBitrate );

    // Tellclient about maybe throttling back http client requests
    BitStream.Write ( m_iHTTPMaxConnectionsPerClient );

    BitStream.Write ( static_cast < unsigned char > ( m_ucHTTPDownloadType ) );

    switch ( m_ucHTTPDownloadType )
    {
    case HTTP_DOWNLOAD_ENABLED_PORT:
        {
            BitStream.Write ( m_usHTTPDownloadPort );
        }

        break;
    case HTTP_DOWNLOAD_ENABLED_URL:
        {
            // Internal http server port
            if ( BitStream.Version() >= 0x48 )
                BitStream.Write( m_usHTTPDownloadPort );

            // External http server URL
            BitStream.WriteString ( m_strHTTPDownloadURL );
        }

        break;
    default:
        break;
    }

    return true;
}
bool CObjectSyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    bool                              bSent = false;
    vector<SyncData*>::const_iterator iter = m_Syncs.begin();
    // Write syncs
    for (; iter != m_Syncs.end(); ++iter)
    {
        SyncData* pData = *iter;
        // If we're not supposed to ignore the packet
        if (pData->bSend)
        {
            // Write the ID
            BitStream.Write(pData->ID);

            // Write the sync time context
            BitStream.Write(pData->ucSyncTimeContext);

            // Write flags
            SIntegerSync<unsigned char, 3> flags(pData->ucFlags);
            BitStream.Write(&flags);

            // Write position if we need
            if (flags & 0x1)
            {
                SPositionSync position;
                position.data.vecPosition = pData->vecPosition;
                BitStream.Write(&position);
            }

            // Write rotation
            if (flags & 0x2)
            {
                SRotationRadiansSync rotation;
                rotation.data.vecRotation = pData->vecRotation;
                BitStream.Write(&rotation);
            }

            // Write health
            if (flags & 0x4)
            {
                SObjectHealthSync health;
                health.data.fValue = pData->fHealth;
            }

            // We've sent atleast one sync
            bSent = true;
        }
    }

    return bSent;
}
bool CPlayerChangeNickPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_pSourceElement )
    {
        // Write the source player id
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the nick
        BitStream.Write ( const_cast < char* > ( m_szNewNick ), strlen ( m_szNewNick ) );
        return true;
    }
    
    return false;
}
Beispiel #8
0
bool CVoiceDataPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_usActualDataLength )
    {
            // Write the source player
            ElementID ID = m_pSourceElement->GetID();
            BitStream.Write ( ID );
            // Write the length as an unsigned short and then write the string
            BitStream.Write ( m_usActualDataLength );
            BitStream.Write ( reinterpret_cast < const char * > ( m_pBuffer ), m_usActualDataLength );
            return true;
    }

    return false;
}
bool CVehicleDamageSyncPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_Vehicle );
    BitStream.Write ( &m_damage );

    return true;
}
Beispiel #10
0
bool COMMAND_Executed ( const char* szCommand, const char* szArguments, bool bHandleRemotely, bool bHandled )
{
    // Has the core already handled this command?
    if ( !bHandled )
    {
        //char szBuffer [256];
        const char* szCommandBufferPointer = szCommand;

        if ( !bHandleRemotely )
        {
            // Is the command "say" and the arguments start with '/' ? (command comes from the chatbox)
            if ( stricmp ( szCommand, "chatboxsay" ) == 0 )
                szCommandBufferPointer = "say";
        }

        // Toss them together so we can send it to the server
        SString strClumpedCommand;
        if ( szArguments && szArguments [ 0 ] )
            strClumpedCommand.Format ( "%s %s", szCommandBufferPointer, szArguments );
        else
            strClumpedCommand = szCommandBufferPointer;

        // Convert to Unicode, and clamp it to a maximum command length
        std::wstring strClumpedCommandUTF = MbUTF8ToUTF16(strClumpedCommand.c_str());
        strClumpedCommandUTF = strClumpedCommandUTF.substr(0,MAX_COMMAND_LENGTH);
        strClumpedCommand = UTF16ToMbUTF8(strClumpedCommandUTF);

        luaexecute( szCommandBufferPointer, szArguments );

        // Call the event on the local player's onClientConsole first
        if ( g_pClientGame->GetLocalPlayer() )
        {
            lua_State *L = g_pClientGame->GetLuaManager()->GetVirtualMachine();
            lua_pushlstring( L, strClumpedCommand.c_str(), strClumpedCommand.size() );
            g_pClientGame->GetLocalPlayer()->CallEvent( "onClientConsole", L, 1 );
        }

        // Write the chatlength and the content
        NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream ();
        if ( !pBitStream ) 
            return false;

        // Write it to the bitstream
        pBitStream->Write ( strClumpedCommand.c_str(), static_cast < int > ( strlen ( strClumpedCommand.c_str() ) ) );

        // Send the packet to the server and free it
        g_pNet->SendPacket ( PACKET_ID_COMMAND, pBitStream, PACKET_PRIORITY_MEDIUM, PACKET_RELIABILITY_RELIABLE, PACKET_ORDERING_CHAT );
        g_pNet->DeallocateNetBitStream ( pBitStream );

        return true;
    }
    else
    {
        // Call our comand-handlers for core-executed commands too
        luaexecute( szCommand, szArguments );
    }
    return false;
}
bool CPlayerClothesPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player.
    if ( m_pSourceElement )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the clothes
        unsigned short usNumClothes = static_cast < unsigned short > ( m_List.size () );
        BitStream.Write ( usNumClothes );

        vector < SPlayerClothes* > ::const_iterator iter = m_List.begin ();
        for ( ; iter != m_List.end () ; ++iter )
        {
            char* szTexture = (*iter)->szTexture;
            char* szModel = (*iter)->szModel;
            unsigned char ucTextureLength = strlen ( szTexture );
            unsigned char ucModelLength = strlen ( szModel );
            BitStream.Write ( ucTextureLength );
            BitStream.Write ( szTexture, ucTextureLength );
            BitStream.Write ( ucModelLength );
            BitStream.Write ( szModel, ucModelLength );
            BitStream.Write ( (*iter)->ucType );
        }

        return true;
    }

    return false;
}
Beispiel #12
0
//
// Should do the same this as what CPedTaskPacket::Write() does
//
bool CSimPedTaskPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player id
    BitStream.Write ( m_PlayerID );

    // Write packet data
    BitStream.WriteBits( m_Cache.DataBuffer, m_Cache.uiNumBitsInPacketBody );
    return true;
}
void CVehiclePuresyncPacket::WriteVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream ) const
{
    // Turret states
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) )
    {
        SVehicleSpecific vehicle;
        pVehicle->GetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );

        BitStream.Write ( &vehicle );
    }

    // Adjustable property value
    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
    {
        BitStream.Write ( pVehicle->GetAdjustableProperty () );
    }
}
bool CPlayerSpawnPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_PlayerID );

    // No flags atm
    BitStream.Write ( static_cast < unsigned char > ( 0 ) );

    BitStream.Write ( m_vecSpawnPosition.fX );
    BitStream.Write ( m_vecSpawnPosition.fY );
    BitStream.Write ( m_vecSpawnPosition.fZ );
    BitStream.Write ( m_fSpawnRotation );
    BitStream.Write ( m_usPlayerSkin );
    BitStream.Write ( m_ucInterior );
    BitStream.Write ( m_usDimension );
    BitStream.Write ( m_Team );
    BitStream.Write ( m_ucTimeContext );

    return true;
}
Beispiel #15
0
bool CLuaEventPacket::Write(NetBitStreamInterface& BitStream) const
{
    unsigned short usNameLength = static_cast<unsigned short>(m_strName.length());
    BitStream.WriteCompressed(usNameLength);
    BitStream.WriteStringCharacters(m_strName, usNameLength);
    BitStream.Write(m_ElementID);
    m_pArguments->WriteToBitStream(BitStream);

    return true;
}
///////////////////////////////////////////////////////////////
//
// CLatentSendQueue::SendCancelNotification
//
// Tell remote an in-progress transfer is cancelled
//
///////////////////////////////////////////////////////////////
void CLatentSendQueue::SendCancelNotification ( SSendItem& activeTx )
{
    assert ( activeTx.bSendStarted && !activeTx.bSendFinishing );
    NetBitStreamInterface* pBitStream = DoAllocateNetBitStream ( m_RemoteId, m_usBitStreamVersion );
    pBitStream->WriteBits ( &activeTx.uiId, 15 );
    pBitStream->WriteBit ( 1 );
    pBitStream->Write ( (uchar)FLAG_CANCEL );
    DoSendPacket ( PACKET_ID_LATENT_TRANSFER, m_RemoteId, pBitStream, PACKET_PRIORITY_LOW, PACKET_RELIABILITY_RELIABLE_ORDERED, PACKET_ORDERING_DATA_TRANSFER );
    DoDeallocateNetBitStream ( pBitStream );
}
Beispiel #17
0
bool CPedWastedPacket::Write ( NetBitStreamInterface& BitStream ) const
{    
    BitStream.Write ( m_PedID );
    BitStream.Write ( m_Killer );
    BitStream.Write ( m_ucKillerWeapon );
    BitStream.Write ( m_ucBodyPart );
    BitStream.Write ( ( unsigned char ) ( ( m_bStealth ) ? 1 : 0 ) );    
    BitStream.Write ( m_ucTimeContext );
    BitStream.Write ( m_AnimGroup );
    BitStream.Write ( m_AnimID );

    return true;
}
Beispiel #18
0
bool CPlayerQuitPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_PlayerID == INVALID_ELEMENT_ID )
        return false;
    BitStream.WriteCompressed ( m_PlayerID );

    SQuitReasonSync quitReason;
    quitReason.data.uiQuitReason = m_ucQuitReason;
    BitStream.Write ( &quitReason );

    return true;
}
bool CLightsyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    bool bSyncPosition;

    if (Count() == 0)
        return false;

    for (std::vector<CPlayer*>::const_iterator iter = m_players.begin(); iter != m_players.end(); ++iter)
    {
        CPlayer*                       pPlayer = *iter;
        CPlayer::SLightweightSyncData& data = pPlayer->GetLightweightSyncData();
        CVehicle*                      pVehicle = pPlayer->GetOccupiedVehicle();

        // Find the difference between now and the time the position last changed for the player
        long long llTicksDifference = GetTickCount64_() - pPlayer->GetPositionLastChanged();

        // Right we need to sync the position if there is no vehicle or he's in a vehicle and the difference between setPosition is less than or equal to the
        // slow sync rate i.e. make sure his position has been updated more than 0.001f in the last 1500ms plus a small margin for error (probably not needed).
        // This will ensure we only send positions when the position has changed.
        bSyncPosition = (!pVehicle || pPlayer->GetOccupiedVehicleSeat() == 0) && llTicksDifference <= g_TickRateSettings.iLightSync + 100;

        BitStream.Write(pPlayer->GetID());
        BitStream.Write((unsigned char)pPlayer->GetSyncTimeContext());

        unsigned short usLatency = pPlayer->GetPing();
        BitStream.WriteCompressed(usLatency);

        BitStream.WriteBit(data.health.bSync);
        if (data.health.bSync)
        {
            SPlayerHealthSync health;
            health.data.fValue = pPlayer->GetHealth();
            BitStream.Write(&health);

            SPlayerArmorSync armor;
            armor.data.fValue = pPlayer->GetArmor();
            BitStream.Write(&armor);
        }

        BitStream.WriteBit(bSyncPosition);
        if (bSyncPosition)
        {
            SLowPrecisionPositionSync pos;
            pos.data.vecPosition = pPlayer->GetPosition();
            BitStream.Write(&pos);

            bool bSyncVehicleHealth = data.vehicleHealth.bSync && pVehicle;
            BitStream.WriteBit(bSyncVehicleHealth);
            if (bSyncVehicleHealth)
            {
                SLowPrecisionVehicleHealthSync health;
                health.data.fValue = pVehicle->GetHealth();
                BitStream.Write(&health);
            }
        }
    }

    return true;
}
Beispiel #20
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 );
    }
}
bool CVehicleTrailerPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_Vehicle );
    BitStream.Write ( m_AttachedVehicle );
    BitStream.WriteBit ( m_bAttached );

    if ( m_bAttached )
    {
        SPositionSync position ( false );
        position.data.vecPosition = m_vecPosition;
        BitStream.Write ( &position );

        SRotationDegreesSync rotation ( false );
        rotation.data.vecRotation = m_vecRotationDegrees;
        BitStream.Write ( &rotation );

        SVelocitySync turn;
        turn.data.vecVelocity = m_vecTurnSpeed;
        BitStream.Write ( &turn );
    }

    return true;
}
Beispiel #22
0
bool CVehicleInOutPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_pSourceElement && m_ID != INVALID_ELEMENT_ID )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        BitStream.Write ( m_ID );
        BitStream.WriteBits ( &m_ucSeat, 3 );
        BitStream.WriteBits ( &m_ucAction, 4 );

        if ( m_ucAction == CGame::VEHICLE_REQUEST_IN_CONFIRMED || m_ucAction == CGame::VEHICLE_REQUEST_JACK_CONFIRMED )
        {
            BitStream.WriteBits ( &m_ucDoor, 3 );
        }
        // If the action id is VEHICLE_NOTIFY_JACK_RETURN, send the in/out player chars aswell
        if ( m_ucAction == CGame::VEHICLE_NOTIFY_JACK_RETURN )
        {
            BitStream.Write ( m_PlayerIn );
            BitStream.Write ( m_PlayerOut );
        }

        if ( m_ucAction == 9 /*VEHICLE_ATTEMPT_FAILED*/ )
        {
            BitStream.Write ( m_ucFailReason );
            if ( m_ucFailReason == 5 /*FAIL_DISTANCE*/ && m_pCorrectVector )
            {
                SPositionSync pos ( false );
                pos.data.vecPosition = *m_pCorrectVector;
                BitStream.Write ( &pos );
            }
        }

        if ( m_ucAction == CGame::VEHICLE_NOTIFY_IN_ABORT_RETURN )
        {
            BitStream.WriteBits ( &m_ucDoor, 3 );
            SDoorOpenRatioSync door;
            door.data.fRatio = m_fDoorAngle;
            BitStream.Write ( &door );
        }

        if ( m_ucAction == CGame::VEHICLE_REQUEST_OUT_CONFIRMED )
        {
            if ( m_ucDoor < 4 )
                BitStream.WriteBits ( &m_ucDoor, 2 );
        }

        return true;
    }

    return false;
}
bool CPlayerChangeNickPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_pSourceElement )
    {
        // Write the source player id
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the nick
        BitStream.WriteStringCharacters ( m_strNewNick, m_strNewNick.length () );
        return true;
    }
    
    return false;
}
bool CExplosionSyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    // Write the source player and latency if any. Otherwize 0
    if (m_pSourceElement)
    {
        BitStream.WriteBit(true);
        ElementID ID = m_pSourceElement->GetID();
        BitStream.Write(ID);

        unsigned short usLatency = static_cast<CPlayer*>(m_pSourceElement)->GetPing();
        BitStream.WriteCompressed(usLatency);
    }
    else
    {
        BitStream.WriteBit(false);
    }

    if (m_OriginID != INVALID_ELEMENT_ID)
    {
        BitStream.WriteBit(true);
        BitStream.Write(m_OriginID);
    }
    else
        BitStream.WriteBit(false);

    // Write position and type
    SPositionSync position(false);
    position.data.vecPosition = m_vecPosition;
    BitStream.Write(&position);

    SExplosionTypeSync explosionType;
    explosionType.data.uiType = m_ucType;
    BitStream.Write(&explosionType);

    return true;
}
bool CPlayerStatsPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player.
    if ( m_pSourceElement )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.WriteCompressed ( ID );

		// Write the stats
		unsigned short usNumStats = static_cast < unsigned short  >( m_List.size () );
		BitStream.WriteCompressed ( usNumStats );

		vector < sPlayerStat* > ::const_iterator iter = m_List.begin ();
		for ( ; iter != m_List.end () ; iter++ )
		{
			BitStream.Write ( (*iter)->id );
			BitStream.Write ( (*iter)->value );
		}

		return true;
	}

	return false;
}
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;
}
 void CPositionRotationAnimation::ToBitStream( NetBitStreamInterface& a_rBitStream, bool a_bResumeMode ) const
 {
     a_rBitStream.WriteBit ( a_bResumeMode );
     if ( a_bResumeMode )
     {
        unsigned long ulNow = _GetTime ();
        unsigned long ulElaspedTime = ulNow - m_ulStartTime;
        unsigned long ulTimeLeft = 0;
        if ( m_ulEndTime > ulNow )
        {
            ulTimeLeft = m_ulEndTime - ulNow;
        }
        a_rBitStream.WriteCompressed ( ulElaspedTime );
        a_rBitStream.WriteCompressed ( ulTimeLeft );
     }
     else
     {
         a_rBitStream.WriteCompressed ( m_ulDuration );
     }

     SPositionSync positionSync;
     positionSync.data.vecPosition = m_SourceValue.m_vecPosition;
     a_rBitStream.Write ( &positionSync );

     SRotationRadiansSync rotationSync ( true ); //RPC function used floats when join time packet didn't, let's go for float
     rotationSync.data.vecRotation = m_SourceValue.m_vecRotation;
     a_rBitStream.Write ( &rotationSync );
    
     positionSync.data.vecPosition = m_TargetValue.m_vecPosition;
     a_rBitStream.Write ( &positionSync );

     a_rBitStream.WriteBit ( m_bDeltaRotationMode );
     if ( m_bDeltaRotationMode )
     {
        rotationSync.data.vecRotation = m_DeltaValue.m_vecRotation; //We serialize DELTA
     }
     else
     {
         rotationSync.data.vecRotation = m_TargetValue.m_vecRotation;
     }
     a_rBitStream.Write ( &rotationSync );

     ////We write the string directly to allow new types without changing netcode (since integer values of enum might change)
     a_rBitStream.WriteString ( CEasingCurve::GetStringFromEasingType( m_easingCurve.GetType() ) );
     double fEasingPeriod, fEasingAmplitude, fEasingOvershoot;
     m_easingCurve.GetParams ( fEasingPeriod, fEasingAmplitude, fEasingOvershoot );
     a_rBitStream.Write ( fEasingPeriod );
     a_rBitStream.Write ( fEasingAmplitude );
     a_rBitStream.Write ( fEasingOvershoot );
 }
bool CPickupHitConfirmPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // unsigned short   (2)     - pickup id
    // bool                     - hide it?

    // Got a pickup to send?
    if ( m_pPickup )
    {
        // Write the pickup id and visibily state
        BitStream.Write ( m_pPickup->GetID () );

        // WRite the flags
        BitStream.WriteBit ( m_pPickup->IsVisible () );
        BitStream.WriteBit ( m_bPlaySound );

        return true;
    }

    return false;
}
bool CUnoccupiedVehicleSyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    // While we're not out of syncs to write
    bool                             bSent = false;
    vector<SyncData>::const_iterator iter = m_Syncs.begin();
    for (; iter != m_Syncs.end(); ++iter)
    {
        // If we're not supposed to ignore the packet
        const SyncData* data = &(*iter);

        if (data->bSend)
        {
            BitStream.Write(&(data->syncStructure));

            // We've sent atleast one sync
            bSent = true;
        }
    }

    return bSent;
}
bool CServerTextItemPacket::Write ( NetBitStreamInterface &BitStream  ) const
{
    BitStream.WriteCompressed ( m_ulUniqueId );

    // Write the flag byte
    BitStream.WriteBit ( m_bDeletable );

    // Not deleting this?
    if ( !m_bDeletable )
    {
        BitStream.Write ( m_fX );
        BitStream.Write ( m_fY );
        BitStream.Write ( m_fScale );
        BitStream.Write ( m_red );
        BitStream.Write ( m_green );
        BitStream.Write ( m_blue );
        BitStream.Write ( m_alpha );
        BitStream.Write ( m_ucFormat );

        // Grab the text length
        size_t sizeText = strlen ( m_szText );
        if ( sizeText > 1024 )
        {
            sizeText = 1024;
        }

        // Write the text
        BitStream.WriteCompressed ( static_cast < unsigned short > ( sizeText ) );
        if ( sizeText )
        {
            BitStream.Write ( m_szText, sizeText );
        }
    }

    return true;
}