Exemplo n.º 1
0
void NFCGuildModule::OnCreateGuildProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqAckCreateGuild);

	std::string strRoleName ;
	int nLevel = 0;
	int nJob = 0;
	int nDonation= 0;
	int nVIP= 0;

	m_pGuildDataModule->GetPlayerInfo(nPlayerID, strRoleName, nLevel, nJob, nDonation, nVIP);
	NFGUID xGuild = CreateGuild(nPlayerID, xMsg.guild_name(), strRoleName, nLevel, nJob, nDonation, nVIP);

	if (!xGuild.IsNull())
	{
		NFMsg::ReqAckCreateGuild xAck;
		*xAck.mutable_guild_id() = NFINetModule::NFToPB(xGuild);
		xAck.set_guild_name(xMsg.guild_name());

		m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_GUILD, xAck, nSockIndex, nPlayerID);
	}
	else
	{
		NFMsg::ReqAckCreateGuild xAck;
		*xAck.mutable_guild_id() = NFINetModule::NFToPB(xGuild);
		xAck.set_guild_name("");

		m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_GUILD, xAck, nSockIndex, nPlayerID);
	}
}
void NFCWorldNet_ServerModule::OnAckSwitchServer(const NFSOCK nSockIndex, const int nMsgID, const char *msg,
                                                  const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nMsgID, msg, nLen, NFMsg::AckSwitchServer);
    nPlayerID = NFINetModule::PBToNF(xMsg.selfid());

    SendMsgToGame((int)xMsg.self_serverid(), NFMsg::EGMI_ACKSWICHSERVER, xMsg, nPlayerID);
}
void NFCWorldNet_ServerModule::OnReqSwitchServer(const NFSOCK nSockIndex, const int nMsgID, const char *msg,
                                                  const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nMsgID, msg, nLen, NFMsg::ReqSwitchServer);
    nPlayerID = NFINetModule::PBToNF(xMsg.selfid());

    //const NFGUID nClientID = NFINetModule::PBToNF(xMsg.client_id());
    //const int nGateID = (int)xMsg.gate_serverid();
    //const int nSceneID = (int)xMsg.sceneid();
    SendMsgToGame((int)xMsg.target_serverid(), NFMsg::EGMI_REQSWICHSERVER, xMsg, nPlayerID);
}
void NFCGSSwichServerModule::OnReqSwichServer(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS_NO_OBJECT(nMsgID, msg, nLen, NFMsg::ReqSwitchServer);
	if (nPlayerID != NFINetModule::PBToNF(xMsg.selfid()))
	{
		return;
	}

	if (xMsg.target_serverid() != pPluginManager->GetAppID())
	{
		m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, nPlayerID, "Target server is not this server", xMsg.target_serverid(), __FUNCTION__, __LINE__);
		return;
	}

	const NFGUID nClientID = NFINetModule::PBToNF(xMsg.client_id());
	const int nGateID = (int)xMsg.gate_serverid(); 
    const int nSceneID = (int)xMsg.sceneid();
    const int nGroup = (int)xMsg.groupid();

	//if (!AddPlayerGateInfo(nPlayerID, nClientID, nGateID))
 //   {
 //       return;
 //   }

    NFDataList var;
    var.AddString(NFrame::Player::GateID());
    var.AddInt(nGateID);

    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(nPlayerID, nSceneID, 0, NFrame::Player::ThisName(), "", var);
    if (NULL == pObject.get())
    {
        //mRoleBaseData
        //mRoleFDData
        return;
    }

    pObject->SetPropertyInt(NFrame::Player::GateID(), nGateID);
    pObject->SetPropertyInt(NFrame::Player::GameID(), pPluginManager->GetAppID());

    m_pKernelModule->DoEvent(pObject->Self(), NFrame::Player::ThisName(), CLASS_OBJECT_EVENT::COE_CREATE_FINISH, NFDataList());

	m_pScenemodule->RequestEnterScene(pObject->Self(), nSceneID, nGroup, 0, NFDataList());
	//m_pEventModule->DoEvent(pObject->Self(), NFED_ON_CLIENT_ENTER_SCENE, varEntry);

    if (!m_pGameServerNet_ServerModule->AddPlayerGateInfo(nPlayerID, nClientID, nGateID))
    {
        m_pKernelModule->DestroyObject(nPlayerID);
        return ;
    }

	m_pGameServerNet_ServerModule->SendMsgPBToGate(NFMsg::EGMI_REQSWICHSERVER, xMsg, nPlayerID);
	m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_WORLD, nPlayerID.ToString(), NFMsg::EGMI_ACKSWICHSERVER, xMsg);
}
Exemplo n.º 5
0
void NFCPVPMatchModule::OnAckCreatePVPEctypeProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::AckCreatePVPEctype);

    NFGUID xRoomID = NFINetModule::PBToNF(xMsg.xroominfo().roomid());
    if (!xRoomID.IsNull())
    {
        int nServerID = 0;
        int nSceneID = 0;
        int nGroup = 0;
        if (!xMsg.xroominfo().has_serverid())
        {
            return;
        }

        if (!xMsg.xroominfo().has_sceneid())
        {
            return;
        }
        if (!xMsg.xroominfo().has_groupid())
        {
            return;
        }

        nServerID = xMsg.xroominfo().serverid();
        nSceneID = xMsg.xroominfo().sceneid();
        nGroup = xMsg.xroominfo().groupid();

        NFMsg::PVPRoomInfo xRoomInfo;
        if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
        {
            UpdateRoomStatus(xRoomInfo, EPVPROOMSTATUS_FIGHT);

            if (xRoomInfo.ncellstatus() == EPVPROOMSTATUS_FIGHT)
            {
                xRoomInfo.set_serverid(nServerID);
                xRoomInfo.set_sceneid(nSceneID);
                xRoomInfo.set_groupid(nGroup);

                if (m_pPVPMatchRedisModule->SetRoomInfo(xRoomID, xRoomInfo))
                {
                    BroadcastMsgToRoom(nPlayerID, xRoomID, NFMsg::EGMI_ACK_CREATEPVPECTYPE, xMsg);
                }
            }
        }
    }
}
void NFCWorldNet_ServerModule::OnOfflineProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nMsgID, msg, nLen, NFMsg::RoleOfflineNotify);
}
Exemplo n.º 7
0
void NFCPVPMatchModule::OnReqPVPApplyMatchProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqPVPApplyMatch);

    NFMsg::AckPVPApplyMatch xAck;
    *xAck.mutable_self_id() = xMsg.self_id();
    xAck.set_applytype(xMsg.applytype());
    xAck.set_nresult(0);

    switch (xMsg.applytype())
    {
    case NFMsg::ReqPVPApplyMatch::EApplyType_Single:
    {
        if (ApplyPVP(nPlayerID, xMsg.npvpmode(), xMsg.score()))
        {
            xAck.set_nresult(1);
        }

        NFGUID xRoomID;
        if (m_pPVPMatchRedisModule->GetPlayerRoomID(nPlayerID, xRoomID))
        {
            NFMsg::PVPRoomInfo xRoomInfo;
            if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
            {
                xAck.mutable_xroominfo()->CopyFrom(xRoomInfo);
            }
        }

        m_pWorldNet_ServerModule->GetNetModule()->SendMsgPB(NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck, nSockIndex, nPlayerID);
    }
    break;
    case NFMsg::ReqPVPApplyMatch::EApplyType_Team:
    {
        if (xMsg.has_team_id())
        {
            NFGUID xTeamID = NFINetModule::PBToNF(xMsg.team_id());
            if (!xTeamID.IsNull())
            {
                std::vector<NFGUID> xPlayerList;
                if (m_pTeamModule->GetMemberList(nPlayerID, xTeamID, xPlayerList))
                {
                    NFCDataList varMember;
                    for (size_t i = 0; i < xPlayerList.size(); i++)
                    {
                        varMember.AddObject(xPlayerList[i]);
                    }

                    if (TeamApplyPVP(xTeamID, varMember, xMsg.npvpmode(), xMsg.score()))
                    {
                        xAck.set_nresult(1);

                        NFGUID xRoomID;
                        if (m_pPVPMatchRedisModule->GetPlayerRoomID(nPlayerID, xRoomID))
                        {
                            NFMsg::PVPRoomInfo xRoomInfo;
                            if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
                            {
                                xAck.mutable_xroominfo()->CopyFrom(xRoomInfo);
                            }
                        }

                        m_pTeamModule->BroadcastMsgToTeam(nPlayerID, xTeamID, NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck);


                        return;
                    }
                }
            }
        }

        m_pWorldNet_ServerModule->GetNetModule()->SendMsgPB(NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck, nSockIndex, nPlayerID);

    }
    break;
    default:
        break;
    }
}