Example #1
0
void CMarker::SetTarget ( const CVector* pTargetVector )
{
    // Got a target vector?
    if ( pTargetVector )
    {
        // Different from our current target
        if ( !m_bHasTarget || m_vecTarget != *pTargetVector )
        {
            // Is this a marker type that has a destination?
            if ( m_ucType == CMarker::TYPE_CHECKPOINT || m_ucType == CMarker::TYPE_RING )
            {
                // Set the target position
                m_bHasTarget = true;
                m_vecTarget = *pTargetVector;

                // Tell everyone that knows about this marker
                CBitStream BitStream;
                BitStream.pBitStream->Write ( static_cast < unsigned char > ( 1 ) );
                BitStream.pBitStream->Write ( m_vecTarget.fX );
                BitStream.pBitStream->Write ( m_vecTarget.fY );
                BitStream.pBitStream->Write ( m_vecTarget.fZ );
                BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_TARGET, *BitStream.pBitStream ) );
            }
            else
            {
                // Reset the target position
                m_bHasTarget = false;
            }
        }
    }
    else
    {
        // Not already without target?
        if ( m_bHasTarget )
        {
            // Reset the target position
            m_bHasTarget = false;

            // Is this a marker type that has a destination?
            if ( m_ucType == CMarker::TYPE_CHECKPOINT || m_ucType == CMarker::TYPE_RING )
            {
                // Tell everyone that knows about this marker
                CBitStream BitStream;
                BitStream.pBitStream->Write ( static_cast < unsigned char > ( 0 ) );
                BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_TARGET, *BitStream.pBitStream ) );
            }
        }
    }
}
Example #2
0
void CRadarArea::SetPosition ( const CVector& vecPosition )
{
    // Remember the last position
    m_vecLastPosition = m_vecPosition;

    // Different from our current position?
    if ( vecPosition != m_vecPosition )
    {
        // Set the new position
        m_vecPosition = vecPosition;

        // We need to make sure the time context is replaced 
        // before that so old packets don't arrive after this.
        GenerateSyncTimeContext ();

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ID );
        BitStream.pBitStream->Write ( vecPosition.fX );
        BitStream.pBitStream->Write ( vecPosition.fY );
        BitStream.pBitStream->Write ( vecPosition.fZ );
        BitStream.pBitStream->Write ( GetSyncTimeContext () );
        BroadcastOnlyVisible ( CLuaPacket ( SET_ELEMENT_POSITION, *BitStream.pBitStream ) );
    }
}
Example #3
0
void CPerPlayerEntity::DestroyEntity(CPlayer* pPlayer)
{
    // Are we visible?
    if (m_bIsSynced)
    {
        // Create the remove entity packet
        CEntityRemovePacket Packet;
        Packet.Add(this);

        // Send it to the player if available, if not everyone
        if (pPlayer)
        {
            // Only send it to him if we can
            if (!pPlayer->DoNotSendEntities())
            {
                pPlayer->Send(Packet);
                // CLogger::DebugPrintf ( "Destroyed %u (%s) for %s\n", GetID (), GetName (), pPlayer->GetNick () );
            }
        }
        else
        {
            // CLogger::DebugPrintf ( "Destroyed %u (%s) for everyone (%u)\n", GetID (), GetName (), m_Players.size () );
            BroadcastOnlyVisible(Packet);
        }
    }
}
Example #4
0
void CMarker::SetPosition ( const CVector& vecPosition )
{
    // Different from our current position?
    if ( m_vecPosition != vecPosition )
    {
        // Set the new position
        m_vecPosition = vecPosition;
        if ( m_pCollision )
            m_pCollision->SetPosition ( vecPosition );
        UpdateSpatialData ();

        // If attached, client should handle the position correctly
        if (  m_pAttachedTo )
            return;

        // We need to make sure the time context is replaced 
        // before that so old packets don't arrive after this.
        GenerateSyncTimeContext ();

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( vecPosition.fX );
        BitStream.pBitStream->Write ( vecPosition.fY );
        BitStream.pBitStream->Write ( vecPosition.fZ );
        BitStream.pBitStream->Write ( GetSyncTimeContext () );
        BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_ELEMENT_POSITION, *BitStream.pBitStream ) );
    }
}
Example #5
0
void CMarker::SetIcon ( unsigned char ucIcon )
{
    if ( m_ucIcon != ucIcon )
    {
        m_ucIcon = ucIcon;

        // Tell everyone that knows about this marker
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ucIcon );
        BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_ICON, *BitStream.pBitStream ) );
    }
}
Example #6
0
void CMarker::SetSize ( float fSize )
{
    // Different from our current size?
    if ( fSize != m_fSize )
    {
        // Set the new size and update the col object
        m_fSize = fSize;
        UpdateCollisionObject ( m_ucType );

        // Tell all players
        CBitStream BitStream;
        BitStream.pBitStream->Write ( fSize );
        BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_SIZE, *BitStream.pBitStream ) );
    }
}
Example #7
0
void CRadarArea::SetColor ( unsigned long ulColor )
{
    // Different from our current color?
    if ( ulColor != m_ulColor )
    {
        // Update the color
        m_ulColor = ulColor;

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ID );
        BitStream.pBitStream->Write ( ulColor );
        BroadcastOnlyVisible ( CLuaPacket ( SET_RADAR_AREA_COLOR, *BitStream.pBitStream ) );
    }
}
Example #8
0
void CRadarArea::SetSize ( const CVector2D& vecSize )
{
    // Different from our current size?
    if ( vecSize != m_vecSize )
    {
        // Update the size
        m_vecSize = vecSize;

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ID );
        BitStream.pBitStream->Write ( vecSize.fX );
        BitStream.pBitStream->Write ( vecSize.fY );
        BroadcastOnlyVisible ( CLuaPacket ( SET_RADAR_AREA_SIZE, *BitStream.pBitStream ) );
    }
}
Example #9
0
void CMarker::SetColor ( const SColor color )
{
    // Different from our current color?
    if ( color != m_Color )
    {
        // Set the new color
        m_Color = color;

        // Tell all the players
        CBitStream BitStream;
        BitStream.pBitStream->Write ( color.B  );
        BitStream.pBitStream->Write ( color.G );
        BitStream.pBitStream->Write ( color.R );
        BitStream.pBitStream->Write ( color.A );
        BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_COLOR, *BitStream.pBitStream ) );
    }
}
Example #10
0
void CRadarArea::SetColor ( const SColor color )
{
    // Different from our current color?
    if ( color != m_Color )
    {
        // Update the color
        m_Color = color;

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ID );
        BitStream.pBitStream->Write ( color.R );
        BitStream.pBitStream->Write ( color.G );
        BitStream.pBitStream->Write ( color.B );
        BitStream.pBitStream->Write ( color.A );
        BroadcastOnlyVisible ( CLuaPacket ( SET_RADAR_AREA_COLOR, *BitStream.pBitStream ) );
    }
}
Example #11
0
void CMarker::SetMarkerType ( unsigned char ucType )
{
    // Different from our current type?
    if ( ucType != m_ucType )
    {
        // Set the new type
        unsigned char ucOldType = m_ucType;
        m_ucType = ucType;
        UpdateCollisionObject ( ucOldType );

        // Tell all players
        CBitStream BitStream;
        BitStream.pBitStream->Write ( ucType );
        BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_MARKER_TYPE, *BitStream.pBitStream ) );

        // Is the new type not a checkpoint or a ring? Remove the target
        if ( ucType != CMarker::TYPE_CHECKPOINT && ucType != CMarker::TYPE_RING )
        {
            m_bHasTarget = false;
        }
    }
}
Example #12
0
void CRadarArea::SetFlashing ( bool bFlashing )
{
    // Different from our current flashing status?
    if ( bFlashing != m_bIsFlashing )
    {
        // Set the new status
        m_bIsFlashing = bFlashing;

        // Tell all the players that know about us
        CBitStream BitStream;
        BitStream.pBitStream->Write ( m_ID );

        if ( bFlashing )
        {
            BitStream.pBitStream->Write ( static_cast < unsigned char > ( 1 ) );
        }
        else
        {
            BitStream.pBitStream->Write ( static_cast < unsigned char > ( 0 ) );
        }

        BroadcastOnlyVisible ( CLuaPacket ( SET_RADAR_AREA_FLASHING, *BitStream.pBitStream ) );
    }
}