bool NFCEquipModule::DressEquipForHero(const NFGUID& self, const NFGUID& hero, const NFGUID& id) { if (id.IsNull() || self.IsNull() || hero.IsNull()) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pBagRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pBagRecord) { return false; } NF_SHARE_PTR<NFIRecord> pHeroRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_PlayerHero()); if (!pHeroRecord) { return false; } NFCDataList xEquipDataList; pBagRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xEquipDataList); if (xEquipDataList.GetCount() != 1) { return false; } NFCDataList xHeroDataList; pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, hero, xHeroDataList); if (xHeroDataList.GetCount() != 1) { return false; } const int nEquipRow = xEquipDataList.Int(0); const int nHeroRow = xHeroDataList.Int(0); const std::string& strEquipID = pBagRecord->GetString(nEquipRow, NFrame::Player::BagEquipList_ConfigID); const int nEquipPos = m_pElementModule->GetPropertyInt(strEquipID, NFrame::Equip::ItemSubType()); if (nEquipRow < 0 || nHeroRow < 0 || strEquipID.empty() || nEquipPos < 0 || nEquipPos > (NFrame::Player::PlayerHero_Equip6 - NFrame::Player::PlayerHero_Equip1)) { return false; } //so there have any bind? //hero, position pHeroRecord->SetObject(nHeroRow, nEquipPos + NFrame::Player::PlayerHero_Equip1, id); pBagRecord->SetObject(nEquipRow, NFrame::Player::BagEquipList_WearGUID, hero); return false; }
bool NFCWorldChatGroupModule::JoinGroup( const NFGUID& self, const NFGUID& xGroupID ) { NF_SHARE_PTR<NFIObject> pGroup = GetGroup(xGroupID); if (NULL == pGroup) { return false; } NF_SHARE_PTR<NFIRecord>pRecord = pGroup->GetRecordManager()->GetElement("GroupMemberList"); if (NULL == pRecord) { return false; } NFCDataList varFind; if (pRecord->FindObject(0, self, varFind) > 0) { return false; } NFCDataList varRow; varRow << self << 0 << 0; int nRet = pRecord->AddRow(-1, varRow); if (nRet >= 0) { return true; } return false; }
int NFCEquipModule::GetEquipElementLevel(const NFGUID & self, const NFGUID & id, NFrame::Player::BagEquipList eIndex) { if (id.IsNull() || self.IsNull()) { return -1; } if (eIndex > NFrame::Player::BagEquipList_ElementLevel5_POISON || eIndex < NFrame::Player::BagEquipList_ElementLevel1_FIRE) { return -1; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return -1; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pRecord) { return -1; } NFCDataList xDataList; pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList); if (xDataList.GetCount() != 1) { return -1; } const int nRow = xDataList.Int(0); return pRecord->GetInt(nRow, eIndex); }
bool NFCEquipModule::AddEquipIntensifyLevel(const NFGUID& self, const NFGUID& id) { if (id.IsNull() || self.IsNull()) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pRecord) { return false; } NFCDataList xDataList; pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList); if (xDataList.GetCount() != 1) { return false; } const int nRow = xDataList.Int(0); const int nLevel = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel); pRecord->SetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel, nLevel + 1); return true; }
bool HelloWorld6Module::AfterInit() { //初始化完毕 std::cout << "Hello, world6, AfterInit" << std::endl; m_pKernelModule = pPluginManager->FindModule<NFIKernelModule>("NFCKernelModule"); m_pEventProcessModule = pPluginManager->FindModule<NFIEventProcessModule>("NFCEventProcessModule"); m_pElementInfoModule = pPluginManager->FindModule<NFIElementInfoModule>("NFCElementInfoModule"); m_pLuaScriptModule = pPluginManager->FindModule<NFILuaScriptModule>("NFCLuaScriptModule"); //assert( NULL != m_pLuaScriptModule); m_pKernelModule->CreateScene(1, ""); NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(NFGUID(), 1, 0, "Player", "", NFCDataList()); if ( !pObject.get() ) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement("TaskList"); if ( pRecord.get() ) { NFCDataList var; var << "Task_From_C++"; var << 0; pRecord->AddRow(-1, var); } pObject->SetPropertyInt("MAXHP",100); m_pEventProcessModule->DoEvent(pObject->Self(), 2222, NFCDataList()); return true; }
int NFCEquipModule::GetEquipHoleCount(const NFGUID & self, const NFGUID & id) { if (id.IsNull() || self.IsNull()) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pRecord) { return false; } NFCDataList xDataList; pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList); if (xDataList.GetCount() != 1) { return false; } const int nRow = xDataList.Int(0); return pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount); }
int NFCPropertyTrailModule::TrailObjectData(const NFGUID& self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (nullptr == xObject) { return -1; } NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = xObject->GetPropertyManager(); if (nullptr != xPropertyManager) { NF_SHARE_PTR<NFIProperty> xProperty = xPropertyManager->First(); while (nullptr != xProperty) { m_pKernelModule->AddPropertyCallBack(self, xProperty->GetKey(), this, &NFCPropertyTrailModule::OnObjectPropertyEvent); xProperty = xPropertyManager->Next(); } } NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (nullptr != xRecordManager) { NF_SHARE_PTR<NFIRecord> xRecord = xRecordManager->First(); while (nullptr != xRecord) { m_pKernelModule->AddRecordCallBack(self, xRecord->GetName(), this, &NFCPropertyTrailModule::OnObjectRecordEvent); xRecord = xRecordManager->Next(); } } return 0; }
void NFCCreateRoleModule::AttachData(const NFGUID & self) { auto it = mxObjectDataCache.find(self); if (it != mxObjectDataCache.end()) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (xObject) { NF_SHARE_PTR<NFIPropertyManager> xPropManager = xObject->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (xPropManager) { ConvertPBToPropertyManager(it->second.property(), xPropManager); } if (xRecordManager) { ConvertPBToRecordManager(it->second.record(), xRecordManager); } mxObjectDataCache.erase(it); } } }
void NFCCreateRoleModule::SaveData(const NFGUID & self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (xObject) { NF_SHARE_PTR<NFIPropertyManager> xPropManager = xObject->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); NFMsg::RoleDataPack xDataPack; *xDataPack.mutable_id() = NFINetModule::NFToPB(self); *(xDataPack.mutable_property()->mutable_player_id()) = NFINetModule::NFToPB(self); *(xDataPack.mutable_record()->mutable_player_id()) = NFINetModule::NFToPB(self); if (xPropManager) { ConvertPropertyManagerToPB(xPropManager, xDataPack.mutable_property()); } if (xRecordManager) { ConvertRecordManagerToPB(xRecordManager, xDataPack.mutable_record()); } m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_DB, self.GetData(), NFMsg::EGMI_REQ_SAVE_ROLE_DATA, xDataPack); } }
bool NFCPackModule::DeleteEquip( const NFGUID& self, const NFGUID& id ) { if (id.IsNull()) { return false; } //删除3个地方,背包,英雄穿戴,玩家穿戴 NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); if (nullptr == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagEquipList() ); if (nullptr == pRecord) { return false; } NFCDataList varFindResult; int nFindRowCount = pRecord->FindObject(NFrame::Player::BagItemList_ConfigID, id, varFindResult); if (nFindRowCount > 0) { int nTotalCount = 0; for (int i = 0; i < varFindResult.GetCount(); ++i) { int nFindRow = varFindResult.Int(i); pRecord->Remove(nFindRow); } } 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::R_BagItemList() ); if (!pRecord) { return false; } NFCDataList 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.Int(i); int nOldCount = pRecord->GetInt(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 NFCWorldChatGroupModule::Offeline( const NFGUID& self, const NFGUID& xGroupID ) { NF_SHARE_PTR<NFIObject> pGroup = GetGroup(xGroupID); if (NULL == pGroup) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pGroup->GetRecordManager()->GetElement("GroupMemberList"); if (NULL == pRecord) { return false; } NFCDataList varList; if (pRecord->FindObject(NFrame::ChatGroup::GroupMemberList_GUID, self, varList) <= 0) { return false; } const int nRow = varList.Int(0); pRecord->SetInt(nRow, NFrame::ChatGroup::GroupMemberList_Online, 0); pRecord->SetInt(nRow, NFrame::ChatGroup::GroupMemberList_GameID, 0); return true; }
NF_SHARE_PTR<NFIRecordManager> NFCElementInfoModule::GetRecordManager(const std::string& strConfigName) { NF_SHARE_PTR<ElementConfigInfo> pElementInfo = GetElement(strConfigName); if (pElementInfo.get()) { return pElementInfo->GetRecordManager(); } return NULL; }
NF_SHARE_PTR<NFIRecordManager> NFCClassModule::GetClassRecordManager(const std::string& strClassName) { NF_SHARE_PTR<NFIClass> pClass = GetElement(strClassName); if (pClass) { return pClass->GetRecordManager(); } return NULL; }
int NFCPropertyTrailModule::LogObjectData(const NFGUID& self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (nullptr == xObject) { return -1; } NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = xObject->GetPropertyManager(); if (nullptr != xPropertyManager) { NF_SHARE_PTR<NFIProperty> xProperty = xPropertyManager->First(); while (nullptr != xProperty) { std::ostringstream stream; stream << " Start trail "; stream << xProperty->ToString(); m_pLogModule->LogProperty(NFILogModule::NF_LOG_LEVEL::NLL_INFO_NORMAL, self, xProperty->GetKey(), stream.str(), __FUNCTION__, __LINE__); xProperty = xPropertyManager->Next(); } } NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (nullptr != xRecordManager) { NF_SHARE_PTR<NFIRecord> xRecord = xRecordManager->First(); while (nullptr != xRecord) { for (int i = 0; i < xRecord->GetRows(); ++i) { NFCDataList xDataList; bool bRet = xRecord->QueryRow(i, xDataList); if (bRet) { std::ostringstream stream; stream << " Start trail Row[" << i << "]"; for (int j = 0; j < xDataList.GetCount(); ++j) { stream << " [" << j << "] " << xDataList.StringValEx(j); } m_pLogModule->LogRecord(NFILogModule::NF_LOG_LEVEL::NLL_INFO_NORMAL, self, xRecord->GetName(), stream.str(), __FUNCTION__, __LINE__); } } xRecord = xRecordManager->Next(); } } return 0; }
void NFCRecordLogic::OnSwapRow(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ObjectRecordSwap xMsg; if (!NFINetModule::ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NF_SHARE_PTR<NFIObject> object = g_pKernelModule->GetObject(NFINetModule::PBToNF(xMsg.player_id())); NF_SHARE_PTR<NFIRecordManager> recordMgr = object->GetRecordManager(); NF_SHARE_PTR<NFIRecord> record = recordMgr->GetElement(xMsg.origin_record_name()); record->SwapRowInfo(xMsg.row_origin(), xMsg.row_target()); }
bool NFCEquipModule::SetEquipInlayStoneID(const NFGUID& self, const NFGUID& id, NFrame::Player::BagEquipList eIndex, const std::string& strStoneID) { if (id.IsNull() || self.IsNull() || strStoneID.empty()) { return false; } if (eIndex > NFrame::Player::BagEquipList_InlayStone10 || eIndex < NFrame::Player::BagEquipList_InlayStone1) { return false; } if (!m_pElementModule->ExistElement(strStoneID)) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pRecord) { return false; } NFCDataList xDataList; pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList); if (xDataList.GetCount() != 1) { return false; } const int nRow = xDataList.Int(0); const int nSoltCount = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount); if ((eIndex - NFrame::Player::BagEquipList_InlayStone1) <= nSoltCount) { return false; } pRecord->SetString(nRow, eIndex, strStoneID); return true; }
bool NFCPackModule::CreateItem( const NFGUID& self, const std::string& strConfigName, const int nCount ) { if (nCount <= 0) { return 0; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); if ( NULL == pObject ) { return 0; } //还得确定有这个装备 bool bExist = m_pElementModule->ExistElement(NFrame::Item::ThisName(), strConfigName ); if ( !bExist ) { return 0; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagItemList() ); if (!pRecord) { return 0; } NFCDataList varFindResult; int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList_ConfigID, strConfigName, varFindResult); if (nFindRowCount <= 0) { NF_SHARE_PTR<NFIDataList> xRowData = pRecord->GetInitData(); xRowData->SetString(NFrame::Player::BagItemList_ConfigID, strConfigName); xRowData->SetInt(NFrame::Player::BagItemList_ItemCount, nCount); xRowData->SetInt(NFrame::Player::BagItemList_Date, NFTime::GetNowTime()); } else { int nFindRow = varFindResult.Int(0); int nOldCount = pRecord->GetInt(nFindRow, NFrame::Player::BagItemList_ItemCount); int nNewCount = nOldCount + nCount; pRecord->SetInt(nFindRow, NFrame::Player::BagItemList_ItemCount, nNewCount); } return 0; }
bool NFCPackModule::EnoughItem( 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; } //还得确定有这个装备 bool bExist = m_pElementModule->ExistElement(NFrame::Item::ThisName(), strItemConfigID ); if ( !bExist ) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagItemList() ); if (!pRecord) { return false; } NFCDataList varFindResult; int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList_ConfigID, strItemConfigID, varFindResult); if (nFindRowCount > 0) { int nTotalCount = 0; for (int i = 0; i < varFindResult.GetCount(); ++i) { int nFindRow = varFindResult.Int(i); int nOldCount = pRecord->GetInt(nFindRow, NFrame::Player::BagItemList_ItemCount); nTotalCount += nOldCount; } if (nTotalCount > 0) { return true; } } return false; }
void NFCRecordLogic::OnAddRow(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ObjectRecordAddRow xMsg; if (!NFINetModule::ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NF_SHARE_PTR<NFIObject> object = g_pKernelModule->GetObject(NFINetModule::PBToNF(xMsg.player_id())); NF_SHARE_PTR<NFIRecordManager> recordMgr = object->GetRecordManager(); for(int i = 0; i < xMsg.row_data_size(); i++) { AddRecord(object, xMsg.record_name(), xMsg.row_data(i)); } }
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); }
const NFGUID& NFCPackModule::CreateEquip( const NFGUID& self, const std::string& strConfigName ) { NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); if ( NULL == pObject ) { return NULL_OBJECT; } //还得确定有这个装备 bool bExist = m_pElementModule->ExistElement( strConfigName ); if ( !bExist ) { return NULL_OBJECT; } int nItemType = m_pElementModule->GetPropertyInt(strConfigName, NFrame::Item::ItemType()); if ( NFMsg::EItemType::EIT_EQUIP != nItemType ) { return NULL_OBJECT; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagEquipList() ); if (!pRecord) { return NULL_OBJECT; } NFGUID ident = m_pUUIDModule->CreateGUID(); NF_SHARE_PTR<NFIDataList> var = pRecord->GetInitData(); var->SetObject(NFrame::Player::BagEquipList_GUID, ident); var->SetString(NFrame::Player::BagEquipList_ConfigID, strConfigName.c_str()); var->SetInt(NFrame::Player::BagEquipList_Date, NFTime::GetNowTime()); int nAddRow = pRecord->AddRow(-1, *var); if (nAddRow > 0) { return pRecord->GetObject(nAddRow, NFrame::Player::BagEquipList_GUID); } return NULL_OBJECT; }
void NFCRecordLogic::OnRecordString(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ObjectRecordString xMsg; if (!NFINetModule::ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NF_SHARE_PTR<NFIObject> object = g_pKernelModule->GetObject(NFINetModule::PBToNF(xMsg.player_id())); NF_SHARE_PTR<NFIRecordManager> recordMgr = object->GetRecordManager(); for(int i = 0; i < xMsg.property_list_size(); i++) { NF_SHARE_PTR<NFIRecord> record = recordMgr->GetElement(xMsg.record_name()); const NFMsg::RecordString &recordString = xMsg.property_list(i); record->SetString(recordString.row(), recordString.col(), recordString.data()); } }
int NFCSLGBuildingModule::AddBuilding(const NFGUID& self, const std::string& strBuilding, const float fX, const float fY, const float fZ) { if (strBuilding.empty()) { return 1; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (!pObject.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no object!", "", __FUNCTION__, __LINE__); return 1; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement("BuildingList"); if (!pRecord.get()) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingList] Record!", "", __FUNCTION__, __LINE__); return 1; } NFDataList xDataList; xDataList << strBuilding; xDataList << m_pKernelModule->CreateGUID(); xDataList << NFMsg::EBS_IDLE;; // state xDataList << int(fX); // x xDataList << int(fY); // y xDataList << int(fZ); // z xDataList << pPluginManager->GetNowTime(); xDataList << int(0); if (0 > pRecord->AddRow(-1, xDataList)) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, strBuilding, "cannot be added, [BuildingList] Record is full!", __FUNCTION__, __LINE__); return 1; } return 0; }
bool NFCWorldChatGroupModule::QuitGroup( const NFGUID& self, const NFGUID& xGroupID ) { NF_SHARE_PTR<NFIObject> pChatGroup = GetGroup(xGroupID); if (pChatGroup == NULL) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pChatGroup->GetRecordManager()->GetElement("GroupMemberList"); if (pRecord == NULL) { return false; } NFCDataList varFind; if (pRecord->FindObject(NFrame::ChatGroup::GroupMemberList_GUID, self, varFind) > 0) { pRecord->Remove(varFind); } return true; }
bool NFCEquipModule::SetEquipRandPropertyID(const NFGUID& self, const NFGUID& id, const std::string& strPropertyID) { if (id.IsNull() || self.IsNull() || strPropertyID.empty()) { return false; } if (!m_pElementModule->ExistElement(strPropertyID)) { return false; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (NULL == pObject) { return false; } NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList()); if (!pRecord) { return false; } NFCDataList xDataList; pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList); if (xDataList.GetCount() != 1) { return false; } const int nRow = xDataList.Int(0); pRecord->SetString(nRow, NFrame::Player::BagEquipList_RandPropertyID, strPropertyID); return true; }
bool NFCElementInfoModule::Load(rapidxml::xml_node<>* attrNode, NF_SHARE_PTR<NFILogicClass> pLogicClass) { //attrNode is the node of a object std::string strConfigID = attrNode->first_attribute("ID")->value(); if (strConfigID.empty()) { NFASSERT(0, strConfigID, __FILE__, __FUNCTION__); return false; } if (ExistElement(strConfigID)) { NFASSERT(0, strConfigID, __FILE__, __FUNCTION__); return false; } NF_SHARE_PTR<ElementConfigInfo> pElementInfo(NF_NEW ElementConfigInfo()); AddElement(strConfigID, pElementInfo); //can find all configid by class name pLogicClass->AddConfigName(strConfigID); //ElementConfigInfo* pElementInfo = CreateElement( strConfigID, pElementInfo ); NF_SHARE_PTR<NFIPropertyManager> pElementPropertyManager = pElementInfo->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> pElementRecordManager = pElementInfo->GetRecordManager(); //1.add property //2.set the default value of them NF_SHARE_PTR<NFIPropertyManager> pClassPropertyManager = pLogicClass->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> pClassRecordManager = pLogicClass->GetRecordManager(); if (pClassPropertyManager.get() && pClassRecordManager.get()) { NF_SHARE_PTR<NFIProperty> pProperty = pClassPropertyManager->First(); while (pProperty.get()) { pElementPropertyManager->AddProperty(NFGUID(), pProperty); pProperty = pClassPropertyManager->Next(); } NF_SHARE_PTR<NFIRecord> pRecord = pClassRecordManager->First(); while (pRecord.get()) { pElementRecordManager->AddRecord(NFGUID(), pRecord->GetName(), pRecord->GetInitData(), pRecord->GetKeyState(), pRecord->GetInitDesc(), pRecord->GetTag(), pRecord->GetRelatedRecord(), pRecord->GetRows(), pRecord->GetPublic(), pRecord->GetPrivate(), pRecord->GetSave(), pRecord->GetView(), pRecord->GetIndex()); pRecord = pClassRecordManager->Next(); } } //3.set the config value to them //const char* pstrConfigID = attrNode->first_attribute( "ID" ); for (rapidxml::xml_attribute<>* pAttribute = attrNode->first_attribute(); pAttribute; pAttribute = pAttribute->next_attribute()) { const char* pstrConfigName = pAttribute->name(); const char* pstrConfigValue = pAttribute->value(); //printf( "%s : %s\n", pstrConfigName, pstrConfigValue ); NF_SHARE_PTR<NFIProperty> temProperty = pElementPropertyManager->GetElement(pstrConfigName); if (!temProperty) { continue; } NFIDataList::TData var; TDATA_TYPE eType = temProperty->GetType(); switch (eType) { case TDATA_INT: { if (!LegalNumber(pstrConfigValue)) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetInt(lexical_cast<NFINT64>(pstrConfigValue)); } break; case TDATA_FLOAT: { if (strlen(pstrConfigValue) <= 0) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetFloat((double)atof(pstrConfigValue)); } break; case TDATA_STRING: var.SetString(pstrConfigValue); break; case TDATA_OBJECT: { if (strlen(pstrConfigValue) <= 0) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetObject(NFGUID()); } break; default: NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); break; } pElementPropertyManager->SetProperty(pstrConfigName, var); } NFIDataList::TData xData; xData.SetString(pLogicClass->GetClassName()); pElementPropertyManager->SetProperty("ClassName", xData); return true; }
int NFCSkillModule::OnRequireUseSkillEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if ( var.GetCount() < 3) { return 1; } //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_SKILL; NF_SHARE_PTR<NFIObject> pObejct = m_pKernelModule->GetObject( var.Object( 0 ) ); if ( pObejct == NULL ) { return 1; } NF_SHARE_PTR<NFIRecord> pRecordSkill = pObejct->GetRecordManager()->GetElement( NFrame::Player::R_SkillTable() ); if ( pRecordSkill == NULL ) { return 1; } NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( var.String( 2 ) ); if ( pPropertyManager == NULL ) { return 1; } NF_SHARE_PTR<NFIProperty> pItemTypeProperty = pPropertyManager->GetElement(NFrame::Skill::SkillType()); if ( pItemTypeProperty == NULL ) { return 1; } //配置表中真的有这么个技能类别 EGameSkillType eItemType = ( EGameSkillType )pItemTypeProperty->GetInt(); NFISkillConsumeProcessModule* pConsumeProcessModule = m_pSkillConsumeManagerModule->GetConsumeModule( EGameSkillType::EGST_JOBSKILL_BRIEF ); if ( pConsumeProcessModule == NULL ) { return 1; } NFCDataList valueOther; valueOther.Append( var, 3, var.GetCount() - 3 ); // 被攻击玩家数量 3表示从第几个参数开始是被攻击玩家 // if ( pConsumeProcessModule->ConsumeLegal( var.ObjectVal( 0 ), var.StringVal( 2 ), valueOther ) != 0 ) // { // return 1; // } // // if ( pConsumeProcessModule->ConsumeSelf( var.ObjectVal( 0 ), var.StringVal( 2 ) ) != 0 ) // { // return 1; // } // NFCDataList damageValueList; NFCDataList damageResultList; int nResult = pConsumeProcessModule->ConsumeProcess( var.Object( 0 ), var.String( 2 ), valueOther, damageValueList, damageResultList ); for (int i = 0; i < valueOther.GetCount(); i++) { m_pKernelModule->SetPropertyInt(valueOther.Object(i), NFrame::NPC::HP(), 0); damageValueList.AddInt(0); damageResultList.AddInt(0); } //结果事件--无论失败或者是成功,都会发下去--当然使用结果只对使用者下发--成果的结果,还得对被施放的人发 if ( damageValueList.GetCount() == damageResultList.GetCount() && damageValueList.GetCount() == valueOther.GetCount() ) { NFCDataList valueResult; valueResult.AddString( var.String( 2 ).c_str() ); valueResult.AddInt( valueOther.GetCount() ); valueResult.Append( valueOther, 0, valueOther.GetCount() ); //伤害对象 valueResult.Append( damageValueList, 0, damageValueList.GetCount() ); //伤害值 valueResult.Append( damageResultList, 0, damageResultList.GetCount() ); //击打效果 //现在不需要反馈,杀了就杀了 //m_pEventProcessModule->DoEvent( pObejct->Self(), NFED_ON_CLIENT_USE_SKILL_RESULT, valueResult ); } return 0; }
int NFCBuffModule::ProcessBuffValuePropertyReferAbsoluteValue( const NFIDENTID& self, NFIBuffConfigModule::NFCBuffConfig* pBuffConfig, const NFIDENTID& releaserIdent ) { //buff group property int nBuffGroup = 0; //RUNTIME_BUFF_INFO NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self ); NF_SHARE_PTR<NFIRecord> pBuffRecord = pObject->GetRecordManager()->GetElement( mstrRunTimeEffectTable ); if ( pBuffRecord ) { NF_SHARE_PTR<NFIRecord> pPropertyGroupRecord = pObject->GetRecordManager()->GetElement( mstrPropertyTable ); std::string strPropertyList; std::string strPropertyName; int* pnEffectValue = pBuffConfig->First( strPropertyName ); while ( pnEffectValue ) { NF_SHARE_PTR<NFIProperty> pProperty = pObject->GetPropertyManager()->GetElement( strPropertyName ); if ( pProperty ) { char szEffectValue[MAX_PATH] = {0}; printf( szEffectValue, "%d", *pnEffectValue ); strPropertyList.append( strPropertyName ); strPropertyList.append( "," ); strPropertyList.append( szEffectValue ); strPropertyList.append( ";" ); //相继设置属性到buff group,增值 //从属性系统得到属性应该在的col函数 int nPropertyGroupCol = 0; int nPropertyBuffGroupRow = 0; TDATA_TYPE eColType = pPropertyGroupRecord->GetColType( nPropertyGroupCol ); if ( NFIBuffConfigModule::BuffReverseType::ERT_NEED_REVERSE == pBuffConfig->NeedReverseType ) { //需要还原 switch ( eColType ) { case TDATA_INT: pPropertyGroupRecord->SetInt( nPropertyBuffGroupRow, nPropertyGroupCol, *pnEffectValue ); break; case TDATA_FLOAT: pPropertyGroupRecord->SetFloat( nPropertyBuffGroupRow, nPropertyGroupCol, float( *pnEffectValue ) ); break; case TDATA_DOUBLE: pPropertyGroupRecord->SetDouble( nPropertyBuffGroupRow, nPropertyGroupCol, double( *pnEffectValue ) ); break; default: break; } } else if ( NFIBuffConfigModule::BuffReverseType::ERT_NO_REVERSE == pBuffConfig->NeedReverseType ) { //不需要还原 NFIDataList::TData valueEffectValue; switch ( eColType ) { case TDATA_INT: valueEffectValue.nType = TDATA_INT; valueEffectValue.variantData = NFINT64( *pnEffectValue ); break; case TDATA_FLOAT: valueEffectValue.nType = TDATA_FLOAT; valueEffectValue.variantData = float( *pnEffectValue ); break; case TDATA_DOUBLE: valueEffectValue.nType = TDATA_DOUBLE; valueEffectValue.variantData = double( *pnEffectValue ); break; default: break; } //const NFIDataList& oldValue = pProperty->GetValue(); pObject->GetPropertyManager()->SetProperty( strPropertyName, valueEffectValue ); } pnEffectValue = pBuffConfig->Next( strPropertyName ); } //还原与否,都需要保存在runtimebuff表 NFCDataList valueBuffProperty; valueBuffProperty.AddString( strPropertyName.c_str() ); valueBuffProperty.AddObject( releaserIdent ); valueBuffProperty.AddFloat( pBuffConfig->EffectTimeInterval ); valueBuffProperty.AddInt( pBuffConfig->EffectTimeValue ); valueBuffProperty.AddString( strPropertyName.c_str() ); pBuffRecord->AddRow( -1, valueBuffProperty ); } } return 0; }
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; }