//----------------------------------------------------------------------------
void cbClientGroupAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint8 index;
    msgin.serial(userId,index);

    if (!checkPlayer(userId, "cbClientGroupAbandonMission")) return;
    CCharacter * user = PlayerManager.getChar( userId );

    user->setAfkState(false);
    CTeam * team = TeamManager.getRealTeam( user->getTeamId() );
    if ( !team )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid team", userId.toString().c_str());
        return;
    }
    if ( team->getLeader() != userId )
    {
        CCharacter::sendDynamicSystemMessage( user->getEntityRowId(), "REQ_LEADER_TO_ABANDON_MISSION" );
        return;
    }

    if ( index >=  team->getMissions().size() )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid group mission %u ( count %u )",
               userId.toString().c_str(), index, team->getMissions().size());
        return;
    }


    CMissionTeam* mission = team->getMissions()[index];
    nlassert(mission);

    if ( mission->getFinished() == false )
    {
        CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
        if ( !templ )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : invalid group mission alias %u",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        if ( templ->Tags.NonAbandonnable )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : group mission alias %u is not abandonnable but user tries to abandon it",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        set<CEntityId> excluded;
        excluded.insert( userId );

        team->sendDynamicMessageToMembers( "ABANDON_GROUP_MISSION",TVectorParamCheck(), excluded );
    }
    team->removeMission( index, mr_abandon );
}
//----------------------------------------------------------------------------
void cbClientMissionGroupWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    msgin.serial(userId);

    uint8 missionGroupIndex;
    msgin.serial(missionGroupIndex);

    CCharacter * user = PlayerManager.getChar(userId);
    if ( !user || !user->getEnterFlag() )
        return;

    user->setAfkState(false);

    CTeam * team = TeamManager.getRealTeam( user->getTeamId() );
    if ( !team )
    {
        MISLOG("user:%s cbClientMissionGroupWake : Invalid team", userId.toString().c_str());
        return;
    }
    if ( team->getLeader() != userId )
    {
        return;
    }

    if ( missionGroupIndex >=  team->getMissions().size() )
    {
        MISLOG("user:%s cbClientMissionGroupWake : Invalid group mission %u ( count %u )",
               userId.toString().c_str(), missionGroupIndex, team->getMissions().size());
        return;
    }


    CMissionTeam* mission = team->getMissions()[missionGroupIndex];
    nlassert(mission);

    if ( mission->getFinished() == false )
    {
        CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
        if ( !templ )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : invalid group mission alias %u",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }

        CMissionQueueManager::getInstance()->playerWakesUp (userId, templ->Alias );
    }
}
//----------------------------------------------------------------------------
bool checkPlayer(const CEntityId &userId, const string &sFuncName)
{
    CCharacter * user = PlayerManager.getChar( userId );
    if ( !user )
    {
        MISLOG("user:%s %s : Invalid char", userId.toString().c_str(), sFuncName.c_str());
        return false;
    }
    // check character is ready
    if (!user->getEnterFlag())
    {
        MISLOG("user:%s %s: Player not ready", userId.toString().c_str(), sFuncName.c_str());
        return false;
    }
    return true;
}
//--------------------------------------------------------------
//					cbDisengageNotification()  
//--------------------------------------------------------------
void cbDisengageNotification( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	H_AUTO(cbDisengageNotification);
	
	if ( ! Mirror.mirrorIsReady() )
	{
		nlwarning("<cbDisengageNotification> Received from %s service but mirror not yet ready", serviceName.c_str() );
		return;
	}
	
	if (NLMISC::nlstricmp(serviceName.c_str(),"AIS")==0)
	{
		TDataSetRow entityRowId;
		msgin.serial( entityRowId );
		
		INFOLOG("<cbDisengageNotification> received disengage notification for entity %s", TheDataset.getEntityId(entityRowId).toString().c_str());
		
		CPhraseManager::getInstance().disengage( entityRowId, true );
	}
	else
	{
		CEntityId entityId;
		msgin.serial( entityId );
		
		INFOLOG("<cbDisengageNotification> received disengage notification for entity %s", entityId.toString().c_str());
		
		CPhraseManager::getInstance().disengage( TheDataset.getDataSetRow(entityId), true );
	}
	
} // cbDisengageNotification //
// ----------------------------------------------------------------------------
void CMissionQueueManager::removePlayerFromQueue(const CEntityId &id, uint32 queueId)
{
	H_AUTO(CMissionQueueManagerRemovePlayer);

	map<uint32,CMissionQueue>::iterator it = _Queues.find(queueId);
	if ( it == _Queues.end() )
	{
		nlwarning("Trying to remove %s from queue %u but this queue doesn't exist in manager !", id.toString().c_str(), queueId);
		return;
	}

	(*it).second.removePlayer(id);

	TPlayerQueues::iterator itPQ = _PlayerQueues.find(id);
	if (itPQ == _PlayerQueues.end())
	{
		nlwarning("Failed to find entry in _PlayerQueues for player ! BUG", id.toString().c_str());
		return;
	}

	(*itPQ).second.removeQueue(queueId);

	// remove entry if player is no longer in a queue
	if ((*itPQ).second.QueueIds.empty())
	{
		_PlayerQueues.erase(itPQ);
	}
}
//--------------------------------------------------------------
//					cbDisengage()  
//--------------------------------------------------------------
void cbDisengage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	H_AUTO(cbDisengage);
	
	if ( ! Mirror.mirrorIsReady() )
	{
		nlwarning("<cbDisengage> Received from %s service but mirror not yet ready", serviceName.c_str() );
		return;
	}

	if (serviceName == "AIS")
	{
		TDataSetRow entityRowId;
		msgin.serial( entityRowId );
		
		DEBUGLOG("<cbDisengage> AIS Disengage entity %s", TheDataset.getEntityId(entityRowId).toString().c_str() );
		
		CPhraseManager::getInstance().disengage( entityRowId, true /*chatMsg*/, true /*disengageCreature*/);
	}
	else
	{
		CEntityId entityId;
		msgin.serial( entityId );

		DEBUGLOG("<cbDisengage> Service %s Disengage entity %s", serviceName.c_str(), entityId.toString().c_str() );

		CPhraseManager::getInstance().disengage( TheDataset.getDataSetRow(entityId), true );
	}
	
} // cbDisengage //
//----------------------------------------------------------------------------
void CBuildingPhysicalPlayer::dumpBuilding(NLMISC::CLog & log) const
{
	log.displayNL("<BUILDING_DUMP> CBuildingPhysicalPlayer");
	log.displayNL("Name: %s, alias: %s", _Name.c_str(), CPrimitivesParser::aliasToString( _Alias ).c_str());

	for (uint i = 0; i < _UsersInside.size(); i++)
	{
		const TDataSetRow rowId = _UsersInside[i];
		CCharacter * c = PlayerManager.getChar( rowId );
		if ( !c )
		{
			log.displayNL("\tError: cannot find character with row id: %s", rowId.toString().c_str());
			continue;
		}

		const string charName = c->getName().toUtf8();
		const string charEId = c->getId().toString();

		CMirrorPropValueRO<TYPE_CELL> mirrorCell(TheDataset, rowId, DSPropertyCELL);
		const sint32 cell = mirrorCell;

		IRoomInstance * room = CBuildingManager::getInstance()->getRoomInstanceFromCell( cell );
		if ( !room )
		{
			log.displayNL("\tError: character %s %s is in cell %d but no room was found", charName.c_str(), charEId.c_str(), cell);
			continue;
		}

		CRoomInstancePlayer * playerRoom = dynamic_cast<CRoomInstancePlayer *>(room);
		if ( !playerRoom )
		{
			log.displayNL("\tError: character %s %s is in cell %d but room is not a player room but a %s",
				charName.c_str(), charEId.c_str(), cell, room->getRoomDescription().c_str()
				);
			continue;
		}

		log.displayNL("\tCharacter %s %s is in cell %d, room desc: %s",
			charName.c_str(), charEId.c_str(), cell, room->getRoomDescription().c_str()
			);
	}

	for (uint i = 0; i < _Players.size(); i++)
	{
		CEntityId id = _Players[i];
		CCharacter * c = PlayerManager.getChar( id );
		if ( !c )
		{
			log.displayNL("\tError: cannot find character with eid: %s", id.toString().c_str());
			continue;
		}

		const string charName = c->getName().toUtf8();
		const string charEId = c->getId().toString();

		log.displayNL("\t> Player registered in building at index %u: %s %s", i, charName.c_str(), charEId.c_str());
	}
}
//----------------------------------------------------------------------------
void cbClientMissionWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    msgin.serial(userId);

    uint8 missionIndex;
    msgin.serial(missionIndex);

    CCharacter * user = PlayerManager.getChar(userId);
    if ( !user || !user->getEnterFlag() )
        return;

    user->setAfkState(false);

    CMission* mission = NULL;
    CMissionTemplate * templ = NULL;
    for ( map<TAIAlias, CMission*>::iterator it =  user->getMissionsBegin(); it != user->getMissionsEnd(); ++it )
    {
        mission = (*it).second;
        if ( mission && mission->getClientIndex() == missionIndex )
        {
            templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
            if ( templ->Tags.NoList ) // skip invisible missions
                continue;
            break;
        }
    }
    if ( !mission )
    {
        MISDBG( "user:%s abandonMission : ERROR : invalid mission index %u sent ",userId.toString().c_str(), missionIndex);
        return;
    }
    if ( mission->getFinished() == false )
    {
        if ( !templ )
        {
            MISDBG( "user:%s abandonMission : ERROR : invalid mission alias %u", userId.toString().c_str(), mission->getTemplateId() );
            return;
        }
    }

    CMissionQueueManager::getInstance()->playerWakesUp (userId, templ->Alias );
}
//---------------------------------------------------
// modifyValue :
//
//---------------------------------------------------
void CCreatureManager::modifyValue( const CEntityId& Id, const string& var, const string& value )
{
	TMapCreatures::iterator it = _Creatures.find( Id );
	if( it != _Creatures.end() )
	{
		(*it).second->modifyValue( var, value );
	}
	else
	{
		nlwarning("(EGS)<CCreatureManager::modifyValue> : Creature %s doesn't exist", Id.toString().c_str());
	}
} // setValue //
//----------------------------------------------------------------------------
void cbClientBotChatPickStaticMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    if ( !MissionSystemEnabled )
        return;
    CEntityId userId;
    uint8 index;
    msgin.serial(userId);
    msgin.serial(index);
    //get the user and the asked mission
    if (!checkPlayer(userId, "cbClientBotChatPickStaticMission")) return;
    CCharacter	* user = PlayerManager.getChar( userId );

    // Create the debug string
    string sDebugPrefix = string("user:"******" cbClientBotChatPickStaticMission :";

    // Check for user
    if ( user == NULL )
    {
        MISLOG("%s cant find user.", sDebugPrefix.c_str());
        return;
    }

    // Check that index falls in good range
    if ( index >= user->getCurrentMissionList().size() )
    {
        MISLOG("%s invalid index %u, there are %u", sDebugPrefix.c_str(), index, user->getCurrentMissionList().size() );
        return;
    }

    // Check if the user is not cheating (trying to get a mission grayed)
    if ( user->getCurrentMissionList()[index].PreReqState != MISSION_DESC::PreReqSuccess)
    {
        MISLOG("%s user choose a mission with failed prerequesit (index %u)", sDebugPrefix.c_str(), index);
        return;
    }

    CCreature * bot = CreatureManager.getCreature( user->getCurrentInterlocutor() );
    if (!bot || bot->getAlias() == CAIAliasTranslator::Invalid )
    {
        MISLOG("%s invalid interlocutor", sDebugPrefix.c_str());
        return;
    }

    // End the user bot chat (must be done before instanciateMission() because it would clear any dynchat's interlocutor open by the mission
    user->endBotChat();
    user->setAfkState(false);

    std::list< CMissionEvent* > eventList;
    CMissionManager::getInstance()->instanciateMission(user, user->getCurrentMissionList()[index].Mission,
            bot->getAlias(), eventList);
    user->processMissionEventList( eventList,true, CAIAliasTranslator::Invalid );
}
//---------------------------------------------------
// removeCreature
//
//---------------------------------------------------
void CCreatureManager::removeCreature( const CEntityId& Id )
{
	TMapCreatures::iterator it = _Creatures.find( Id );
	if( it != _Creatures.end() )
	{
		delete (*it).second;
		_Creatures.erase( it );
//		nlinfo("(EGS)<CCreatureManager::removeCreature> creature %s removed", Id.toString().c_str());
	}
	else
	{
		nlwarning("(EGS)<CCreatureManager::removeCreature> : Creature %s doesn't exist", Id.toString().c_str());
	}
} // removeCreature //
Exemple #12
0
/****************************************************************\
						init
\****************************************************************/
void	CWorldEntity::init( const CEntityId& id, const TDataSetRow &index )
{
	Id = id;
	Index = index;

	// Keep properties local for invisible group entities (aiVision).
	// This is obsolete, as aiVision are not used anymore. Because these entities were not
	// in mirror, their property values always stayed in temp storage. All the code was
	// the same for aiVision and visible entities, i.e. we used the CMirrorPropValueAlice.
	// Now the 'Alice' version is not needed anymore, because all entities go into
	// registerEntityProperty().
//	if ( Id.getType() != RYZOMID::aiVision )
//	{

	registerEntityProperty("X", &X, id);
	registerEntityProperty("Y", &Y, id);
	registerEntityProperty("Z", &Z, id);
	registerEntityProperty("LocalX", &LocalX, id);
	registerEntityProperty("LocalY", &LocalY, id);
	registerEntityProperty("LocalZ", &LocalZ, id);
	registerEntityProperty("Theta", &Theta, id);
	registerEntityProperty("Sheet", &Sheet, id);
	registerEntityProperty("TickPos", &Tick, id);
	registerEntityProperty("Cell", &Cell, id);
	registerEntityProperty("VisionCounter", &VisionCounter, id);
	registerEntityProperty("WhoSeesMe", &WhoSeesMe, id);
	if (Cell > 0)
	{
		nlwarning("Entity %s Cell is preset to %d which should be 0 or negative, forced to 0", id.toString().c_str(), Cell());
		Cell = 0;
	}
//	}
//	else
//		Cell = -1;

	//IsStaticObject = false;
	//IsInvisible = false;
	//IsAgent = false;
	//IsTrigger = false;
	//IsInvisibleToPlayer = false;

	RefCounter = 0;
	TickLock = 0;

	TempVisionState = false;
	TempControlInVision = false;
	TempParentInVision = false;

	HasVision = false;

	Previous = NULL;
	Next = NULL;

	PlayerInfos = NULL;

	Parent = NULL;
	Control = NULL;

	PosInitialised = false;
	Continent = INVALID_CONTINENT_INDEX;
	MoveContainer = NULL;
	Primitive = NULL;
	UsePrimitive = false;
	ForceUsePrimitive = false;
	ForceDontUsePrimitive = false;

	VisionCounter = (uint8)0x0;
	PlayersSeeingMe = 0;
	ClosestPlayer = NULL;

	CellPtr = NULL;

	PatatEntryIndex = 0;

	if (id.getType() == RYZOMID::object )
	{
		_Type = Object;
	}
	else if (id.getType() == RYZOMID::player)
	{
		_Type = Player;
	}
	else if (id.getType() == RYZOMID::trigger)
	{
		_Type = Trigger;
	}
	else if ( (id.getType() >= RYZOMID::npc ) || ( id.getType() <= RYZOMID::flora)  )
	{
		_Type = AI;
	}
	else
	{
		_Type = Unknown;
	}


	// commented, now set by the EGS
	//WhoSeesMe = 0xffffffff;

	CheckMotion = true;

} // CWorldEntity constructor
//---------------------------------------------------
// addCreature :
//
//---------------------------------------------------
void CCreatureManager::addCreature( const CEntityId& Id, CCreature * creature )
{
	H_AUTO(CCreatureManagerAddCreature);

	// if we have loaded a totem bot object, we must update pointers
	NLMISC::CSString sheetIdName = creature->getType().toString();
	
	if ( creature->isSpire() )
	{
		CPVPFactionRewardManager::getInstance().addBotObject( creature );
	}

	TMapCreatures::iterator itCreature = _Creatures.find( Id );
	if( itCreature == _Creatures.end() )
	{
		_Creatures.insert( make_pair( Id, creature ) );

		TDataSetRow	row=TheDataset.getDataSetRow(Id);

		for (list< CGenNpcDescMsgImp >::iterator it = _UnaffectedDescription.begin(); it!= _UnaffectedDescription.end(); ++it )
		{
			if ( it->getEntityIndex()==row )
			{
				string name;
				it->callback(name, NLNET::TServiceId(0));
				_UnaffectedDescription.erase(it);
				break;
			}
		}
		for ( uint i = 0; i < _UnaffectedFaunaGroups.size(); i++ )
		{
			if ( _UnaffectedFaunaGroups[i].EntityIndex == row )
			{
				creature->setAIGroupAlias( _UnaffectedFaunaGroups[i].GroupAlias );
				_UnaffectedFaunaGroups[i] = _UnaffectedFaunaGroups.back();
				_UnaffectedFaunaGroups.pop_back();
				break;
			}
		}
	}
	else
	{
		nlwarning("(EGS)<CCreatureManager::addCreature> : The creature %s has already been added", Id.toString().c_str() );
	}

} // addCreature //
Exemple #14
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 #15
0
//---------------------------------------------------
// 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 //
Exemple #16
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 //