Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim

slimupdates
Justin Clark-Casey (justincc) 2010-04-19 21:28:30 +01:00
commit 6b963e73d9
14 changed files with 113 additions and 31 deletions

View File

@ -239,6 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Fire after attach, so we don't get messy perms dialogs // Fire after attach, so we don't get messy perms dialogs
// 3 == AttachedRez // 3 == AttachedRez
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3); objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3);
objatt.ResumeScripts();
// Do this last so that event listeners have access to all the effects of the attachment // Do this last so that event listeners have access to all the effects of the attachment
m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
@ -413,4 +414,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
} }
} }

View File

@ -601,6 +601,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// Fire on_rez // Fire on_rez
group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0); group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0);
rootPart.ParentGroup.ResumeScripts();
rootPart.ScheduleFullUpdate(); rootPart.ScheduleFullUpdate();
} }

View File

@ -284,6 +284,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
sceneObjectsLoadedCount++; sceneObjectsLoadedCount++;
sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
sceneObject.ResumeScripts();
} }
} }

View File

@ -74,6 +74,7 @@ namespace OpenSim.Region.Framework.Interfaces
void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
ArrayList GetScriptErrors(UUID itemID); ArrayList GetScriptErrors(UUID itemID);
void ResumeScripts();
/// <summary> /// <summary>
/// Stop all the scripts in this entity. /// Stop all the scripts in this entity.

View File

@ -41,6 +41,14 @@ namespace OpenSim.Region.Framework.Interfaces
bool PostScriptEvent(UUID itemID, string name, Object[] args); bool PostScriptEvent(UUID itemID, string name, Object[] args);
bool PostObjectEvent(UUID itemID, string name, Object[] args); bool PostObjectEvent(UUID itemID, string name, Object[] args);
// Suspend ALL scripts in a given scene object. The item ID
// is the UUID of a SOG, and the method acts on all contained
// scripts. This is different from the suspend/resume that
// can be issued by a client.
//
void SuspendScript(UUID itemID);
void ResumeScript(UUID itemID);
ArrayList GetScriptErrors(UUID itemID); ArrayList GetScriptErrors(UUID itemID);
} }
} }

View File

@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes
if (group is SceneObjectGroup) if (group is SceneObjectGroup)
{ {
((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
((SceneObjectGroup) group).ResumeScripts();
} }
} }
} }
@ -220,6 +221,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
remoteClient.SendAgentAlertMessage("Script saved", false); remoteClient.SendAgentAlertMessage("Script saved", false);
} }
part.ParentGroup.ResumeScripts();
return errors; return errors;
} }
@ -1281,6 +1283,7 @@ namespace OpenSim.Region.Framework.Scenes
// "Rezzed script {0} into prim local ID {1} for user {2}", // "Rezzed script {0} into prim local ID {1} for user {2}",
// item.inventoryName, localID, remoteClient.Name); // item.inventoryName, localID, remoteClient.Name);
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
part.ParentGroup.ResumeScripts();
} }
else else
{ {
@ -1350,6 +1353,7 @@ namespace OpenSim.Region.Framework.Scenes
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
part.ParentGroup.ResumeScripts();
} }
} }
@ -1453,6 +1457,8 @@ namespace OpenSim.Region.Framework.Scenes
destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0); destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, DefaultScriptEngine, 0);
} }
destPart.ParentGroup.ResumeScripts();
ScenePresence avatar; ScenePresence avatar;
if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))

View File

@ -1131,7 +1131,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_scripts_enabled != !ScriptEngine) if (m_scripts_enabled != !ScriptEngine)
{ {
// Tedd! Here's the method to disable the scripting engine!
if (ScriptEngine) if (ScriptEngine)
{ {
m_log.Info("Stopping all Scripts in Scene"); m_log.Info("Stopping all Scripts in Scene");
@ -1153,6 +1152,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
((SceneObjectGroup)ent).ResumeScripts();
} }
} }
} }

View File

@ -1755,6 +1755,7 @@ namespace OpenSim.Region.Framework.Scenes
copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0);
copy.HasGroupChanged = true; copy.HasGroupChanged = true;
copy.ScheduleGroupForFullUpdate(); copy.ScheduleGroupForFullUpdate();
copy.ResumeScripts();
// required for physics to update it's position // required for physics to update it's position
copy.AbsolutePosition = copy.AbsolutePosition; copy.AbsolutePosition = copy.AbsolutePosition;

View File

@ -416,5 +416,13 @@ namespace OpenSim.Region.Framework.Scenes
scriptModule.SetXMLState(itemID, n.OuterXml); scriptModule.SetXMLState(itemID, n.OuterXml);
} }
} }
public void ResumeScripts()
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.Inventory.ResumeScripts();
}
}
} }
} }

View File

@ -282,36 +282,32 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
} }
m_part.ParentGroup.Scene.AssetService.Get( AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) if (null == asset)
{ {
if (null == asset) m_log.ErrorFormat(
{ "[PRIM INVENTORY]: " +
m_log.ErrorFormat( "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
"[PRIM INVENTORY]: " + item.Name, item.ItemID, m_part.AbsolutePosition,
"Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
item.Name, item.ItemID, m_part.AbsolutePosition, }
m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); else
} {
else if (m_part.ParentGroup.m_savedScriptState != null)
{ RestoreSavedScriptState(item.OldItemID, item.ItemID);
if (m_part.ParentGroup.m_savedScriptState != null)
RestoreSavedScriptState(item.OldItemID, item.ItemID);
lock (m_items) lock (m_items)
{ {
m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero; m_items[item.ItemID].PermsGranter = UUID.Zero;
}
string script = Utils.BytesToString(asset.Data);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
m_part.ParentGroup.AddActiveScriptCount(1);
m_part.ScheduleFullUpdate();
}
} }
);
string script = Utils.BytesToString(asset.Data);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
m_part.ParentGroup.AddActiveScriptCount(1);
m_part.ScheduleFullUpdate();
}
} }
} }
@ -1032,5 +1028,28 @@ namespace OpenSim.Region.Framework.Scenes
return ret; return ret;
} }
public void ResumeScripts()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
if (engines == null)
return;
lock (m_items)
{
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule engine in engines)
{
if (engine != null)
engine.ResumeScript(item.ItemID);
}
}
}
}
}
} }
} }

View File

@ -182,6 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
foreach (SceneObjectGroup sceneObject in sceneObjects) foreach (SceneObjectGroup sceneObject in sceneObjects)
{ {
sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0);
sceneObject.ResumeScripts();
} }
} }

View File

@ -81,6 +81,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
void PostEvent(EventParams data); void PostEvent(EventParams data);
void Suspend();
void Resume();
/// <summary> /// <summary>
/// Process the next event queued for this script /// Process the next event queued for this script
/// </summary> /// </summary>

View File

@ -95,6 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private bool m_startedFromSavedState; private bool m_startedFromSavedState;
private UUID m_CurrentStateHash; private UUID m_CurrentStateHash;
private UUID m_RegionID; private UUID m_RegionID;
private bool m_Suspended = false;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
m_LineMap; m_LineMap;
@ -638,6 +639,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
/// <returns></returns> /// <returns></returns>
public object EventProcessor() public object EventProcessor()
{ {
if (m_Suspended)
return 0;
lock (m_Script) lock (m_Script)
{ {
EventParams data = null; EventParams data = null;
@ -1011,5 +1015,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{ {
get { return m_RegionID; } get { return m_RegionID; }
} }
public void Suspend()
{
m_Suspended = true;
}
public void Resume()
{
m_Suspended = false;
}
} }
} }

View File

@ -1488,5 +1488,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return new ArrayList(); return new ArrayList();
} }
} }
public void SuspendScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return;
instance.Suspend();
}
public void ResumeScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return;
instance.Resume();
}
} }
} }