aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-26 02:51:00 +0000
committerMelanie Thielker2008-09-26 02:51:00 +0000
commitc21a8b99694e459408a9ccc43e525928038b2b22 (patch)
tree21190b513065cc7b1f3442d2cf2ed9ce1d2077f4 /OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
parentMantis#2265. Thank you kindly, Idb for a patch that: (diff)
downloadopensim-SC_OLD-c21a8b99694e459408a9ccc43e525928038b2b22.zip
opensim-SC_OLD-c21a8b99694e459408a9ccc43e525928038b2b22.tar.gz
opensim-SC_OLD-c21a8b99694e459408a9ccc43e525928038b2b22.tar.bz2
opensim-SC_OLD-c21a8b99694e459408a9ccc43e525928038b2b22.tar.xz
Full API convergence. Api is back in LSL_Api.cs and OSSL_Api.cs.
The binaries are still different, but that is only a small step away now. The OSSLPrim has been removed. This commit will breal all scripts using Prim.Scale(), etc, syntax. It was not secure and will have to be brought back in another form.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs262
1 files changed, 0 insertions, 262 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
deleted file mode 100644
index 8252bfc..0000000
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ /dev/null
@@ -1,262 +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 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 System.Collections;
30using System.Collections.Generic;
31using System.Runtime.Remoting.Lifetime;
32using System.Text;
33using System.Threading;
34using Nini.Config;
35using OpenMetaverse;
36using OpenMetaverse.Packets;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Region.Environment;
40using OpenSim.Region.Interfaces;
41using OpenSim.Region.Environment.Interfaces;
42using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
43using OpenSim.Region.Environment.Modules.World.Land;
44using OpenSim.Region.Environment.Scenes;
45using OpenSim.Region.Physics.Manager;
46using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
47using OpenSim.Region.ScriptEngine.Shared;
48using OpenSim.Region.ScriptEngine.Shared.Api;
49
50using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
51using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
52using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
54using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
55using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
56using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
57
58namespace OpenSim.Region.ScriptEngine.Common
59{
60 /// <summary>
61 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
62 /// </summary>
63 public class LSL_BuiltIn_Commands : LSL_Api_Base, LSL_BuiltIn_Commands_Interface
64 {
65// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
66
67 internal ScriptEngineBase.ScriptEngine m_ScriptEngineDirect;
68
69 public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
70 {
71 m_ScriptEngineDirect = ScriptEngine;
72 m_ScriptEngine = ScriptEngine;
73 m_host = host;
74 m_localID = localID;
75 m_itemID = itemID;
76
77 AsyncCommands = new AsyncCommandManager(m_ScriptEngine);
78
79 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
80
81
82 IConfigSource config = new IniConfigSource(Application.iniFilePath);
83 if (config.Configs["LL-Functions"] == null)
84 config.AddConfig("LL-Functions");
85
86 m_ScriptDelayFactor = config.Configs["LL-Functions"].GetFloat("ScriptDelayFactor", 1.0f);
87 m_ScriptDistanceFactor = config.Configs["LL-Functions"].GetFloat("ScriptDistanceLimitFactor", 1.0f);
88
89 }
90
91 private string m_state = "default";
92
93 protected void ScriptSleep(int delay)
94 {
95 delay = (int)((float)delay * m_ScriptDelayFactor);
96 if (delay == 0)
97 return;
98 System.Threading.Thread.Sleep(delay);
99 }
100
101 // Object never expires
102 public override Object InitializeLifetimeService()
103 {
104 ILease lease = (ILease)base.InitializeLifetimeService();
105
106 if (lease.CurrentState == LeaseState.Initial)
107 {
108 lease.InitialLeaseTime = TimeSpan.Zero;
109 }
110 return lease;
111 }
112
113 public string State
114 {
115 get { return m_state; }
116 set {
117 // Set it if it changed
118 if (m_state != value)
119 {
120 try
121 {
122 m_ScriptEngineDirect.m_EventManager.state_exit(m_localID);
123
124 }
125 catch (AppDomainUnloadedException)
126 {
127 Console.WriteLine("[SCRIPT]: state change called when script was unloaded. Nothing to worry about, but noting the occurance");
128 }
129 m_state = value;
130 try
131 {
132 int eventFlags = m_ScriptEngineDirect.m_ScriptManager.GetStateEventFlags(m_localID, m_itemID);
133 m_host.SetScriptEvents(m_itemID, eventFlags);
134 m_ScriptEngineDirect.m_EventManager.state_entry(m_localID);
135 }
136 catch (AppDomainUnloadedException)
137 {
138 Console.WriteLine("[SCRIPT]: state change called when script was unloaded. Nothing to worry about, but noting the occurance");
139 }
140 }
141 }
142 }
143
144 // Extension commands use this:
145 public ICommander GetCommander(string name)
146 {
147 return World.GetCommander(name);
148 }
149
150 public LSL_Integer llGetScriptState(string name)
151 {
152 UUID item;
153 ScriptManager sm;
154 IScript script = null;
155
156 m_host.AddScriptLPS(1);
157
158 // These functions are supposed to be robust,
159 // so get the state one step at a time.
160
161 if ((item = ScriptByName(name)) != UUID.Zero)
162 {
163 if ((sm = m_ScriptEngineDirect.m_ScriptManager) != null)
164 {
165 if ((script = sm.GetScript(m_localID, item)) != null)
166 {
167 return script.Exec.Running?1:0;
168 }
169 }
170 }
171
172 // Required by SL
173
174 if (script == null)
175 ShoutError("llGetScriptState: script "+name+" not found");
176
177 // If we didn't find it, then it's safe to
178 // assume it is not running.
179
180 return 0;
181 }
182
183 public void llResetOtherScript(string name)
184 {
185 UUID item;
186 ScriptManager sm;
187 IScript script = null;
188
189 m_host.AddScriptLPS(8000);
190
191 // These functions are supposed to be robust,
192 // so get the state one step at a time.
193
194 if ((item = ScriptByName(name)) != UUID.Zero)
195 if ((sm = m_ScriptEngineDirect.m_ScriptManager) != null)
196 sm.ResetScript(m_localID, item);
197
198 // Required by SL
199
200 if (script == null)
201 ShoutError("llResetOtherScript: script "+name+" not found");
202
203 // If we didn't find it, then it's safe to
204 // assume it is not running.
205 }
206
207 public void llResetScript()
208 {
209 m_host.AddScriptLPS(800);
210 m_ScriptEngineDirect.m_ScriptManager.ResetScript(m_localID, m_itemID);
211 }
212
213 public void llSetScriptState(string name, int run)
214 {
215 UUID item;
216 ScriptManager sm;
217 IScript script = null;
218
219 m_host.AddScriptLPS(1);
220
221 // These functions are supposed to be robust,
222 // so get the state one step at a time.
223
224 if ((item = ScriptByName(name)) != UUID.Zero)
225 {
226 if ((sm = m_ScriptEngineDirect.m_ScriptManager) != null)
227 {
228 if (sm.Scripts.ContainsKey(m_localID))
229 {
230 if ((script = sm.GetScript(m_localID, item)) != null)
231 {
232 script.Exec.Running = (run==0) ? false : true;
233 }
234 }
235 }
236 }
237
238 // Required by SL
239
240 if (script == null)
241 ShoutError("llSetScriptState: script "+name+" not found");
242
243 // If we didn't find it, then it's safe to
244 // assume it is not running.
245 }
246
247 internal UUID ScriptByName(string name)
248 {
249 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
250 {
251 if (item.Type == 10 && item.Name == name)
252 return item.ItemID;
253 }
254 return UUID.Zero;
255 }
256
257 internal void ShoutError(string msg)
258 {
259 llShout(ScriptBaseClass.DEBUG_CHANNEL, msg);
260 }
261 }
262}