Beispiel #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);
}
Beispiel #2
0
bool NFCTeamModule::KickTeamMmember( const NFGUID& self, const NFGUID& xTeamID, const NFGUID& xMmember )
{
    NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->GetCacheRecordInfo(xTeamID, NFrame::Team::ThisName());
    if (!pRecordManager)
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = pRecordManager->GetElement(NFrame::Team::MemberList::ThisName());
    if (!pMemberRecord.get())
    {
        return false;
    }

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pCommonRedisModule->GetCachePropertyInfo(xTeamID, NFrame::Team::ThisName());
    if (!pPropertyManager)
    {
        return false;
    }

    if (self == xMmember)
    {
        return false;
    }

	const NFGUID xID = pPropertyManager->GetPropertyObject(NFrame::Team::Captain());
	if (self != xID)
	{
		return false;
	}

    NFDataList varList;
    pMemberRecord->FindObject(NFrame::Team::MemberList::GUID, self, varList);
    if (varList.GetCount() == 0)
    {
        return false;
    }

    const int nRow = varList.Int32(0);
    if (!pMemberRecord->Remove(nRow))
    {
        return false;
    }
    
    return m_pCommonRedisModule->SaveCacheRecordInfo(xTeamID, pRecordManager);
}
Beispiel #3
0
void NFCTeamModule::OnTeamEnterEctypeProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqTeamEnterEctype);

    NFGUID xTeam = NFINetModule::PBToNF(xMsg.team_id());
    NFGUID xSelfID = NFINetModule::PBToNF(xMsg.self_id());
    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pCommonRedisModule->GetCachePropertyInfo(xTeam, NFrame::Team::ThisName());
    if (pPropertyManager)
    {
        NFGUID xCaptain = pPropertyManager->GetPropertyObject(NFrame::Team::Captain());
        if (xCaptain == xSelfID)
        {
            BroadcastMsgToTeam(nPlayerID, xTeam, NFMsg::EGMI_REQ_TEAM_ENTER_ECTYPE, xMsg);
            return;
        }
    }

	m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_TEAM_ENTER_ECTYPE, xMsg, nSockIndex, nPlayerID);
}
Beispiel #4
0
bool NFCGuildModule::JoinGuild( const NFGUID& self, const NFGUID& xGuildID )
{
    NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuildID);
    if (!pGuildObject.get())
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuildID, NFrame::Guild::R_GuildMemberList());
    if (!pMemberRecord.get())
    {
        return false;
    }

    NFDataList varList;
    pMemberRecord->FindObject(NFrame::Guild::GuildMemberList_GUID, self, varList);
    if (varList.GetCount() > 0)
    {
        return false;
    }

    const NFINT64 nCount = m_pKernelModule->GetPropertyInt(xGuildID, NFrame::Guild::GuildMemeberCount());
    if (nCount >= m_pKernelModule->GetPropertyInt(xGuildID, NFrame::Guild::GuildMemeberMaxCount()))
    {
        //limit
        return false;
    }

    NFDataList varData;

    std::string strName ;
    int nLevel = 0;
    int nJob = 0;
    int nDonation = 0;
    int nReceive = 0;
    int nVIP = 0;
    int nOnLine = 0;
    int nPower = NFMsg::GUILD_POWER_TYPE_NORMAL;

    const NFGUID& xPresident = pGuildObject->GetPropertyObject(NFrame::Guild::PresidentID());
    if (xPresident == self)
    {
        nPower = NFMsg::GUILD_POWER_TYPE_PRESIDENT;
    }
    
    int nTitle = 0;
    int nOnlineGameID = 0;

    m_pGuildDataModule->GetPlayerGameID(self, nOnlineGameID);
    m_pGuildDataModule->GetPlayerInfo(self, strName, nLevel, nJob, nDonation, nVIP);

    varData << self << strName << (NFINT64)nLevel << (NFINT64)nJob << (NFINT64)nDonation << (NFINT64)nReceive << (NFINT64)nVIP << (NFINT64)nOnLine << (NFINT64)nPower << nTitle << nOnlineGameID ;

    if (pMemberRecord->AddRow(-1, varData) < 0)
    {
        return false;
    }
    
    m_pKernelModule->SetPropertyInt(xGuildID, NFrame::Guild::GuildMemeberCount(), nCount+1);

	return true;
}
Beispiel #5
0
bool NFCTeamModule::GetTeamInfo(const NFGUID& self, const NFGUID& xTeam, NFMsg::TeamInfo& xTeamInfo)
{
    if (xTeam.IsNull())
    {
        return false;
    }

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pCommonRedisModule->GetCachePropertyInfo(xTeam, NFrame::Team::ThisName());
    NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->GetCacheRecordInfo(xTeam, NFrame::Team::ThisName());

    if (!pPropertyManager)
    {
        return false;
    }

    if (!pRecordManager)
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = pRecordManager->GetElement(NFrame::Team::MemberList::ThisName());
    if (!pMemberRecord.get())
    {
        return false;
    }

    NFGUID xCaptain = pPropertyManager->GetPropertyObject(NFrame::Team::Captain());
    if (!xCaptain.IsNull())
    {
        return false;
    }

    *xTeamInfo.mutable_team_id() = NFINetModule::NFToPB(xTeam);
    *xTeamInfo.mutable_captain_id() = NFINetModule::NFToPB(xCaptain);

    for (int i = 0; i < pMemberRecord->GetRows(); i++)
    {
        if (!pMemberRecord->IsUsed(i))
        {
            continue;
        }

        NFMsg::TeammemberInfo* pMemberinfo = xTeamInfo.add_teammemberinfo();
        if (!pMemberinfo)
        {
            continue;
        }


        std::string strName = pMemberRecord->GetString(i, NFrame::Team::MemberList::Name);
        const int nLevel = pMemberRecord->GetInt32(i, NFrame::Team::MemberList::Level);
        const int nJob = pMemberRecord->GetInt32(i, NFrame::Team::MemberList::Job);
        const NFGUID xPlayerID = pMemberRecord->GetObject(i, NFrame::Team::MemberList::GUID);

        pMemberinfo->set_name(strName);
        pMemberinfo->set_nlevel(nLevel);
        pMemberinfo->set_job(nJob);
        pMemberinfo->set_headicon("");
        *pMemberinfo->mutable_player_id() = NFINetModule::NFToPB(xPlayerID);
    }

    return true;
}