bool NFCWorldNet_ServerModule::SendMsgToPlayer(const NFMsg::EGameMsgID eMsgID, google::protobuf::Message& xData, const NFGUID nPlayer)
{
    int nGameID = GetPlayerGameID(nPlayer);
    if (nGameID < 0)
    {
        return false;
    }

    return SendMsgToGame(nGameID, eMsgID, xData, nPlayer);
}
Exemplo n.º 2
0
bool NFCTeamModule::JoinTeam( const NFGUID& self, const NFGUID& xTeamID )
{
    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;
    }

    NFDataList varList;
    pMemberRecord->FindObject(NFrame::Team::MemberList::GUID, self, varList);
    if (varList.GetCount() > 0)
    {
        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 nTitle = 0;
    int nOnlineGameID = 0;

    GetPlayerGameID(self, nOnlineGameID);

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

    if (pMemberRecord->AddRow(-1, varData) < 0)
    {
        return false;
    }

    return m_pCommonRedisModule->SaveCacheRecordInfo(xTeamID, pRecordManager);
}
Exemplo n.º 3
0
NFGUID NFCTeamModule::CreateTeam( const NFGUID& self, const NFGUID& xDefaultTeamID, const std::string& strName, const std::string& strRoleName, const int nLevel, const int nJob , const int nDonation , const int nVIP)
{
    if (strName.empty())
    {
        return NULL_OBJECT;
    }

    NFGUID xTeam = xDefaultTeamID;
    if (xTeam.IsNull())
    {
        xTeam = m_pKernelModule->CreateGUID();
    }

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pCommonRedisModule->NewPropertyManager(NFrame::Team::ThisName());
    NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->NewRecordManager(NFrame::Team::ThisName());

    if (!pPropertyManager)
    {
        return NFGUID();
    }

    if (!pRecordManager)
    {
        return NFGUID();
    }

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

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

    NFDataList varData;

    int nReceive = 0;
    int nOnLine = 0;

    int nTitle = 0;
    int nOnlineGameID = 0;

    GetPlayerGameID(self, nOnlineGameID);

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

    if (pMemberRecord->AddRow(-1, varData) < 0)
    {
        return NFGUID();
    }

    if (!pPropertyManager->SetPropertyObject(NFrame::Team::Captain(), self))
    {
        return NFGUID();
    }

    if (!m_pCommonRedisModule->SaveCachePropertyInfo(xTeam, pPropertyManager))
    {
        return NFGUID();
    }

    if (!m_pCommonRedisModule->SaveCacheRecordInfo(xTeam, pRecordManager))
    {
        return NFGUID();
    }

    return xTeam;
}