当前位置: 首页>>代码示例>>C++>>正文


C++ nlmisc::CBitMemStream类代码示例

本文整理汇总了C++中nlmisc::CBitMemStream的典型用法代码示例。如果您正苦于以下问题:C++ CBitMemStream类的具体用法?C++ CBitMemStream怎么用?C++ CBitMemStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CBitMemStream类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pack

/* Pack an action to a bit stream. Set transmitTimestamp=true for server-->client,
 * false for client-->server. If true, set the current gamecycle.
 */
void CActionFactory::pack (CAction *action, NLMISC::CBitMemStream &message, NLMISC::TGameCycle /* currentCycle */ )
{
	//H_BEFORE(FactoryPack);
	//sint32 val = message.getPosInBit ();

	//

	if (action->Code < 4)
	{
		// short code (0 1 2 3)
		bool shortcode = true;
		uint32 code = action->Code;
		message.serialAndLog1 (shortcode);
		message.serialAndLog2 (code, 2);
	}
	else
	{
		bool shortcode = false;
		message.serialAndLog1 (shortcode);
		message.serialAndLog1 (action->Code);
	}

	action->pack (message);
	//H_AFTER(FactoryPack);

	//OLIV: nlassertex (message.getPosInBit () - val == (sint32)CActionFactory::getInstance()->size (action), ("CActionFactory::pack () : action %d packed %u bits, should be %u, size() is wrong", action->Code, message.getPosInBit () - val, CActionFactory::getInstance()->size (action)));

//	nlinfo ("ac:%p pack one action in message %d %hu %u %d", action, action->Code, (uint16)(action->CLEntityId), val, message.getPosInBit()-val);
}
开发者ID:mixxit,项目名称:solinia,代码行数:32,代码来源:action_factory.cpp

示例2: processTellString

// ***************************************************************************
void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisplayer &chatDisplayer)
{
	CChatMsg chatMsg;

	// Serial. For tell message, there is no chat mode, coz we know we are in tell mode !
	bms.serial (chatMsg.CompressedIndex);
	bms.serial (chatMsg.SenderNameId);
	bms.serial (chatMsg.Content);

	if (PermanentlyBanned) return;

	chatMsg.ChatMode = (uint8) CChatGroup::tell;

	// If !complete, wait
	ucstring senderStr;
	bool	complete = true;
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, true));
		nldebug("<impulseTell> Received TELL, put in buffer : waiting association");
		return;
	}

	// display
	ucstring	ucstr;
	buildTellSentence(senderStr, chatMsg.Content, ucstr);
	chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:30,代码来源:client_chat_manager.cpp

示例3: Unknown

/*
 * Push one change to the stream (permanent mode)
 */
void	CCDBSynchronised::pushDeltaPermanent( NLMISC::CBitMemStream& s, CCDBStructNodeLeaf *node, uint32& bitsize )
{
	TCDBDataIndex index = node->getDataIndex();

	// Test if the property type is valid.
	if ( node->type() > ICDBStructNode::UNKNOWN && node->type() < ICDBStructNode::Nb_Prop_Type )
	{
		// Serialize the Property Value according to the Property Type.
		uint64 value;
		value = (uint64)_DataContainer.getValue64( index ); // "delta from 0"

		if ( node->type() == ICDBStructNode::TEXT )
		{
			s.serialAndLog2( value, 32 );
			bitsize += 32;
			if ( VerboseDatabase )
				nldebug( "CDB: Pushing permanent value %"NL_I64"d (TEXT-32) for index %d prop %s", (sint64)value, index, node->buildTextId().toString().c_str() );
		}
		else
		{
			s.serialAndLog2( value, (uint)node->type() );
			bitsize += (uint32)node->type();
			if ( VerboseDatabase )
				nldebug( "CDB: Pushing permanent value %"NL_I64"d (%u bits) for index %d prop %s", (sint64)value, (uint32)node->type(), index, node->buildTextId().toString().c_str() );
		}
	}
	else
		nlwarning("CCDBStructNodeLeaf::writeDeltaPermanent : Property Type Unknown ('%d') -> not serialized.", (uint)node->type());
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:32,代码来源:cdb_synchronised.cpp

示例4:

// ***************************************************************************
void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDisplayer &chatDisplayer)
{
	// serial
	CChatMsg2 chatMsg;
	chatMsg.ChatMode = CChatGroup::tell;
	bms.serial(chatMsg.CompressedIndex);
	bms.serial(chatMsg.SenderNameId);
	bms.serial(chatMsg.PhraseId);

	// if !complete, wait
	ucstring senderStr;
	ucstring rawMessage;
	bool	complete = true;
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage);
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, true));
		nldebug("<impulseTell> Received TELL, put in buffer : waiting association");
		return;
	}

	// display
	ucstring	ucstr;
	buildTellSentence(senderStr, rawMessage, ucstr);
	chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:28,代码来源:client_chat_manager.cpp

示例5: sendChoices

// ***************************************************************************************
void CBotChatPageDynamicMission::sendChoices()
{
	uint k;
	#ifdef NL_DEBUG
		for(k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k)
		{
			nlassert(_Choice[k] != -1);
		}
	#endif
	NLMISC::CBitMemStream out;
	static const char *msgName = "BOTCHAT:DM_CHOICE";
	if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
	{
		for(k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k)
		{
			uint8 u8Choice = (uint8) _Choice[k];
			out.serial(u8Choice);
		}
		NetMngr.push(out);
	}
	else
	{
		nlwarning(" unknown message name %s", msgName);
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:26,代码来源:bot_chat_page_dynamic_mission.cpp

示例6: acceptMission

// ***************************************************************************************
void CBotChatPageMission::acceptMission()
{
	if (!_CurrSel) return;
	sint index = _CurrSel->getIndexInParent();
	if (index < 0) return;
	// send msg to server
	NLMISC::CBitMemStream out;
	static const char *msgName;
	if(_MType==MISSION_DESC::ZCCharge)
		msgName= "BOTCHAT:DUTY_APPLY";
	else
		msgName= "BOTCHAT:PICK_MISSION";
	if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
	{
		uint8 missionIndex = (uint8) index;
		out.serial(missionIndex);
		NetMngr.push(out);
	}
	else
	{
		nlwarning(" unknown message name %s", msgName);
	}
	// close the selection box
	activateWindow(WIN_BOT_CHAT_ACCEPT_MISSION, false);
	// close the botchat
	CBotChatManager::getInstance()->setCurrPage(NULL);
	_CurrSel = NULL;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:29,代码来源:bot_chat_page_mission.cpp

示例7: ucstring

// ***************************************************************************
void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDisplayer &chatDisplayer)
{
	CChatMsg2 chatMsg;
	bms.serial( chatMsg );
	if (PermanentlyBanned) return;
	CChatGroup::TGroupType	type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
	ucstring	senderStr;
	ucstring	rawMessage;

	// here, the type cannot be dyn_chat (no DynChatId in the message) => discard
	if(type==CChatGroup::dyn_chat)
	{
		nlwarning("Client don't support dyn_chat with CChatMsg2 messages => '%x' aborted", chatMsg.PhraseId);
		return;
	}

	// if !complete, wait
	bool	complete = true;
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage);
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, false));
		//nldebug("<impulseChat> Received CHAT, put in buffer : waiting association");
		return;
	}

	rawMessage += ucstring(" ");
	rawMessage += chatMsg.CustomTxt;

	// display
	ucstring	ucstr;
	buildChatSentence(chatMsg.CompressedIndex, senderStr, rawMessage, type, ucstr);
	chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, rawMessage, type, CEntityId::Unknown, senderStr);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:36,代码来源:client_chat_manager.cpp

示例8: processChatStringWithNoSender

// ***************************************************************************
void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& bms, CChatGroup::TGroupType type, IChatDisplayer &chatDisplayer)
{
	nlassert(type!=CChatGroup::dyn_chat);

	// serial
	CChatMsg2 chatMsg;
	uint32 phraseID;
	bms.serial(phraseID);
	if (PermanentlyBanned) return;
	chatMsg.CompressedIndex = INVALID_DATASET_INDEX;
	chatMsg.SenderNameId = 0;
	chatMsg.ChatMode = type;
	chatMsg.PhraseId = phraseID;
	ucstring ucstr;

	// if !complete, wait
	bool	complete = STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, ucstr);
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, false));
		//nldebug("<impulseDynString> Received CHAT, put in buffer : waiting association");
		return;
	}

	// diplay
	ucstring senderName("");
	chatDisplayer.displayChat(INVALID_DATASET_INDEX, ucstr, ucstr, type, CEntityId::Unknown, senderName);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:29,代码来源:client_chat_manager.cpp

示例9: fillBitMemStream

	void fillBitMemStream( const CCharacterInfos *charInfo, CStringManager::TLanguages language, const CStringManager::TReplacement &rep, NLMISC::CBitMemStream &bms)
	{
		uint32 eventFactionId = SM->translateEventFaction(Identifier);

		// serial the string ID
		bms.serial(eventFactionId);
	}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:7,代码来源:parameter_traits.cpp

示例10:

void CStringManager::CParameterTraits::fillBitMemStream( const CCharacterInfos *charInfo,TLanguages language, const TReplacement &rep, NLMISC::CBitMemStream &bms)
{
	const CStringManager::CEntityWords &ew = SM->getEntityWords(language, ParamId.Type);
	std::string rowName = NLMISC::strlwr(getParameterId());
	uint32 stringId;
	stringId = ew.getStringId(rowName, rep.Format);
	bms.serial(stringId);
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:8,代码来源:parameter_traits.cpp

示例11:

/*
 * Write the id to a bit stream for server-client comms, and return the size of data written
 */
inline sint ICDBStructNode::CBinId::writeToBitMemStream( NLMISC::CBitMemStream& f ) const
{
	sint bitsize = 0;
	for ( uint i=0; i<Ids.size(); i++ )
	{
		uint32& nodeIndex = const_cast<uint32&>(Ids[i].first);
		f.serialAndLog2( nodeIndex, Ids[i].second );
		bitsize += Ids[i].second;
	}
	return bitsize;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:14,代码来源:cdb_synchronised.cpp

示例12: unpack

/* Unpack some actions from a bit stream. Set transmitTimestamp=true for server-->client,
 * false for client-->server. If true, set the current gamecycle.
 */
void CActionFactory::unpack (NLMISC::CBitMemStream &message, std::vector <CAction *>& actions, NLMISC::TGameCycle /* currentCycle */ )
{
	actions.clear ();

	static int n = 0;
	n++;
	while ((sint32)message.length() * 8 - message.getPosInBit () >= 8)
	{
		TActionCode code;

		bool shortcode;
		message.serial (shortcode);

		if (shortcode)
		{
			code = 0;
			uint32 val;
			message.serial (val, 2);
			code = (TActionCode) val;
		}
		else
		{
			message.serial (code);
		}

		CAction *action = create (INVALID_SLOT, code);

		//nlinfo ("m%d size: p:%d s:%d c:%d (actionsize: %d) slot:%hu", n, message.getPosInBit (), message.length() * 8, code, action->size(), (uint16)action->CLEntityId);

		if (action == NULL)
		{
			nlwarning ("Unpacking an action with unknown code, skip it (%u)", code);
		}
		else
		{
			action->unpack (message);
			actions.push_back (action);
		}
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:43,代码来源:action_factory.cpp

示例13: 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;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:100,代码来源:cdb_synchronised.cpp


注:本文中的nlmisc::CBitMemStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。