Ejemplo n.º 1
0
void NFCMapModule::SetKingForGrid(const std::string& strTitleID, const NFGUID& xGuildID)
{
	if (!m_pElementModule->ExistElement(strTitleID))
	{
		return;
	}

	NFMsg::BigMapGridBaseInfo xGridBaseInfo;
	if (!m_pBigMapRedisModule->GetGridBaseInfo(strTitleID, xGridBaseInfo))
	{
		return;
	}

	//get all guild information to set in grid base info
	NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = m_pGuildRedisModule->GetGuildCachePropertyInfo(xGuildID);
	const NFGUID xGUID = xPropertyManager->GetPropertyObject(NFrame::Guild::GuildID());
	const std::string& strIcon = xPropertyManager->GetPropertyString(NFrame::Guild::GuildIcon());
	const int nLevel = xPropertyManager->GetPropertyInt(NFrame::Guild::GuildLevel());
	const int nMemberCount = xPropertyManager->GetPropertyInt(NFrame::Guild::GuildMemeberCount());
	const int nResource = xPropertyManager->GetPropertyInt(NFrame::Guild::KingWarResource());

	xGridBaseInfo.mutable_guild_info()->mutable_id()->CopyFrom(NFINetModule::NFToPB(xGUID));
	xGridBaseInfo.mutable_guild_info()->set_level(nLevel);
	xGridBaseInfo.mutable_guild_info()->set_count(nMemberCount);
	xGridBaseInfo.mutable_guild_info()->set_icon(strIcon);
	xGridBaseInfo.mutable_guild_info()->set_resource(nResource);

	m_pBigMapRedisModule->SetGridBaseInfo(strTitleID, xGridBaseInfo);
}
Ejemplo n.º 2
0
int NFCEctypeModule::OnEctypeSettleEvent(const NFIDENTID& self, int nResult, int nStar)
{
    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
    if (!pObject.get())
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "player not exit", "", __FUNCTION__, __LINE__);
        return 1;
    }

    int nSceneID = pObject->GetPropertyInt("SceneID");
    if (nSceneID <= 0)
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "scene id error", "", __FUNCTION__, __LINE__);
        return 1;
    }

    // 失败
    if (nResult == 0)
    {
        int nLevel = m_pKernelModule->GetPropertyInt(self, "Level");
        const std::string& strAccout = m_pKernelModule->GetPropertyString(self, "Account");

        std::ostringstream stream;
        stream << "[ExitEctype] Account[" << strAccout << "] Level[" << nLevel << "] Scene[" << nSceneID << "] [0]";
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, self, stream, __FUNCTION__, __LINE__);
        return 1;
    }

    if (!m_pSceneProcessModule->IsCloneScene(nSceneID))
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "player not int clone scene", "", __FUNCTION__, __LINE__);
        return 1;
    }

    // 通关记录
    // TODO

    // 通关奖励
    AddEctypeAward(self, nSceneID);

    return 0;
}
Ejemplo n.º 3
0
void NFCMapModule::ReqStation(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqHoldMapGrid);

	if (!m_pElementModule->ExistElement(xMsg.map_title_id()))
	{
		return;
	}

	NFGUID xGuildID = NFINetModule::PBToNF(xMsg.guild_id());
	NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = m_pGuildRedisModule->GetGuildCachePropertyInfo(xGuildID);
	if (!xPropertyManager)
	{
		return;
	}

	//remove form last grid

	int nResourece = xPropertyManager->GetPropertyInt(NFrame::Guild::KingWarResource());
	m_pBigMapRedisModule->AddGridStationInfo(xMsg.map_title_id(), xGuildID, nResourece);
}
int NFCSceneProcessModule::OnEnterSceneEvent( const NFIDENTID& self, const int nEventID, const NFIDataList& var )
{
    if ( var.GetCount() != 4 
        || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, 
        TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return 0;
    }

    NFIDENTID ident = var.Object( 0 );
    int nType = var.Int( 1 );
    int nTargetScene = var.Int( 2 );
    int nTargetGroupID = var.Int( 3 );
    int nOldSceneID = m_pKernelModule->GetPropertyInt( self, "SceneID" );

    char szSceneID[MAX_PATH] = {0};
    sprintf(szSceneID, "%d", nTargetScene);
#ifdef NF_USE_ACTOR
	int nActorID = m_pElementInfoModule->GetPropertyInt(szSceneID, "ActorID");
	int nSelfActorID = pPluginManager->GetActorID();
	if (nSelfActorID != nActorID)
	{
		m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "target scene not runing in this server", nTargetScene);
		return 1;
#endif

    if ( self != ident )
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "you are not you self, but you want to entry this scene", nTargetScene);
        return 1;
    }

    const int nNowContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID");
    const int nNowGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID");
    if (nNowContainerID == nTargetScene
        && nNowGroupID == nTargetGroupID)
    {
        //本来就是这个层这个场景就别切换了
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "in same scene and group but it not a clone scene", nTargetScene);

        return 1;
    }

    nTargetGroupID = CreateCloneScene( nTargetScene, nTargetGroupID, "File.xml", NFCDataList() );
    if ( nTargetGroupID <= 0 )
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "CreateCloneScene failed", nTargetScene);
        return 0;
    }

    //得到坐标
    float fX = 0.0f;
    float fY = 0.0f;
    float fZ = 0.0f;

    const std::string& strRelivePosList = m_pElementInfoModule->GetPropertyString(szSceneID, "RelivePos");
    NFCDataList valueRelivePosList( strRelivePosList.c_str(), ";" );
    if ( valueRelivePosList.GetCount() >= 1 )
    {
        NFCDataList valueRelivePos( valueRelivePosList.String( 0 ).c_str(), "," );
        if ( valueRelivePos.GetCount() == 3 )
        {
            fX = boost::lexical_cast<float>( valueRelivePos.String( 0 ) );
            fY = boost::lexical_cast<float>( valueRelivePos.String( 1 ) );
            fZ = boost::lexical_cast<float>( valueRelivePos.String( 2 ) );
        }
    }

    NFCDataList xSceneResult( var );
    xSceneResult.Add( fX );
    xSceneResult.Add( fY );
    xSceneResult.Add( fZ );

    m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_BEFORE, xSceneResult );

    if(!m_pKernelModule->SwitchScene( self, nTargetScene, nTargetGroupID, fX, fY, fZ, 0.0f, var ))
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "SwitchScene failed", nTargetScene);

        return 0;
    }

    xSceneResult.Set(3, NFINT64(nTargetGroupID));//spicial
    m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_RESULT, xSceneResult );

    return 0;
}

int NFCSceneProcessModule::OnLeaveSceneEvent( const NFIDENTID& object, const int nEventID, const NFIDataList& var )
{
    if (1 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return -1;
    }

    NFINT32 nOldGroupID = var.Int(0);

    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(object);
    if (pObject.get() && nOldGroupID > 0)
    {
        int nContainerID = pObject->GetPropertyInt("SceneID");
        if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE)
        {
            m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, object, "DestroyCloneSceneGroup", nOldGroupID);
            DestroyCloneScene(nContainerID, nOldGroupID, var);
        }
    }

    return 0;
}

int NFCSceneProcessModule::OnObjectClassEvent( const NFIDENTID& self, const std::string& strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFIDataList& var )
{
    if ( strClassName == "Player" )
    {
        if ( CLASS_OBJECT_EVENT::COE_DESTROY == eClassEvent )
        {
            //如果在副本中,则删除他的那个副本
            int nContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID");
            if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE)
            {
                int nGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID");

                m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, self, "DestroyCloneSceneGroup", nGroupID);
                DestroyCloneScene(nContainerID, nGroupID, NFCDataList());
            }
        }
        else if ( CLASS_OBJECT_EVENT::COE_CREATE_HASDATA == eClassEvent )
        {
            m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_ENTER_SCENE, this, &NFCSceneProcessModule::OnEnterSceneEvent );
            m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_LEAVE_SCENE, this, &NFCSceneProcessModule::OnLeaveSceneEvent );
        }
    }

    return 0;
}

E_SCENE_TYPE NFCSceneProcessModule::GetCloneSceneType( const int nContainerID )
{
    char szSceneIDName[MAX_PATH] = { 0 };
    sprintf( szSceneIDName, "%d", nContainerID );
    if (m_pElementInfoModule->ExistElement(szSceneIDName))
    {
        return (E_SCENE_TYPE)m_pElementInfoModule->GetPropertyInt(szSceneIDName, "SceneType");
    }

    return SCENE_TYPE_ERROR;
}