int NFCLoginNet_ServerModule::OnSelectWorldResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (7 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } const int nWorldID = var.Int(0); const NFIDENTID xClientIdent = var.Object(1); const int nLoginID = var.Int(2); const std::string& strAccount = var.String(3); const std::string& strWorldAddress = var.String(4); int nPort = var.Int(5); const std::string& strWorldKey = var.String(6); NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xClientIdent); if (xFD) { NFMsg::AckConnectWorldResult xMsg; xMsg.set_world_id(nWorldID); xMsg.mutable_sender()->CopyFrom(NFToPB(xClientIdent)); xMsg.set_login_id(nLoginID); xMsg.set_account(strAccount); xMsg.set_world_ip(strWorldAddress); xMsg.set_world_port(nPort); xMsg.set_world_key(strWorldKey); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_CONNECT_WORLD, xMsg, *xFD); } return 0; }
int NFCLoginLogicModule::OnLoginEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (3 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } ////////////////////////////////////////////////////////////////////////// const NFIDENTID xIdent = var.Object(0); const std::string& strAccount = var.String(1); const std::string& strPassword = var.String(2); int64_t nState = -1; std::vector<std::string> xFieldVec; std::vector<std::string> xValueVec; xFieldVec.push_back("Password"); if (m_pClusterSqlModule->Query("AccountInfo", strAccount, xFieldVec, xValueVec) && xFieldVec.size() == xValueVec.size() && strPassword == xValueVec[0]) { //µÇ¼³É¹¦ nState = 0; } NFCDataList valEventInfo; valEventInfo << nState << xIdent << strAccount; m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_LOGIN_RESULTS, valEventInfo); return 0; }
int NFCWorldToMasterModule::OnSelectServerResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (var.GetCount() != 7 || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } const int nWorldID = var.Int(0); const NFIDENTID xClientIdent = var.Object(1); const int nLoginID = var.Int(2); const std::string& strAccount = var.String(3); const std::string& strWorldAddress = var.String(4); const int nPort = var.Int(5); const std::string& strKey = var.String(6); NFMsg::AckConnectWorldResult xMsg; xMsg.set_world_id(nWorldID); xMsg.set_login_id(nLoginID); xMsg.set_world_port(nPort); xMsg.mutable_sender()->CopyFrom(NFINetModule::NFToPB(xClientIdent)); xMsg.set_account(strAccount); xMsg.set_world_ip(strWorldAddress); xMsg.set_world_key(strKey); SendSuitByPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xMsg); return 0; }
int NFCLoginLogicModule::OnDisconnectEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (2 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } //std::string strAccount = var.String(0); return 0; }
int NFCLoginNet_ServerModule::OnLoginResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (3 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } const int nState = var.Int(0); const NFIDENTID xIdent = var.Object(1); const std::string& strAccount = var.String(2); NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xIdent); if (xFD) { if (0 != nState) { //此帐号密码错误或者被封号 //登录失败 NFMsg::AckEventResult xMsg; xMsg.set_event_code(NFMsg::EGEC_ACCOUNTPWD_INVALID); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xMsg, *xFD); return 0; } NetObject* pNetObject = GetNet()->GetNetObject(*xFD); if (pNetObject) { //记录他登录过 pNetObject->SetConnectKeyState(1); pNetObject->SetAccount(strAccount); } //把服务器列表广播下去 NFMsg::AckEventResult xData; xData.set_event_code(NFMsg::EGEC_ACCOUNT_SUCCESS); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xData, *xFD); //SynWorldToClient(unAddress); m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, *xFD), "Login successed :", strAccount.c_str()); } return 0; }
int NFCWorldNet_ServerModule::OnSelectServerEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (4 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } const int nWorldID = var.Int(0); const int nSenderAddress = var.Int(1); const int nLoginID = var.Int(2); const std::string& strAccount = var.String(3); ////////////////////////////////////////////////////////////////////////// if (InThisWorld(strAccount)) { return 0; } NF_SHARE_PTR<ServerData> pServerData = mProxyMap.First(); if (pServerData.get()) { NFMsg::AckConnectWorldResult xData; xData.set_world_id(nWorldID); xData.set_sender_ip(nSenderAddress); xData.set_login_id(nLoginID); xData.set_account(strAccount); xData.set_world_ip(pServerData->pData->server_ip()); xData.set_world_port(pServerData->pData->server_port()); xData.set_world_key(strAccount); SendMsgPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xData, pServerData->nFD); //结果 NFCDataList varResult; varResult << nWorldID << nSenderAddress << nLoginID << strAccount << pServerData->pData->server_ip() << pServerData->pData->server_port() << strAccount; m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_SELECT_SERVER_RESULTS, varResult); } return 0; }
int NFCItemModule::OnRequireUseItemEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if (var.GetCount() != 2 || !var.TypeEx(TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_ITEM; const std::string& strItemID = var.String(0); const NFGUID xTargetID = var.Object(0); if(!m_pElementInfoModule->ExistElement(strItemID) || !m_pKernelModule->GetObject(xTargetID)) { return 0; } NF_SHARE_PTR<NFIRecord> pRecordPack = m_pKernelModule->FindRecord(self, NFrame::Player::R_BagItemList()); if (nullptr != pRecordPack) { // const bool bRet = m_pPackModule->DeleteItem(self, strItemID, 1); // if (bRet) // { // int nItemType = m_pElementInfoModule->GetPropertyInt(strItemID, "ItemType"); // NFIItemConsumeProcessModule* pConsumeProcessModule = m_pItemConsumeManagerModule->GetConsumeModule(nItemType); // if (pConsumeProcessModule) // { // if (pConsumeProcessModule->ConsumeLegal(self, strItemID, xTargetID) > 0) // { // pConsumeProcessModule->ConsumeProcess(self, strItemID, xTargetID); // // return 0; // } // } // } } return 0; }
int NFCSceneProcessModule::OnLeaveSceneEvent( const NFGUID& 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); if (nOldGroupID > 0) { int nSceneID = m_pKernelModule->GetPropertyInt(object, NFrame::Player::SceneID()); if (GetCloneSceneType(nSceneID) == SCENE_TYPE_CLONE_SCENE) { m_pKernelModule->ReleaseGroupScene(nSceneID, nOldGroupID); m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, object, "DestroyCloneSceneGroup", nOldGroupID); } } return 0; }
int NFCSkillModule::OnRequireUseSkillPosEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if ( var.GetCount() < 4 || !var.TypeEx(TDATA_OBJECT, TDATA_FLOAT, TDATA_FLOAT, TDATA_FLOAT, TDATA_OBJECT)) { return 1; } int nSkillID = var.Int( 0 ); double fX = var.Float( 1 ); double fY = var.Float( 2 ); double fZ = var.Float( 3 ); //群伤,就只计算第一个人的闪避 //结果事件 // NFCDataList valueResult; // valueResult.AddInt(nSkillID); // valueResult.AddInt(nResult); // valueResult.Append(var, 4, var.GetCount()); // // m_pEventProcessModule->DoEvent(self, NFED_ON_CLIENT_USE_SKILL_POS_RESULT, valueResult); return 0; }
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; }
int NFCSceneProcessModule::OnEnterSceneEvent( const NFGUID& 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; } const NFGUID ident = var.Object( 0 ); const int nType = var.Int( 1 ); const int nTargetScene = var.Int( 2 ); const int nTargetGroupID = var.Int( 3 ); const int nNowSceneID = m_pKernelModule->GetPropertyInt( self, NFrame::Player::SceneID()); const int nNowGroupID = m_pKernelModule->GetPropertyInt(self, NFrame::Player::GroupID()); 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; } if (nNowSceneID == nTargetScene && nTargetGroupID == nNowGroupID) { //本来就是这个层这个场景就别切换了 m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "in same scene and group but it not a clone scene", nTargetScene); return 1; } //每个玩家,一个副本 NFINT64 nNewGroupID = 0; if (nTargetGroupID <= 0) { nNewGroupID = CreateCloneScene( nTargetScene ); } else { nNewGroupID = nTargetGroupID; } if ( nNewGroupID <= 0 ) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "CreateCloneScene failed", nTargetScene); return 0; } //得到坐标 double fX = 0.0; double fY = 0.0; double fZ = 0.0; const std::string strSceneID = lexical_cast<std::string>(nTargetScene); const std::string& strRelivePosList = m_pElementInfoModule->GetPropertyString(strSceneID, NFrame::Scene::RelivePos()); NFCDataList valueRelivePosList( strRelivePosList.c_str(), ";" ); if ( valueRelivePosList.GetCount() >= 1 ) { NFCDataList valueRelivePos( valueRelivePosList.String( 0 ).c_str(), "," ); if ( valueRelivePos.GetCount() == 3 ) { fX = lexical_cast<double>( valueRelivePos.String( 0 ) ); fY = lexical_cast<double>( valueRelivePos.String( 1 ) ); fZ = lexical_cast<double>( valueRelivePos.String( 2 ) ); } } NFCDataList xSceneResult( var ); xSceneResult.Add( fX ); xSceneResult.Add( fY ); xSceneResult.Add( fZ ); m_pKernelModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_BEFORE, xSceneResult ); if(!m_pKernelModule->SwitchScene( self, nTargetScene, nNewGroupID, fX, fY, fZ, 0.0f, var )) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "SwitchScene failed", nTargetScene); return 0; } xSceneResult.Add( nNewGroupID ); m_pKernelModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_RESULT, xSceneResult ); return 0; }