Added SceneObjectPart.UpdateCollisionSound w/o calling CollisionSound set function, so that

not to trigger aggregateScriptEvent if not necessary (so as not to change LastUpdatedTimeStamp and
LastUpdatedActorID to local actor if CollisionSound is not changed).
dsg
Huaiyu (Kitty) Liu 2011-01-24 17:20:16 -08:00
parent 005c743fae
commit 65c4889474
3 changed files with 116 additions and 62 deletions

View File

@ -91,8 +91,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript. //for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript.
//RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors. //RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors.
m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript; m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript;
m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript; m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript;
//m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript;
m_scene.EventManager.OnAggregateScriptEvents += ScriptEngine_OnAggregateScriptEvents;
LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName; LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName;
} }
@ -200,6 +201,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.SymSync_OnUpdateScript(agentID, itemID, primID, isScriptRunning, newAssetID); m_scene.SymSync_OnUpdateScript(agentID, itemID, primID, isScriptRunning, newAssetID);
} }
public void ScriptEngine_OnAggregateScriptEvents(SceneObjectPart part)
{
part.aggregateScriptEvents();
}
#endregion //ScriptEngineSyncModule #endregion //ScriptEngineSyncModule
} }

View File

@ -2528,6 +2528,28 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public delegate void AggregateScriptEvents(SceneObjectPart part);
public event AggregateScriptEvents OnAggregateScriptEvents;
public void TriggerAggregateScriptEvents(SceneObjectPart part)
{
AggregateScriptEvents handlerAggregateScriptEvents = OnAggregateScriptEvents;
if (handlerAggregateScriptEvents != null)
{
foreach (AggregateScriptEvents d in handlerAggregateScriptEvents.GetInvocationList())
{
try
{
d(part);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerAggregateScriptEvents failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
//end of SYMMETRIC SYNC //end of SYMMETRIC SYNC
} }
} }

View File

@ -4962,6 +4962,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
private Object propertyUpdateLock = new Object();
//!!!!!! -- TODO: //!!!!!! -- TODO:
//!!!!!! -- We should call UpdateXXX functions to update each property, cause some of such updates involves sanity checking. //!!!!!! -- We should call UpdateXXX functions to update each property, cause some of such updates involves sanity checking.
public Scene.ObjectUpdateResult UpdateAllProperties(SceneObjectPart updatedPart) public Scene.ObjectUpdateResult UpdateAllProperties(SceneObjectPart updatedPart)
@ -5005,72 +5007,96 @@ namespace OpenSim.Region.Framework.Scenes
//Otherwise, our timestamp is less up to date, update the prim with the received copy //Otherwise, our timestamp is less up to date, update the prim with the received copy
Scene.ObjectUpdateResult partUpdateResult = Scene.ObjectUpdateResult.Updated; Scene.ObjectUpdateResult partUpdateResult = Scene.ObjectUpdateResult.Updated;
bool collisionSoundUpdated = false;
lock (propertyUpdateLock)
{
//See SceneObjectSerializer for the properties that are included in a serialized SceneObjectPart. //See SceneObjectSerializer for the properties that are included in a serialized SceneObjectPart.
this.AllowedDrop = updatedPart.AllowedDrop; this.AllowedDrop = updatedPart.AllowedDrop;
this.CreatorID = updatedPart.CreatorID; this.CreatorID = updatedPart.CreatorID;
this.CreatorData = updatedPart.CreatorData; this.CreatorData = updatedPart.CreatorData;
this.FolderID = updatedPart.FolderID; this.FolderID = updatedPart.FolderID;
this.InventorySerial = updatedPart.InventorySerial; this.InventorySerial = updatedPart.InventorySerial;
this.TaskInventory = updatedPart.TaskInventory; this.TaskInventory = updatedPart.TaskInventory;
//Following two properties, UUID and LocalId, shall not be updated. //Following two properties, UUID and LocalId, shall not be updated.
//this.UUID //this.UUID
//this.LocalId //this.LocalId
this.Name = updatedPart.Name; this.Name = updatedPart.Name;
this.Material = updatedPart.Material; this.Material = updatedPart.Material;
this.PassTouches = updatedPart.PassTouches; this.PassTouches = updatedPart.PassTouches;
//RegionHandle shall not be copied, since updatedSog is sent by a different actor, which has a different local region //RegionHandle shall not be copied, since updatedSog is sent by a different actor, which has a different local region
//this.RegionHandle //this.RegionHandle
this.ScriptAccessPin = updatedPart.ScriptAccessPin; this.ScriptAccessPin = updatedPart.ScriptAccessPin;
this.GroupPosition = updatedPart.GroupPosition; this.GroupPosition = updatedPart.GroupPosition;
this.OffsetPosition = updatedPart.OffsetPosition; this.OffsetPosition = updatedPart.OffsetPosition;
this.RotationOffset = updatedPart.RotationOffset; this.RotationOffset = updatedPart.RotationOffset;
this.Velocity = updatedPart.Velocity; this.Velocity = updatedPart.Velocity;
this.AngularVelocity = updatedPart.AngularVelocity; this.AngularVelocity = updatedPart.AngularVelocity;
this.Acceleration = updatedPart.Acceleration; this.Acceleration = updatedPart.Acceleration;
this.Description = updatedPart.Description; this.Description = updatedPart.Description;
this.Color = updatedPart.Color; this.Color = updatedPart.Color;
this.Text = updatedPart.Text; this.Text = updatedPart.Text;
this.SitName = updatedPart.SitName; this.SitName = updatedPart.SitName;
this.TouchName = updatedPart.TouchName; this.TouchName = updatedPart.TouchName;
this.LinkNum = updatedPart.LinkNum; this.LinkNum = updatedPart.LinkNum;
this.ClickAction = updatedPart.ClickAction; this.ClickAction = updatedPart.ClickAction;
this.Shape = updatedPart.Shape; this.Shape = updatedPart.Shape;
this.Scale = updatedPart.Scale; this.Scale = updatedPart.Scale;
this.UpdateFlag = updatedPart.UpdateFlag; this.UpdateFlag = updatedPart.UpdateFlag;
this.SitTargetOrientation = updatedPart.SitTargetOrientation; this.SitTargetOrientation = updatedPart.SitTargetOrientation;
this.SitTargetPosition = updatedPart.SitTargetPosition; this.SitTargetPosition = updatedPart.SitTargetPosition;
this.SitTargetPositionLL = updatedPart.SitTargetPositionLL; this.SitTargetPositionLL = updatedPart.SitTargetPositionLL;
this.SitTargetOrientationLL = updatedPart.SitTargetOrientationLL; this.SitTargetOrientationLL = updatedPart.SitTargetOrientationLL;
//ParentID should still point to the rootpart in the local sog, do not update. If the root part changed, we will update it in SceneObjectGroup.UpdateObjectProperties() //ParentID should still point to the rootpart in the local sog, do not update. If the root part changed, we will update it in SceneObjectGroup.UpdateObjectProperties()
//this.ParentID; //this.ParentID;
this.CreationDate = updatedPart.CreationDate; this.CreationDate = updatedPart.CreationDate;
this.Category = updatedPart.Category; this.Category = updatedPart.Category;
this.SalePrice = updatedPart.SalePrice; this.SalePrice = updatedPart.SalePrice;
this.ObjectSaleType = updatedPart.ObjectSaleType; this.ObjectSaleType = updatedPart.ObjectSaleType;
this.OwnershipCost = updatedPart.OwnershipCost; this.OwnershipCost = updatedPart.OwnershipCost;
this.GroupID = updatedPart.GroupID; this.GroupID = updatedPart.GroupID;
this.OwnerID = updatedPart.OwnerID; this.OwnerID = updatedPart.OwnerID;
this.LastOwnerID = updatedPart.LastOwnerID; this.LastOwnerID = updatedPart.LastOwnerID;
this.BaseMask = updatedPart.BaseMask; this.BaseMask = updatedPart.BaseMask;
this.OwnerMask = updatedPart.OwnerMask; this.OwnerMask = updatedPart.OwnerMask;
this.GroupMask = updatedPart.GroupMask; this.GroupMask = updatedPart.GroupMask;
this.EveryoneMask = updatedPart.EveryoneMask; this.EveryoneMask = updatedPart.EveryoneMask;
this.NextOwnerMask = updatedPart.NextOwnerMask; this.NextOwnerMask = updatedPart.NextOwnerMask;
this.Flags = updatedPart.Flags; this.Flags = updatedPart.Flags;
this.CollisionSound = updatedPart.CollisionSound;
this.CollisionSoundVolume = updatedPart.CollisionSoundVolume;
this.MediaUrl = updatedPart.MediaUrl;
this.TextureAnimation = updatedPart.TextureAnimation;
this.ParticleSystem = updatedPart.ParticleSystem;
//Update the timestamp and LastUpdatedByActorID first. //We will update CollisionSound with special care so that it does not lead to ScheduleFullUpdate of this part, to make the actor think it just made an update and
this.m_lastUpdateActorID = updatedPart.LastUpdateActorID; //need to propogate that update to other actors.
this.m_lastUpdateTimeStamp = updatedPart.LastUpdateTimeStamp; //this.CollisionSound = updatedPart.CollisionSound;
collisionSoundUpdated = UpdateCollisionSound(updatedPart.CollisionSound);
this.CollisionSoundVolume = updatedPart.CollisionSoundVolume;
this.MediaUrl = updatedPart.MediaUrl;
this.TextureAnimation = updatedPart.TextureAnimation;
this.ParticleSystem = updatedPart.ParticleSystem;
//Update the timestamp and LastUpdatedByActorID first.
this.m_lastUpdateActorID = updatedPart.LastUpdateActorID;
this.m_lastUpdateTimeStamp = updatedPart.LastUpdateTimeStamp;
}
if (collisionSoundUpdated)
{
m_parentGroup.Scene.EventManager.TriggerAggregateScriptEvents(this);
}
return partUpdateResult; return partUpdateResult;
} }
private bool UpdateCollisionSound(UUID updatedCollisionSound)
{
if (this.CollisionSound != updatedCollisionSound)
{
m_collisionSound = updatedCollisionSound;
return true;
}
return false;
}
/// <summary> /// <summary>
/// Schedules this prim for a full update, without changing the timestamp or actorID (info on when and who modified any property). /// Schedules this prim for a full update, without changing the timestamp or actorID (info on when and who modified any property).
/// NOTE: this is the same as the original SceneObjectPart.ScheduleFullUpdate(). /// NOTE: this is the same as the original SceneObjectPart.ScheduleFullUpdate().