bool NFCPackModule::CreateItemInTempBag(const NFGUID & self, const std::string & strConfigName, const int nCount) { NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::TempItemList::ThisName()); if (nullptr == pRecord) { return false; } NFDataList varFindResult; int nFindRowCount = pRecord->FindString(NFrame::Player::TempItemList::ConfigID, strConfigName, varFindResult); if (nFindRowCount <= 0) { NF_SHARE_PTR<NFDataList> xRowData = pRecord->GetInitData(); xRowData->SetString(NFrame::Player::TempItemList::ConfigID, strConfigName); xRowData->SetInt(NFrame::Player::TempItemList::ItemCount, nCount); pRecord->AddRow(-1, *xRowData); } else { int nFindRow = varFindResult.Int32(0); int nOldCount = pRecord->GetInt32(nFindRow, NFrame::Player::TempItemList::ItemCount); int nNewCount = nOldCount + nCount; pRecord->SetInt(nFindRow, NFrame::Player::TempItemList::ItemCount, nNewCount); } return true; }
bool NFCPackModule::DeleteItem( const NFGUID& self, const std::string& strItemConfigID, const int nCount ) { if(nCount <= 0) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); if ( NULL == pObject ) { return false; } if (!m_pElementModule->ExistElement(NFrame::Item::ThisName(), strItemConfigID)) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::BagItemList::ThisName() ); if (!pRecord) { return false; } NFDataList varFindResult; int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList::ConfigID, strItemConfigID, varFindResult); if (nFindRowCount > 0) { int nNeedDelCount = nCount; for (int i = 0; i < varFindResult.GetCount(); ++i) { int nFindRow = varFindResult.Int32(i); int nOldCount = pRecord->GetInt32(nFindRow, NFrame::Player::BagItemList::ItemCount); if (nOldCount > nNeedDelCount) { int nNewCount = nOldCount - nNeedDelCount; pRecord->SetInt(nFindRow, NFrame::Player::BagItemList::ItemCount, nNewCount); nNeedDelCount = 0; } else if (nOldCount == nNeedDelCount) { pRecord->Remove(nFindRow); nNeedDelCount = 0; } else if (nOldCount < nNeedDelCount) { pRecord->Remove(nFindRow); nNeedDelCount -= nOldCount; } } if (nNeedDelCount <= 0) { return true; } } return false; }
bool NFCSceneAOIModule::DestroySceneNPC(const int nSceneID, const int nGroupID) { NF_SHARE_PTR<NFCSceneInfo> pSceneInfo = GetElement(nSceneID); if (pSceneInfo) { if (pSceneInfo->GetElement(nGroupID)) { NFDataList xMonsterlistObject; if (m_pKernelModule->GetGroupObjectList(nSceneID, nGroupID, xMonsterlistObject, false)) { for (int i = 0; i < xMonsterlistObject.GetCount(); ++i) { NFGUID ident = xMonsterlistObject.Object(i); m_pKernelModule->DestroyObject(ident); } } pSceneInfo->RemoveElement(nGroupID); return true; } } return false; }
bool NFCSLGBuildingModule::GetProduceDataCount( const NFGUID& self, const NFGUID& xBuilID, const std::string& strItemID, int& nCount ) { NF_SHARE_PTR<NFIRecord> pProduce = m_pKernelModule->FindRecord(self, "BuildingProduce"); if (NULL == pProduce.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingProduce] Record!", "", __FUNCTION__, __LINE__); return false; } NFDataList varProduce; pProduce->FindObject("BuildingGUID", xBuilID, varProduce); if(varProduce.GetCount() <= 0) { nCount = 0; return true; } for (int i = 0; i< varProduce.GetCount(); i++) { const std::string& strHasItemID = pProduce->GetString(i, "ItemID"); if (strHasItemID == strItemID) { const int nOldCount = pProduce->GetInt(i, "LeftCount"); nCount = pProduce->GetInt(i, "LeftCount"); return true; } } return false; }
bool NFCTeamModule::MemberOffline( const NFGUID& self, const NFGUID& xTeam ) { NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->GetCacheRecordInfo(xTeam, 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; } const int nRow = varList.Int32(0); pMemberRecord->SetInt(nRow, NFrame::Team::MemberList::Online, 0); pMemberRecord->SetInt(nRow, NFrame::Team::MemberList::GameID, 0); return m_pCommonRedisModule->SaveCacheRecordInfo(xTeam, pRecordManager); }
int NFCSLGBuildingModule::Boost(const NFGUID& self, const NFGUID& xBuilID) { NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, "BuildingList"); if (NULL == pRecord.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingList] Record!", "", __FUNCTION__, __LINE__); return 1; } NFDataList var; pRecord->FindObject("BuildingGUID", xBuilID, var); if (var.GetCount() <= 0) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "there are no the building", xBuilID.ToString(), __FUNCTION__, __LINE__); return 1; } const int nRow = var.Int(0); const int nBoostTime = 20; const std::string strBuildID = pRecord->GetString(nRow, "BuildingID"); //NFDataList varHeart; //varHeart << xBuilID; m_pScheduleModule->AddSchedule(self, "OnBoostHeartBeat", this, &NFCSLGBuildingModule::OnBoostHeartBeat, /*varHeart,*/ nBoostTime, 1); pRecord->SetInt(nRow, "State", NFMsg::EBS_BOOST); pRecord->SetInt(nRow, "StateStartTime", pPluginManager->GetNowTime()); pRecord->SetInt(nRow, "StateEndTime", pPluginManager->GetNowTime() + nBoostTime); return 0; }
bool NFCGuildModule::GetOnlineMember( const NFGUID& self, const NFGUID& xGuild, NFDataList& varMemberList, NFDataList& varGameList) { NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuild); if (!pGuildObject.get()) { return false; } NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuild, NFrame::Guild::R_GuildMemberList()); if (!pMemberRecord.get()) { return false; } for (int i = 0; i< pMemberRecord->GetRows(); i++) { if (!pMemberRecord->IsUsed(i)) { continue; } const NFINT64 nOnline = pMemberRecord->GetInt(i, NFrame::Guild::GuildMemberList_Online); const NFINT64 nGameID = pMemberRecord->GetInt(i, NFrame::Guild::GuildMemberList_GameID); const NFGUID& xID = pMemberRecord->GetObject(i, NFrame::Guild::GuildMemberList_GUID); if (nOnline > 0 && !xID.IsNull()) { varMemberList.Add(xID); varGameList.Add(nGameID); } } return true; }
bool NFCGuildModule::KickGuildMmember( const NFGUID& self, const NFGUID& xGuildID, const NFGUID& xMmember ) { 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; } if (self == xMmember) { return false; } CheckPower(self, xGuildID, NFMsg::ReqAckOprGuildMember::EGAT_KICK); NFDataList varList; pMemberRecord->FindObject(NFrame::Guild::GuildMemberList_GUID, self, varList); if (varList.GetCount() == 0) { return false; } const int nRow = varList.Int(0); pMemberRecord->Remove(nRow); return true; }
bool NFCPackModule::DeleteEquip( const NFGUID& self, const NFGUID& id ) { if (id.IsNull()) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); if (nullptr == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::BagEquipList::ThisName() ); if (nullptr == pRecord) { return false; } NFDataList varFindResult; int nFindRowCount = pRecord->FindObject(NFrame::Player::BagEquipList::GUID, id, varFindResult); if (nFindRowCount > 0) { //int nTotalCount = 0; for (int i = 0; i < varFindResult.GetCount(); ++i) { int nFindRow = varFindResult.Int32(i); pRecord->Remove(nFindRow); } } return true; }
bool NFCGuildModule::LeaveGuild( 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 int nRow = varList.Int(0); return pMemberRecord->Remove(nRow); }
bool NFCGuildModule::UpGuildMmember( const NFGUID& self, const NFGUID& xGuildID, const NFGUID& xMmember ) { 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; } CheckPower(self, xGuildID, NFMsg::ReqAckOprGuildMember::EGAT_UP); NFDataList varList; pMemberRecord->FindObject(NFrame::Guild::GuildMemberList_GUID, self, varList); if (varList.GetCount() == 0) { return false; } const int nRow = varList.Int(0); const int nPower = pMemberRecord->GetInt(nRow, NFrame::Guild::GuildMemberList_Power); if (nPower >= NFMsg::GUILD_POWER_TYPE_PRESIDENT) { return false; } pMemberRecord->SetInt(nRow, NFrame::Guild::GuildMemberList_Power, (nPower + 1)) ; return true; }
int NFCSLGBuildingModule::Produce(const NFGUID& self, const NFGUID& xBuilID, const std::string& strItemID, const int nCount) { NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, "BuildingList"); if (NULL == pRecord.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingList] Record!", "", __FUNCTION__, __LINE__); return 1; } NFDataList var; pRecord->FindObject("BuildingGUID", xBuilID, var); if (var.GetCount() <= 0) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "there are no the building", xBuilID.ToString(), __FUNCTION__, __LINE__); return 1; } AddProduceData(self, xBuilID, strItemID, nCount); const std::string strHeartname = GetProduceHeartName(self, xBuilID, strItemID); const int nTime = 50;//To ADD if (!m_pScheduleModule->ExistSchedule(self, strHeartname)) { //NFDataList varHeart; //varHeart << xBuilID; //varHeart << strItemID; m_pScheduleModule->AddSchedule(self, strHeartname, this, &NFCSLGBuildingModule::OnProduceHeartBeat, /*varHeart, */nTime, nCount); } return 0; }
bool NFCSceneAOIModule::CreateSceneNPC(const int nSceneID, const int nGroupID, const NFDataList& argList) { NF_SHARE_PTR<NFCSceneInfo> pSceneInfo = GetElement(nSceneID); if (!pSceneInfo) { return false; } //prepare monster for player //create monster before the player enter the scene, then we can send monster's data by one message pack //if you create monster after player enter scene, then send monster's data one by one NF_SHARE_PTR<SceneSeedResource> pResource = pSceneInfo->mtSceneResourceConfig.First(); for (; pResource; pResource = pSceneInfo->mtSceneResourceConfig.Next()) { int nWeight = m_pKernelModule->Random(0, 100); if (nWeight <= pResource->nWeight) { const std::string& strClassName = m_pElementModule->GetPropertyString(pResource->strConfigID, NFrame::IObject::ClassName()); NFDataList arg; arg << NFrame::IObject::Position() << pResource->vSeedPos; arg << NFrame::NPC::SeedID() << pResource->strSeedID; arg.Append(argList); m_pKernelModule->CreateObject(NFGUID(), nSceneID, nGroupID, strClassName, pResource->strConfigID, arg); } } return false; }
bool NFCTeamModule::LeaveTeam( 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; } const int nRow = varList.Int32(0); if (!pMemberRecord->Remove(nRow)) { return false; } return m_pCommonRedisModule->SaveCacheRecordInfo(xTeamID, pRecordManager); }
bool NFCGuildModule::MemberOffline( const NFGUID& self, const NFGUID& xGuild ) { NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuild); if (!pGuildObject.get()) { return false; } NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuild, 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 int nRow = varList.Int(0); pMemberRecord->SetInt(nRow, NFrame::Guild::GuildMemberList_Online, 0); pMemberRecord->SetInt(nRow, NFrame::Guild::GuildMemberList_GameID, 0); return true; }
bool NFCHeroModule::AddHeroExp(const NFGUID& self, const NFGUID& xHeroID, const int64_t nExp) { NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName()); if (nullptr == pHeroRecord.get()) { return false; } if (xHeroID.IsNull()) { return false; } if (nExp <= 0) { return false; } int nRow = pHeroRecord->FindObject(NFrame::Player::PlayerHero::GUID, xHeroID); if (nRow < 0) { return false; } NFDataList varRowData; if (!pHeroRecord->QueryRow(nRow, varRowData)) { return false; } const int64_t nCurExp = varRowData.Int(NFrame::Player::PlayerHero::Exp); const int nBeforeLevel = varRowData.Int32(NFrame::Player::PlayerHero::Level); int64_t nLeftExp = nCurExp + nExp; int nAfterLevel = nBeforeLevel; for (int i = nBeforeLevel; i < ECONSTDEFINE_HERO_MAXLEVEL; i++) { const int64_t nNeedExp = (i + 1) * ECONSTDEFINE_HERO_ONCELEVEEXP; if (nLeftExp >= nNeedExp) { nAfterLevel += 1; nLeftExp -= nNeedExp; pHeroRecord->SetInt(nRow, NFrame::Player::PlayerHero::Level, nAfterLevel); } else { break; } } pHeroRecord->SetInt(nRow, NFrame::Player::PlayerHero::Exp, nLeftExp); return true; }
bool NFPatrolState::RandomPatrol(const NFGUID& self, NFIStateMachine* pStateMachine) { //首先,得看有没路径 //没有的话,随机找个地址走吧(以出生点为中心开始找,种子地址)NPCConfigID const std::string& strConfigID = m_pKernelModule->GetPropertyString(self, "NPCConfigID"); const std::string& strNPCID = m_pKernelModule->GetPropertyString(self, "ConfigID"); if (!strConfigID.empty()) { NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = m_pElementModule->GetPropertyManager(strConfigID); if (xPropertyManager) { NF_SHARE_PTR<NFIProperty> xPropertyX = xPropertyManager->GetElement("SeedX"); NF_SHARE_PTR<NFIProperty> xPropertyY = xPropertyManager->GetElement("SeedY"); NF_SHARE_PTR<NFIProperty> xPropertyZ = xPropertyManager->GetElement("SeedZ"); double fCurX = xPropertyX->GetFloat(); double fCurY = xPropertyY->GetFloat(); double fCurZ = xPropertyZ->GetFloat(); double fPosOffestX = (double)(rand() / double(RAND_MAX) - 0.5); double fPosOffestZ = (double)(rand() / double(RAND_MAX) - 0.5); fPosOffestX *= 10; fPosOffestZ *= 10; fCurX += fPosOffestX; fCurZ += fPosOffestZ; //if (fCurX > 0.0f && fCurZ > 0.0f) { //看能否寻路,不能寻路则重来 NFAI_STATE eStateType = NFAI_STATE::ChaseState; double fRand = (double)(rand() / double(RAND_MAX)); if (fRand < 0.5f) { eStateType = NFAI_STATE::ChaseState; } NFDataList valueList; valueList.AddFloat(fCurX); valueList.AddFloat(fCurY); valueList.AddFloat(fCurZ); //m_pKernelModule->DoEvent(self, NFED_ON_CLIENT_REQUIRE_MOVE, valueList); m_pKernelModule->SetPropertyFloat(self, "X", fCurX); m_pKernelModule->SetPropertyFloat(self, "Y", fCurY); m_pKernelModule->SetPropertyFloat(self, "Z", fCurZ); return true; } } } return false; }
int NFCRecord::FindVector3(const std::string & strColTag, const NFVector3 & value) { NFDataList xDataList; int nRowCount = FindVector3(strColTag, value, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
int NFCRecord::FindVector3(const int nCol, const NFVector3 & value) { NFDataList xDataList; int nRowCount = FindVector3(nCol, value, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
int NFCRecord::FindString(const int nCol, const std::string & value) { NFDataList xDataList; int nRowCount = FindString(nCol, value, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
int NFCRecord::FindFloat(const int nCol, const double value) { NFDataList xDataList; int nRowCount = FindFloat(nCol, value, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
int NFCRecord::FindRowByColValue(const int nCol, const NFData & var) { NFDataList xDataList; int nRowCount = FindRowByColValue(nCol, var, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
int NFCRecord::FindRowByColValue(const std::string & strColTag, const NFData & var) { NFDataList xDataList; int nRowCount = FindRowByColValue(strColTag, var, xDataList); if (nRowCount > 0 && xDataList.GetCount() > 0) { return (int) xDataList.Int(0); } return -1; }
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); }
int NFCRecord::FindVector3(const int nCol, const NFVector3& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_VECTOR3 != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetVector3(i, nCol) == value) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
int NFCRecord::FindString(const int nCol, const std::string& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_STRING != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } const std::string& strData = GetString(i, nCol); if (0 == strcmp(strData.c_str(), value.c_str())) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
int NFCRecord::FindFloat(const int nCol, const double value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_FLOAT != mVarRecordType->Type(nCol)) { return -1; } for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetFloat(i, nCol) == value) { varResult << i; } } return varResult.GetCount(); }
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); } }
int NFCSLGBuildingModule::AddProduceData(const NFGUID& self, const NFGUID& xBuilID, const std::string& strItemID, const int nCount) { NF_SHARE_PTR<NFIRecord> pProduce = m_pKernelModule->FindRecord(self, "BuildingProduce"); if (NULL == pProduce.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingProduce] Record!", "", __FUNCTION__, __LINE__); return 1; } NFDataList varProduce; pProduce->FindObject("BuildingGUID", xBuilID, varProduce); int nFindRow = -1; for (int i = 0; i< varProduce.GetCount(); i++) { const std::string& strHasItemID = pProduce->GetString(i, "ItemID"); if (strHasItemID == strItemID) { nFindRow = i; break; } } if (nFindRow < 0) { //already exit const int nOldCount = pProduce->GetInt(nFindRow, "LeftCount"); pProduce->SetInt(nFindRow, "LeftCount", nOldCount + nCount); } else { const int nTime = 20; NFDataList varItem; varItem << xBuilID; varItem << strItemID; varItem << nCount; varItem << nTime; varItem << pPluginManager->GetNowTime(); pProduce->AddRow(-1, varItem); } return 0; }
bool NFCWorldNet_ServerModule::SendMsgToGame(const NFDataList& argObjectVar, const NFDataList& argGameID, const NFMsg::EGameMsgID eMsgID, google::protobuf::Message& xData) { if (argGameID.GetCount() != argObjectVar.GetCount()) { return false; } for (int i = 0; i < argObjectVar.GetCount(); i++) { const NFGUID& identOther = argObjectVar.Object(i); const int nGameID = (int) argGameID.Int(i); SendMsgToGame(nGameID, eMsgID, xData, identOther); } return true; }