Updated PrimSyncInfo.CompareAndUpdateHashedValueByLocal, to overwrite SOP's

properties Shape and TaskInventory if PrimSyncInfo's value has newer timestamp.
dsg
Huaiyu (Kitty) Liu 2011-04-08 15:55:40 -07:00
parent 7c033f9d08
commit 2f41b216d3
2 changed files with 43 additions and 7 deletions

View File

@ -3427,7 +3427,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private bool CompareAndUpdateHashedValueByLocal(SceneObjectPart part, SceneObjectPartProperties property, ulong lastUpdateTS, string syncID)
{
bool isLocalValueDifferent = false;
bool updated = false;
switch (property)
{
case SceneObjectPartProperties.Shape:
@ -3435,22 +3435,41 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
string primShapeStringHash = Util.Md5Hash(primShapeString);
//primShapeString.GetHashCode
if (!m_propertiesSyncInfo[property].IsHashValueEqual(primShapeStringHash))
{
if (lastUpdateTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp)
{
UpdatePropertySyncInfoByLocal(property, lastUpdateTS, syncID, (Object)primShapeString, primShapeStringHash);
updated = true;
}
else if (lastUpdateTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp)
{
PrimitiveBaseShape shape = DeSerializeShape((string)m_propertiesSyncInfo[property].LastUpdateValue);
part.Shape = shape;
}
}
break;
case SceneObjectPartProperties.TaskInventory:
string primTaskInventoryString = SerializePrimPropertyTaskInventory(part);
string primTaskInventoryStringHash = Util.Md5Hash(primTaskInventoryString);
if (!m_propertiesSyncInfo[property].IsHashValueEqual(primTaskInventoryStringHash))
{
if (lastUpdateTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp)
{
UpdatePropertySyncInfoByLocal(property, lastUpdateTS, syncID, (Object)primTaskInventoryString, primTaskInventoryStringHash);
updated = true;
}
else if (lastUpdateTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp)
{
TaskInventoryDictionary taskInv = DeSerializeTaskInventory((string)m_propertiesSyncInfo[property].LastUpdateValue);
part.TaskInventory = taskInv;
}
}
break;
default:
break;
}
return isLocalValueDifferent;
return updated;
}
private string SerializePrimPropertyShape(SceneObjectPart part)
@ -3467,6 +3486,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return serializedShape;
}
//TO BE TESTED
private PrimitiveBaseShape DeSerializeShape(string shapeString)
{
StringReader sr = new StringReader(shapeString);
XmlTextReader reader = new XmlTextReader(sr);
return SceneObjectSerializer.ReadShape(reader, "Shape");
}
private string SerializePrimPropertyTaskInventory(SceneObjectPart part)
{
string serializedTaskInventory;
@ -3481,7 +3508,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return serializedTaskInventory;
}
private TaskInventoryDictionary DeSerializeTaskInventory(string taskInvString)
{
StringReader sr = new StringReader(taskInvString);
XmlTextReader reader = new XmlTextReader(sr);
return SceneObjectSerializer.ReadTaskInventory(reader, "TaskInventory");
}
/// <summary>
/// Compare the value (not "reference") of the given property.

View File

@ -1600,7 +1600,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
return obj;
}
static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
//DSG SYNC: make it public to be called outside
//static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
public static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
{
TaskInventoryDictionary tinv = new TaskInventoryDictionary();
@ -1639,7 +1641,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
return tinv;
}
static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
//DSG SYNC: make it public to be called outside
//static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
{
PrimitiveBaseShape shape = new PrimitiveBaseShape();