diff options
author | Charles Krinke | 2008-06-28 16:08:12 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-28 16:08:12 +0000 |
commit | 9a0ef22ed979433f4d017a252173f38fe5e56892 (patch) | |
tree | 98bd25e3a49a38922b37728df4de9e0fa5b7366a /OpenSim/Region/Environment/Scenes | |
parent | plumbing for multiple inventory servers. Mostly done on the region server side. (diff) | |
download | opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.zip opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.gz opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.bz2 opensim-SC_OLD-9a0ef22ed979433f4d017a252173f38fe5e56892.tar.xz |
Mantis#1616. Applied Melanie's patch. This may or may
not break trunk.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
8 files changed, 118 insertions, 163 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index 5c750e4..f3af0d1 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs | |||
@@ -95,17 +95,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
95 | 95 | ||
96 | public event OnPermissionErrorDelegate OnPermissionError; | 96 | public event OnPermissionErrorDelegate OnPermissionError; |
97 | 97 | ||
98 | public delegate void NewRezScript(uint localID, LLUUID itemID, string script); | 98 | public delegate void NewRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez); |
99 | public delegate void RezEvent(uint localID, LLUUID itemID, int param); | ||
100 | 99 | ||
101 | public event NewRezScript OnRezScript; | 100 | public event NewRezScript OnRezScript; |
102 | 101 | ||
103 | public event RezEvent OnRezEvent; | ||
104 | |||
105 | public delegate void RemoveScript(uint localID, LLUUID itemID); | 102 | public delegate void RemoveScript(uint localID, LLUUID itemID); |
106 | 103 | ||
107 | public event RemoveScript OnRemoveScript; | 104 | public event RemoveScript OnRemoveScript; |
108 | 105 | ||
106 | public delegate void StartScript(uint localID, LLUUID itemID); | ||
107 | |||
108 | public event StartScript OnStartScript; | ||
109 | |||
110 | public delegate void StopScript(uint localID, LLUUID itemID); | ||
111 | |||
112 | public event StopScript OnStopScript; | ||
113 | |||
109 | public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta); | 114 | public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta); |
110 | 115 | ||
111 | public event SceneGroupMoved OnSceneGroupMove; | 116 | public event SceneGroupMoved OnSceneGroupMove; |
@@ -332,8 +337,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
332 | private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab; | 337 | private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab; |
333 | private ScriptResetDelegate handlerScriptReset = null; // OnScriptReset | 338 | private ScriptResetDelegate handlerScriptReset = null; // OnScriptReset |
334 | private NewRezScript handlerRezScript = null; //OnRezScript; | 339 | private NewRezScript handlerRezScript = null; //OnRezScript; |
335 | private RezEvent handlerOnRezEvent = null; //OnRezEvent; | ||
336 | private RemoveScript handlerRemoveScript = null; //OnRemoveScript; | 340 | private RemoveScript handlerRemoveScript = null; //OnRemoveScript; |
341 | private StartScript handlerStartScript = null; //OnStartScript; | ||
342 | private StopScript handlerStopScript = null; //OnStopScript; | ||
337 | private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove; | 343 | private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove; |
338 | private SceneGroupGrabed handlerSceneGroupGrab = null; //OnSceneGroupGrab; | 344 | private SceneGroupGrabed handlerSceneGroupGrab = null; //OnSceneGroupGrab; |
339 | private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded; | 345 | private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded; |
@@ -523,21 +529,30 @@ namespace OpenSim.Region.Environment.Scenes | |||
523 | } | 529 | } |
524 | } | 530 | } |
525 | 531 | ||
526 | public void TriggerRezScript(uint localID, LLUUID itemID, string script) | 532 | public void TriggerRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) |
527 | { | 533 | { |
528 | handlerRezScript = OnRezScript; | 534 | handlerRezScript = OnRezScript; |
529 | if (handlerRezScript != null) | 535 | if (handlerRezScript != null) |
530 | { | 536 | { |
531 | handlerRezScript(localID, itemID, script); | 537 | handlerRezScript(localID, itemID, script, startParam, postOnRez); |
538 | } | ||
539 | } | ||
540 | |||
541 | public void TriggerStartScript(uint localID, LLUUID itemID) | ||
542 | { | ||
543 | handlerStartScript = OnStartScript; | ||
544 | if (handlerStartScript != null) | ||
545 | { | ||
546 | handlerStartScript(localID, itemID); | ||
532 | } | 547 | } |
533 | } | 548 | } |
534 | 549 | ||
535 | public void TriggerOnRezEvent(uint localID, LLUUID itemID, int param) | 550 | public void TriggerStopScript(uint localID, LLUUID itemID) |
536 | { | 551 | { |
537 | handlerOnRezEvent = OnRezEvent; | 552 | handlerStopScript = OnStopScript; |
538 | if (handlerOnRezEvent != null) | 553 | if (handlerStopScript != null) |
539 | { | 554 | { |
540 | handlerOnRezEvent(localID, itemID, param); | 555 | handlerStopScript(localID, itemID); |
541 | } | 556 | } |
542 | } | 557 | } |
543 | 558 | ||
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index fd8e2f8..d553f4b 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1522 | copy.UpdateGroupRotation(new LLQuaternion(rot.x, rot.y, rot.z, rot.w)); | 1522 | copy.UpdateGroupRotation(new LLQuaternion(rot.x, rot.y, rot.z, rot.w)); |
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | copy.StartScripts(); | 1525 | copy.CreateScriptInstances(0, false); |
1526 | copy.HasGroupChanged = true; | 1526 | copy.HasGroupChanged = true; |
1527 | copy.ScheduleGroupForFullUpdate(); | 1527 | copy.ScheduleGroupForFullUpdate(); |
1528 | return copy; | 1528 | return copy; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index f030e12..d134ea3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Start all the scripts in the scene which should be started. | 47 | /// Start all the scripts in the scene which should be started. |
48 | /// </summary> | 48 | /// </summary> |
49 | public void StartScripts() | 49 | public void CreateScriptInstances() |
50 | { | 50 | { |
51 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); | 51 | m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); |
52 | 52 | ||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
54 | { | 54 | { |
55 | if (group is SceneObjectGroup) | 55 | if (group is SceneObjectGroup) |
56 | { | 56 | { |
57 | ((SceneObjectGroup) group).StartScripts(); | 57 | ((SceneObjectGroup) group).CreateScriptInstances(0, false); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
@@ -234,6 +234,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
234 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); | 234 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); |
235 | AssetCache.AddAsset(asset); | 235 | AssetCache.AddAsset(asset); |
236 | 236 | ||
237 | if (isScriptRunning) | ||
238 | { | ||
239 | part.RemoveScriptInstance(item.ItemID); | ||
240 | } | ||
237 | // Update item with new asset | 241 | // Update item with new asset |
238 | item.AssetID = asset.FullID; | 242 | item.AssetID = asset.FullID; |
239 | group.UpdateInventoryItem(item); | 243 | group.UpdateInventoryItem(item); |
@@ -242,8 +246,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
242 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) | 246 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) |
243 | if (isScriptRunning) | 247 | if (isScriptRunning) |
244 | { | 248 | { |
245 | group.StopScript(part.LocalId, item.ItemID); | 249 | part.CreateScriptInstance(item.ItemID, 0, false); |
246 | group.StartScript(part.LocalId, item.ItemID); | ||
247 | } | 250 | } |
248 | } | 251 | } |
249 | 252 | ||
@@ -1219,7 +1222,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1219 | if (ExternalChecks.ExternalChecksCanRunScript(item.ID, part.UUID, remoteClient.AgentId)) | 1222 | if (ExternalChecks.ExternalChecksCanRunScript(item.ID, part.UUID, remoteClient.AgentId)) |
1220 | { | 1223 | { |
1221 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); | 1224 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); |
1222 | part.ParentGroup.StartScript(localID, copyID); | 1225 | // TODO: set this to "true" when scripts in inventory have persistent state to fire on_rez |
1226 | part.CreateScriptInstance(copyID, 0, false); | ||
1223 | part.GetProperties(remoteClient); | 1227 | part.GetProperties(remoteClient); |
1224 | 1228 | ||
1225 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1229 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
@@ -1280,7 +1284,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1280 | 1284 | ||
1281 | if (ExternalChecks.ExternalChecksCanRunScript(taskItem.AssetID, part.UUID, remoteClient.AgentId)) | 1285 | if (ExternalChecks.ExternalChecksCanRunScript(taskItem.AssetID, part.UUID, remoteClient.AgentId)) |
1282 | { | 1286 | { |
1283 | part.StartScript(taskItem); | 1287 | part.CreateScriptInstance(taskItem, 0, false); |
1284 | } | 1288 | } |
1285 | } | 1289 | } |
1286 | } | 1290 | } |
@@ -1312,6 +1316,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
1312 | return; | 1316 | return; |
1313 | } | 1317 | } |
1314 | 1318 | ||
1319 | // Must own the object, and have modify rights | ||
1320 | if(srcPart.OwnerID != destPart.OwnerID) | ||
1321 | return; | ||
1322 | |||
1323 | if((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0) | ||
1324 | return; | ||
1325 | |||
1315 | if (destPart.ScriptAccessPin != pin) | 1326 | if (destPart.ScriptAccessPin != pin) |
1316 | { | 1327 | { |
1317 | m_log.WarnFormat( | 1328 | m_log.WarnFormat( |
@@ -1362,17 +1373,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
1362 | destTaskItem.InvType = srcTaskItem.InvType; | 1373 | destTaskItem.InvType = srcTaskItem.InvType; |
1363 | destTaskItem.Type = srcTaskItem.Type; | 1374 | destTaskItem.Type = srcTaskItem.Type; |
1364 | 1375 | ||
1365 | // need something like destPart.AddInventoryItemExclusive(destTaskItem); | 1376 | destPart.AddInventoryItemExclusive(destTaskItem); |
1366 | // this function is supposed to silently overwrite an existing script with the same name | ||
1367 | |||
1368 | destPart.AddInventoryItem(destTaskItem); | ||
1369 | 1377 | ||
1370 | if ( running > 0 ) | 1378 | if ( running > 0 ) |
1371 | { | 1379 | { |
1372 | if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID)) | 1380 | if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID)) |
1373 | { | 1381 | { |
1374 | // why doesn't the start_param propogate? | 1382 | destPart.CreateScriptInstance(destTaskItem, 0, false); |
1375 | destPart.StartScript(destTaskItem, start_param); | ||
1376 | } | 1383 | } |
1377 | } | 1384 | } |
1378 | 1385 | ||
@@ -1874,7 +1881,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1874 | //group.ApplyPhysics(m_physicalPrim); | 1881 | //group.ApplyPhysics(m_physicalPrim); |
1875 | } | 1882 | } |
1876 | 1883 | ||
1877 | group.StartScripts(); | 1884 | // TODO: make this true to fire on_rez when scripts have state while in inventory |
1885 | group.CreateScriptInstances(0, false); | ||
1878 | 1886 | ||
1879 | if (!attachment) | 1887 | if (!attachment) |
1880 | rootPart.ScheduleFullUpdate(); | 1888 | rootPart.ScheduleFullUpdate(); |
@@ -1919,9 +1927,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
1919 | 1927 | ||
1920 | AddNewSceneObject(group, true); | 1928 | AddNewSceneObject(group, true); |
1921 | 1929 | ||
1922 | // Set the startup parameter for on_rez event and llGetStartParameter() function | ||
1923 | group.StartParameter = param; | ||
1924 | |||
1925 | // we set it's position in world. | 1930 | // we set it's position in world. |
1926 | group.AbsolutePosition = pos; | 1931 | group.AbsolutePosition = pos; |
1927 | 1932 | ||
@@ -1970,7 +1975,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1970 | group.UpdateGroupRotation(rot); | 1975 | group.UpdateGroupRotation(rot); |
1971 | group.ApplyPhysics(m_physicalPrim); | 1976 | group.ApplyPhysics(m_physicalPrim); |
1972 | group.Velocity = vel; | 1977 | group.Velocity = vel; |
1973 | group.StartScripts(param); | 1978 | group.CreateScriptInstances(param, true); |
1974 | rootPart.ScheduleFullUpdate(); | 1979 | rootPart.ScheduleFullUpdate(); |
1975 | return rootPart.ParentGroup; | 1980 | return rootPart.ParentGroup; |
1976 | } | 1981 | } |
@@ -2120,5 +2125,26 @@ namespace OpenSim.Region.Environment.Scenes | |||
2120 | 2125 | ||
2121 | } | 2126 | } |
2122 | 2127 | ||
2128 | public void GetScriptRunning(IClientAPI controllingClient, LLUUID objectID, LLUUID itemID) | ||
2129 | { | ||
2130 | IScriptModule scriptModule = RequestModuleInterface<IScriptModule>(); | ||
2131 | if(scriptModule == null) | ||
2132 | return; | ||
2133 | |||
2134 | controllingClient.SendScriptRunningReply(objectID, itemID, | ||
2135 | scriptModule.GetScriptRunning(objectID, itemID)); | ||
2136 | } | ||
2137 | |||
2138 | public void SetScriptRunning(IClientAPI controllingClient, LLUUID objectID, LLUUID itemID, bool running) | ||
2139 | { | ||
2140 | SceneObjectPart part = GetSceneObjectPart(objectID); | ||
2141 | if(part == null) | ||
2142 | return; | ||
2143 | |||
2144 | if(running) | ||
2145 | EventManager.TriggerStartScript(part.LocalId, itemID); | ||
2146 | else | ||
2147 | EventManager.TriggerStopScript(part.LocalId, itemID); | ||
2148 | } | ||
2123 | } | 2149 | } |
2124 | } | 2150 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b7117df..291a7ae 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -553,7 +553,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
553 | { | 553 | { |
554 | if (ent is SceneObjectGroup) | 554 | if (ent is SceneObjectGroup) |
555 | { | 555 | { |
556 | ((SceneObjectGroup)ent).StopScripts(); | 556 | ((SceneObjectGroup)ent).RemoveScriptInstances(); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | } | 559 | } |
@@ -567,7 +567,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
567 | { | 567 | { |
568 | if (ent is SceneObjectGroup) | 568 | if (ent is SceneObjectGroup) |
569 | { | 569 | { |
570 | ((SceneObjectGroup)ent).StartScripts(); | 570 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false); |
571 | } | 571 | } |
572 | } | 572 | } |
573 | } | 573 | } |
@@ -2029,6 +2029,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
2029 | client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; | 2029 | client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate; |
2030 | client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; | 2030 | client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; |
2031 | client.OnScriptReset += ProcessScriptReset; | 2031 | client.OnScriptReset += ProcessScriptReset; |
2032 | client.OnGetScriptRunning += GetScriptRunning; | ||
2033 | client.OnSetScriptRunning += SetScriptRunning; | ||
2032 | 2034 | ||
2033 | // EventManager.TriggerOnNewClient(client); | 2035 | // EventManager.TriggerOnNewClient(client); |
2034 | } | 2036 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs index dba10df..c7d1ce2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs +++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs | |||
@@ -72,6 +72,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
72 | (uint)LLObject.ObjectFlags.ObjectMove | | 72 | (uint)LLObject.ObjectFlags.ObjectMove | |
73 | (uint)LLObject.ObjectFlags.ObjectTransfer | | 73 | (uint)LLObject.ObjectFlags.ObjectTransfer | |
74 | (uint)LLObject.ObjectFlags.ObjectYouOwner | | 74 | (uint)LLObject.ObjectFlags.ObjectYouOwner | |
75 | (uint)LLObject.ObjectFlags.ObjectAnyOwner | | ||
75 | (uint)LLObject.ObjectFlags.ObjectOwnerModify | | 76 | (uint)LLObject.ObjectFlags.ObjectOwnerModify | |
76 | (uint)LLObject.ObjectFlags.ObjectYouOfficer; | 77 | (uint)LLObject.ObjectFlags.ObjectYouOfficer; |
77 | 78 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index aea433e..799cb41 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -39,115 +39,32 @@ namespace OpenSim.Region.Environment.Scenes | |||
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | 40 | ||
41 | /// <summary> | 41 | /// <summary> |
42 | /// Start a given script. | ||
43 | /// </summary> | ||
44 | /// <param name="localID"> | ||
45 | /// A <see cref="System.UInt32"/> | ||
46 | /// </param> | ||
47 | public void StartScript(uint localID, LLUUID itemID) | ||
48 | { | ||
49 | SceneObjectPart part = GetChildPart(localID); | ||
50 | if (part != null) | ||
51 | { | ||
52 | |||
53 | part.StartScript(itemID); | ||
54 | |||
55 | } | ||
56 | else | ||
57 | { | ||
58 | m_log.ErrorFormat( | ||
59 | "[PRIM INVENTORY]: " + | ||
60 | "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}", | ||
61 | localID, Name, UUID, itemID); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | // /// Start a given script. | ||
66 | // /// </summary> | ||
67 | // /// <param name="localID"> | ||
68 | // /// A <see cref="System.UInt32"/> | ||
69 | // /// </param> | ||
70 | // public void StartScript(LLUUID partID, LLUUID itemID) | ||
71 | // { | ||
72 | // SceneObjectPart part = GetChildPart(partID); | ||
73 | // if (part != null) | ||
74 | // { | ||
75 | // part.StartScript(itemID); | ||
76 | // } | ||
77 | // else | ||
78 | // { | ||
79 | // m_log.ErrorFormat( | ||
80 | // "[PRIM INVENTORY]: " + | ||
81 | // "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}", | ||
82 | // localID, Name, UUID, itemID); | ||
83 | // } | ||
84 | // } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Start the scripts contained in all the prims in this group. | 42 | /// Start the scripts contained in all the prims in this group. |
88 | /// </summary> | 43 | /// </summary> |
89 | public void StartScripts() | 44 | public void CreateScriptInstances(int startParam, bool postOnRez) |
90 | { | 45 | { |
91 | // Don't start scripts if they're turned off in the region! | 46 | // Don't start scripts if they're turned off in the region! |
92 | if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts)) | 47 | if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts)) |
93 | { | 48 | { |
94 | foreach (SceneObjectPart part in m_parts.Values) | 49 | foreach (SceneObjectPart part in m_parts.Values) |
95 | { | 50 | { |
96 | part.StartScripts(); | 51 | part.CreateScriptInstances(startParam, postOnRez); |
97 | } | 52 | } |
98 | } | 53 | } |
99 | } | 54 | } |
100 | 55 | ||
101 | /// <summary> | 56 | public void RemoveScriptInstances() |
102 | /// Start the scripts contained in all the prims in this group. | ||
103 | /// </summary> | ||
104 | public void StartScripts(int param) | ||
105 | { | ||
106 | // Don't start scripts if they're turned off in the region! | ||
107 | if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts)) | ||
108 | { | ||
109 | foreach (SceneObjectPart part in m_parts.Values) | ||
110 | { | ||
111 | part.StartScripts(param); | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | public void StopScripts() | ||
117 | { | 57 | { |
118 | lock (m_parts) | 58 | lock (m_parts) |
119 | { | 59 | { |
120 | foreach (SceneObjectPart part in m_parts.Values) | 60 | foreach (SceneObjectPart part in m_parts.Values) |
121 | { | 61 | { |
122 | part.StopScripts(); | 62 | part.RemoveScriptInstances(); |
123 | } | 63 | } |
124 | } | 64 | } |
125 | } | 65 | } |
126 | 66 | ||
127 | /// <summary> | 67 | /// <summary> |
128 | /// Start a given script. | ||
129 | /// </summary> | ||
130 | /// <param name="localID"> | ||
131 | /// A <see cref="System.UInt32"/> | ||
132 | /// </param> | ||
133 | public void StopScript(uint partID, LLUUID itemID) | ||
134 | { | ||
135 | SceneObjectPart part = GetChildPart(partID); | ||
136 | if (part != null) | ||
137 | { | ||
138 | part.StopScript(itemID); | ||
139 | part.RemoveScriptEvents(itemID); | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | m_log.ErrorFormat( | ||
144 | "[PRIM INVENTORY]: " + | ||
145 | "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}", | ||
146 | partID, Name, UUID, itemID); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | /// <summary> | ||
151 | /// | 68 | /// |
152 | /// </summary> | 69 | /// </summary> |
153 | /// <param name="remoteClient"></param> | 70 | /// <param name="remoteClient"></param> |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 4a24dad..ebefdce 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -114,8 +114,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
114 | private bool m_scriptListens_atTarget = false; | 114 | private bool m_scriptListens_atTarget = false; |
115 | private bool m_scriptListens_notAtTarget = false; | 115 | private bool m_scriptListens_notAtTarget = false; |
116 | 116 | ||
117 | private int m_startparameter = 0; | ||
118 | |||
119 | #region Properties | 117 | #region Properties |
120 | 118 | ||
121 | /// <summary> | 119 | /// <summary> |
@@ -137,16 +135,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
137 | protected bool m_isSelected = false; | 135 | protected bool m_isSelected = false; |
138 | 136 | ||
139 | /// <summary> | 137 | /// <summary> |
140 | /// Set start parameter for on_rez event and llGetStartParameter() | ||
141 | /// </summary> | ||
142 | [XmlIgnore] | ||
143 | public int StartParameter | ||
144 | { | ||
145 | get { return m_startparameter; } | ||
146 | set { m_startparameter = value; } | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// Number of prims in this group | 138 | /// Number of prims in this group |
151 | /// </summary> | 139 | /// </summary> |
152 | public int PrimCount | 140 | public int PrimCount |
@@ -937,7 +925,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
937 | { | 925 | { |
938 | foreach (SceneObjectPart part in m_parts.Values) | 926 | foreach (SceneObjectPart part in m_parts.Values) |
939 | { | 927 | { |
940 | part.StopScripts(); | 928 | part.RemoveScriptInstances(); |
941 | 929 | ||
942 | List<ScenePresence> avatars = Scene.GetScenePresences(); | 930 | List<ScenePresence> avatars = Scene.GetScenePresences(); |
943 | for (int i = 0; i < avatars.Count; i++) | 931 | for (int i = 0; i < avatars.Count; i++) |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index fbf2794..dc195f8 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
137 | /// <summary> | 137 | /// <summary> |
138 | /// Start all the scripts contained in this prim's inventory | 138 | /// Start all the scripts contained in this prim's inventory |
139 | /// </summary> | 139 | /// </summary> |
140 | public void StartScripts() | 140 | public void CreateScriptInstances(int startParam, bool postOnRez) |
141 | { | 141 | { |
142 | lock (m_taskInventory) | 142 | lock (m_taskInventory) |
143 | { | 143 | { |
@@ -146,25 +146,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | // XXX more hardcoding badness. Should be an enum in TaskInventoryItem | 146 | // XXX more hardcoding badness. Should be an enum in TaskInventoryItem |
147 | if (10 == item.Type) | 147 | if (10 == item.Type) |
148 | { | 148 | { |
149 | StartScript(item); | 149 | CreateScriptInstance(item, startParam, postOnRez); |
150 | } | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Start all the scripts contained in this prim's inventory | ||
157 | /// </summary> | ||
158 | public void StartScripts(int param) | ||
159 | { | ||
160 | lock (m_taskInventory) | ||
161 | { | ||
162 | foreach (TaskInventoryItem item in m_taskInventory.Values) | ||
163 | { | ||
164 | // XXX more hardcoding badness. Should be an enum in TaskInventoryItem | ||
165 | if (10 == item.Type) | ||
166 | { | ||
167 | StartScript(item, param); | ||
168 | } | 150 | } |
169 | } | 151 | } |
170 | } | 152 | } |
@@ -173,7 +155,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
173 | /// <summary> | 155 | /// <summary> |
174 | /// Stop all the scripts in this prim. | 156 | /// Stop all the scripts in this prim. |
175 | /// </summary> | 157 | /// </summary> |
176 | public void StopScripts() | 158 | public void RemoveScriptInstances() |
177 | { | 159 | { |
178 | lock (m_taskInventory) | 160 | lock (m_taskInventory) |
179 | { | 161 | { |
@@ -181,7 +163,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
181 | { | 163 | { |
182 | if (10 == item.Type) | 164 | if (10 == item.Type) |
183 | { | 165 | { |
184 | StopScript(item.ItemID); | 166 | RemoveScriptInstance(item.ItemID); |
185 | RemoveScriptEvents(item.ItemID); | 167 | RemoveScriptEvents(item.ItemID); |
186 | } | 168 | } |
187 | } | 169 | } |
@@ -193,13 +175,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
193 | /// </summary> | 175 | /// </summary> |
194 | /// <param name="item"></param> | 176 | /// <param name="item"></param> |
195 | /// <returns></returns> | 177 | /// <returns></returns> |
196 | public void StartScript(TaskInventoryItem item, int param) | ||
197 | { | ||
198 | StartScript(item); | ||
199 | m_parentGroup.Scene.EventManager.TriggerOnRezEvent(LocalId, item.ItemID, param); | ||
200 | } | ||
201 | 178 | ||
202 | public void StartScript(TaskInventoryItem item) | 179 | public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez) |
203 | { | 180 | { |
204 | // m_log.InfoFormat( | 181 | // m_log.InfoFormat( |
205 | // "[PRIM INVENTORY]: " + | 182 | // "[PRIM INVENTORY]: " + |
@@ -223,7 +200,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
223 | else | 200 | else |
224 | { | 201 | { |
225 | string script = Helpers.FieldToUTF8String(asset.Data); | 202 | string script = Helpers.FieldToUTF8String(asset.Data); |
226 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script); | 203 | m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script, startParam, postOnRez); |
227 | m_parentGroup.AddActiveScriptCount(1); | 204 | m_parentGroup.AddActiveScriptCount(1); |
228 | ScheduleFullUpdate(); | 205 | ScheduleFullUpdate(); |
229 | } | 206 | } |
@@ -237,13 +214,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
237 | /// <param name="itemId"> | 214 | /// <param name="itemId"> |
238 | /// A <see cref="LLUUID"/> | 215 | /// A <see cref="LLUUID"/> |
239 | /// </param> | 216 | /// </param> |
240 | public void StartScript(LLUUID itemId) | 217 | public void CreateScriptInstance(LLUUID itemId, int startParam, bool postOnRez) |
241 | { | 218 | { |
242 | lock (m_taskInventory) | 219 | lock (m_taskInventory) |
243 | { | 220 | { |
244 | if (m_taskInventory.ContainsKey(itemId)) | 221 | if (m_taskInventory.ContainsKey(itemId)) |
245 | { | 222 | { |
246 | StartScript(m_taskInventory[itemId]); | 223 | CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez); |
247 | 224 | ||
248 | } | 225 | } |
249 | else | 226 | else |
@@ -260,7 +237,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
260 | /// Stop a script which is in this prim's inventory. | 237 | /// Stop a script which is in this prim's inventory. |
261 | /// </summary> | 238 | /// </summary> |
262 | /// <param name="itemId"></param> | 239 | /// <param name="itemId"></param> |
263 | public void StopScript(LLUUID itemId) | 240 | public void RemoveScriptInstance(LLUUID itemId) |
264 | { | 241 | { |
265 | if (m_taskInventory.ContainsKey(itemId)) | 242 | if (m_taskInventory.ContainsKey(itemId)) |
266 | { | 243 | { |
@@ -330,6 +307,35 @@ namespace OpenSim.Region.Environment.Scenes | |||
330 | ParentGroup.HasGroupChanged = true; | 307 | ParentGroup.HasGroupChanged = true; |
331 | } | 308 | } |
332 | 309 | ||
310 | public void AddInventoryItemExclusive(TaskInventoryItem item) | ||
311 | { | ||
312 | item.ParentID = UUID; | ||
313 | item.ParentPartID = UUID; | ||
314 | |||
315 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values); | ||
316 | foreach(TaskInventoryItem i in il) | ||
317 | { | ||
318 | if(i.Name == item.Name) | ||
319 | { | ||
320 | if(i.Type == 10) | ||
321 | RemoveScriptInstance(i.ItemID); | ||
322 | RemoveInventoryItem(i.ItemID); | ||
323 | break; | ||
324 | } | ||
325 | } | ||
326 | |||
327 | lock (m_taskInventory) | ||
328 | { | ||
329 | m_taskInventory.Add(item.ItemID, item); | ||
330 | TriggerScriptChangedEvent(Changed.INVENTORY); | ||
331 | } | ||
332 | |||
333 | m_inventorySerial++; | ||
334 | //m_inventorySerial += 2; | ||
335 | HasInventoryChanged = true; | ||
336 | ParentGroup.HasGroupChanged = true; | ||
337 | } | ||
338 | |||
333 | /// <summary> | 339 | /// <summary> |
334 | /// Restore a whole collection of items to the prim's inventory at once. | 340 | /// Restore a whole collection of items to the prim's inventory at once. |
335 | /// We assume that the items already have all their fields correctly filled out. | 341 | /// We assume that the items already have all their fields correctly filled out. |