diff --git a/NFComm/NFCore/NFCProperty.cpp b/NFComm/NFCore/NFCProperty.cpp index 4db0efa22f..3506bf6b3b 100644 --- a/NFComm/NFCore/NFCProperty.cpp +++ b/NFComm/NFCore/NFCProperty.cpp @@ -563,12 +563,58 @@ std::string NFCProperty::ToString() bool NFCProperty::FromString(const std::string& strData) { - if (!mxData) + try + { + switch (GetType()) + { + case TDATA_INT: + SetInt(lexical_cast (strData)); + break; + + case TDATA_FLOAT: + SetFloat(lexical_cast (strData)); + break; + + case TDATA_STRING: + SetString(strData); + break; + + case TDATA_OBJECT: + { + NFGUID xID; + xID.FromString(strData); + SetObject(xID); + } + break; + + case TDATA_VECTOR2: + { + NFVector2 v; + v.FromString(strData); + SetVector2(v); + } + break; + + case TDATA_VECTOR3: + { + NFVector3 v; + v.FromString(strData); + SetVector3(v); + } + break; + + default: + break; + } + + return true; + } + catch (...) { - mxData = NF_SHARE_PTR(NF_NEW NFData(GetType())); + return false; } - return mxData->FromString(strData); + return false; } bool NFCProperty::DeSerialization() diff --git a/NFServer/NFDataAgent_NosqlPlugin/NFCPlayerRedisModule.cpp b/NFServer/NFDataAgent_NosqlPlugin/NFCPlayerRedisModule.cpp index 7b8f0155c8..ac3cf76af3 100644 --- a/NFServer/NFDataAgent_NosqlPlugin/NFCPlayerRedisModule.cpp +++ b/NFServer/NFDataAgent_NosqlPlugin/NFCPlayerRedisModule.cpp @@ -179,7 +179,7 @@ const bool NFCPlayerRedisModule::AttachData(const NFGUID & self) if (pObject) { m_pCommonRedisModule->ConvertPBToPropertyManager(xPlayerDataCache->mvPropertyKeyList, xPlayerDataCache->mvPropertyValueList, pObject->GetPropertyManager()); - m_pCommonRedisModule->ConvertPBToRecordManager(xPlayerDataCache->mvPropertyKeyList, xPlayerDataCache->mvPropertyValueList, pObject->GetRecordManager()); + m_pCommonRedisModule->ConvertPBToRecordManager(xPlayerDataCache->mvRecordKeyList, xPlayerDataCache->mvRecordValueList, pObject->GetRecordManager()); return true; } diff --git a/NFServer/NFGameServerPlugin/NFCPropertyModule.cpp b/NFServer/NFGameServerPlugin/NFCPropertyModule.cpp index f362f873a6..921bcfdaea 100644 --- a/NFServer/NFGameServerPlugin/NFCPropertyModule.cpp +++ b/NFServer/NFGameServerPlugin/NFCPropertyModule.cpp @@ -143,19 +143,24 @@ int NFCPropertyModule::OnObjectClassEvent(const NFGUID& self, const std::string& { if (strClassName == NFrame::Player::ThisName()) { - if (CLASS_OBJECT_EVENT::COE_CREATE_AFTER_ATTACHDATA == eClassEvent) + if (CLASS_OBJECT_EVENT::COE_CREATE_NODATA == eClassEvent) + { + NF_SHARE_PTR pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName()); + if (pRecord) + { + for (int i = 0; i < NFPropertyGroup::NPG_ALL; i++) + { + pRecord->AddRow(-1); + } + } + + m_pKernelModule->AddPropertyCallBack(self, NFrame::Player::Level(), this, &NFCPropertyModule::OnObjectLevelEvent); + m_pKernelModule->AddRecordCallBack(self, NFrame::Player::CommValue::ThisName(), this, &NFCPropertyModule::OnRecordEvent); + } + else if (CLASS_OBJECT_EVENT::COE_CREATE_AFTER_ATTACHDATA == eClassEvent) { - NF_SHARE_PTR pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName()); - if (pRecord) - { - for (int i = 0; i < NFPropertyGroup::NPG_ALL; i++) - { - pRecord->AddRow(-1); - } - } + - m_pKernelModule->AddPropertyCallBack(self, NFrame::Player::Level(), this, &NFCPropertyModule::OnObjectLevelEvent); - m_pKernelModule->AddRecordCallBack(self, NFrame::Player::CommValue::ThisName(), this, &NFCPropertyModule::OnRecordEvent); } else if (CLASS_OBJECT_EVENT::COE_CREATE_EFFECTDATA == eClassEvent) {