コード例 #1
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// joinDecline :
//---------------------------------------------------
void CTeamManager::joinDecline( const NLMISC::CEntityId &charId)
{
	CCharacter * invited = PlayerManager.getOnlineChar(charId);
	if ( invited == NULL )
	{
		nlwarning("<CTeamManager joinDecline>Invalid char %s",charId.toString().c_str());
		return;
	}
	invited->setAfkState(false);
	if ( invited->getTeamInvitor() == CEntityId::Unknown )
	{
		nlwarning("<CTeamManager joinDecline>character %s has an Invalid invitor",charId.toString().c_str());
		return;
	}

	//inform both players
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);	
	params[0].setEIdAIAlias( charId, CAIAliasTranslator::getInstance()->getAIAlias( charId) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(invited->getTeamInvitor()), "TEAM_DECLINE", params);
	
	params[0].setEIdAIAlias( invited->getTeamInvitor(), CAIAliasTranslator::getInstance()->getAIAlias( invited->getTeamInvitor() ) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(invited->getEntityRowId(), "TEAM_YOU_DECLINE", params);

	//cancel the proposal
	invited->setTeamInvitor( CEntityId::Unknown );
} // joinDecline //
コード例 #2
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// 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();	
}
コード例 #3
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// removeCharacter :
//---------------------------------------------------
void CTeamManager::removeCharacter( const CEntityId &charId )
{
	CCharacter * player = PlayerManager.getOnlineChar( charId );
	if ( player == NULL )
	{
		nlwarning("<CTeamManager removeCharacter> Player %s is invalid", charId.toString().c_str() );
		return;
	}
	player->setAfkState(false);
	CTeam * team = getRealTeam( player->getTeamId() );	
	if ( team == NULL )
	{
		nlwarning("<CTeamManager removeCharacter> Player %s has an invalid team id %d", charId.toString().c_str(), player->getTeamId() );
		return;
	}

	uint16 nbMembers = team->getTeamSize();
	// send message to former member
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);
	if (nbMembers > 2)
	{
		if (charId != team->getLeader())
		{
			params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) );
			PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE", params);
		}
		else
		{
			const list<CEntityId> &members = team->getTeamMembers();
			
			CEntityId eId(team->getSuccessor());
			params[0].setEIdAIAlias( eId, CAIAliasTranslator::getInstance()->getAIAlias(eId) );
			PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_LEADER", params);
		}
	}
	else if(nbMembers==2)
	{
		params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) );
		PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_DISOLVE", params);
	}

	// send message to all other team members
	params[0].setEIdAIAlias( charId, CAIAliasTranslator::getInstance()->getAIAlias(charId) );
	set<CEntityId> exclude;
	exclude.insert( charId );
	team->sendDynamicMessageToMembers("TEAM_LEAVE", params, exclude);

	// remove the player from his team
	team->removeCharacter( player );

	/*
	TGroupId groupId =CHAT_GROUPS_IDS::getTeamChatGroupId(player->getTeamId());
	string msgName = "OPS_LEAVE_TEAM_E";
	CMessage msggroup("STATIC_STRING");
	msggroup.serial( groupId );
	std::set<CEntityId> exclude;
	exclude.insert( charId );
	msggroup.serialCont( exclude);
	msggroup.serial( msgName );
	msggroup.serial( (CEntityId&) charId );
	sendMessageViaMirror( "IOS", msggroup );
	*/
} // removeCharacter //
コード例 #4
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// kickCharacter :
//---------------------------------------------------
void CTeamManager::kickCharacter( CCharacter * leader, uint8 memberIndex )
{
	// check must be done before
	nlassert(leader);
	const NLMISC::CEntityId & leaderId = leader->getId();
	
	// get the leader's team
	CTeam * team = getRealTeam( leader->getTeamId() );	
	if ( team == NULL )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s has an invalid team id %d", leaderId.toString().c_str(), leader->getTeamId() );
		return;
	}
	// only leaders can kick
	if ( leaderId != team->getLeader() )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s tries kicking but is not the leader", leaderId.toString().c_str() );
		return;
	}

	// increment the target index as the leader is not in its team list
	memberIndex++;
	const std::list< NLMISC::CEntityId >  & members = team->getTeamMembers();
	std::list< NLMISC::CEntityId >::const_iterator it = members.begin();
	uint i = 0;
	for (; i < memberIndex; i++ )
	{
		if ( it == members.end() )
		{
			nlwarning("<CTeamManager kickCharacter> Player %s kicks teammate %d but there are %d members", leaderId.toString().c_str(), memberIndex,i+1 );
			return;
		}
		++it;
	}
	if ( it == members.end() )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s kicks teammate %d but there are %d members", leaderId.toString().c_str(), memberIndex,i+1 );
		return;
	}

	CCharacter * kickedChar = PlayerManager.getOnlineChar( (*it) );
	if ( kickedChar == NULL )
	{
		nlwarning("<CTeamManager kickCharacter> kicked Player %d is invalid", memberIndex );
		return;
	}


	// inform the kicked player
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);	
	params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias( leaderId ) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(*it), "TEAM_KICKED_YOU", params);
	
	// inform other team members
	params[0].setEIdAIAlias( *it, CAIAliasTranslator::getInstance()->getAIAlias( *it ) );
	set<CEntityId> exclude;
	exclude.insert(*it);
	team->sendDynamicMessageToMembers("TEAM_KICKED", params, exclude);

	//  remove the kicked player from team	
	team->removeCharacter( kickedChar );

	leader->updateTarget();
	/*
	TGroupId groupId = CEntityId(RYZOMID::chatGroup, leader->getTeamId() + 1);
	string msgName = "OPS_KICKED_TEAM_E";
	CMessage msggroup("STATIC_STRING");
	msggroup.serial( groupId );
	std::set<CEntityId> exclude;
	exclude.insert(*it);
	msggroup.serialCont( exclude);
	msggroup.serial( msgName );
	msggroup.serial( (CEntityId&)(*it) );
	sendMessageViaMirror( "IOS", msggroup );
	*/

	CMissionManager::getInstance()->updateEscortTeam( kickedChar->getId() );
	
}// kickCharacter
コード例 #5
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// joinAccept :
//---------------------------------------------------
void CTeamManager::joinAccept( const NLMISC::CEntityId &charId)
{
	// get the invited char
	CCharacter * invited = PlayerManager.getOnlineChar(charId);
	if ( invited == NULL )
	{
		nlwarning("<CTeamManager joinAccept>Invalid char %s",charId.toString().c_str());
		return;
	}

	// get the invitor id
	const NLMISC::CEntityId & invitorId = invited->getTeamInvitor();

	if ( invitorId == CEntityId::Unknown )
	{
		nlwarning("<CTeamManager joinAccept>character %s has an Invalid invitor",charId.toString().c_str());
		return;
	}
	//get the invitor char
	CCharacter * invitor = PlayerManager.getOnlineChar(invitorId);
	if ( invitor == NULL  )
	{
		nlwarning("<CTeamManager joinAccept>character %s, Invalid invitor id %s",charId.toString().c_str(),invitorId.toString().c_str());
		invited->setTeamInvitor( CEntityId::Unknown );
		return;
	}
	invitor->setAfkState(false);
	//cancel the proposal
	invited->setTeamInvitor( CEntityId::Unknown );

	CTeam *team;
	//if the invited player had a fake team, remove it
	team = getTeam( invited->getTeamId() );
	
	if ( team )
	{
		// if the team is not fake, there is a problem...
		if ( !team->isFake() )
		{
			nlwarning("<CTeamManager joinAccept>character %s, invitor id %s, the invited player is in a valid team. ",charId.toString().c_str(),invitor->getId().toString().c_str() );
			return ;
		}
		else
		{
			team->release();
			removeTeam( invited->getTeamId() );
		}
	}

	team = getTeam(invitor->getTeamId());
	//  create the team if it does not exist
	if ( !team )
	{
		//check for reallocation
		if ( _FirstFreeTeamId >= (uint16)_Teams.size() )
		{
			_Teams.resize( _TeamAllocStep + _FirstFreeTeamId );
			for (uint i = _FirstFreeTeamId; i < _Teams.size(); i++)
			{
				_Teams[i].setNextFreeId( i + 1 );
			}
		}
		//get a pointer on the new team
		team = &_Teams[_FirstFreeTeamId];
		// set the invitor team id
		invitor->setTeamId(_FirstFreeTeamId);
		//init the team
		team->init( invitor,_FirstFreeTeamId );
		// update alloc data
		_FirstFreeTeamId = team->getNextFreeId();
	}
	// If the team is fake transform it in an unfake team
	else if ( team->isFake() )
	{
		// init the team
		team->init( invitor,invitor->getTeamId() );
	}

	// check the team size
	if ( team->getTeamSize() < CTEAM::TeamMaxNbMembers )
	{
		//add the new character to the team
		team->addCharacter(invited);
	}
	else
	{
		CCharacter::sendDynamicSystemMessage(charId,"OPS_TEAM_MAX_SIZE_REACHED");
//		CCharacter::sendMessageToClient(charId,"OPS_TEAM_MAX_SIZE_REACHED");
	}

	CMissionManager::getInstance()->updateEscortTeam( charId );
} // joinAccept //
コード例 #6
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// 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 //
コード例 #7
0
ファイル: team_manager.cpp プロジェクト: Kiddinglife/ryzom
//---------------------------------------------------
// joinLeagueAccept :
//---------------------------------------------------
void CTeamManager::joinLeagueAccept( const NLMISC::CEntityId &charId)
{
	// get the invited char
	CCharacter * invited = PlayerManager.getOnlineChar(charId);
	if ( invited == NULL )
	{
		nlwarning("<CTeamManager joinLeagueAccept>Invalid char %s",charId.toString().c_str());
		return;
	}

	// get the invitor id
	const NLMISC::CEntityId & invitorId = invited->getLeagueInvitor();

	if ( invitorId == CEntityId::Unknown )
	{
		nlwarning("<CTeamManager joinLeagueAccept>character %s has an Invalid invitor",charId.toString().c_str());
		return;
	}
	//get the invitor char
	CCharacter * invitor = PlayerManager.getOnlineChar(invitorId);
	if ( invitor == NULL  )
	{
		nlwarning("<CTeamManager joinLeagueAccept>character %s, Invalid invitor id %s",charId.toString().c_str(),invitorId.toString().c_str());
		invited->setLeagueInvitor( CEntityId::Unknown );
		return;
	}
	invitor->setAfkState(false);
	
	//cancel the proposal
	invited->setLeagueInvitor( CEntityId::Unknown );

	CTeam *teamInvitor;
	CTeam *teamInvited;
	//if the invited player had a fake team, remove it
	teamInvited = getRealTeam(invited->getTeamId());
	teamInvitor = getRealTeam(invitor->getTeamId());
	
	if ( !teamInvitor )
	{
		nlwarning("<CTeamManager joinLeagueAccept>character %s, invitor id %s, the invited or invitor player is not in a valid team. ",charId.toString().c_str(),invitor->getId().toString().c_str() );
		return;
	}
	
	
	// check that the invitor team have league else create them
	if (teamInvitor->getLeagueId() == DYN_CHAT_INVALID_CHAN )
	{
		teamInvitor->setLeague("League");
	}
	
	if (teamInvited) {
		const string playerName = CEntityIdTranslator::getInstance()->getByEntity(invited->getId()).toString();
		CPVPManager2::getInstance()->broadcastMessage(teamInvitor->getLeagueId(), string("<TEAM>"), "<-- "+playerName);
		teamInvited->setLeagueId(teamInvitor->getLeagueId());
		teamInvited->updateLeague();
	} else {
		const string playerName = CEntityIdTranslator::getInstance()->getByEntity(invited->getId()).toString();
		CPVPManager2::getInstance()->broadcastMessage(teamInvitor->getLeagueId(), string("<PLAYER>"), "<-- "+playerName);
		invited->setLeagueId(teamInvitor->getLeagueId(), true);
	}
	
} // joinLeagueAccept //