本文整理汇总了C++中nlmisc::CBitMemStream::serial方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitMemStream::serial方法的具体用法?C++ CBitMemStream::serial怎么用?C++ CBitMemStream::serial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::CBitMemStream
的用法示例。
在下文中一共展示了CBitMemStream::serial方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ***************************************************************************
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);
}
示例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);
}
示例3: 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);
}
示例4: 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;
}
示例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);
}
}
示例6: 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);
}
示例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);
}
示例8:
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);
}
示例9: 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);
}
}
}
示例10: 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;
}