aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IClientAPI.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServerMain.cs2
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs3
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs29
-rw-r--r--OpenSim/Region/Environment/Interfaces/IScriptModule.cs38
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs3
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs37
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs60
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs91
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs14
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs70
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs175
24 files changed, 372 insertions, 200 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index a646224..9307aef 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -643,6 +643,8 @@ namespace OpenSim.Framework
643 public delegate void EstateDebugRegionRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, bool scripted, bool collisionEvents, bool physics); 643 public delegate void EstateDebugRegionRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, bool scripted, bool collisionEvents, bool physics);
644 public delegate void EstateTeleportOneUserHomeRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID prey); 644 public delegate void EstateTeleportOneUserHomeRequest(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, LLUUID prey);
645 public delegate void ScriptReset(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID); 645 public delegate void ScriptReset(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID);
646 public delegate void GetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID);
647 public delegate void SetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, bool running);
646 648
647 public interface IClientAPI 649 public interface IClientAPI
648 { 650 {
@@ -839,6 +841,8 @@ namespace OpenSim.Framework
839 841
840 event RequestObjectPropertiesFamily OnObjectGroupRequest; 842 event RequestObjectPropertiesFamily OnObjectGroupRequest;
841 event ScriptReset OnScriptReset; 843 event ScriptReset OnScriptReset;
844 event GetScriptRunning OnGetScriptRunning;
845 event SetScriptRunning OnSetScriptRunning;
842 event UpdateVector OnAutoPilotGo; 846 event UpdateVector OnAutoPilotGo;
843 847
844 // [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")] 848 // [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")]
@@ -1015,6 +1019,8 @@ namespace OpenSim.Framework
1015 1019
1016 void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia); 1020 void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia);
1017 1021
1022 void SendScriptRunningReply(LLUUID objectID, LLUUID itemID, bool running);
1023
1018 void SendAsset(AssetRequestToClient req); 1024 void SendAsset(AssetRequestToClient req);
1019 1025
1020 void SendTexture(AssetBase TextureAsset); 1026 void SendTexture(AssetBase TextureAsset);
diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
index 9de250b..844f27d 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Grid.ScriptServer
93 93
94 if (Command == "OnRezScript") 94 if (Command == "OnRezScript")
95 { 95 {
96 Engine.EventManager().OnRezScript((uint)p[0], new LLUUID((string)p[1]), (string)p[2]); 96 Engine.EventManager().OnRezScript((uint)p[0], new LLUUID((string)p[1]), (string)p[2], 0, false);
97 } 97 }
98 } 98 }
99 99
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 06b4de7..a32210b 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -535,7 +535,7 @@ namespace OpenSim
535 } 535 }
536 536
537 // We need to do this after we've initialized the scripting engines. 537 // We need to do this after we've initialized the scripting engines.
538 scene.StartScripts(); 538 scene.CreateScriptInstances();
539 539
540 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); 540 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
541 scene.EventManager.TriggerParcelPrimCountUpdate(); 541 scene.EventManager.TriggerParcelPrimCountUpdate();
@@ -729,3 +729,4 @@ namespace OpenSim
729} 729}
730 730
731 731
732
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 0294ca7..cd3efe3 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -277,6 +277,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
277 277
278 private RequestObjectPropertiesFamily handlerObjectGroupRequest = null; 278 private RequestObjectPropertiesFamily handlerObjectGroupRequest = null;
279 private ScriptReset handlerScriptReset = null; 279 private ScriptReset handlerScriptReset = null;
280 private GetScriptRunning handlerGetScriptRunning = null;
281 private SetScriptRunning handlerSetScriptRunning = null;
280 private UpdateVector handlerAutoPilotGo = null; 282 private UpdateVector handlerAutoPilotGo = null;
281 283
282 /* Properties */ 284 /* Properties */
@@ -921,6 +923,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
921 public event EstateDebugRegionRequest OnEstateDebugRegionRequest; 923 public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
922 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; 924 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
923 public event ScriptReset OnScriptReset; 925 public event ScriptReset OnScriptReset;
926 public event GetScriptRunning OnGetScriptRunning;
927 public event SetScriptRunning OnSetScriptRunning;
924 public event UpdateVector OnAutoPilotGo; 928 public event UpdateVector OnAutoPilotGo;
925 929
926 #region Scene/Avatar to Client 930 #region Scene/Avatar to Client
@@ -6187,7 +6191,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6187 m_log.Warn("[CLIENT]: unhandled InventoryDescent packet"); 6191 m_log.Warn("[CLIENT]: unhandled InventoryDescent packet");
6188 break; 6192 break;
6189 case PacketType.GetScriptRunning: 6193 case PacketType.GetScriptRunning:
6190 m_log.Warn("[CLIENT]: unhandled GetScriptRunning packet"); 6194 GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
6195 handlerGetScriptRunning = OnGetScriptRunning;
6196 if (handlerGetScriptRunning != null)
6197 {
6198 handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
6199 }
6200 break;
6201 case PacketType.SetScriptRunning:
6202 SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
6203 handlerSetScriptRunning = OnSetScriptRunning;
6204 if (handlerSetScriptRunning != null)
6205 {
6206 handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
6207 }
6191 break; 6208 break;
6192 default: 6209 default:
6193 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString()); 6210 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString());
@@ -6390,6 +6407,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6390 OutPacket(lsrp, ThrottleOutPacketType.Task); 6407 OutPacket(lsrp, ThrottleOutPacketType.Task);
6391 } 6408 }
6392 6409
6410 public void SendScriptRunningReply(LLUUID objectID, LLUUID itemID, bool running)
6411 {
6412 ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
6413 scriptRunningReply.Script.ObjectID = objectID;
6414 scriptRunningReply.Script.ItemID = itemID;
6415 scriptRunningReply.Script.Running = running;
6416
6417 OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
6418 }
6419
6393 public void SendAsset(AssetRequestToClient req) 6420 public void SendAsset(AssetRequestToClient req)
6394 { 6421 {
6395 6422
diff --git a/OpenSim/Region/Environment/Interfaces/IScriptModule.cs b/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
new file mode 100644
index 0000000..7aecaf7
--- /dev/null
+++ b/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
@@ -0,0 +1,38 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Framework;
30using libsecondlife;
31
32namespace OpenSim.Region.Environment.Interfaces
33{
34 public interface IScriptModule : IRegionModule
35 {
36 bool GetScriptRunning(LLUUID objectID, LLUUID itemID);
37 }
38}
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index 83d4603..5d94407 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -291,6 +291,8 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
291 public event EstateDebugRegionRequest OnEstateDebugRegionRequest; 291 public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
292 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; 292 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
293 public event ScriptReset OnScriptReset; 293 public event ScriptReset OnScriptReset;
294 public event GetScriptRunning OnGetScriptRunning;
295 public event SetScriptRunning OnSetScriptRunning;
294 public event UpdateVector OnAutoPilotGo; 296 public event UpdateVector OnAutoPilotGo;
295 297
296#pragma warning restore 67 298#pragma warning restore 67
@@ -783,6 +785,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
783 { 785 {
784 } 786 }
785 787
788 public void SendScriptRunningReply(LLUUID objectID, LLUUID itemID, bool running)
789 {
790 }
791
786 public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) 792 public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
787 { 793 {
788 } 794 }
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index d6ee739..6cf2f29 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -300,6 +300,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
300 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod) 300 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod)
301 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 301 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
302 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object 302 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object
303 LLObject.ObjectFlags.ObjectAnyOwner | // Tells client that someone owns the object
303 LLObject.ObjectFlags.ObjectOwnerModify | // Tells client that you're the owner of the object 304 LLObject.ObjectFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
304 LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set 305 LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
305 ); 306 );
@@ -307,7 +308,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
307 // Creating the three ObjectFlags options for this method to choose from. 308 // Creating the three ObjectFlags options for this method to choose from.
308 // Customize the OwnerMask 309 // Customize the OwnerMask
309 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags); 310 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
310 objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner | (uint)LLObject.ObjectFlags.ObjectOwnerModify; 311 objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner | (uint)LLObject.ObjectFlags.ObjectAnyOwner | (uint)LLObject.ObjectFlags.ObjectOwnerModify;
311 312
312 // Customize the GroupMask 313 // Customize the GroupMask
313 // uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags); 314 // uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
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.
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 8a77b15..4379c44 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -196,6 +196,8 @@ namespace OpenSim.Region.Examples.SimpleModule
196 public event EstateDebugRegionRequest OnEstateDebugRegionRequest; 196 public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
197 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; 197 public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
198 public event ScriptReset OnScriptReset; 198 public event ScriptReset OnScriptReset;
199 public event GetScriptRunning OnGetScriptRunning;
200 public event SetScriptRunning OnSetScriptRunning;
199 public event UpdateVector OnAutoPilotGo; 201 public event UpdateVector OnAutoPilotGo;
200 202
201#pragma warning restore 67 203#pragma warning restore 67
@@ -776,6 +778,10 @@ namespace OpenSim.Region.Examples.SimpleModule
776 { 778 {
777 } 779 }
778 780
781 public void SendScriptRunningReply(LLUUID objectID, LLUUID itemID, bool running)
782 {
783 }
784
779 public void SendAsset(AssetRequestToClient req) 785 public void SendAsset(AssetRequestToClient req)
780 { 786 {
781 } 787 }
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 6f4943d..c240573 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -2344,8 +2344,8 @@ namespace OpenSim.Region.ScriptEngine.Common
2344 public LSL_Types.LSLInteger llGetStartParameter() 2344 public LSL_Types.LSLInteger llGetStartParameter()
2345 { 2345 {
2346 m_host.AddScriptLPS(1); 2346 m_host.AddScriptLPS(1);
2347 // NotImplemented("llGetStartParameter"); 2347 NotImplemented("llGetStartParameter");
2348 return m_host.ParentGroup.StartParameter; 2348 return 0;
2349 } 2349 }
2350 2350
2351 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) 2351 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos)
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index 5a3ebc7..93b68d4 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -186,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
186 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); 186 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
187 } 187 }
188 188
189 public void OnRezScript(uint localID, LLUUID itemID, string script) 189 public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez)
190 { 190 {
191 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + 191 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
192 script.Length); 192 script.Length);
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index 59f828d..f04ac01 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Common
39 public interface RemoteEvents 39 public interface RemoteEvents
40 { 40 {
41 void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); 41 void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient);
42 void OnRezScript(uint localID, LLUUID itemID, string script); 42 void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez);
43 void OnRemoveScript(uint localID, LLUUID itemID); 43 void OnRemoveScript(uint localID, LLUUID itemID);
44 void state_exit(uint localID); 44 void state_exit(uint localID);
45 void touch(uint localID, LLUUID itemID); 45 void touch(uint localID, LLUUID itemID);
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 2fa67a4..579af31 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
53 void SetScriptState(LLUUID itemID, bool state); 53 void SetScriptState(LLUUID itemID, bool state);
54 bool GetScriptState(LLUUID itemID); 54 bool GetScriptState(LLUUID itemID);
55 void SetState(LLUUID itemID, string newState); 55 void SetState(LLUUID itemID, string newState);
56 int GetStartParameter(LLUUID itemID);
56 57
57 DetectParams GetDetectParams(LLUUID item, int number); 58 DetectParams GetDetectParams(LLUUID item, int number);
58 } 59 }
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
index 54a6643..6924dd2 100644
--- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
77 } 77 }
78 } 78 }
79 79
80 public void OnRezScript(uint localID, LLUUID itemID, string script) 80 public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez)
81 { 81 {
82 // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID 82 // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID
83 myScriptEngine.Log.Info("[RemoteEngine]: Creating new script (with connection)"); 83 myScriptEngine.Log.Info("[RemoteEngine]: Creating new script (with connection)");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index afdd898..0320857 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2200,8 +2200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2200 public LSL_Types.LSLInteger llGetStartParameter() 2200 public LSL_Types.LSLInteger llGetStartParameter()
2201 { 2201 {
2202 m_host.AddScriptLPS(1); 2202 m_host.AddScriptLPS(1);
2203 // NotImplemented("llGetStartParameter"); 2203 return m_ScriptEngine.GetStartParameter(m_itemID);
2204 return m_host.ParentGroup.StartParameter;
2205 } 2204 }
2206 2205
2207 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) 2206 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 8bfef79..3fd4942 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -53,7 +53,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
53 myScriptEngine.Log.Info("[XEngine] Hooking up to server events"); 53 myScriptEngine.Log.Info("[XEngine] Hooking up to server events");
54 myScriptEngine.World.EventManager.OnObjectGrab += touch_start; 54 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
55 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; 55 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
56 myScriptEngine.World.EventManager.OnRezEvent += on_rez;
57 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; 56 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
58 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; 57 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
59 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; 58 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target;
@@ -254,14 +253,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
254 // timer: not handled here 253 // timer: not handled here
255 // listen: not handled here 254 // listen: not handled here
256 255
257 public void on_rez(uint localID, LLUUID itemID, int startParam)
258 {
259 myScriptEngine.PostObjectEvent(localID, new EventParams(
260 "on_rez",new object[] {
261 new LSL_Types.LSLInteger(startParam)},
262 new DetectParams[0]));
263 }
264
265 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) 256 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change)
266 { 257 {
267 myScriptEngine.PostObjectEvent(localID, new EventParams( 258 myScriptEngine.PostObjectEvent(localID, new EventParams(
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index f025090..4c9ffd0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -49,7 +49,7 @@ using OpenSim.Region.ScriptEngine.Interfaces;
49 49
50namespace OpenSim.Region.ScriptEngine.XEngine 50namespace OpenSim.Region.ScriptEngine.XEngine
51{ 51{
52 public class XEngine : IRegionModule, IScriptEngine 52 public class XEngine : IScriptModule, IScriptEngine
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
@@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
64 private int m_EventLimit; 64 private int m_EventLimit;
65 private bool m_KillTimedOutScripts; 65 private bool m_KillTimedOutScripts;
66 public AsyncCommandManager m_AsyncCommands; 66 public AsyncCommandManager m_AsyncCommands;
67 bool m_firstStart = true;
67 68
68 private static List<XEngine> m_ScriptEngines = 69 private static List<XEngine> m_ScriptEngines =
69 new List<XEngine>(); 70 new List<XEngine>();
@@ -93,6 +94,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
93 private Dictionary<LLUUID, List<LLUUID> > m_DomainScripts = 94 private Dictionary<LLUUID, List<LLUUID> > m_DomainScripts =
94 new Dictionary<LLUUID, List<LLUUID> >(); 95 new Dictionary<LLUUID, List<LLUUID> >();
95 96
97 private Queue m_CompileQueue = new Queue(100);
98 IWorkItemResult m_CurrentCompile = null;
99
96 public string ScriptEngineName 100 public string ScriptEngineName
97 { 101 {
98 get { return "XEngine"; } 102 get { return "XEngine"; }
@@ -202,6 +206,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
202 m_Scene.EventManager.OnRezScript += OnRezScript; 206 m_Scene.EventManager.OnRezScript += OnRezScript;
203 m_Scene.EventManager.OnRemoveScript += OnRemoveScript; 207 m_Scene.EventManager.OnRemoveScript += OnRemoveScript;
204 m_Scene.EventManager.OnScriptReset += OnScriptReset; 208 m_Scene.EventManager.OnScriptReset += OnScriptReset;
209 m_Scene.EventManager.OnStartScript += OnStartScript;
210 m_Scene.EventManager.OnStopScript += OnStopScript;
205 211
206 m_AsyncCommands = new AsyncCommandManager(this); 212 m_AsyncCommands = new AsyncCommandManager(this);
207 213
@@ -217,6 +223,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
217 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 223 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
218 this.DoBackup), new Object[] { saveTime }); 224 this.DoBackup), new Object[] { saveTime });
219 } 225 }
226
227 scene.RegisterModuleInterface<IScriptModule>(this);
220 } 228 }
221 229
222 public void PostInitialise() 230 public void PostInitialise()
@@ -314,23 +322,90 @@ namespace OpenSim.Region.ScriptEngine.XEngine
314 get { return m_MaxScriptQueue; } 322 get { return m_MaxScriptQueue; }
315 } 323 }
316 324
317 // 325 public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez)
318 // Hooks
319 //
320 public void OnRezScript(uint localID, LLUUID itemID, string script)
321 { 326 {
322// m_ThreadPool.QueueWorkItem(new WorkItemCallback( 327 Object[] parms = new Object[]
323// this.DoOnRezScript), new Object[] 328 { localID, itemID, script, startParam, postOnRez};
324// { localID, itemID, script}); 329
325 DoOnRezScript(new Object[] { localID, itemID, script}); 330 lock(m_CompileQueue)
331 {
332 m_CompileQueue.Enqueue(parms);
333 if(m_CurrentCompile == null)
334 {
335 if(m_firstStart)
336 {
337 m_firstStart = false;
338 m_CurrentCompile = m_ThreadPool.QueueWorkItem(
339 new WorkItemCallback(
340 this.DoScriptWait), new Object[0]);
341 return;
342 }
343 m_CurrentCompile = m_ThreadPool.QueueWorkItem(
344 new WorkItemCallback(
345 this.DoOnRezScriptQueue), new Object[0]);
346 }
347 }
326 } 348 }
327 349
328 private object DoOnRezScript(object parm) 350 public Object DoScriptWait(Object dummy)
351 {
352 Thread.Sleep(30000);
353
354 lock(m_CompileQueue)
355 {
356 if(m_CompileQueue.Count > 0)
357 {
358 m_CurrentCompile = m_ThreadPool.QueueWorkItem(
359 new WorkItemCallback(
360 this.DoOnRezScriptQueue), new Object[0]);
361 }
362 else
363 {
364 m_CurrentCompile = null;
365 }
366 }
367 return null;
368 }
369
370 public Object DoOnRezScriptQueue(Object dummy)
371 {
372 Object o;
373 lock(m_CompileQueue)
374 {
375 o = m_CompileQueue.Dequeue();
376 if(o == null)
377 {
378 m_CurrentCompile = null;
379 return null;
380 }
381 }
382
383 DoOnRezScript(o);
384
385 lock(m_CompileQueue)
386 {
387 if(m_CompileQueue.Count > 0)
388 {
389 m_CurrentCompile = m_ThreadPool.QueueWorkItem(
390 new WorkItemCallback(
391 this.DoOnRezScriptQueue), new Object[0]);
392 }
393 else
394 {
395 m_CurrentCompile = null;
396 }
397 }
398 return null;
399 }
400
401 private bool DoOnRezScript(object parm)
329 { 402 {
330 Object[] p = (Object[])parm; 403 Object[] p = (Object[])parm;
331 uint localID = (uint)p[0]; 404 uint localID = (uint)p[0];
332 LLUUID itemID = (LLUUID)p[1]; 405 LLUUID itemID = (LLUUID)p[1];
333 string script =(string)p[2]; 406 string script =(string)p[2];
407 int startParam = (int)p[3];
408 bool postOnRez = (bool)p[4];
334 409
335 // Get the asset ID of the script, so we can check if we 410 // Get the asset ID of the script, so we can check if we
336 // already have it. 411 // already have it.
@@ -427,7 +502,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
427 part.UUID, itemID, assetID, assembly, 502 part.UUID, itemID, assetID, assembly,
428 m_AppDomains[appDomain], 503 m_AppDomains[appDomain],
429 part.ParentGroup.RootPart.Name, 504 part.ParentGroup.RootPart.Name,
430 item.Name, XScriptInstance.StateSource.NewRez); 505 item.Name, startParam, postOnRez,
506 XScriptInstance.StateSource.NewRez);
431 507
432 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", 508 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}",
433 part.ParentGroup.RootPart.Name, item.Name); 509 part.ParentGroup.RootPart.Name, item.Name);
@@ -505,6 +581,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
505 ResetScript(itemID); 581 ResetScript(itemID);
506 } 582 }
507 583
584 public void OnStartScript(uint localID, LLUUID itemID)
585 {
586 StartScript(itemID);
587 }
588
589 public void OnStopScript(uint localID, LLUUID itemID)
590 {
591 StopScript(itemID);
592 }
593
508 private void CleanAssemblies() 594 private void CleanAssemblies()
509 { 595 {
510 List<LLUUID> assetIDList = new List<LLUUID>(m_Assemblies.Keys); 596 List<LLUUID> assetIDList = new List<LLUUID>(m_Assemblies.Keys);
@@ -674,7 +760,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
674 if (running) 760 if (running)
675 instance.Start(); 761 instance.Start();
676 else 762 else
677 instance.Stop(500); 763 instance.Stop(100);
678 } 764 }
679 } 765 }
680 766
@@ -693,6 +779,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
693 instance.ResetScript(); 779 instance.ResetScript();
694 } 780 }
695 781
782 public void StartScript(LLUUID itemID)
783 {
784 XScriptInstance instance = GetInstance(itemID);
785 if (instance != null)
786 instance.Start();
787 }
788
789 public void StopScript(LLUUID itemID)
790 {
791 XScriptInstance instance = GetInstance(itemID);
792 if (instance != null)
793 instance.Stop(0);
794 }
795
696 public DetectParams GetDetectParams(LLUUID itemID, int idx) 796 public DetectParams GetDetectParams(LLUUID itemID, int idx)
697 { 797 {
698 XScriptInstance instance = GetInstance(itemID); 798 XScriptInstance instance = GetInstance(itemID);
@@ -723,6 +823,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
723 return "default"; 823 return "default";
724 return instance.State; 824 return instance.State;
725 } 825 }
826
827 public int GetStartParameter(LLUUID itemID)
828 {
829 XScriptInstance instance = GetInstance(itemID);
830 if (instance == null)
831 return 0;
832 return instance.StartParam;
833 }
834
835 public bool GetScriptRunning(LLUUID objectID, LLUUID itemID)
836 {
837 return GetScriptState(itemID);
838 }
726 } 839 }
727 840
728 public class XScriptInstance 841 public class XScriptInstance
@@ -745,6 +858,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
745 private string m_PrimName; 858 private string m_PrimName;
746 private string m_ScriptName; 859 private string m_ScriptName;
747 private string m_Assembly; 860 private string m_Assembly;
861 private int m_StartParam = 0;
862
748 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); 863 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
749 864
750 public enum StateSource 865 public enum StateSource
@@ -823,9 +938,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
823 m_EventQueue.Clear(); 938 m_EventQueue.Clear();
824 } 939 }
825 940
941 public int StartParam
942 {
943 get { return m_StartParam; }
944 set { m_StartParam = value; }
945 }
946
826 public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, 947 public XScriptInstance(XEngine engine, uint localID, LLUUID objectID,
827 LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, 948 LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom,
828 string primName, string scriptName, StateSource stateSource) 949 string primName, string scriptName, int startParam,
950 bool postOnRez, StateSource stateSource)
829 { 951 {
830 m_Engine = engine; 952 m_Engine = engine;
831 953
@@ -836,6 +958,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
836 m_PrimName = primName; 958 m_PrimName = primName;
837 m_ScriptName = scriptName; 959 m_ScriptName = scriptName;
838 m_Assembly = assembly; 960 m_Assembly = assembly;
961 m_StartParam = startParam;
839 962
840 ApiManager am = new ApiManager(); 963 ApiManager am = new ApiManager();
841 964
@@ -918,6 +1041,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
918 { 1041 {
919 m_RunEvents = false; 1042 m_RunEvents = false;
920 Start(); 1043 Start();
1044 if(postOnRez)
1045 PostEvent(new EventParams("on_rez",
1046 new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0]));
921 } 1047 }
922 1048
923 // we get new rez events on sim restart, too 1049 // we get new rez events on sim restart, too
@@ -934,25 +1060,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine
934 else 1060 else
935 { 1061 {
936 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); 1062 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded");
1063 Start();
937 PostEvent(new EventParams("state_entry", 1064 PostEvent(new EventParams("state_entry",
938 new Object[0], new DetectParams[0])); 1065 new Object[0], new DetectParams[0]));
939 Start(); 1066 if(postOnRez)
1067 PostEvent(new EventParams("on_rez",
1068 new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0]));
1069
940 } 1070 }
941 } 1071 }
942 catch (Exception e) 1072 catch (Exception e)
943 { 1073 {
944 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); 1074 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml);
1075 Start();
945 PostEvent(new EventParams("state_entry", 1076 PostEvent(new EventParams("state_entry",
946 new Object[0], new DetectParams[0])); 1077 new Object[0], new DetectParams[0]));
947 Start(); 1078 if(postOnRez)
1079 PostEvent(new EventParams("on_rez",
1080 new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0]));
948 } 1081 }
949 } 1082 }
950 else 1083 else
951 { 1084 {
952 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); 1085// m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found");
1086 Start();
953 PostEvent(new EventParams("state_entry", 1087 PostEvent(new EventParams("state_entry",
954 new Object[0], new DetectParams[0])); 1088 new Object[0], new DetectParams[0]));
955 Start(); 1089
1090 if(postOnRez)
1091 PostEvent(new EventParams("on_rez",
1092 new Object[] {new LSL_Types.LSLInteger(startParam)}, new DetectParams[0]));
956 } 1093 }
957 } 1094 }
958 1095
@@ -1062,6 +1199,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1062 { 1199 {
1063// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", 1200// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}",
1064// m_PrimName, m_ScriptName, data.EventName, m_State); 1201// m_PrimName, m_ScriptName, data.EventName, m_State);
1202
1203 if(!Running)
1204 return;
1205
1065 lock (m_EventQueue) 1206 lock (m_EventQueue)
1066 { 1207 {
1067 if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) 1208 if (m_EventQueue.Count >= m_Engine.MaxScriptQueue)