Skip to content

Commit

Permalink
fixed bugs for refreshing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ketoo committed Sep 21, 2017
1 parent 63f7a8f commit a3af573
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 15 deletions.
52 changes: 49 additions & 3 deletions NFComm/NFCore/NFCProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t> (strData));
break;

case TDATA_FLOAT:
SetFloat(lexical_cast<float> (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<NFData>(NF_NEW NFData(GetType()));
return false;
}

return mxData->FromString(strData);
return false;
}

bool NFCProperty::DeSerialization()
Expand Down
2 changes: 1 addition & 1 deletion NFServer/NFDataAgent_NosqlPlugin/NFCPlayerRedisModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 16 additions & 11 deletions NFServer/NFGameServerPlugin/NFCPropertyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NFIRecord> 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<NFIRecord> 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)
{
Expand Down

0 comments on commit a3af573

Please sign in to comment.