Пример #1
0
void SystemBubble::_BubblecastAddBall( SystemEntity* about_who )
{
    if( m_dynamicEntities.empty() )
    {
        _log( DESTINY__TRACE, "Add Ball: Nobody to receive." );
        return;
    }

    Buffer* destinyBuffer = new Buffer;

    //create AddBalls header
    Destiny::AddBall_header head;
    head.more = 0;
    head.sequence = DestinyManager::GetStamp();
    destinyBuffer->Append( head );

    DoDestiny_AddBalls addballs;
    addballs.slims = new PyList;

    //encode destiny binary
    about_who->EncodeDestiny( *destinyBuffer );
    addballs.destiny_binary = new PyBuffer( &destinyBuffer );
    SafeDelete( destinyBuffer );

    //encode damage state
    addballs.damages[ about_who->GetID() ] = about_who->MakeDamageState();
    //encode SlimItem
    addballs.slims->AddItem( new PyObject( new PyString( "foo.SlimItem" ), about_who->MakeSlimItem() ) );

    //bubblecast the update
    PyTuple* t = addballs.Encode();
    BubblecastDestinyUpdate( &t, "AddBall" );
    PySafeDecRef( t );
}
Пример #2
0
void SystemBubble::_SendAddBalls( SystemEntity* to_who )
{
	if( m_entities.empty() )
    {
		_log( DESTINY__TRACE, "Add Balls: Nothing to send." );
		return;
	}

    Buffer* destinyBuffer = new Buffer;

    Destiny::AddBall_header head;
	head.packet_type = 0;
	head.sequence = DestinyManager::GetStamp();

    destinyBuffer->Append( head );

    DoDestiny_AddBalls addballs;
    addballs.slims = new PyList;

    std::map<uint32, SystemEntity*>::const_iterator cur, end;
	cur = m_entities.begin();
	end = m_entities.end();
	for(; cur != end; ++cur)
    {
		if( cur->second->IsVisibleSystemWide() )
			continue;	//it is already in their destiny state

        //damageState
		addballs.damages[ cur->second->GetID() ] = cur->second->MakeDamageState();
		//slim item
		addballs.slims->AddItem( new PyObject( "foo.SlimItem", cur->second->MakeSlimItem() ) );
		//append the destiny binary data...
		cur->second->EncodeDestiny( *destinyBuffer );
	}

    addballs.destiny_binary = new PyBuffer( &destinyBuffer );
    SafeDelete( destinyBuffer );

    _log( DESTINY__TRACE, "Add Balls:" );
    addballs.Dump( DESTINY__TRACE, "    " );
    _log( DESTINY__TRACE, "    Ball Binary:" );
    _hex( DESTINY__TRACE, &( addballs.destiny_binary->content() )[0],
                          addballs.destiny_binary->content().size() );

    _log( DESTINY__TRACE, "    Ball Decoded:" );
    Destiny::DumpUpdate( DESTINY__TRACE, &( addballs.destiny_binary->content() )[0],
                                         addballs.destiny_binary->content().size() );

    PyTuple* t = addballs.Encode();
	to_who->QueueDestinyUpdate( &t );	//may consume, but may not.
    PySafeDecRef( t );
}