Beispiel #1
0
void CMirrorService::pushMessageToLocalQueueFromMessage( std::vector<TMessageCarrier>& msgQueue, NLNET::CMessage& msgin )
{
	TMessageCarrier mc( true );
	msgQueue.push_back( mc );
	msgin.serial( msgQueue.back().SenderId );
	msgin.serialMemStream( msgQueue.back().Msg );
}
//--------------------------------------------------------------
//					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 //
//--------------------------------------------------------------
//					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 //
Beispiel #4
0
void cbReleaseRange( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId mirrorServiceId )
{
	vector<string> datasetNames;
	NLNET::TServiceId declaratorServiceId;
	msgin.serialCont( datasetNames );
	msgin.serial( declaratorServiceId );
	RMMInstance->releaseRanges( datasetNames, declaratorServiceId, mirrorServiceId );
}
Beispiel #5
0
/*
 * PDS init failed, stop everything!
 */
void	cbPDSInitFailed(NLNET::CMessage& msgin, const std::string &serviceName, TServiceId serviceId)
{
	uint32	databaseId;
	msgin.serial(databaseId);
	string	error;
	msgin.serial(error);

	nlerror("Database '%d' initialisation failed: '%s'", databaseId, error.c_str());
}
//----------------------------------------------------------------------------
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 );
}
Beispiel #7
0
/*
 * Flush client messages, when they are acknowledged by the PDS
 */
void	cbFlushAckUpdates(NLNET::CMessage& msgin, const std::string &serviceName, TServiceId serviceId)
{
	uint32	databaseId;
	msgin.serial(databaseId);

	vector<uint32>	ack;
	msgin.serialCont(ack);

	CPDSLib*	lib = CPDSLib::getLib(databaseId);

	if (lib != NULL)
		lib->flushAcknowledged(ack);
}
static void cbStopNpcControlNotification(NLNET::CMessage &msgin, const std::string &serviceName, TServiceId sid)
{
	TAIAlias alias;
	CEntityId creatureId;
	msgin.serial(alias);
	msgin.serial(creatureId);
	CDynamicMapService* dms = CDynamicMapService::getInstance();
	IServerAnimationModule*  imodule= dms->getAnimationModule();
	CServerAnimationModule* module = safe_cast<CServerAnimationModule*>(imodule);

	module->onStopNpcControlNotification(creatureId);

}
Beispiel #9
0
/*
 * Add RBS Task
 */
NLNET::CMessage&	CDbManager::addTask(const std::string& msg, ITaskEventListener* listener, void* arg)
{
	NLNET::CMessage*	msgrbs = new NLNET::CMessage(msg);
	_RBSMessages.push_back(msgrbs);

	uint32	id = nextTaskId();
	msgrbs->serial(id);

	// add listener to task listeners
	if (listener != NULL)
		_TaskListeners[id] = std::make_pair<ITaskEventListener*, void*>(listener, arg);

	return *msgrbs;
}
//----------------------------------------------------------------------------
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 );
    }
}
//----------------------------------------------------------------------------
void cbClientContinueMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint8 index;
    msgin.serial(userId);
    msgin.serial(index);

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

    if ( !user->startBotChat( BOTCHATTYPE::UnknownFlag ) )
        return;
    user->botChatMissionAdvance(index);
    user->setAfkState(false);
}
//----------------------------------------------------------------------------
void cbClientBotChatDynChatSend( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    TDataSetIndex index;
    uint8 choice;
    msgin.serial(userId);
    msgin.serial(index);
    msgin.serial(choice);

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

    CMissionManager::getInstance()->dynChatChoice( user, TheDataset.getCurrentDataSetRow(index) , choice);
    user->setAfkState(false);
}
void	cbStallMode( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	try
	{
		bool		stalled;
		std::string	reason;

		msgin.serial(stalled, reason);

		if (stalled)
		{
			CMessage	msgout("HALT_TICK");
			msgout.serial(reason);

			nlwarning("Shard stalled by %s: %s", serviceName.c_str(), reason.c_str());

			CUnifiedNetwork::getInstance()->send("TICKS", msgout);
		}
		else
		{
			CMessage	msgout("RESUME_TICK");

			nlwarning("Shard resumed by %s: %s", serviceName.c_str(), reason.c_str());

			CUnifiedNetwork::getInstance()->send("TICKS", msgout);
		}
	}
	catch (Exception&)
	{
	}

}
//----------------------------------------------------------------------------
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 );
}
//----------------------------------------------------------------------------
static void cbOutpostSquadDied( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	COutpostSquadDiedMsg params;
	msgin.serial(params);
	NLMISC::CSmartPtr<COutpost> outpost = COutpostManager::getInstance().getOutpostFromAlias(params.Outpost);
	if (outpost)
	{
		outpost->aieventSquadDied(params.GroupId);
	}
}
Beispiel #16
0
/*
 * fetch data failed
 */
void	cbFetchFailure(NLNET::CMessage& msgin, const std::string &serviceName, TServiceId serviceId)
{
	uint32	databaseId;
	msgin.serial(databaseId);

	CPDSLib*	lib = CPDSLib::getLib(databaseId);

	if (lib != NULL)
		lib->notifyFetchFailure(msgin);
}
//----------------------------------------------------------------------------
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 );
}
Beispiel #18
0
void cbGetRange( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId mirrorServiceId )
{
	if ( Pause )
	{
		nlwarning( "A service is getting a range while the shard is paused" );
		beep( 880, 150 );
		beep( 660, 150 );
		beep( 880, 150 );
	}
	vector<string> datasetNames;
	NLNET::TServiceId declaratorServiceId;
	sint32 maxNbEntities;
	uint8 entityTypeId;
	msgin.serialCont( datasetNames );
	msgin.serial( declaratorServiceId );
	msgin.serial( maxNbEntities );
	msgin.serial( entityTypeId );

	RMMInstance->getRange( datasetNames, maxNbEntities, declaratorServiceId, mirrorServiceId, entityTypeId );
}
//----------------------------------------------------------------------------
void cbClientValidateMissionGift( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    msgin.serial(userId);

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

    user->acceptExchange(0);
    user->setAfkState(false);
}
//----------------------------------------------------------------------------
void cbClientBotChatEndGift( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    msgin.serial(userId);

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

    user->clearBotGift();
    user->setAfkState(false);
}
//----------------------------------------------------------------------------
void cbClientAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint8 index;
    msgin.serial(userId,index);

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

    user->abandonMission( index );
    user->setAfkState(false);
}
//----------------------------------------------------------------------------
void cbClientBotChatNextMissionPage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint16 session;
    msgin.serial(userId,session);

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

    user->setAfkState(false);
    user->fillMissionPage(session);
}//	cbClientBotChatNextMissionPage
// received stall order form backup service due to server problem on writing player saves
void cbStallShard( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
	string filename;
	msgin.serial( filename );

	nlwarning("Backup service send Stall order when trying write %s file", filename.c_str() );
	PlayerManager.broadcastMessage( 2, 0, 5, "Technical problem occured on the server,");
	PlayerManager.broadcastMessage( 2, 0, 5, "All non administrator accounts are disconnected immediately.");
	PlayerManager.broadcastMessage( 2, 0, 5, "Customer Support is already working on it.");
	PlayerManager.broadcastMessage( 2, 0, 5, "Sorry for any inconveniences.");
	PlayerManager.broadcastMessage( 2, 0, 5, "...");
	PlayerManager.setStallMode( true );
}
Beispiel #24
0
/*
 * Reacquire ranges after a service failure or shutdown
 *
 * Warning: this will fail if some services acquire some ranges before any reacquisition!
 */
void				CRangeMirrorManager::reacquireRanges( NLNET::CMessage& msgin, NLNET::TServiceId mirrorServiceId )
{
	uint nbReacquired = 0;
	uint16 nbServices;
	msgin.serial( nbServices );
	for ( uint i=0; i!=(uint)nbServices; ++i )
	{
		NLNET::TServiceId serviceId;
		uint16 nbRanges;
		msgin.serial( serviceId );
		msgin.serial( nbRanges );
		for ( uint r=0; r!=(uint)nbRanges; ++r )
		{
			string datasetname;
			TDataSetIndex first, last;
			msgin.serial( datasetname );
			msgin.serial( first, last );
			TRangeListByDataSet::iterator ids = _RangeListByDataSet.find( datasetname );
			if ( ids != _RangeListByDataSet.end() )
			{
				if ( ! CUnifiedNetwork::getInstance()->getServiceName( serviceId ).empty() )
				{
					GET_RANGE_LIST(ids).reacquireRange( serviceId, mirrorServiceId, first, last );
					++nbReacquired;
				}
				else
				{
					nlinfo( "RangeMirrorManager: skipping offline service %hu when reacquiring", serviceId.get() );
				}
			}
			else
			{
				nlwarning( "RangeMirrorManager: dataset %s not found", datasetname.c_str() );
			}
		}
	}
	nlinfo( "RangeMirrorManager: reacquired %u ranges for MS-%hu", nbReacquired, mirrorServiceId.get() );
}
	bool CWelcomeServiceSkel::fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message)
	{
		const TMessageHandlerMap &mh = getMessageHandlers();

		TMessageHandlerMap::const_iterator it(mh.find(message.getName()));

		if (it == mh.end())
		{
			return false;
		}

		TMessageHandler cmd = it->second;
		(this->*cmd)(sender, message);

		return true;
	}
Beispiel #26
0
	bool CServerPatchApplierSkel::onDispatchMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message)
	{
		const TMessageHandlerMap &mh = getMessageHandlers();

		TMessageHandlerMap::const_iterator it(mh.find(message.getName()));

		if (it == mh.end())
		{
			return false;
		}

		TMessageHandler cmd = it->second;
		(this->*cmd)(sender, message);

		return true;
	}
Beispiel #27
0
/*
 * receive index allocators
 */
void	cbAllocs(NLNET::CMessage& msgin, const std::string &serviceName, TServiceId serviceId)
{
	uint32	databaseId;
	msgin.serial(databaseId);

	CPDSLib*	lib = CPDSLib::getLib(databaseId);

	if (lib == NULL)
		return;

	// do not reinit allocator as it may contain newer data
	if (lib->allocsInitialised())
		return;

	lib->setupIndexAllocators(msgin);
	lib->initAllocs();
}
//----------------------------------------------------------------------------
void cbClientBotChatChooseStaticMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint16 session;
    msgin.serial(userId, session);

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

    user->setAfkState(false);
    // start a bot chat
    CCreature  * c = user->startBotChat( BOTCHATTYPE::ChooseMissionFlag );
    if ( !c )
    {
        return;
    }
    user->buildMissionList(c,session);
}
Beispiel #29
0
/**
 *	Send a tell line from a bot (mainly NPC) to a player
 *	phraseId is a phrase identifier in the phrase translation file.
 */
void npcTellToPlayer(const TDataSetRow &senderId, const TDataSetRow &receiverId, const std::string &phraseId, bool needSenderNpc)
{
	NLNET::CMessage	msgout;
	if ( needSenderNpc )
	{
		msgout.setType("NPC_TELL");
		msgout.serial(const_cast<TDataSetRow&>(senderId));
	}
	else
	{
		msgout.setType("GHOST_TELL");
	}
	msgout.serial(const_cast<TDataSetRow&>(receiverId));
	msgout.serial(const_cast<std::string&>(phraseId));
	sendMessageViaMirror("IOS", msgout);
}