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

@ -92,7 +92,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors.
m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript;
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;
}
@ -200,6 +201,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.SymSync_OnUpdateScript(agentID, itemID, primID, isScriptRunning, newAssetID);
}
public void ScriptEngine_OnAggregateScriptEvents(SceneObjectPart part)
{
part.aggregateScriptEvents();
}
#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
}
}

View File

@ -4962,6 +4962,8 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private Object propertyUpdateLock = new Object();
//!!!!!! -- TODO:
//!!!!!! -- We should call UpdateXXX functions to update each property, cause some of such updates involves sanity checking.
public Scene.ObjectUpdateResult UpdateAllProperties(SceneObjectPart updatedPart)
@ -5005,6 +5007,9 @@ namespace OpenSim.Region.Framework.Scenes
//Otherwise, our timestamp is less up to date, update the prim with the received copy
Scene.ObjectUpdateResult partUpdateResult = Scene.ObjectUpdateResult.Updated;
bool collisionSoundUpdated = false;
lock (propertyUpdateLock)
{
//See SceneObjectSerializer for the properties that are included in a serialized SceneObjectPart.
this.AllowedDrop = updatedPart.AllowedDrop;
@ -5058,7 +5063,12 @@ namespace OpenSim.Region.Framework.Scenes
this.EveryoneMask = updatedPart.EveryoneMask;
this.NextOwnerMask = updatedPart.NextOwnerMask;
this.Flags = updatedPart.Flags;
this.CollisionSound = updatedPart.CollisionSound;
//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
//need to propogate that update to other actors.
//this.CollisionSound = updatedPart.CollisionSound;
collisionSoundUpdated = UpdateCollisionSound(updatedPart.CollisionSound);
this.CollisionSoundVolume = updatedPart.CollisionSoundVolume;
this.MediaUrl = updatedPart.MediaUrl;
this.TextureAnimation = updatedPart.TextureAnimation;
@ -5067,10 +5077,26 @@ namespace OpenSim.Region.Framework.Scenes
//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;
}
private bool UpdateCollisionSound(UUID updatedCollisionSound)
{
if (this.CollisionSound != updatedCollisionSound)
{
m_collisionSound = updatedCollisionSound;
return true;
}
return false;
}
/// <summary>
/// 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().