示例#1
0
//
// Should do the same this as what CPedTaskPacket::Read() does
//
bool CSimPedTaskPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Read and save packet data
    m_Cache.uiNumBitsInPacketBody = BitStream.GetNumberOfUnreadBits();
    uint uiNumBytes = ( m_Cache.uiNumBitsInPacketBody + 1 ) / 8;
    dassert( uiNumBytes < sizeof( m_Cache.DataBuffer ) );
    if( uiNumBytes < sizeof( m_Cache.DataBuffer ) )
        if ( BitStream.ReadBits( m_Cache.DataBuffer, m_Cache.uiNumBitsInPacketBody ) )
            return true;

    return false;
}
示例#2
0
void CWorldRPCs::SetTrafficLightState(NetBitStreamInterface& bitStream)
{
    char ucTrafficLightState;

    if (bitStream.ReadBits(&ucTrafficLightState, 4))
    {
        bool bForced = bitStream.ReadBit();
        // We ignore updating the serverside traffic light state if it's blocked, unless script forced it
        if (bForced || !g_pMultiplayer->GetTrafficLightsLocked())
            g_pMultiplayer->SetTrafficLightState((unsigned char)*&ucTrafficLightState);
    }
}
示例#3
0
bool CVehicleInOutPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Read out the vehicle id
    m_ID = INVALID_ELEMENT_ID;
    BitStream.Read ( m_ID );
    if ( m_ID == INVALID_ELEMENT_ID )
    {
        return false;
    }

    // Read out the action id
    m_ucAction = 0xFF;
    if ( !BitStream.ReadBits ( &m_ucAction, 4 ) )
        return false;

    // If the action is requesting to get in, read out the "passenger" flag too
    if ( m_ucAction == CGame::VEHICLE_REQUEST_IN )
    {
        return BitStream.ReadBits ( &m_ucSeat, 3 ) &&
               BitStream.ReadBit  ( m_bOnWater ) &&
               BitStream.ReadBits ( &m_ucDoor, 3 );
    }
    else if ( m_ucAction == CGame::VEHICLE_NOTIFY_JACK_ABORT )
    {
        SDoorOpenRatioSync door;
        bool bStartedJacking;
        if ( BitStream.ReadBits ( &m_ucDoor, 3 ) &&
             BitStream.Read ( &door ) &&
             BitStream.ReadBit ( bStartedJacking ) )
        {
            m_ucStartedJacking = bStartedJacking;
            m_fDoorAngle = door.data.fRatio;
        }
        else
            return false;
    }
    else if ( m_ucAction == CGame::VEHICLE_NOTIFY_IN_ABORT )
    {
        SDoorOpenRatioSync door;
        if ( BitStream.ReadBits ( &m_ucDoor, 3 ) &&
             BitStream.Read ( &door ) )
        {
            m_fDoorAngle = door.data.fRatio;
        }
        else
            return false;
    }
    else if ( m_ucAction == CGame::VEHICLE_REQUEST_OUT )
    {
        m_ucDoor = 0;
        if ( !BitStream.ReadBits ( &m_ucDoor, 2 ) )
            m_ucDoor = 0xFF;
    }
    return true;
}