本文整理汇总了C++中nlmisc::CBitMemStream::poke方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitMemStream::poke方法的具体用法?C++ CBitMemStream::poke怎么用?C++ CBitMemStream::poke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::CBitMemStream
的用法示例。
在下文中一共展示了CBitMemStream::poke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushed
//-----------------------------------------------
// writePermanentDelta
//
// TODO: Maybe an optimization will be required to prevent sending null properties
// when a character is added to a CCDBGroup.
//-----------------------------------------------
bool CCDBSynchronised::writePermanentDelta( NLMISC::CBitMemStream& s )
{
static uint nbPermaDeltaSent = 0;
// Test the changed property count and make room to store the number of property pushed (poked later)
uint origChangedPropertyCount = _DataContainer.getPermanentChangedPropertyCount();
if ( origChangedPropertyCount == 0 )
return false;
uint bitposOfNbChanges = s.getPosInBit();
uint32 dummy = 0;
s.serial( dummy, CDBChangedPropertyCountBitSize ); // optimising s.reserveBits( CDBChangedPropertyCountBitSize )
// Browse changes and write them
uint32 nbChanges = 0;
uint32 bitsize = CDBChangedPropertyCountBitSize; // initialize with the size of the reserved bits for the number of changes
TCDBDataIndex dataIndex = _DataContainer.getPermanentFirstChanged();
while ( dataIndex != CDB_LAST_CHANGED
/*&& (bitsize < maxBitSize)*/ )
{
++nbPermaDeltaSent;
// Retrieve the structure node corresponding to the index
ICDBStructNode *node = CCDBStructBanks::instance()->getNodeFromDataIndex( _Bank, dataIndex );
nlassert( node );
if ( node->isAtomic() ) // counts for 1 change
{
#ifdef NL_DEBUG
nlassert( dynamic_cast<CCDBStructNodeBranch*>(node) ); // should not be leaf because the main tracker pushes the atom group index for atomic leaves
#endif
// Build and push the binary atom id
ICDBStructNode::CBinId binId;
(static_cast<CCDBStructNodeBranch*>(node))->buildBinIdFromLeaf( binId );
bitsize += binId.writeToBitMemStream( s );
//nlinfo( "CDB/ATOM: Written bin id %s", binId.toString().c_str() );
//_DataContainer.displayAtomChanges( node->getDataIndex() );
// Make room to store the atom bitfield
uint bitposOfAtomBitfield = s.getPosInBit();
uint indexInAtom = 0;
node->foreachLeafCall( cbNop, indexInAtom, NULL ); // count the number of siblings
uint nbAtomElements = indexInAtom;
s.reserveBits( nbAtomElements );
bitsize += nbAtomElements;
//nlinfo( "CDB/ATOM: Reserved %u bits (%d)", nbAtomElements, s.getPosInBit()-bitposOfAtomBitfield );
// Browse the siblings of the atom node, and push the deltas for the properties marked as changes, updating the bitfield
TPushAtomChangeStruct arg;
arg.CdbSync = this;
arg.BitSize = &bitsize;
arg.S = &s;
arg.AtomBitfield.resize( nbAtomElements );
indexInAtom = 0;
node->foreachLeafCall( cbPushDeltaOfLeafInAtomIfChangedPermanent, indexInAtom, (void*)&arg );
// Fill the placeholder with the bitfield
s.pokeBits( arg.AtomBitfield, bitposOfAtomBitfield );
if ( VerboseDatabase )
{
nldebug( "CDB/ATOM: Bitfield: %s", arg.AtomBitfield.toString().c_str() );
}
}
else
{
#ifdef NL_DEBUG
nlassert( dynamic_cast<CCDBStructNodeLeaf*>(node) );
#endif
// Push the binary property id
bitsize += static_cast<CCDBStructNodeLeaf*>(node)->binLeafId().writeToBitMemStream( s );
// Push the value
pushDeltaPermanent( s, static_cast<CCDBStructNodeLeaf*>(node), bitsize );
}
dataIndex = _DataContainer.getPermanentNextChanged( dataIndex );
++nbChanges;
}
// Fill the placeholder with the number of changes
s.poke( nbChanges, bitposOfNbChanges, CDBChangedPropertyCountBitSize );
//s.displayStream( "writeDelta" );
#ifdef TRACE_SET_VALUE
if ( VerboseDatabase )
nldebug( "%u: CDB: Permanent Delta pushed (%u changes written, %u remaining)", CTickEventHandler::getGameCycle(), nbChanges, getChangedPropertyCount() );
#endif
nldebug( "Filled %u permanent changes", nbPermaDeltaSent );
return true;
}