aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-21 21:47:00 +0000
committerMelanie Thielker2008-09-21 21:47:00 +0000
commit94aaf67dfaafbcbd4d871f674c465a34c1c1f332 (patch)
tree33476e5660a95bdf7d29d14beae67a6294af28a7 /OpenSim/Region/ScriptEngine/Common
parent* minor: warnings removal (diff)
downloadopensim-SC-94aaf67dfaafbcbd4d871f674c465a34c1c1f332.zip
opensim-SC-94aaf67dfaafbcbd4d871f674c465a34c1c1f332.tar.gz
opensim-SC-94aaf67dfaafbcbd4d871f674c465a34c1c1f332.tar.bz2
opensim-SC-94aaf67dfaafbcbd4d871f674c465a34c1c1f332.tar.xz
Change the scirpt engine loading mechanism. Script engines are now
ordinary region modules and are able to coexist in one instance. See http://opensimulator.org/wiki/ScriptEngines for details. There were changes to OpenSim.ini.example, please note DefaultScriptEngine. Also see the User docs and FAQ on the Wiki. Default is DotNetEngine.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs50
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs2
5 files changed, 61 insertions, 28 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index 5a9385f..4a4e808 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -65,31 +65,36 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
65 myScriptEngine = _ScriptEngine; 65 myScriptEngine = _ScriptEngine;
66 ReadConfig(); 66 ReadConfig();
67 67
68 // Hook up to events from OpenSim
69 // We may not want to do it because someone is controlling us and will deliver events to us
70 if (performHookUp) 68 if (performHookUp)
71 { 69 {
72 myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events");
73 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
74 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
75 myScriptEngine.World.EventManager.OnRezScript += OnRezScript; 70 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
76 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; 71 }
77 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; 72 }
78 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; 73
79 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; 74 public void HookUpEvents()
80 myScriptEngine.World.EventManager.OnScriptControlEvent += control; 75 {
81 myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start; 76 // Hook up to events from OpenSim
82 myScriptEngine.World.EventManager.OnScriptColliding += collision; 77 // We may not want to do it because someone is controlling us and will deliver events to us
83 myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end;
84
85 // TODO: HOOK ALL EVENTS UP TO SERVER!
86 IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
87 if (money != null)
88 {
89 money.OnObjectPaid+=HandleObjectPaid;
90 }
91 78
79 myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events");
80 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
81 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
82 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
83 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
84 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
85 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target;
86 myScriptEngine.World.EventManager.OnScriptControlEvent += control;
87 myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start;
88 myScriptEngine.World.EventManager.OnScriptColliding += collision;
89 myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end;
90
91 // TODO: HOOK ALL EVENTS UP TO SERVER!
92 IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
93 if (money != null)
94 {
95 money.OnObjectPaid+=HandleObjectPaid;
92 } 96 }
97
93 } 98 }
94 99
95 public void ReadConfig() 100 public void ReadConfig()
@@ -187,8 +192,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
187 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); 192 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
188 } 193 }
189 194
190 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez) 195 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
191 { 196 {
197 if (engine != "DotNetEngine")
198 return;
199
192 myScriptEngine.Log.Debug("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + 200 myScriptEngine.Log.Debug("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
193 script.Length); 201 script.Length);
194 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez); 202 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez);
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index af7fca3..282559a 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -353,6 +353,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
353 /// <param name="param">Array of parameters to match event mask</param> 353 /// <param name="param">Array of parameters to match event mask</param>
354 public void AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) 354 public void AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
355 { 355 {
356 List<UUID> keylist = new List<UUID>(m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID));
357
358 if (!keylist.Contains(itemID)) // We don't manage that script
359 return;
360
356 lock (eventQueue) 361 lock (eventQueue)
357 { 362 {
358 if (eventQueue.Count >= EventExecutionMaxQueueSize) 363 if (eventQueue.Count >= EventExecutionMaxQueueSize)
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index b0c6314..26e5ec2 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -56,6 +56,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
56 public IConfigSource ConfigSource; 56 public IConfigSource ConfigSource;
57 public IConfig ScriptConfigSource; 57 public IConfig ScriptConfigSource;
58 public abstract string ScriptEngineName { get; } 58 public abstract string ScriptEngineName { get; }
59 private bool m_enabled = true;
60 private bool m_hookUpToServer = false;
59 61
60 /// <summary> 62 /// <summary>
61 /// How many seconds between re-reading config-file. 0 = never. ScriptEngine will try to adjust to new config changes. 63 /// How many seconds between re-reading config-file. 0 = never. ScriptEngine will try to adjust to new config changes.
@@ -91,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
91 { 93 {
92 World = Sceneworld; 94 World = Sceneworld;
93 ConfigSource = config; 95 ConfigSource = config;
96 m_hookUpToServer = HookUpToServer;
97
94 m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing"); 98 m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
95 99
96 // Make sure we have config 100 // Make sure we have config
@@ -98,13 +102,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
98 ConfigSource.AddConfig(ScriptEngineName); 102 ConfigSource.AddConfig(ScriptEngineName);
99 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName]; 103 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
100 104
105 m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
106 if (!m_enabled)
107 return;
108
101 //m_log.Info("[" + ScriptEngineName + "]: InitializeEngine"); 109 //m_log.Info("[" + ScriptEngineName + "]: InitializeEngine");
102 110
103 // Create all objects we'll be using 111 // Create all objects we'll be using
104 m_EventQueueManager = new EventQueueManager(this); 112 m_EventQueueManager = new EventQueueManager(this);
105 m_EventManager = new EventManager(this, HookUpToServer); 113 m_EventManager = new EventManager(this, HookUpToServer);
106 // We need to start it 114 // We need to start it
107 newScriptManager.Start();
108 m_ScriptManager = newScriptManager; 115 m_ScriptManager = newScriptManager;
109 m_AppDomainManager = new AppDomainManager(this); 116 m_AppDomainManager = new AppDomainManager(this);
110 m_ASYNCLSLCommandManager = new AsyncCommandManager(this); 117 m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
@@ -118,6 +125,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
118 // Or can we assume we are loaded before anything else so we can use proper events? 125 // Or can we assume we are loaded before anything else so we can use proper events?
119 } 126 }
120 127
128 public void PostInitialise()
129 {
130 if (!m_enabled)
131 return;
132
133 if (m_hookUpToServer)
134 m_EventManager.HookUpEvents();
135
136 m_ScriptManager.Start();
137 }
138
121 public void Shutdown() 139 public void Shutdown()
122 { 140 {
123 // We are shutting down 141 // We are shutting down
@@ -155,10 +173,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
155 173
156 public abstract void Initialise(Scene scene, IConfigSource config); 174 public abstract void Initialise(Scene scene, IConfigSource config);
157 175
158 public void PostInitialise()
159 {
160 }
161
162 public void Close() 176 public void Close()
163 { 177 {
164 } 178 }
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
index 60333b1..47cb2fd 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
@@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
64 private static bool PrivateThread; 64 private static bool PrivateThread;
65 private int LoadUnloadMaxQueueSize; 65 private int LoadUnloadMaxQueueSize;
66 private Object scriptLock = new Object(); 66 private Object scriptLock = new Object();
67 private bool m_started = false;
67 68
68 // Load/Unload structure 69 // Load/Unload structure
69 private struct LUStruct 70 private struct LUStruct
@@ -119,6 +120,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
119 public abstract void Initialize(); 120 public abstract void Initialize();
120 public void Start() 121 public void Start()
121 { 122 {
123 m_started = true;
124
122 ReadConfig(); 125 ReadConfig();
123 Initialize(); 126 Initialize();
124 127
@@ -213,6 +216,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
213 216
214 public void DoScriptLoadUnload() 217 public void DoScriptLoadUnload()
215 { 218 {
219 if (!m_started)
220 return;
221
216 lock (LUQueue) 222 lock (LUQueue)
217 { 223 {
218 if (LUQueue.Count > 0) 224 if (LUQueue.Count > 0)
@@ -258,7 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
258 { 264 {
259 lock (LUQueue) 265 lock (LUQueue)
260 { 266 {
261 if (LUQueue.Count >= LoadUnloadMaxQueueSize) 267 if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
262 { 268 {
263 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script."); 269 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: ERROR: Load/unload queue item count is at " + LUQueue.Count + ". Config variable \"LoadUnloadMaxQueueSize\" is set to " + LoadUnloadMaxQueueSize + ", so ignoring new script.");
264 return; 270 return;
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index a6473ee..aa8dc61 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, uint originalID, Vector3 offsetPos, IClientAPI remoteClient); 41 void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient);
42 void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez); 42 void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
43 void OnRemoveScript(uint localID, UUID itemID); 43 void OnRemoveScript(uint localID, UUID itemID);
44 void state_exit(uint localID); 44 void state_exit(uint localID);
45 void touch(uint localID, uint originalID, UUID itemID); 45 void touch(uint localID, uint originalID, UUID itemID);