void NFCProxyServerToWorldModule::LogServerInfo(const std::string& strServerInfo) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFGUID(), strServerInfo, ""); }
bool NFCPVPMatchModule::PlayerListLeaveRoom(const std::vector<NFGUID>& xPlayerList, const NFGUID& xRoomID) { if (!xRoomID.IsNull()) { return false; } NFMsg::PVPRoomInfo xRoomInfo; if (!m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo)) { return false; } NFMsg::PVPRoomInfo xNewRoomInfo; xNewRoomInfo.CopyFrom(xRoomInfo); std::map<NFGUID, NFGUID> xMapPlayerList; for (int i = 0; i < xPlayerList.size(); i++) { const NFGUID xPlayerID = xPlayerList[i]; xMapPlayerList[xPlayerID] = xPlayerID; } xNewRoomInfo.clear_xredplayer(); for (int i = 0; i < xRoomInfo.xredplayer_size(); ++i) { std::map<NFGUID, NFGUID>::iterator iter = xMapPlayerList.find(NFINetModule::PBToNF(xRoomInfo.xredplayer(i))); if (iter != xMapPlayerList.end()) { m_pPVPMatchRedisModule->SetPlayerRoomID(NFINetModule::PBToNF(xRoomInfo.xredplayer(i)), NFGUID()); continue; } xRoomInfo.add_xredplayer()->CopyFrom(xRoomInfo.xredplayer(i)); } xNewRoomInfo.clear_xblueplayer(); for (int i = 0; i < xRoomInfo.xblueplayer_size(); ++i) { std::map<NFGUID, NFGUID>::iterator iter = xMapPlayerList.find(NFINetModule::PBToNF(xRoomInfo.xblueplayer(i))); if (iter != xMapPlayerList.end()) { m_pPVPMatchRedisModule->SetPlayerRoomID(NFINetModule::PBToNF(xRoomInfo.xblueplayer(i)), NFGUID()); continue; } xRoomInfo.add_xredplayer()->CopyFrom(xRoomInfo.xblueplayer(i)); } { return false; } UpdateRoomStatus(xRoomInfo); if (!m_pPVPMatchRedisModule->SetRoomInfo(xRoomID, xRoomInfo)) { return false; } return true; }
bool NFCElementModule::Load(rapidxml::xml_node<>* attrNode, NF_SHARE_PTR<NFIClass> 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->AddId(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 && pClassRecordManager) { NF_SHARE_PTR<NFIProperty> pProperty = pClassPropertyManager->First(); while (pProperty) { pElementPropertyManager->AddProperty(NFGUID(), pProperty); pProperty = pClassPropertyManager->Next(); } NF_SHARE_PTR<NFIRecord> pRecord = pClassRecordManager->First(); while (pRecord) { NF_SHARE_PTR<NFIRecord> xRecord = pElementRecordManager->AddRecord(NFGUID(), pRecord->GetName(), pRecord->GetInitData(), pRecord->GetTag(), pRecord->GetRows()); xRecord->SetPublic(pRecord->GetPublic()); xRecord->SetPrivate(pRecord->GetPrivate()); xRecord->SetSave(pRecord->GetSave()); xRecord->SetCache(pRecord->GetCache()); xRecord->SetUpload(pRecord->GetUpload()); 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; const 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; } temProperty->SetValue(var); if (eType == TDATA_STRING) { temProperty->DeSerialization(); } } NFIDataList::TData xData; xData.SetString(pLogicClass->GetClassName()); pElementPropertyManager->SetProperty("ClassName", xData); return true; }
bool NFCCreateRoleModule::ConvertPBToPropertyManager(const NFMsg::ObjectPropertyList& pPropertyData, NF_SHARE_PTR<NFIPropertyManager> pProps) { if (pProps) { for (int i = 0; i < pPropertyData.property_int_list_size(); ++i) { const NFMsg::PropertyInt& xData = pPropertyData.property_int_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_INT); } pProps->SetPropertyInt(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_float_list_size(); ++i) { const NFMsg::PropertyFloat& xData = pPropertyData.property_float_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_FLOAT); } pProps->SetPropertyFloat(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_string_list_size(); ++i) { const NFMsg::PropertyString& xData = pPropertyData.property_string_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_STRING); } pProps->SetPropertyString(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_object_list_size(); ++i) { const NFMsg::PropertyObject& xData = pPropertyData.property_object_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_OBJECT); } pProps->SetPropertyObject(xData.property_name(), NFGUID(xData.data().svrid(), xData.data().index())); } for (int i = 0; i < pPropertyData.property_vector2_list_size(); ++i) { const NFMsg::PropertyVector2& xData = pPropertyData.property_vector2_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR2); } pProps->SetPropertyVector2(xData.property_name(), NFVector2(xData.data().x(), xData.data().y())); } for (int i = 0; i < pPropertyData.property_vector3_list_size(); ++i) { const NFMsg::PropertyVector3& xData = pPropertyData.property_vector3_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR3); } pProps->SetPropertyVector3(xData.property_name(), NFVector3(xData.data().x(), xData.data().y(), xData.data().z())); } } return true; }
bool NFCClassModule::AddPropertys(rapidxml::xml_node<>* pPropertyRootNode, NF_SHARE_PTR<NFIClass> pClass) { for (rapidxml::xml_node<>* pPropertyNode = pPropertyRootNode->first_node(); pPropertyNode; pPropertyNode = pPropertyNode->next_sibling()) { if (pPropertyNode) { const char* strPropertyName = pPropertyNode->first_attribute("Id")->value(); if (pClass->GetPropertyManager()->GetElement(strPropertyName)) { //error NFASSERT(0, strPropertyName, __FILE__, __FUNCTION__); continue; } const char* pstrType = pPropertyNode->first_attribute("Type")->value(); const char* pstrPublic = pPropertyNode->first_attribute("Public")->value(); const char* pstrPrivate = pPropertyNode->first_attribute("Private")->value(); const char* pstrSave = pPropertyNode->first_attribute("Save")->value(); const char* pstrCache = pPropertyNode->first_attribute("Cache")->value(); const char* pstrRef = pPropertyNode->first_attribute("Ref")->value(); const char* pstrUpload = pPropertyNode->first_attribute("Upload")->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 bRef = lexical_cast<bool>(pstrRef); bool bUpload = lexical_cast<bool>(pstrUpload); NFIDataList::TData varProperty; if (TDATA_UNKNOWN == ComputerType(pstrType, varProperty)) { //std::cout << "error:" << pClass->GetTypeName() << " " << pClass->GetInstancePath() << ": " << strPropertyName << " type error!!!" << std::endl; NFASSERT(0, strPropertyName, __FILE__, __FUNCTION__); } //printf( " Property:%s[%s]\n", pstrPropertyName, pstrType ); NF_SHARE_PTR<NFIProperty> xProperty = pClass->GetPropertyManager()->AddProperty(NFGUID(), strPropertyName, varProperty.GetType()); xProperty->SetPublic(bPublic); xProperty->SetPrivate(bPrivate); xProperty->SetSave(bSave); xProperty->SetCache(bCache); xProperty->SetRef(bRef); xProperty->SetUpload(bUpload); } } 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<NFIDataList> recordVar(NF_NEW NFCDataList()); NF_SHARE_PTR<NFIDataList> recordTag(NF_NEW NFCDataList()); for (rapidxml::xml_node<>* recordColNode = pRecordNode->first_node(); recordColNode; recordColNode = recordColNode->next_sibling()) { //const char* pstrColName = recordColNode->first_attribute( "Id" )->value(); NFIDataList::TData 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; }
NF_SHARE_PTR<NFIComponent> NFCMysqlComponent::CreateNewInstance() { return NF_SHARE_PTR<NFIComponent> (NF_NEW NFCMysqlComponent(NFGUID(1, 2), "")); }