Пример #1
0
bool UdpChain::readPacket( SBuffer& buffer , unsigned& readSize )
{
    if ( !buffer.getAvailableSize() )
        return false;

    uint32  incoming;
    uint32  outgoing;

    int count = 0;

    uint32 maxOutgoing = 0;
    while( buffer.getAvailableSize() )
    {
        buffer.take( incoming );
        buffer.take( outgoing );
        buffer.take( readSize );

        if ( maxOutgoing < outgoing )
            maxOutgoing = outgoing;

        if ( incoming <= mIncomingAck )
        {

            if ( readSize > buffer.getAvailableSize() )
            {
                ::Msg( "UdpChain::error incoming data" );
                return false;
            }

            {
                //::Msg( "UdpChain::old incoming data" );
                buffer.shiftUseSize( readSize );
            }
        }
        else if ( incoming > mIncomingAck )
        {
            mIncomingAck = incoming;

            if ( readSize )
                break;
        }

        ++count;
    }

    refrushReliableData( maxOutgoing );
    //Msg( "readPacket %u %u %u" , outgoing , incoming , readSize );
    return buffer.getAvailableSize() != 0;
}
Пример #2
0
	bool Game::restoreData( SBuffer& buffer )
	{
		mStepVec.clear();

		restart();

		unsigned size;
		buffer.take( size );

		for( int i = 0 ; i < size ; ++i )
		{
			int idxPos;
			buffer.take( idxPos );
			if ( idxPos == -1 )
			{
				pass();
			}
			else if ( play( mBoard.getPos( idxPos ) ) )
			{
				return false;
			}
		}
		return true;
	}