//-----------------------------------------------
//	chat
//
//-----------------------------------------------
void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam )
{
	// Truncate to 255 chars max (because of server restriction)
	ucstring	str= strIn.substr(0,255);

	// send str to IOS
	CBitMemStream bms;
	string msgType;

	if (isChatTeam)
	{
		if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool())
			msgType = "STRING:CHAT_TEAM";
		else
			return;		// don't display team chat message if there is no team chat
	}
	else
		msgType = "STRING:CHAT";

	if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
	{
		bms.serial( str );
		NetMngr.push( bms );
		//nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str());
	}
	else
	{
		nlwarning("<CClientChatManager::chat> unknown message name : %s", msgType.c_str());
	}

	if (UserEntity != NULL) UserEntity->setAFK(false);

} // chat //
//-----------------------------------------------
//	setChatMode
//
//-----------------------------------------------
void CClientChatManager::setChatMode(CChatGroup::TGroupType group, TChanID dynamicChannelId)
{
	uint8 mode = group;
	 // mode really changed ?
	if (mode == _ChatMode && dynamicChannelId==_ChatDynamicChannelId) return;

	// Chat team don't need swap mode
	if (group != CChatGroup::team)
	{
		CBitMemStream bms;
		string msgType = "STRING:CHAT_MODE";
		if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
		{
			bms.serial( mode );
			bms.serial( dynamicChannelId );
			NetMngr.push( bms );
			//nlinfo("impulseCallBack : %s %d sent", msgType.c_str(), mode);
		}
		else
		{
			nlwarning("<CClientChatManager::setChatMode> unknown message name : STRING:CHAT_MODE");
		}
	}

	// update cache
	_ChatMode = mode;
	_ChatDynamicChannelId = dynamicChannelId;

	if (UserEntity != NULL) UserEntity->setAFK(false);

} // filter //
Exemple #3
0
void CTeam::rewardSharing(CRewardSharing * reward)
{
	// if there is a reward add the new it
	if ( _RewardSharing )
	{
		_RewardSharing->addReward(reward,this);
	}
	// otherwise, create a new one
	else
	{
		_RewardSharing = reward;
		for (list<CEntityId>::const_iterator it = _TeamMembers.begin() ; it != _TeamMembers.end() ; ++it)
		{
			CCharacter * user = PlayerManager.getOnlineChar( (*it) );
			if (user )
			{
				CMessage msgout ("IMPULSION_ID");
				msgout.serial ((CEntityId&)(*it));
				CBitMemStream bms;
				
				if (!GenericMsgManager.pushNameToStream ("TEAM:SHARE_OPEN", bms))
					nlstopex (("Missing TEAM:SHARE_OPEN in msg.xml"));
				msgout.serialBufferWithSize ((uint8*)bms.buffer(), bms.length());
				sendMessageViaMirror ( NLNET::TServiceId((*it).getDynamicId()), msgout);
			}
		}
		_RewardSharing->resetCandidates(this);
	}
}// CTeam::rewardSharing
//-----------------------------------------------
//	tell
//
//-----------------------------------------------
void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn )
{
	// Truncate to 255 chars max (because of server restriction)
	string		receiver= receiverIn.substr(0,255);
	ucstring	str= strIn.substr(0,255);

	// *** send str
	CBitMemStream bms;
	string msgType = "STRING:TELL";
	if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
	{
		bms.serial( receiver );
		bms.serial( str );
		NetMngr.push( bms );
		//nlinfo("impulseCallBack : %s %s %s sent", msgType.c_str(), receiver.c_str(), str.toString().c_str());
	}
	else
	{
		nlwarning("<CClientChatManager::tell> unknown message name : STRING:TELL");
	}


	// *** manage list of last telled people
	// remove the telled people from list (if present)
	std::list<ucstring>::iterator it = _TellPeople.begin();
	while(it != _TellPeople.end())
	{
		if (*it == ucstring(receiver))
		{
			it = _TellPeople.erase(it);
			nlassert(_NumTellPeople != 0);
			-- _NumTellPeople;
		}
		else
		{
			++it;
		}
	}

	// readd to back of the list (most recent telled people)
	_TellPeople.push_back(receiver);
	++ _NumTellPeople;

	// if too much people, remove the older one
	if (_NumTellPeople > _MaxNumTellPeople)
	{
		-- _NumTellPeople;
		_TellPeople.pop_front();
	}

	// tell => the user is no more AFK.
	if (UserEntity != NULL) UserEntity->setAFK(false);

} // tell //
//-----------------------------------------------
//	filter
//
//-----------------------------------------------
void CClientChatManager::filter( uint8 filter )
{
	CBitMemStream bms;
	string msgType = "STRING:FILTER";
	if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
	{
		bms.serial( filter );
		NetMngr.push( bms );
		//nlinfo("impulseCallBack : %s %d sent", msgType.c_str(), filter);
	}
	else
	{
		nlwarning("<CClientChatManager::filter> unknown message name : STRING:FILTER");
	}

	if (UserEntity != NULL) UserEntity->setAFK(false);

} // filter //
Exemple #6
0
//---------------------------------------------------
// CTeam removeCharacter
//---------------------------------------------------
void CTeam::removeCharacter( CCharacter * player )
{
	// check already done
	nlassert(player);

	const CEntityId & charId = player->getId();
	uint16 teamId = player->getTeamId();

	// check if the character is in the team and remove him
	uint formerPos = 0;
	bool found = false;
	for ( std::list<NLMISC::CEntityId>::iterator it = _TeamMembers.begin(); it != _TeamMembers.end(); ++it )
	{
		if ( charId  == *it )
		{
			clearPlayerTeamDB(charId);
			_TeamMembers.erase(it);
			--_NbMembers;
			found = true;
			break;
		}
		formerPos++;
	}
	if ( !found )
	{
		nlwarning("<CTeam removeCharacter> charId %s not found in the team", charId.toString().c_str() );
		return;
	}
	if ( _RewardSharing )
	{
		CMessage msgout ("IMPULSION_ID");
		msgout.serial ((CEntityId&)(player->getId()));
		CBitMemStream bms;
		if (!GenericMsgManager.pushNameToStream ("TEAM:SHARE_CLOSE", bms))
			nlstopex (("Missing TEAM:SHARE_CLOSE in msg.xml"));
		msgout.serialBufferWithSize ((uint8*)bms.buffer(), bms.length());
		sendMessageViaMirror (NLNET::TServiceId(player->getId().getDynamicId()), msgout);
		_RewardSharing->resetCandidates(this);
	}

	///\todo give him a player team Id
	player->setTeamId( CTEAM::InvalidTeamId );
	player->updateTargetingChars();

	// tell progression system this player has been removed from his team
	PROGRESSIONPVE::CCharacterProgressionPVE::getInstance()->playerLeavesTeam(charId, _TeamId);
	PROGRESSIONPVP::CCharacterProgressionPVP::getInstance()->playerLeavesTeam(player, _TeamId);

	if ( player->getPVPInterface().isValid() )
		player->getPVPInterface().leavePVP( IPVP::QuitTeam );

	// check if the team must be removed
	if ( _NbMembers == 1 )
	{
		const uint size = (uint)_Missions.size();
		uint count = 0;
		while ( !_Missions.empty() && count < size )
		{
			_Missions[0]->onFailure(true);
			count++;
		}
		
		// send a message to the last team member
		PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(_TeamMembers.front()), "TEAM_DISOLVED");
		
		// clear the player DB
		clearPlayerTeamDB( *_TeamMembers.begin() );
		CCharacter * lastPlayer = PlayerManager.getOnlineChar( *_TeamMembers.begin() );
		if ( lastPlayer )
			lastPlayer->setTeamId( CTEAM::InvalidTeamId );
		else
		{
			nlwarning("<CTeam removeCharacter> charId %s not found in the team", (*_TeamMembers.begin()).toString().c_str() );
			return;
		}

		// remove the team chat group
		TGroupId idGroupe = CHAT_GROUPS_IDS::getTeamChatGroupId(_TeamId);
		CMessage msgRemoveGroup("REMOVE_GROUP");
		msgRemoveGroup.serial( idGroupe );
		sendMessageViaMirror( "IOS", msgRemoveGroup );
	
		// release the team
		release();
		//remove the team from the manager
		TeamManager.removeTeam(teamId);

		// let the last player continue his escort mission (with a fake team) if he has one
		CMissionManager::getInstance()->updateEscortTeam( lastPlayer->getId() );

		return;
	}

	// if that was the leader, get another one
	else if ( _LeaderId == charId )
	{
		_LeaderId = _SuccessorId;
		_SuccessorId = CEntityId::Unknown;
		for (list<CEntityId>::const_iterator it = _TeamMembers.begin(); it != _TeamMembers.end(); ++it)
		{
			if ( (*it) != _LeaderId )
			{
				_SuccessorId = (*it );
				break;
			}
		}


		// switch dyn chat speaker
		CMissionManager::getInstance()->switchDynChatSpeaker(player,_LeaderId);

		// inform the new leader
		SM_STATIC_PARAMS_1(params1, STRING_MANAGER::player);		
		params1[0].setEId( charId );
		PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(_LeaderId), "TEAM_YOU_NEW_LEADER", params1);

		// inform the group 
		SM_STATIC_PARAMS_2(params, STRING_MANAGER::player, STRING_MANAGER::player);		
		params[0].setEId( charId );
		params[1].setEId( _LeaderId );

		set<CEntityId> exclude;
		exclude.insert( _LeaderId );
		exclude.insert( charId );
		sendDynamicMessageToMembers("TEAM_NEW_LEADER", params, exclude);

		// update leader DB
		CCharacter *leader = PlayerManager.getOnlineChar( _LeaderId );
		if (leader)
		{
//			leader->_PropertyDatabase.setProp( "GROUP:LEADER_INDEX", -1 );
			CBankAccessor_PLR::getGROUP().setLEADER_INDEX(leader->_PropertyDatabase, 0xf);
//			leader->_PropertyDatabase.setProp( "GROUP:SUCCESSOR_INDEX", 0 );
			CBankAccessor_PLR::getGROUP().setSUCCESSOR_INDEX(leader->_PropertyDatabase, 0);
		}
		else
			nlwarning("<CTeam removeCharacter> invalid new leader %s", _LeaderId.toString().c_str() );
	}
	// if that was the successor, inform the new one
/*	else if ( formerPos == 1 && _NbMembers > 2)
	{
		list<CEntityId>::iterator itTmp = _TeamMembers.begin();
		++itTmp;
		const CEntityId & successorId = *(itTmp);
		CCharacter *successor = PlayerManager.getOnlineChar( successorId );
		if (successor)
		{
			successor->_PropertyDatabase.setProp( "GROUP:SUCCESSOR_INDEX", -1 );
		}
		else
			nlwarning("<CTeam removeCharacter> invalid new successor %s", successorId.toString().c_str() );

	}
*/
	else if ( _SuccessorId == charId )
	{
		for (list<CEntityId>::const_iterator it = _TeamMembers.begin(); it != _TeamMembers.end(); ++it)
		{
			if ( (*it) != _LeaderId )
			{
				_SuccessorId = (*it );
				CCharacter *successor = PlayerManager.getOnlineChar( _SuccessorId );
				if (successor)
				{
//					successor->_PropertyDatabase.setProp( "GROUP:SUCCESSOR_INDEX", -1 );
					CBankAccessor_PLR::getGROUP().setSUCCESSOR_INDEX(successor->_PropertyDatabase, 0xf);
				}
				break;
			}
		}
	}

	for (std::list<NLMISC::CEntityId>::iterator it = _TeamMembers.begin() ; it != _TeamMembers.end() ; ++it)
	{
		uint8 hp, sap, stamina;
		uint32 nameId;
		uint pos = 0;
//		char buffer[256];

		CCharacter * ch1 = PlayerManager.getOnlineChar( (*it) );
		///\todo log if nothing
		if (ch1)
		{
			for (std::list<NLMISC::CEntityId>::iterator it2 = _TeamMembers.begin() ; it2 != _TeamMembers.end() ; ++it2)
			{
				if ( (*it) == (*it2) )
					continue;	

				CBankAccessor_PLR::TGROUP::TArray &groupItem = CBankAccessor_PLR::getGROUP().getArray(pos);

				CCharacter * ch2 = PlayerManager.getOnlineChar( (*it2) );	
				if (ch2 != NULL)
				{
					// update new char for old char
					if ( ch2->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max != 0)
						hp = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( ch2->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Current ) ) / ( ch2->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max ) );
					else
						hp = 0;
					if ( ch2->getPhysScores()._PhysicalScores[ SCORES::sap ].Max != 0)
						sap = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( ch2->getPhysScores()._PhysicalScores[ SCORES::sap ].Current ) ) / ( ch2->getPhysScores()._PhysicalScores[ SCORES::sap ].Max ) );
					else
						sap = 0;
					if ( ch2->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max != 0)
						stamina = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( ch2->getPhysScores()._PhysicalScores[ SCORES::stamina ].Current ) ) / ( ch2->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max ) );
					else
						stamina = 0;
					
					CMirrorPropValueRO<uint32> nameIndexValue( TheDataset, ch2->getId(), "NameIndex" );
					nameId = nameIndexValue();
									
//					sprintf(buffer, "GROUP:%d:HP",pos );
//					ch1->_PropertyDatabase.setProp( buffer, hp );
					groupItem.setHP(ch1->_PropertyDatabase, hp);
					
//					sprintf(buffer, "GROUP:%d:SAP",pos );
//					ch1->_PropertyDatabase.setProp( buffer, sap );
					groupItem.setSAP(ch1->_PropertyDatabase, sap);
					
//					sprintf(buffer, "GROUP:%d:STA",pos );
//					ch1->_PropertyDatabase.setProp( buffer, stamina );
					groupItem.setSTA(ch1->_PropertyDatabase, stamina);
					
//					sprintf(buffer, "GROUP:%d:NAME",pos );
//					ch1->_PropertyDatabase.setProp( buffer, nameId );
					groupItem.setNAME(ch1->_PropertyDatabase, nameId);

//					sprintf(buffer, "GROUP:%d:UID",pos );
//					ch1->_PropertyDatabase.setProp( buffer, ch2->getEntityRowId().getCompressedIndex() );
					groupItem.setUID(ch1->_PropertyDatabase, ch2->getEntityRowId().getCompressedIndex());
					
//					sprintf(buffer, "GROUP:%d:PRESENT",pos );
//					ch1->_PropertyDatabase.setProp( buffer, (uint8)1 );
					groupItem.setPRESENT(ch1->_PropertyDatabase, true);
				}
				pos++;
			}

			CBankAccessor_PLR::TGROUP::TArray &groupItem = CBankAccessor_PLR::getGROUP().getArray(pos);

//			sprintf(buffer, "GROUP:%d:PRESENT",pos );
//			ch1->_PropertyDatabase.setProp( buffer, (uint8)0 );
			groupItem.setHP(ch1->_PropertyDatabase, 0);
//			sprintf(buffer, "GROUP:%d:NAME",pos );
//			ch1->_PropertyDatabase.setProp( buffer, (uint32)0 );
			groupItem.setNAME(ch1->_PropertyDatabase, 0);
//			sprintf(buffer, "GROUP:%d:UID",pos );
//			ch1->_PropertyDatabase.setProp( buffer, (uint32)CLFECOMMON::INVALID_CLIENT_DATASET_INDEX );
			groupItem.setUID(ch1->_PropertyDatabase, CLFECOMMON::INVALID_CLIENT_DATASET_INDEX);
		}
	}

	if ( _RewardSharing )
		_RewardSharing->resetCandidates(this);

	// update positions
	updateMembersPositions();

	// remove character from chat group
	TGroupId idGroupe = CHAT_GROUPS_IDS::getTeamChatGroupId(_TeamId);
	CMessage msgRemoveGroup("REMOVE_FROM_GROUP");
	msgRemoveGroup.serial( idGroupe );
	msgRemoveGroup.serial( const_cast<CEntityId&> ( charId ) );
	sendMessageViaMirror( "IOS", msgRemoveGroup );

}// CTeam removeCharacter
Exemple #7
0
//---------------------------------------------------
// CTeam addCharacter
//---------------------------------------------------
void CTeam::addCharacter(CCharacter *newCharacter)
{
	// check already done
	nlassert(newCharacter);

	// init new character DB
//	newCharacter->_PropertyDatabase.setProp( "USER:TEAM_MEMBER", 1 );
	CBankAccessor_PLR::getUSER().setTEAM_MEMBER(newCharacter->_PropertyDatabase, true);
//	newCharacter->_PropertyDatabase.setProp( "USER:TEAM_LEADER", 0 );
	CBankAccessor_PLR::getUSER().setTEAM_LEADER(newCharacter->_PropertyDatabase, false);
//	newCharacter->_PropertyDatabase.setProp( "GROUP:LEADER_INDEX", 0 );
	CBankAccessor_PLR::getGROUP().setLEADER_INDEX(newCharacter->_PropertyDatabase, 0);

	if ( _TeamMembers.size() == 1 )
	{
		_SuccessorId = newCharacter->getId();
//		newCharacter->_PropertyDatabase.setProp( "GROUP:SUCCESSOR_INDEX", -1  );
		CBankAccessor_PLR::getGROUP().setSUCCESSOR_INDEX(newCharacter->_PropertyDatabase, 0xf);
	}
	else
	{
//		newCharacter->_PropertyDatabase.setProp( "GROUP:SUCCESSOR_INDEX", 1  );
		CBankAccessor_PLR::getGROUP().setSUCCESSOR_INDEX(newCharacter->_PropertyDatabase, 1);
	}
	
	// update all member's DB
//	char buffer[256];
	uint position = (uint)_TeamMembers.size()-1;
	uint i =0;
	for (std::list<CEntityId>::const_iterator it = _TeamMembers.begin() ; it != _TeamMembers.end() ; ++it)
	{
		uint8 hp, sap, stamina;
		uint32 nameId;
		CCharacter* character = PlayerManager.getOnlineChar( (*it) );
		if (character != NULL)
		{
			// update the current character team slot
///\todo: can be done outside the loop
			if ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max != 0)
				hp = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Current ) ) / ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max ) );
			else
				hp = 0;

			if ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::sap ].Max != 0)
				sap = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::sap ].Current ) ) / ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::sap ].Max ) );
			else
				sap = 0;

			if ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max != 0)
				stamina = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::stamina ].Current ) ) / ( newCharacter->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max ) );
			else
				stamina = 0;

			CMirrorPropValueRO<uint32> nameIndexValue1( TheDataset, newCharacter->getId(), "NameIndex" );
			nameId = nameIndexValue1();

			CBankAccessor_PLR::TGROUP::TArray &arrayItem = CBankAccessor_PLR::getGROUP().getArray(position);
//			sprintf(buffer, "GROUP:%d:HP",position );
//			character->_PropertyDatabase.setProp( buffer, hp );
			arrayItem.setHP(character->_PropertyDatabase, hp);

//			sprintf(buffer, "GROUP:%d:SAP",position );
//			character->_PropertyDatabase.setProp( buffer, sap );
			arrayItem.setSAP(character->_PropertyDatabase, sap);

//			sprintf(buffer, "GROUP:%d:STA",position );
//			character->_PropertyDatabase.setProp( buffer, stamina );
			arrayItem.setSTA(character->_PropertyDatabase, stamina);

//			sprintf(buffer, "GROUP:%d:NAME",position );
//			character->_PropertyDatabase.setProp( buffer, nameId );
			arrayItem.setNAME(character->_PropertyDatabase, nameId);

//			sprintf(buffer, "GROUP:%d:UID",position );
//			character->_PropertyDatabase.setProp( buffer, newCharacter->getEntityRowId().getCompressedIndex() );
			arrayItem.setUID(character->_PropertyDatabase, newCharacter->getEntityRowId().getCompressedIndex());

//			sprintf(buffer, "GROUP:%d:PRESENT",position );
//			character->_PropertyDatabase.setProp( buffer, (uint8)1 );
			arrayItem.setPRESENT(character->_PropertyDatabase, true);

			// update the new character team slot corresponding to character
			if ( character->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max != 0)
				hp = (uint8)  ( ( float(TeamMembersStatusMaxValue) * ( character->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Current ) ) / ( character->getPhysScores()._PhysicalScores[ SCORES::hit_points ].Max ) );
			else
				hp = 0;
				
			if ( character->getPhysScores()._PhysicalScores[ SCORES::sap ].Max != 0)
				sap = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( character->getPhysScores()._PhysicalScores[ SCORES::sap ].Current ) ) / ( character->getPhysScores()._PhysicalScores[ SCORES::sap ].Max ) );
			else
				sap = 0;

			if ( character->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max != 0)
				stamina = (uint8) ( ( float(TeamMembersStatusMaxValue) * ( character->getPhysScores()._PhysicalScores[ SCORES::stamina ].Current ) ) / ( character->getPhysScores()._PhysicalScores[ SCORES::stamina ].Max ) );
			else
				stamina = 0;

			CMirrorPropValueRO<uint32> nameIndexValue2( TheDataset, character->getId(), "NameIndex" );
			nameId = nameIndexValue2();

			CBankAccessor_PLR::TGROUP::TArray &newArrayItem = CBankAccessor_PLR::getGROUP().getArray(i);
//			sprintf(buffer, "GROUP:%d:HP",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, hp );
			newArrayItem.setHP(newCharacter->_PropertyDatabase, hp);
				
//			sprintf(buffer, "GROUP:%d:SAP",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, sap );
			newArrayItem.setSAP(newCharacter->_PropertyDatabase, sap);

//			sprintf(buffer, "GROUP:%d:STA",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, stamina );
			newArrayItem.setSTA(newCharacter->_PropertyDatabase, stamina);

//			sprintf(buffer, "GROUP:%d:NAME",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, nameId );
			newArrayItem.setNAME(newCharacter->_PropertyDatabase, nameId);

//			sprintf(buffer, "GROUP:%d:UID",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, character->getEntityRowId().getCompressedIndex() );
			newArrayItem.setUID(newCharacter->_PropertyDatabase, character->getEntityRowId().getCompressedIndex());

//			sprintf(buffer, "GROUP:%d:PRESENT",i );
//			newCharacter->_PropertyDatabase.setProp( buffer, (uint8)1 );
			newArrayItem.setPRESENT(newCharacter->_PropertyDatabase, true);
		}
		else
			nlwarning("<CTeam::addCharacter> Unknown character %s", (*it).toString().c_str() );
		++i;
	}


	// insert new member
	_TeamMembers.push_back( newCharacter->getId() );
	++_NbMembers;
	
	// set the character team
	newCharacter->setTeamId(_TeamId);

	// Add character to chat group
	TGroupId idGroupe = CHAT_GROUPS_IDS::getTeamChatGroupId(_TeamId);
	CMessage msgout("ADD_TO_GROUP");
	msgout.serial( idGroupe );
	msgout.serial( const_cast<CEntityId&> (newCharacter->getId()) );
	sendMessageViaMirror( "IOS", msgout );
	
	// send messages to members
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);

	// to new member
	//CCharacter::sendMessageToClient(newCharacter->getId(),"OPS_JOIN_TEAM_E",_LeaderId);
	params[0].setEId(  _LeaderId );
	PHRASE_UTILITIES::sendDynamicSystemMessage(newCharacter->getEntityRowId(), "TEAM_YOU_JOIN", params);
	
	params[0].setEIdAIAlias( newCharacter->getId(), CAIAliasTranslator::getInstance()->getAIAlias( newCharacter->getId()) );

	set<CEntityId> exclude;
	exclude.insert( newCharacter->getId() );
	this->sendDynamicMessageToMembers("TEAM_ACCEPT",params,exclude);

	// update the reward share if needed
	if ( _RewardSharing )
	{
		CMessage msgout ("IMPULSION_ID");
		msgout.serial ((CEntityId&)(newCharacter->getId()));
		CBitMemStream bms;
		if (!GenericMsgManager.pushNameToStream ("TEAM:SHARE_OPEN", bms))
			nlstopex (("Missing TEAM:SHARE_OPEN in msg.xml"));
		msgout.serialBufferWithSize ((uint8*)bms.buffer(), bms.length());
		sendMessageViaMirror ( NLNET::TServiceId(newCharacter->getId().getDynamicId()), msgout);
		_RewardSharing->resetCandidates(this);
	}

	// update positions
	updateMembersPositions(true);

	/*TGroupId groupId = TGroupId idGroupe = CHAT_GROUPS_IDS::getTeamChatGroupId(_TeamId);
	string msgName = "OPS_JOIN_TEAM_ACCEPT_E";
	CMessage msggroup("STATIC_STRING");
	msggroup.serial( groupId );
	
	msggroup.serialCont( exclude);
	msggroup.serial( msgName );
	msggroup.serial( const_cast<CEntityId&>(newCharacter->getId()) );
	sendMessageViaMirror( "IOS", msggroup );
*/

	// tell progression system this player has joigned this team
	PROGRESSIONPVE::CCharacterProgressionPVE::getInstance()->playerJoinsTeam(newCharacter->getId(), _TeamId);
	PROGRESSIONPVP::CCharacterProgressionPVP::getInstance()->playerJoinsTeam(newCharacter, _TeamId);

	newCharacter->updateTargetingChars();
}// CTeam addCharacter
Exemple #8
0
//---------------------------------------------------
// 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();	
}
Exemple #9
0
//---------------------------------------------------
// 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 //