Пример #1
0
	bool getCharInfo(NLNET::IModuleProxy *senderModuleProxy, uint32 & charId, NLMISC::CEntityId & clientEid, std::string & userPriv, std::string &extendedPriv)
	{
		const NLNET::TSecurityData *securityData = senderModuleProxy->findSecurityData(rmst_client_info);

		if (!CDynamicMapService::getInstance()->useNetwork())
		{
	//		userId = 999<;
			charId = 999<<4;

			clientEid = CEntityId::Unknown;
			clientEid.setShortId(charId);
			clientEid.setDynamicId(0x86); //FrontendId
			clientEid.setType(RYZOMID::player);

			userPriv =":DEV:";
			extendedPriv = "";
			return true;
		}

		if (securityData != NULL)
		{
			const struct TClientInfo* clientInfo= static_cast<const struct TClientInfo *>(securityData); //safe_cast ???
			//userId = clientInfo->UserId;
			charId = uint32(clientInfo->ClientEid.getShortId());
			clientEid = clientInfo->ClientEid;
			userPriv = clientInfo->UserPriv;
			extendedPriv = clientInfo->ExtendedPriv;
			return true;
		}
		else
		{
			return false;
		}
	}
Пример #2
0
//---------------------------------------------------
// 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 //
Пример #3
0
CSPhrasePtr ISPhraseFactory::buildPhrase( const TDataSetRow & actorRowId,const std::vector< NLMISC::CSheetId>& brickIds, bool execution )
{
	// the check to see if there is at least a brick is made before
	nlassert( !brickIds.empty() );
	nlassert( Factories );
	
	// transform sheet ids into forms
	std::vector< const CStaticBrick* > bricks( brickIds.size() );
	uint16 nbNull = 0;
	for ( uint i = 0; i < bricks.size(); ++i )
	{
		// skip unknown sheetIds
		if (  brickIds[i] == NLMISC::CSheetId::Unknown )
		{
			++nbNull;
			continue;
		}
		
		bricks[i-nbNull] = CSheets::getSBrickForm( brickIds[i] );
		
		if ( bricks[i-nbNull] == NULL )
		{
			nlwarning( "<ISPhraseFactory buildPhrase> invalid SBrick sheet %u, named %s",brickIds[i].asInt(),brickIds[i].toString().c_str() );
			return NULL;
		}
	}
	
	if (nbNull)
		bricks.resize( bricks.size() - nbNull);
	
#ifdef NL_DEBUG
	if (UseDebugBrick)
	{
		NLMISC::CEntityId id = TheDataset.getEntityId(actorRowId);
		if ( id.getType() == RYZOMID::player )
			bricks.push_back(&DebugBrick);
	}		
#endif
	
	//get the root brick family and the associated factory
	for ( uint i = 0; i < Factories->size(); i++ )
	{
		if ( (*Factories)[i].first == BRICK_FAMILIES::brickType(bricks[0]->Family) )
		{
			CSPhrasePtr phrase = (*Factories)[i].second->buildPhrase( actorRowId, bricks, execution);
			if ( phrase )
			{
				phrase->setBrickSheets(brickIds);
				return phrase;
			}
			return NULL;
		}
	}
	nlwarning( "<ISPhraseFactory buildPhrase> the brick type %s has no corresponding phrase class", BRICK_TYPE::toString(BRICK_FAMILIES::brickType( bricks[0]->Family )).c_str() );
	return NULL;
}
Пример #4
0
// ------------------------------------
// Stop
void	CReynoldsManager::leaveMove(const NLMISC::CEntityId &entity)
{
	TControlledTrackMap::iterator	ite = _ControlledTrackMap.find(entity);
	if (ite == _ControlledTrackMap.end())
	{
		nlwarning("ReynoldsLib:CReynoldsManager:leaveMove(): undefined entity %s", entity.toString().c_str());
		return;
	}

	nldebug("ReynoldsLib:CReynoldsManager:leaveMove(): %s control left", entity.toString().c_str());

	(*ite).second->leave();
	_ControlledTrackMap.erase(ite);
}
Пример #5
0
void CAiWrapperServer::setAggroRange(NLMISC::CEntityId entityId, float range)
{
	CMessage msgout("EXEC_COMMAND");
	std::string command = NLMISC::toString("eventSetNpcGroupAggroRange %s %f", entityId.toString().c_str(), range);
	msgout.serial(command);
	CUnifiedNetwork::getInstance()->send("EGS",msgout);
}
Пример #6
0
	// same getCharInfo but return true only if client has been allowad by su to connect
	bool checkSecurityInfo(NLNET::IModuleProxy *senderModuleProxy, uint32 & charId, NLMISC::CEntityId & clientEid, std::string & userPriv, std::string &extendedPriv)
	{
		bool ok =  getCharInfo(senderModuleProxy, charId, clientEid, userPriv, extendedPriv);
		if (!ok )
		{
			nlwarning("Warning: Security issues: a client '%s' without security data try to connect... ", senderModuleProxy->getModuleName().c_str() );
			return false;
		}
		IServerEditionModule* edition = CDynamicMapService::getInstance()->getEditionModule();
		if (!edition)
		{
			return false;
		}
		ok = edition->isClientAuthorized(charId);
		if (!ok)
		{
			nlwarning( "Warning: A client '%s' '%s' %u '%s' try to send messages, without begin allowed (he was disconnected)",
				senderModuleProxy->getModuleName().c_str(), clientEid.toString().c_str(),  charId, userPriv.c_str());

			edition->disconnectChar(charId);
			edition->returnToPreviousSession(charId);

			return false;
		}
		return true;
	}
Пример #7
0
// ------------------------------------
// Set Sheet
void	CReynoldsManager::setSheet(const NLMISC::CEntityId &id, const NLMISC::CSheetId &sheet)
{
	CTrack	*track = getTrack(id);
	if (track == NULL)
	{
		nlwarning("ReynoldsLib:CReynoldsManager:setSheet(): Track %s not found", id.toString().c_str());
		return;
	}

	if (track->hasId())
	{
		nlwarning("ReynoldsLib:CReynoldsManager:setSheet(): Track %s already has an Id", id.toString().c_str());
		return;
	}

	track->setId(id, sheet);
}
Пример #8
0
// ------------------------------------
// Set Vision
void	CReynoldsManager::setVision(const NLMISC::CEntityId &id, const std::vector<NLMISC::CEntityId> &vision)
{
	CTrack	*track = getTrack(id);
	if (track == NULL)
	{
		nlwarning("ReynoldsLib:CReynoldsManager:setVision(): Track %s not found", id.toString().c_str());
		return;
	}

	track->updateVision(vision);
}
Пример #9
0
// ------------------------------------
// Set Position
void	CReynoldsManager::setPosition(const NLMISC::CEntityId &id, const NLMISC::CVectorD &position, float heading)
{
	CTrack	*track = getTrack(id);
	if (track == NULL)
	{
		nlwarning("ReynoldsLib:CReynoldsManager:setPosition(): Track %s not found", id.toString().c_str());
		return;
	}

	track->setPosition(position, heading);
}
Пример #10
0
// ------------------------------------
// Follow
void	CReynoldsManager::follow(const NLMISC::CEntityId &entity, const NLMISC::CEntityId &target)
{
	// look for the track, and create a new one if not found -- in both maps
	CTrack	*etrack = createTrack(entity);

	TControlledTrackMap::iterator	ite = _ControlledTrackMap.find(entity);
	if (ite == _ControlledTrackMap.end())
		_ControlledTrackMap.insert(TControlledTrackMap::value_type(entity, etrack));

	// look for the target, and create a new track if not found
	CTrack	*ttrack = createTrack(target);

	nldebug("ReynoldsLib:CReynoldsManager:follow(): %s now follows %s", entity.toString().c_str(), target.toString().c_str());

	// let entity follow the target
	etrack->follow(ttrack);
}
Пример #11
0
// ------------------------------------
// Go to
void	CReynoldsManager::goTo(const NLMISC::CEntityId &entity, const NLMISC::CVectorD &position)
{
	// look for the track, and create a new one if not found -- in both maps
	CTrack	*etrack = createTrack(entity);

	TControlledTrackMap::iterator	ite = _ControlledTrackMap.find(entity);
	if (ite == _ControlledTrackMap.end())
		_ControlledTrackMap.insert(TControlledTrackMap::value_type(entity, etrack));

	// create a fake track for point position
	static uint	i = 0;
	CEntityId	id(0, i++, 0, 0);
	CTrack	*pointTo = createTrack(id);
	pointTo->setStatic();
	pointTo->setId(id, CSheetId::Unknown);
	pointTo->setPosition(position, 0.0f);

	nldebug("ReynoldsLib:CReynoldsManager:goTo(): %s now goes to (%.1f,%.1f)", entity.toString().c_str(), position.x, position.y);

	// let entity follow the target
	etrack->follow(pointTo);
}
Пример #12
0
// ----------------------------------------------------------------------------
void CMissionQueueManager::playerEntersCriticalArea(const NLMISC::CEntityId &id, uint32 queueId, bool accept)
{
	H_AUTO(CMissionQueueManagerPlayerEntersCriticalArea);

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

	(*it).second.playerEntersCriticalArea(id, accept);
}
Пример #13
0
// Unmap a string in pds
void	CPDSLib::unmapString(const NLMISC::CEntityId& eid)
{
	CDbMessage&	msg = nextMessage();
	msg.unmapString(eid.asUint64());
}
Пример #14
0
// Add a string in pds
void	CPDSLib::addString(const NLMISC::CEntityId& eid, const ucstring& str)
{
	CDbMessage&	msg = nextMessage();
	msg.addString(eid.asUint64(), str);
}
Пример #15
0
//---------------------------------------------------
// 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 //
Пример #16
0
//---------------------------------------------------
// 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 //