//--------------------------------------------------- // 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 //
// ------------------------------------ // 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); }
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); }
// 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; }
// ------------------------------------ // 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); }
// ------------------------------------ // 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); }
// ------------------------------------ // 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); }
// ------------------------------------ // 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); }
// ------------------------------------ // 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); }
// ---------------------------------------------------------------------------- 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); }
//--------------------------------------------------- // 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 //
//--------------------------------------------------- // 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 //