const NF_SHARE_PTR<NFDataList> NFCRecord::GetInitData() const { NF_SHARE_PTR<NFDataList> pIniData = NF_SHARE_PTR<NFDataList>( NF_NEW NFDataList()); pIniData->Append(*mVarRecordType); return pIniData; }
void NFCRecordLogic::AddRecord(const NF_SHARE_PTR<NFIObject>& object, const std::string &strRecordName, const NFMsg::RecordAddRowStruct &data) { NF_SHARE_PTR<NFIRecordManager> recordMgr = object->GetRecordManager(); NF_SHARE_PTR<NFDataList> varData = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); NF_SHARE_PTR<NFDataList> varInit = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); NF_SHARE_PTR<NFDataList> varTag = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); for(int j = 0; j < data.record_float_list_size(); j++) { varInit->AddFloat(0); varData->AddFloat(data.record_float_list(j).data()); } for(int j = 0; j < data.record_int_list_size(); j++) { varInit->AddInt(0); varData->AddInt(data.record_int_list(j).data()); } for(int j = 0; j < data.record_string_list_size(); j++) { varInit->AddString(""); varData->AddString(data.record_string_list(j).data()); } for(int j = 0; j < data.record_object_list_size(); j++) { varInit->AddObject(NFGUID()); varData->AddObject(NFINetModule::PBToNF(data.record_object_list(j).data())); } for(int j = 0; j < data.record_vector2_list_size(); j++) { varInit->AddVector2(NFVector2()); varData->AddVector2(NFINetModule::PBToNF(data.record_vector2_list(j).data())); } for(int j = 0; j < data.record_vector3_list_size(); j++) { varInit->AddVector3(NFVector3()); varData->AddVector3(NFINetModule::PBToNF(data.record_vector3_list(j).data())); } NF_SHARE_PTR<NFIRecord> record = recordMgr->GetElement(strRecordName); if(record == nullptr) { record = recordMgr->AddRecord(NFGUID(), strRecordName, varInit, varTag, 255); } record->AddRow(data.row(), *varData); }
int NFCSceneAOIModule::OnPlayerSceneEvent(const NFGUID & self, const std::string & strPropertyName, const NFData & oldVar, const NFData & newVar) { //no more player in this group of this scene at the same time //so now only one player(that you) in this group of this scene //BTW, most of time, we dont create monsters in the group 0 //so no one at this group but u //therefore u just need post the new scene id to you self OnPropertyEvent(self, strPropertyName, oldVar, newVar, NFDataList() << self); return 0; }
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); }
void NFCGamePVPModule::OnAckSearchOpponentProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { CLIENT_MSG_PROCESS(nMsgID, msg, nLen, NFMsg::AckSearchOppnent); if (!m_pKernelModule->ExistObject(nPlayerID)) { return; } m_pKernelModule->SetPropertyObject(nPlayerID, NFrame::Player::OpponentFighting(), NFGUID()); m_pKernelModule->SetPropertyInt(nPlayerID, NFrame::Player::FightingStar(), 0); m_pKernelModule->SetPropertyInt(nPlayerID, NFrame::Player::PVPType(), NFMsg::EPVPType::PVP_INDIVIDUAL); m_pSceneProcessModule->RequestEnterScene(nPlayerID, xMsg.scene_id(), 0, NFDataList()); int nNoWSceneID = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::SceneID()); int nGroupID = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::GroupID()); if (nNoWSceneID != xMsg.scene_id()) { return; } //process opponent data ProcessOpponentData(nPlayerID, xMsg); m_pGameServerNet_ServerModule->SendMsgToGate(NFMsg::EGMI_ACK_SEARCH_OPPNENT, std::string(msg, nLen), nPlayerID); for (int i = 0; i < xMsg.title().building_size(); ++i) { const NFMsg::TileBuilding& xTileBuilding = xMsg.title().building().Get(i); NFGUID xBuildingID = NFINetModule::PBToNF(xTileBuilding.guid()); NFVector3 vPos; vPos.SetX(xTileBuilding.x()); vPos.SetY(xTileBuilding.y()); std::string strCnfID = xTileBuilding.configid(); NFDataList xDataArg; xDataArg.AddString(NFrame::NPC::Position()); xDataArg.AddVector3(vPos); xDataArg.AddString(NFrame::NPC::MasterID()); xDataArg.AddObject(NFINetModule::PBToNF(xMsg.opponent())); xDataArg.AddString(NFrame::NPC::AIOwnerID()); xDataArg.AddObject(nPlayerID); xDataArg.AddString(NFrame::NPC::NPCType()); xDataArg.AddInt(NFMsg::ENPCType::ENPCTYPE_TURRET); m_pKernelModule->CreateObject(xBuildingID, nNoWSceneID, nGroupID, NFrame::NPC::ThisName(), strCnfID, xDataArg); } }
void NFGamePVPModule::OnReqSwapHomeSceneProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqAckHomeScene); //int nHomeSceneID = m_pKernelModule->GetPropertyInt32(nPlayerID, NFrame::Player::HomeSceneID()); int nSceneID = m_pKernelModule->GetPropertyInt32(nPlayerID, NFrame::Player::SceneID()); ResetPVPData(nPlayerID); //m_pKernelModule->SetPropertyInt(nPlayerID, NFrame::Player::PVPType(), NFMsg::EPVPType::PVP_HOME); m_pSceneProcessModule->RequestEnterScene(nPlayerID, 1, 0, NFDataList()); }
//--------------------------------------------收消息------------------------------------------------------------- void NFCPlayerLogic::OnRoleList(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::AckRoleLiteInfoList xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } // 目前服务器只有一个角色 m_RoleList.clear(); for(int i = 0; i < xMsg.char_data_size(); i++) { m_RoleList.push_back(xMsg.char_data(i)); } DoEvent(E_PlayerEvent_RoleList, NFDataList()); }
int NFCSceneAOIModule::OnPlayerGroupEvent(const NFGUID & self, const std::string & strPropertyName, const NFData & oldVar, const NFData & newVar) { //this event only happened in the same scene int nSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::IObject::SceneID()); int nOldGroupID = oldVar.GetInt32(); int nNewGroupID = newVar.GetInt32(); //maybe form 0, maybe not, only three stuation //example1: 0 -> 1 ==> new_group > 0 && old_group <= 0 //example2: 1 -> 2 ==> new_group > 0 && old_group > 0 //example3: 5 -> 0 ==> new_group <= 0 && old_group > 0 if (nNewGroupID > 0) { if (nOldGroupID > 0) { //example2: 1 -> 2 ==> new_group > 0 && old_group > 0 //step1: leave NFDataList valueAllOldNPCListNoSelf; NFDataList valueAllOldPlayerListNoSelf; m_pKernelModule->GetGroupObjectList(nSceneID, nOldGroupID, valueAllOldNPCListNoSelf, false, self); m_pKernelModule->GetGroupObjectList(nSceneID, nOldGroupID, valueAllOldPlayerListNoSelf, true, self); OnObjectListLeave(valueAllOldPlayerListNoSelf, NFDataList() << self); OnObjectListLeave(NFDataList() << self, valueAllOldPlayerListNoSelf); OnObjectListLeave(NFDataList() << self, valueAllOldNPCListNoSelf); } else { //example1: 0 -> 1 == > new_group > 0 && old_group <= 0 //only use step2 that enough } //step2: enter NFDataList valueAllNewNPCListNoSelf; NFDataList valueAllNewPlayerListNoSelf; m_pKernelModule->GetGroupObjectList(nSceneID, nNewGroupID, valueAllNewNPCListNoSelf, false, self); m_pKernelModule->GetGroupObjectList(nSceneID, nNewGroupID, valueAllNewPlayerListNoSelf, true, self); OnObjectListEnter(valueAllNewPlayerListNoSelf, NFDataList() << self); OnObjectListEnter(NFDataList() << self, valueAllNewPlayerListNoSelf); OnObjectListEnter(NFDataList() << self, valueAllNewNPCListNoSelf); //bc others data to u for (int i = 0; i < valueAllNewNPCListNoSelf.GetCount(); i++) { NFGUID identOld = valueAllNewNPCListNoSelf.Object(i); OnPropertyEnter(NFDataList() << self, identOld); OnRecordEnter(NFDataList() << self, identOld); OnObjectListEnterFinished(NFDataList() << self, NFDataList() << identOld); } //bc others data to u for (int i = 0; i < valueAllNewPlayerListNoSelf.GetCount(); i++) { NFGUID identOld = valueAllNewPlayerListNoSelf.Object(i); OnPropertyEnter(NFDataList() << self, identOld); OnRecordEnter(NFDataList() << self, identOld); OnObjectListEnterFinished(NFDataList() << self, NFDataList() << identOld); } //bc u data to others OnPropertyEnter(valueAllNewPlayerListNoSelf, self); OnRecordEnter(valueAllNewPlayerListNoSelf, self); OnObjectListEnterFinished(valueAllNewPlayerListNoSelf, NFDataList() << self); } else { if (nOldGroupID > 0) { //example3: 5 -> 0 ==> new_group <= 0 && old_group > 0 //step1: leave NFDataList valueAllOldNPCListNoSelf; NFDataList valueAllOldPlayerListNoSelf; m_pKernelModule->GetGroupObjectList(nSceneID, nOldGroupID, valueAllOldNPCListNoSelf, false, self); m_pKernelModule->GetGroupObjectList(nSceneID, nOldGroupID, valueAllOldPlayerListNoSelf, true, self); OnObjectListLeave(valueAllOldPlayerListNoSelf, NFDataList() << self); OnObjectListLeave(NFDataList() << self, valueAllOldPlayerListNoSelf); OnObjectListLeave(NFDataList() << self, valueAllOldNPCListNoSelf); } } return 0; }
int NFCSceneAOIModule::OnClassCommonEvent(const NFGUID & self, const std::string & strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFDataList & var) { if (CLASS_OBJECT_EVENT::COE_DESTROY == eClassEvent) { const int nObjectSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::IObject::SceneID()); const int nObjectGroupID = m_pKernelModule->GetPropertyInt32(self, NFrame::IObject::GroupID()); if (nObjectGroupID < 0 || nObjectSceneID <= 0) { return 0; } NFDataList valueAllPlayrNoSelfList; m_pKernelModule->GetGroupObjectList(nObjectSceneID, nObjectGroupID, valueAllPlayrNoSelfList, true, self); //tell other people that you want to leave from this scene or this group //every one want to know you want to leave notmater you are a monster maybe you are a player OnObjectListLeave(valueAllPlayrNoSelfList, NFDataList() << self); } else if (CLASS_OBJECT_EVENT::COE_CREATE_NODATA == eClassEvent) { } else if (CLASS_OBJECT_EVENT::COE_CREATE_LOADDATA == eClassEvent) { } else if (CLASS_OBJECT_EVENT::COE_CREATE_HASDATA == eClassEvent) { if (strClassName == NFrame::Player::ThisName()) { //tell youself<client>, u want to enter this scene or this group OnObjectListEnter(NFDataList() << self, NFDataList() << self); //tell youself<client>, u want to broad your properties and records to youself OnPropertyEnter(NFDataList() << self, self); OnRecordEnter(NFDataList() << self, self); OnObjectListEnterFinished(NFDataList() << self, NFDataList() << self); } else { const int nObjectSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::IObject::SceneID()); const int nObjectGroupID = m_pKernelModule->GetPropertyInt32(self, NFrame::IObject::GroupID()); if (nObjectGroupID < 0 || nObjectSceneID <= 0) { return 0; } NFDataList valueAllPlayrObjectList; m_pKernelModule->GetGroupObjectList(nObjectSceneID, nObjectGroupID, valueAllPlayrObjectList, true); //monster or others need to tell all player OnObjectListEnter(valueAllPlayrObjectList, NFDataList() << self); OnPropertyEnter(valueAllPlayrObjectList, self); OnObjectListEnterFinished(valueAllPlayrObjectList, NFDataList() << self); } } else if (CLASS_OBJECT_EVENT::COE_CREATE_FINISH == eClassEvent) { } return 0; }
bool NFCSceneAOIModule::CreateSceneNPC(const int nSceneID, const int nGroupID) { return CreateSceneNPC(nSceneID, nGroupID, NFDataList()); }
bool NFCHeroModule::CreateHero(const NFGUID& self, const NFGUID& xHeroID) { if (xHeroID.IsNull()) { return false; } const int nSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::SceneID()); const int nGroupID = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::GroupID()); E_SCENE_TYPE eSceneType = (E_SCENE_TYPE)m_pElementModule->GetPropertyInt(std::to_string(nSceneID), NFrame::Scene::Type()); if (eSceneType == E_SCENE_TYPE::SCENE_TYPE_ERROR) { return false; } NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName()); if (nullptr == pHeroRecord.get()) { return false; } int nRow = pHeroRecord->FindObject(NFrame::Player::PlayerHero::GUID, xHeroID); if (nRow < 0) { return false; } const std::string& strConfigID = pHeroRecord->GetString(nRow, NFrame::Player::PlayerHero::ConfigID); NFDataList varList; int nCamp = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::Camp()); varList << NFrame::NPC::Camp() << nCamp; varList << NFrame::NPC::MasterID() << self; NF_SHARE_PTR<NFIObject> pHero = m_pKernelModule->CreateObject(xHeroID, nSceneID, nGroupID, NFrame::NPC::ThisName(), strConfigID, NFDataList()); if (!pHero) { return false; } return true; }
bool NFCClassModule::AddRecords(rapidxml::xml_node<>* pRecordRootNode, NF_SHARE_PTR<NFIClass> pClass) { for (rapidxml::xml_node<>* pRecordNode = pRecordRootNode->first_node(); pRecordNode; pRecordNode = pRecordNode->next_sibling()) { if (pRecordNode) { const char* pstrRecordName = pRecordNode->first_attribute("Id")->value(); if (pClass->GetRecordManager()->GetElement(pstrRecordName)) { //error //file << pClass->mstrType << ":" << pstrRecordName << std::endl; //assert(0); NFASSERT(0, pstrRecordName, __FILE__, __FUNCTION__); continue; } const char* pstrRow = pRecordNode->first_attribute("Row")->value(); const char* pstrCol = pRecordNode->first_attribute("Col")->value(); const char* pstrPublic = pRecordNode->first_attribute("Public")->value(); const char* pstrPrivate = pRecordNode->first_attribute("Private")->value(); const char* pstrSave = pRecordNode->first_attribute("Save")->value(); const char* pstrCache = pRecordNode->first_attribute("Cache")->value(); const char* pstrUpload = pRecordNode->first_attribute("Upload")->value(); std::string strView; if (pRecordNode->first_attribute("View") != NULL) { strView = pRecordNode->first_attribute("View")->value(); } bool bPublic = lexical_cast<bool>(pstrPublic); bool bPrivate = lexical_cast<bool>(pstrPrivate); bool bSave = lexical_cast<bool>(pstrSave); bool bCache = lexical_cast<bool>(pstrCache); bool bUpload = lexical_cast<bool>(pstrUpload); NF_SHARE_PTR<NFDataList> recordVar(NF_NEW NFDataList()); NF_SHARE_PTR<NFDataList> recordTag(NF_NEW NFDataList()); for (rapidxml::xml_node<>* recordColNode = pRecordNode->first_node(); recordColNode; recordColNode = recordColNode->next_sibling()) { //const char* pstrColName = recordColNode->first_attribute( "Id" )->value(); NFData TData; const char* pstrColType = recordColNode->first_attribute("Type")->value(); if (TDATA_UNKNOWN == ComputerType(pstrColType, TData)) { //assert(0); NFASSERT(0, pstrRecordName, __FILE__, __FUNCTION__); } recordVar->Append(TData); ////////////////////////////////////////////////////////////////////////// if (recordColNode->first_attribute("Tag") != NULL) { const char* pstrTag = recordColNode->first_attribute("Tag")->value(); recordTag->Add(pstrTag); } else { recordTag->Add(""); } } NF_SHARE_PTR<NFIRecord> xRecord = pClass->GetRecordManager()->AddRecord(NFGUID(), pstrRecordName, recordVar, recordTag, atoi(pstrRow)); xRecord->SetPublic(bPublic); xRecord->SetPrivate(bPrivate); xRecord->SetSave(bSave); xRecord->SetCache(bCache); xRecord->SetUpload(bUpload); } } return true; }
void NFCCreateRoleModule::OnDBLoadRoleDataProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFGUID nClientID; NFMsg::RoleDataPack xMsg; if (!m_pNetModule->ReceivePB(nMsgID, msg, nLen, xMsg, nClientID)) { //releasing all the resource that allow when the user login, then kick off the user // TODO //m_pGameServerNet_ServerModule->RemovePlayerGateInfo(); //Avtually, the developer may not know the user id in this situation, therefore the developer must record the login-time when the user coming //and check the time per min to kick off the user who are not active. return; } NFGUID nRoleID = NFINetModule::PBToNF(xMsg.id()); if (m_pKernelModule->GetObject(nRoleID)) { //it should be rebind with proxy's netobject m_pKernelModule->DestroyObject(nRoleID); } mxObjectDataCache[nRoleID] = xMsg; NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateBaseInfo> pGateInfo = m_pGameServerNet_ServerModule->GetPlayerGateInfo(nRoleID); if (nullptr != pGateInfo) { if (pGateInfo->eStatus == NFIGameServerNet_ServerModule::GateBaseInfo::E_LOADING) { pGateInfo->eStatus = NFIGameServerNet_ServerModule::GateBaseInfo::E_LOADED; } } NFDataList var; var.AddString(NFrame::Player::GateID()); var.AddInt(pGateInfo->nGateID); var.AddString(NFrame::Player::GameID()); var.AddInt(pPluginManager->GetAppID()); var.AddString(NFrame::Player::HomeSceneID()); var.AddInt(1); var.AddString(NFrame::Player::SceneID()); var.AddInt(1); NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(nRoleID, 1, 0, NFrame::Player::ThisName(), "", var); if (nullptr == pObject) { //mRoleBaseData //mRoleFDData mxObjectDataCache.erase(nRoleID); return; } //get data first then create player m_pSceneProcessModule->RequestEnterScene(pObject->Self(), 1, -1, 0, NFDataList()); }
void NFCCreateRoleModule::OnClienEnterGameProcess(const NFSOCK nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFGUID nClientID; NFMsg::ReqEnterGameServer xMsg; if (!m_pNetModule->ReceivePB( nMsgID, msg, nLen, xMsg, nClientID)) { return; } NFGUID nRoleID = NFINetModule::PBToNF(xMsg.id()); if (m_pKernelModule->GetObject(nRoleID)) { //it should be rebind with proxy's netobject m_pKernelModule->DestroyObject(nRoleID); } ////////////////////////////////////////////////////////////////////////// NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateBaseInfo> pGateInfo = m_pGameServerNet_ServerModule->GetPlayerGateInfo(nRoleID); if (nullptr != pGateInfo) { m_pGameServerNet_ServerModule->RemovePlayerGateInfo(nRoleID); } NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateServerInfo> pGateServerinfo = m_pGameServerNet_ServerModule->GetGateServerInfoBySockIndex(nSockIndex); if (nullptr == pGateServerinfo) { return; } int nGateID = -1; if (pGateServerinfo->xServerData.pData) { nGateID = pGateServerinfo->xServerData.pData->server_id(); } if (nGateID < 0) { return; } if (!m_pGameServerNet_ServerModule->AddPlayerGateInfo(nRoleID, nClientID, nGateID)) { return; } if (m_pPlayerRedisModule->LoadPlayerData(nRoleID)) { int nHomeSceneID = m_pPlayerRedisModule->GetPlayerHomeSceneID(nRoleID); if (nHomeSceneID <= 0) { nHomeSceneID = m_pPVPModule->RandomTileScene(); } NFDataList var; var.AddString(NFrame::Player::Name()); var.AddString(xMsg.name()); var.AddString(NFrame::Player::GateID()); var.AddInt(nGateID); var.AddString(NFrame::Player::GameID()); var.AddInt(pPluginManager->GetAppID()); var.AddString(NFrame::Player::HomeSceneID()); var.AddInt(nHomeSceneID); var.AddString(NFrame::Player::SceneID()); var.AddInt(nHomeSceneID); var.AddString(NFrame::Player::ViewOppnent()); var.AddObject(nRoleID); NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(nRoleID, nHomeSceneID, 0, NFrame::Player::ThisName(), "", var); if (nullptr == pObject) { //mRoleBaseData //mRoleFDData return; } //get data first then create player m_pSceneProcessModule->RequestEnterScene(pObject->Self(), nHomeSceneID, -1, 0, NFDataList()); } }
bool NFCItemModule::UseItem(const NFGUID & self, const std::string & strItemID, const NFGUID & xTargetID) { int nCount = 1; if (!m_pElementModule->ExistElement(strItemID) || !m_pKernelModule->GetObject(xTargetID)) { return false; } if (!ConsumeDataItemProperty(self, strItemID)) { return false; } if (!m_pPackModule->DeleteItem(self, strItemID, nCount)) { return false; } NFMsg::EItemType eItemType = (NFMsg::EItemType)m_pElementModule->GetPropertyInt(strItemID, NFrame::Item::ItemType()); NF_SHARE_PTR<NFIItemConsumeProcessModule> pConsumeProcessModule = m_pItemConsumeManagerModule->GetConsumeModule(eItemType); if (!pConsumeProcessModule) { return false; } switch (eItemType) { case NFMsg::EItemType::EIT_CARD: case NFMsg::EItemType::EIT_EQUIP: case NFMsg::EItemType::EIT_GEM: case NFMsg::EItemType::EIT_TOKEN: { if (pConsumeProcessModule->ConsumeLegal(self, strItemID, NFDataList()) == 0) { pConsumeProcessModule->ConsumeProcess(self, strItemID, NFDataList()); } } break; case NFMsg::EItemType::EIT_ITEM: { NFDataList xTarget; xTarget.AddObject(xTargetID); xTarget.AddString(strItemID); //this is Item Config ID xTarget.AddInt(nCount); //this is Item Count to Consume if (pConsumeProcessModule->ConsumeLegal(self, strItemID, xTarget) == 0) { pConsumeProcessModule->ConsumeProcess(self, strItemID, xTarget); } } break; break; default: break; } /* AddItemEffectDataProperty(self, xTargetID, strItemID); const std::string& strAwardPackID = m_pElementModule->GetPropertyString(strItemID, "AwardData"); if (!strAwardPackID.empty()) { DoAwardPack( self, strAwardPackID); } */ return false; }