本文整理汇总了C++中CBitMemStream::length方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitMemStream::length方法的具体用法?C++ CBitMemStream::length怎么用?C++ CBitMemStream::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitMemStream
的用法示例。
在下文中一共展示了CBitMemStream::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: joinLeagueProposal
//---------------------------------------------------
// leagueJoinProposal :
//---------------------------------------------------
void CTeamManager::joinLeagueProposal( CCharacter * leader, const CEntityId &targetId)
{
//check already done
nlassert(leader);
const NLMISC::CEntityId &leaderId = leader->getId();
if (targetId == leaderId )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" );
return;
}
// get targeted player
CCharacter *invitedPlayer = PlayerManager.getOnlineChar( targetId );
if ( invitedPlayer == NULL )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" );
return;
}
// god player are forbidden to team
if (leader->godMode() || invitedPlayer->godMode())
{
nlwarning("<CTeamManager joinLeagueProposal> Player %s invited %s, but at least on of them is god, forbidden",
leaderId.toString().c_str(),
targetId.toString().c_str());
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_GOD_FORBIDDEN" );
return;
}
TInviteRetCode code = isLeagueInvitableBy(invitedPlayer,leader);
if ( code == AlreadyInvited )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_ALREADY_INVITED" );
return;
}
else if ( code == AlreadyInLeague )
{
CTeam * team = getRealTeam( invitedPlayer->getTeamId() );
CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_ALREADY_IN_LEAGUE" );
return;
}
else if ( code == NotLeader )
{
CTeam * team = getRealTeam( invitedPlayer->getTeamId() );
joinLeagueProposal(leader, team->getLeader());
return;
}
else if ( code == CantInvite )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_INVITOR_NOT_LEADER" );
return;
}
/// the invitor must not be in the ignore list of the target
if(invitedPlayer->hasInIgnoreList(leaderId))
{
SM_STATIC_PARAMS_1( params1, STRING_MANAGER::player );
params1[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId) );
// Use the standard "player declines your offer". Don't use specific message because
// maybe not a good idea to inform a player that someone ignores him
CCharacter::sendDynamicSystemMessage( leaderId, "TEAM_DECLINE", params1 );
return;
}
//set the target's invitor
invitedPlayer->setLeagueInvitor(leaderId);
CEntityId msgTargetEId = targetId;
//send the appropriate string to the client
SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);
params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias(leaderId) );
uint32 txt = STRING_MANAGER::sendStringToClient(TheDataset.getDataSetRow(targetId), "LEAGUE_PROPOSAL", params );
CMessage msgout( "IMPULSION_ID" );
msgout.serial( const_cast<CEntityId&>(msgTargetEId) );
CBitMemStream bms;
nlverify ( GenericMsgManager.pushNameToStream( "PVP_CHALLENGE:INVITATION", bms) );
bms.serial( txt );
msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length());
sendMessageViaMirror( NLNET::TServiceId(msgTargetEId.getDynamicId()), msgout );
params[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId ) );
PHRASE_UTILITIES::sendDynamicSystemMessage(leader->getEntityRowId(), "LEAGUE_INVITE", params);
leader->updateTarget();
}
示例2: joinProposal
//---------------------------------------------------
// joinProposal :
//---------------------------------------------------
void CTeamManager::joinProposal( CCharacter * leader, const CEntityId &targetId)
{
//check already done
nlassert(leader);
const NLMISC::CEntityId &leaderId = leader->getId();
if (targetId == leaderId )
{
nlwarning("<CTeamManager joinProposal> Player %s invited himself in his team, cancel", leaderId.toString().c_str() );
return;
}
// get targeted player
CCharacter *invitedPlayer = PlayerManager.getOnlineChar( targetId );
if ( invitedPlayer == NULL )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" );
return;
}
// god player are forbidden to team
if (leader->godMode() || invitedPlayer->godMode())
{
nlwarning("<CTeamManager joinProposal> Player %s invited %s, but at least on of them is god, forbidden",
leaderId.toString().c_str(),
targetId.toString().c_str());
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_GOD_FORBIDDEN" );
return;
}
TInviteRetCode code = isInvitableBy(invitedPlayer,leader);
if ( code == AlreadyInvited )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_ALREADY_INVITED" );
return;
}
else if ( code == AlreadyInTeam )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_TARGET_ALREADY_IN_TEAM" );
return;
}
else if ( code == CantInviteEnemy )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_CANT_INVITE_ENEMY" );
return;
}
else if ( code == CantInvite )
{
CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_CANT_INVITE" );
return;
}
/// the invitor must not be in the ignore list of the target
if(invitedPlayer->hasInIgnoreList(leaderId))
{
SM_STATIC_PARAMS_1( params1, STRING_MANAGER::player );
params1[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId) );
// Use the standard "player declines your offer". Don't use specific message because
// maybe not a good idea to inform a player that someone ignores him
CCharacter::sendDynamicSystemMessage( leaderId, "TEAM_DECLINE", params1 );
return;
}
//set the target's invitor
invitedPlayer->setTeamInvitor(leaderId);
//send the appropriate string to the client
SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);
params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias( leaderId ) );
uint32 strId = STRING_MANAGER::sendStringToClient(TheDataset.getDataSetRow(targetId),"TEAM_PROPOSAL", params);
//send the invitation msg to the target, with the id of the built string
CMessage msgout( "IMPULSION_ID" );
CBitMemStream bms;
CEntityId targetIdToSerial = targetId;
msgout.serial( targetIdToSerial );
if ( ! GenericMsgManager.pushNameToStream( "TEAM:INVITATION", bms) )
{
nlwarning("<CTeamManager joinProposal> Msg name TEAM:INVITATION not found");
return;
}
bms.serial(strId);
msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length());
sendMessageViaMirror( NLNET::TServiceId(targetId.getDynamicId()), msgout );
// TVectorParamCheck params;
// params.resize(1);
// inform the team leader
// params[0].Type = STRING_MANAGER::player;
params[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId ) );
PHRASE_UTILITIES::sendDynamicSystemMessage(leader->getEntityRowId(), "TEAM_INVITE", params);
leader->updateTarget();
} // joinProposal //