aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-27 13:31:04 -0700
committerJohn Hurliman2009-10-27 13:31:04 -0700
commit2525810e2a1b23f9c5b17b3d075e02c0c6255e2c (patch)
treef4312229b82d5edf8477920a97e7e79c40379473 /OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
parentLowering the position tolerance of terse updates for ScenePresences to mitiga... (diff)
downloadopensim-SC-2525810e2a1b23f9c5b17b3d075e02c0c6255e2c.zip
opensim-SC-2525810e2a1b23f9c5b17b3d075e02c0c6255e2c.tar.gz
opensim-SC-2525810e2a1b23f9c5b17b3d075e02c0c6255e2c.tar.bz2
opensim-SC-2525810e2a1b23f9c5b17b3d075e02c0c6255e2c.tar.xz
Removed the DotNetEngine scripting engine. You will need to create a fresh checkout or clean out all *DotNet*.dll assemblies from the bin/ directory to run OpenSim moving forward
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs485
1 files changed, 0 insertions, 485 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
deleted file mode 100644
index 9806218..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ /dev/null
@@ -1,485 +0,0 @@
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 OpenSimulator 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 System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Region.CoreModules.Framework.EventQueue;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenMetaverse;
39using OpenMetaverse.StructuredData;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
42
43namespace OpenSim.Region.ScriptEngine.DotNetEngine
44{
45 [Serializable]
46 public class ScriptEngine : INonSharedRegionModule, IScriptEngine, IScriptModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static List<ScriptEngine> ScriptEngines =
51 new List<ScriptEngine>();
52
53 private Scene m_Scene;
54 public Scene World
55 {
56 get { return m_Scene; }
57 }
58
59 // Handles and queues incoming events from OpenSim
60 public EventManager m_EventManager;
61
62 // Executes events, handles script threads
63 public EventQueueManager m_EventQueueManager;
64
65 // Load, unload and execute scripts
66 public ScriptManager m_ScriptManager;
67
68 // Handles loading/unloading of scripts into AppDomains
69 public AppDomainManager m_AppDomainManager;
70
71 // Thread that does different kinds of maintenance,
72 // for example refreshing config and killing scripts
73 // that has been running too long
74 public static MaintenanceThread m_MaintenanceThread;
75
76 private IConfigSource m_ConfigSource;
77 public IConfig ScriptConfigSource;
78 private bool m_enabled = false;
79
80 public IConfig Config
81 {
82 get { return ScriptConfigSource; }
83 }
84
85 public IConfigSource ConfigSource
86 {
87 get { return m_ConfigSource; }
88 }
89
90 // How many seconds between re-reading config-file.
91 // 0 = never. ScriptEngine will try to adjust to new config changes.
92 public int RefreshConfigFileSeconds {
93 get { return (int)(RefreshConfigFilens / 10000000); }
94 set { RefreshConfigFilens = value * 10000000; }
95 }
96
97 public long RefreshConfigFilens;
98
99 public string ScriptEngineName
100 {
101 get { return "ScriptEngine.DotNetEngine"; }
102 }
103
104 public IScriptModule ScriptModule
105 {
106 get { return this; }
107 }
108
109 public event ScriptRemoved OnScriptRemoved;
110 public event ObjectRemoved OnObjectRemoved;
111
112 public ScriptEngine()
113 {
114 // For logging, just need any instance, doesn't matter
115 Common.mySE = this;
116
117 lock (ScriptEngines)
118 {
119 // Keep a list of ScriptEngines for shared threads
120 // to process all instances
121 ScriptEngines.Add(this);
122 }
123 }
124
125 public void Initialise(IConfigSource config)
126 {
127 m_ConfigSource = config;
128 }
129
130 public void AddRegion(Scene Sceneworld)
131 {
132 // Make sure we have config
133 if (ConfigSource.Configs[ScriptEngineName] == null)
134 ConfigSource.AddConfig(ScriptEngineName);
135
136 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
137
138 m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
139 if (!m_enabled)
140 return;
141
142 m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
143
144 m_Scene = Sceneworld;
145
146 // Create all objects we'll be using
147 m_EventQueueManager = new EventQueueManager(this);
148 m_EventManager = new EventManager(this, true);
149
150 // We need to start it
151 m_ScriptManager = new ScriptManager(this);
152 m_ScriptManager.Setup();
153 m_AppDomainManager = new AppDomainManager(this);
154 if (m_MaintenanceThread == null)
155 m_MaintenanceThread = new MaintenanceThread();
156
157 m_log.Info("[" + ScriptEngineName + "]: Reading configuration "+
158 "from config section \"" + ScriptEngineName + "\"");
159
160 ReadConfig();
161
162 m_Scene.StackModuleInterface<IScriptModule>(this);
163 }
164
165 public void RemoveRegion(Scene scene)
166 {
167 }
168
169 public void RegionLoaded(Scene scene)
170 {
171 if (!m_enabled)
172 return;
173
174 m_EventManager.HookUpEvents();
175
176 m_Scene.EventManager.OnScriptReset += OnScriptReset;
177 m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
178 m_Scene.EventManager.OnStartScript += OnStartScript;
179 m_Scene.EventManager.OnStopScript += OnStopScript;
180
181 m_ScriptManager.Start();
182 }
183
184 public void Shutdown()
185 {
186 // We are shutting down
187 lock (ScriptEngines)
188 {
189 ScriptEngines.Remove(this);
190 }
191 }
192
193 public void ReadConfig()
194 {
195 RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 0);
196
197 if (m_EventQueueManager != null) m_EventQueueManager.ReadConfig();
198 if (m_EventManager != null) m_EventManager.ReadConfig();
199 if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
200 if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig();
201 if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig();
202 }
203
204 #region IRegionModule
205
206 public void Close()
207 {
208 }
209
210 public Type ReplaceableInterface
211 {
212 get { return null; }
213 }
214
215 public string Name
216 {
217 get { return "Common." + ScriptEngineName; }
218 }
219
220 public bool IsSharedModule
221 {
222 get { return false; }
223 }
224
225 public bool PostObjectEvent(uint localID, EventParams p)
226 {
227 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName,
228 p.DetectParams, p.Params);
229 }
230
231 public bool PostScriptEvent(UUID itemID, EventParams p)
232 {
233 uint localID = m_ScriptManager.GetLocalID(itemID);
234 return m_EventQueueManager.AddToScriptQueue(localID, itemID,
235 p.EventName, p.DetectParams, p.Params);
236 }
237
238 public bool PostScriptEvent(UUID itemID, string name, Object[] p)
239 {
240 Object[] lsl_p = new Object[p.Length];
241 for (int i = 0; i < p.Length ; i++)
242 {
243 if (p[i] is int)
244 lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
245 else if (p[i] is string)
246 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
247 else if (p[i] is Vector3)
248 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
249 else if (p[i] is Quaternion)
250 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
251 else if (p[i] is float)
252 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
253 else
254 lsl_p[i] = p[i];
255 }
256
257 return PostScriptEvent(itemID, new EventParams(name, lsl_p, new DetectParams[0]));
258 }
259
260 public bool PostObjectEvent(UUID itemID, string name, Object[] p)
261 {
262 SceneObjectPart part = m_Scene.GetSceneObjectPart(itemID);
263 if (part == null)
264 return false;
265
266 Object[] lsl_p = new Object[p.Length];
267 for (int i = 0; i < p.Length ; i++)
268 {
269 if (p[i] is int)
270 lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
271 else if (p[i] is string)
272 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
273 else if (p[i] is Vector3)
274 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
275 else if (p[i] is Quaternion)
276 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
277 else if (p[i] is float)
278 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
279 else
280 lsl_p[i] = p[i];
281 }
282
283 return PostObjectEvent(part.LocalId, new EventParams(name, lsl_p, new DetectParams[0]));
284 }
285
286 public DetectParams GetDetectParams(UUID itemID, int number)
287 {
288 uint localID = m_ScriptManager.GetLocalID(itemID);
289 if (localID == 0)
290 return null;
291
292 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
293
294 if (id == null)
295 return null;
296
297 DetectParams[] det = m_ScriptManager.GetDetectParams(id);
298
299 if (number < 0 || number >= det.Length)
300 return null;
301
302 return det[number];
303 }
304
305 public int GetStartParameter(UUID itemID)
306 {
307 return m_ScriptManager.GetStartParameter(itemID);
308 }
309
310 public void SetMinEventDelay(UUID itemID, double delay)
311 {
312 // TODO in DotNet, done in XEngine
313 throw new NotImplementedException();
314 }
315
316 #endregion
317
318 public void SetState(UUID itemID, string state)
319 {
320 uint localID = m_ScriptManager.GetLocalID(itemID);
321 if (localID == 0)
322 return;
323
324 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
325
326 if (id == null)
327 return;
328
329 string currentState = id.State;
330
331 if (currentState != state)
332 {
333 try
334 {
335 m_EventManager.state_exit(localID);
336
337 }
338 catch (AppDomainUnloadedException)
339 {
340 m_log.Error("[SCRIPT]: state change called when "+
341 "script was unloaded. Nothing to worry about, "+
342 "but noting the occurance");
343 }
344
345 id.State = state;
346
347 try
348 {
349 int eventFlags = m_ScriptManager.GetStateEventFlags(localID,
350 itemID);
351
352 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
353 if (part != null)
354 part.SetScriptEvents(itemID, eventFlags);
355
356 m_EventManager.state_entry(localID);
357 }
358 catch (AppDomainUnloadedException)
359 {
360 m_log.Error("[SCRIPT]: state change called when "+
361 "script was unloaded. Nothing to worry about, but "+
362 "noting the occurance");
363 }
364 }
365 }
366
367 public bool GetScriptState(UUID itemID)
368 {
369 uint localID = m_ScriptManager.GetLocalID(itemID);
370 if (localID == 0)
371 return false;
372
373 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
374 if (id == null)
375 return false;
376
377 return id.Running;
378 }
379
380 public void SetScriptState(UUID itemID, bool state)
381 {
382 uint localID = m_ScriptManager.GetLocalID(itemID);
383 if (localID == 0)
384 return;
385
386 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
387 if (id == null)
388 return;
389
390 if (!id.Disabled)
391 id.Running = state;
392 }
393
394 public void ApiResetScript(UUID itemID)
395 {
396 uint localID = m_ScriptManager.GetLocalID(itemID);
397 if (localID == 0)
398 return;
399
400 m_ScriptManager.ResetScript(localID, itemID);
401 }
402
403 public void ResetScript(UUID itemID)
404 {
405 uint localID = m_ScriptManager.GetLocalID(itemID);
406 if (localID == 0)
407 return;
408
409 m_ScriptManager.ResetScript(localID, itemID);
410 }
411
412 public void OnScriptReset(uint localID, UUID itemID)
413 {
414 ResetScript(itemID);
415 }
416
417 public void OnStartScript(uint localID, UUID itemID)
418 {
419 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
420 if (id == null)
421 return;
422
423 if (!id.Disabled)
424 id.Running = true;
425 }
426
427 public void OnStopScript(uint localID, UUID itemID)
428 {
429 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
430 if (id == null)
431 return;
432
433 id.Running = false;
434 }
435
436 public void OnGetScriptRunning(IClientAPI controllingClient,
437 UUID objectID, UUID itemID)
438 {
439 uint localID = m_ScriptManager.GetLocalID(itemID);
440 if (localID == 0)
441 return;
442
443 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
444 if (id == null)
445 return;
446
447 IEventQueue eq = World.RequestModuleInterface<IEventQueue>();
448 if (eq == null)
449 {
450 controllingClient.SendScriptRunningReply(objectID, itemID,
451 id.Running);
452 }
453 else
454 {
455 eq.Enqueue(EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, id.Running, true),
456 controllingClient.AgentId);
457 }
458 }
459
460 public IScriptApi GetApi(UUID itemID, string name)
461 {
462 return m_ScriptManager.GetApi(itemID, name);
463 }
464
465 public IScriptWorkItem QueueEventHandler(Object o)
466 {
467 return null;
468 }
469
470 public string GetAssemblyName(UUID itemID)
471 {
472 return "";
473 }
474
475 public string GetXMLState(UUID itemID)
476 {
477 return "";
478 }
479
480 public bool CanBeDeleted(UUID itemID)
481 {
482 return true;
483 }
484 }
485}