aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs430
6 files changed, 375 insertions, 93 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
index 04bc6cf..2c7cc34 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
@@ -2115,9 +2115,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
2115 public const double DEG_TO_RAD = 0.01745329238f; 2115 public const double DEG_TO_RAD = 0.01745329238f;
2116 public const double RAD_TO_DEG = 57.29578f; 2116 public const double RAD_TO_DEG = 57.29578f;
2117 public const double SQRT2 = 1.414213538f; 2117 public const double SQRT2 = 1.414213538f;
2118 public const int DEBUG_CHANNEL 0x7FFFFFFF;
2119 public const int PUBLIC_CHANNEL 0x00000000
2118 2120
2119 // Can not be public const? 2121 // Can not be public const?
2120 public vector ZERO_VECTOR = new vector(0, 0, 0); 2122 public vector ZERO_VECTOR = new vector(0, 0, 0);
2121 public rotation ZERO_ROTATION = new rotation(0, 0, 0, 0); 2123 public rotation ZERO_ROTATION = new rotation(0, 0, 0, 0);
2122 } 2124 }
2123} \ No newline at end of file 2125}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 2b13751..4711748 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.Environment.Scenes
93 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating 93 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
94 /// new ones or setting existing UUIDs to the correct parent UUIDs 94 /// new ones or setting existing UUIDs to the correct parent UUIDs
95 /// </summary> 95 /// </summary>
96 /// <param name="linkNum'>Link number for the part</param> 96 /// <param name="linkNum">Link number for the part</param>
97 public void ResetInventoryIDs() 97 public void ResetInventoryIDs()
98 { 98 {
99 lock (TaskInventory) 99 lock (TaskInventory)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index e9d4c66..3d52119 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1087,7 +1087,7 @@ namespace OpenSim.Region.Environment.Scenes
1087 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and 1087 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and
1088 /// generating new LLUUIDs for all the items in the inventory. 1088 /// generating new LLUUIDs for all the items in the inventory.
1089 /// </summary> 1089 /// </summary>
1090 /// <param name="linkNum'>Link number for the part</param> 1090 /// <param name="linkNum">Link number for the part</param>
1091 public void ResetIDs(int linkNum) 1091 public void ResetIDs(int linkNum)
1092 { 1092 {
1093 UUID = LLUUID.Random(); 1093 UUID = LLUUID.Random();
diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs
index 957f55c..9e30958 100644
--- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs
@@ -2310,9 +2310,9 @@ namespace OpenSim.Region.ScriptEngine.Common
2310 public const double DEG_TO_RAD = 0.01745329238f; 2310 public const double DEG_TO_RAD = 0.01745329238f;
2311 public const double RAD_TO_DEG = 57.29578f; 2311 public const double RAD_TO_DEG = 57.29578f;
2312 public const double SQRT2 = 1.414213538f; 2312 public const double SQRT2 = 1.414213538f;
2313 public const int STRING_TRIM_HEAD = 1; 2313 public const int STRING_TRIM_HEAD = 1;
2314 public const int STRING_TRIM_TAIL = 2; 2314 public const int STRING_TRIM_TAIL = 2;
2315 public const int STRING_TRIM = 3; 2315 public const int STRING_TRIM = 3;
2316 public const int LIST_STAT_RANGE = 0; 2316 public const int LIST_STAT_RANGE = 0;
2317 public const int LIST_STAT_MIN = 1; 2317 public const int LIST_STAT_MIN = 1;
2318 public const int LIST_STAT_MAX = 2; 2318 public const int LIST_STAT_MAX = 2;
@@ -2333,6 +2333,9 @@ namespace OpenSim.Region.ScriptEngine.Common
2333 public const int PARCEL_COUNT_SELECTED = 4; 2333 public const int PARCEL_COUNT_SELECTED = 4;
2334 public const int PARCEL_COUNT_TEMP = 5; 2334 public const int PARCEL_COUNT_TEMP = 5;
2335 2335
2336 public const int DEBUG_CHANNEL = 0x7FFFFFFF;
2337 public const int PUBLIC_CHANNEL = 0x00000000;
2338
2336 // Can not be public const? 2339 // Can not be public const?
2337 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); 2340 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
2338 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0); 2341 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
index 30c40f4..c272400 100644
--- a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs
@@ -42,6 +42,25 @@ namespace OpenSim.Region.ScriptEngine.Common
42 /// If set to False events will not be executed. 42 /// If set to False events will not be executed.
43 /// </summary> 43 /// </summary>
44 protected bool m_Running = true; 44 protected bool m_Running = true;
45 /// <summary>
46 /// True indicates that the ScriptManager has stopped
47 /// this script. This prevents a script that has been
48 /// stopped as part of deactivation from being
49 /// resumed by a pending llSetScriptState request.
50 /// </summary>
51 protected bool m_Disable = false;
52
53 /// <summary>
54 /// Indicate the scripts current running status.
55 /// </summary>
56 public bool Running
57 {
58 get { return m_Running; }
59 set {
60 if(!m_Disable)
61 m_Running = value;
62 }
63 }
45 64
46 /// <summary> 65 /// <summary>
47 /// Create a new instance of ExecutorBase 66 /// Create a new instance of ExecutorBase
@@ -102,6 +121,8 @@ namespace OpenSim.Region.ScriptEngine.Common
102 public void StopScript() 121 public void StopScript()
103 { 122 {
104 m_Running = false; 123 m_Running = false;
124 m_Disable = true;
105 } 125 }
126
106 } 127 }
107} 128}
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index daf5e21..58b22d9 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -50,9 +50,9 @@ namespace OpenSim.Region.ScriptEngine.Common
50 /// </summary> 50 /// </summary>
51 public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface 51 public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface
52 { 52 {
53 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 53 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
54 54
55 private ASCIIEncoding enc = new ASCIIEncoding(); 55 // private ASCIIEncoding enc = new ASCIIEncoding();
56 private ScriptEngineBase.ScriptEngine m_ScriptEngine; 56 private ScriptEngineBase.ScriptEngine m_ScriptEngine;
57 private SceneObjectPart m_host; 57 private SceneObjectPart m_host;
58 private uint m_localID; 58 private uint m_localID;
@@ -76,14 +76,10 @@ namespace OpenSim.Region.ScriptEngine.Common
76 { 76 {
77 get { return m_state; } 77 get { return m_state; }
78 set { 78 set {
79 bool changed = false; 79 // Set it if it changed
80 if (m_state != value) 80 if (m_state != value)
81 changed = true;
82 // Set it
83 m_state = value;
84
85 if (changed)
86 { 81 {
82 m_state = value;
87 m_ScriptEngine.m_EventManager.state_entry(m_localID); 83 m_ScriptEngine.m_EventManager.state_entry(m_localID);
88 } 84 }
89 } 85 }
@@ -1793,8 +1789,33 @@ namespace OpenSim.Region.ScriptEngine.Common
1793 1789
1794 public void llSetScriptState(string name, int run) 1790 public void llSetScriptState(string name, int run)
1795 { 1791 {
1792
1793 LLUUID item;
1794 ScriptManager sm;
1795 IScript script = null;
1796
1796 m_host.AddScriptLPS(1); 1797 m_host.AddScriptLPS(1);
1797 NotImplemented("llSetScriptState"); 1798
1799 // These functions are supposed to be robust,
1800 // so get the state one step at a time.
1801
1802 if((item = ScriptByName(name)) != LLUUID.Zero)
1803 if((sm = m_ScriptEngine.m_ScriptManager) != null)
1804 if(sm.Scripts.ContainsKey(m_localID))
1805 if((script = sm.GetScript(m_localID, item)) != null)
1806 script.Exec.Running = (run==0) ? false : true;
1807
1808
1809 // Required by SL
1810
1811 if(script == null)
1812 ShoutError("llSetScriptState: script "+name+" not found");
1813
1814 // If we didn;t find it, then it's safe to
1815 // assume it is not running.
1816
1817 return;
1818
1798 } 1819 }
1799 1820
1800 public double llGetEnergy() 1821 public double llGetEnergy()
@@ -1911,9 +1932,22 @@ namespace OpenSim.Region.ScriptEngine.Common
1911 1932
1912 public string llGetScriptName() 1933 public string llGetScriptName()
1913 { 1934 {
1935
1936 string result = null;
1937
1914 m_host.AddScriptLPS(1); 1938 m_host.AddScriptLPS(1);
1915 1939
1916 return String.Empty; 1940 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1941 {
1942 if(item.Type == 10 && item.ItemID == m_itemID)
1943 {
1944 result = item.Name;
1945 break;
1946 }
1947 }
1948
1949 return result;
1950
1917 } 1951 }
1918 1952
1919 public int llGetNumberOfSides() 1953 public int llGetNumberOfSides()
@@ -2269,81 +2303,216 @@ namespace OpenSim.Region.ScriptEngine.Common
2269 return ret; 2303 return ret;
2270 } 2304 }
2271 2305
2306 /// <summary>
2307 /// The supplied string is scanned for commas
2308 /// and converted into a list. Commas are only
2309 /// effective if they are encountered outside
2310 /// of '<' '>' delimiters. Any whitespace
2311 /// before or after an element is trimmed.
2312 /// </summary>
2313
2272 public LSL_Types.list llCSV2List(string src) 2314 public LSL_Types.list llCSV2List(string src)
2273 { 2315 {
2316
2317 LSL_Types.list result = new LSL_Types.list();
2318 int parens = 0;
2319 int start = 0;
2320 int length = 0;
2321
2274 m_host.AddScriptLPS(1); 2322 m_host.AddScriptLPS(1);
2275 return new LSL_Types.list(src.Split(",".ToCharArray())); 2323
2324 for(int i=0; i<src.Length; i++)
2325 {
2326 switch(src[i])
2327 {
2328 case '<' :
2329 parens++;
2330 length++;
2331 break;
2332 case '>' :
2333 if(parens > 0)
2334 parens--;
2335 length++;
2336 break;
2337 case ',' :
2338 if(parens == 0)
2339 {
2340 result.Add(src.Substring(start,length).Trim());
2341 start += length+1;
2342 length = 0;
2343 } else
2344 length++;
2345 break;
2346 default :
2347 length++;
2348 break;
2349 }
2350 }
2351
2352 result.Add(src.Substring(start,length).Trim());
2353
2354 return result;
2355
2276 } 2356 }
2277 2357
2358 /// <summary>
2359 /// Randomizes the list, be arbitrarily reordering
2360 /// sublists of stride elements. As the stride approaches
2361 /// the size of the list, the options become very
2362 /// limited.
2363 /// </summary>
2364 /// <remarks>
2365 /// This could take a while for very large list
2366 /// sizes.
2367 /// </remarks>
2368
2278 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) 2369 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
2279 { 2370 {
2371
2372 LSL_Types.list result;
2373 Random rand = new Random();
2374
2375 int chunkk;
2376 int[] chunks;
2377 int index1;
2378 int index2;
2379 int tmp;
2380
2280 m_host.AddScriptLPS(1); 2381 m_host.AddScriptLPS(1);
2281 //int s = stride;
2282 //if (s < 1)
2283 // s = 1;
2284 2382
2285 // This is a cowardly way of doing it ;) 2383 if(stride == 0)
2286 // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange 2384 stride = 1;
2287 //List<LSL_Types.list> tmp = new List<LSL_Types.list>();
2288 2385
2289 // Add chunks to an array 2386 // Stride MUST be a factor of the list length
2290 //int c = 0; 2387 // If not, then return the src list. This also
2291 //LSL_Types.list chunk = new LSL_Types.list(); 2388 // traps those cases where stride > length.
2292 //foreach (string element in src) 2389
2293 //{ 2390 if(src.Length != stride && src.Length%stride == 0)
2294 // c++; 2391 {
2295 // if (c > s)
2296 // {
2297 // tmp.Add(chunk);
2298 // chunk = new LSL_Types.list();
2299 // c = 0;
2300 // }
2301 // chunk.Add(element);
2302 //}
2303 //if (chunk.Count > 0)
2304 // tmp.Add(chunk);
2305 2392
2306 // Decreate (<- what kind of word is that? :D ) array back into a list 2393 chunkk = src.Length/stride;
2307 //int rnd; 2394
2308 //LSL_Types.list ret = new LSL_Types.list(); 2395 chunks = new int[chunkk];
2309 //while (tmp.Count > 0) 2396
2310 //{ 2397 for(int i=0;i<chunkk;i++)
2311 // rnd = Util.RandomClass.Next(tmp.Count); 2398 chunks[i] = i;
2312 // foreach (string str in tmp[rnd]) 2399
2313 // { 2400 for(int i=0; i<chunkk-1; i++)
2314 // ret.Add(str); 2401 {
2315 // } 2402 // randomly select 2 chunks
2316 // tmp.RemoveAt(rnd); 2403 index1 = rand.Next(rand.Next(65536));
2317 //} 2404 index1 = index1%chunkk;
2405 index2 = rand.Next(rand.Next(65536));
2406 index2 = index2%chunkk;
2407
2408 // and swap their relative positions
2409 tmp = chunks[index1];
2410 chunks[index1] = chunks[index2];
2411 chunks[index2] = tmp;
2412 }
2413
2414 // Construct the randomized list
2415
2416 result = new LSL_Types.list();
2417
2418 for(int i=0; i<chunkk; i++)
2419 for(int j=0;j<stride;j++)
2420 result.Add(src.Data[chunks[i]*stride+j]);
2421
2422 }
2423 else {
2424 object[] array = new object[src.Length];
2425 Array.Copy(src.Data, 0, array, 0, src.Length);
2426 result = new LSL_Types.list(array);
2427 }
2428
2429 return result;
2318 2430
2319 //return ret;
2320 NotImplemented("llListRandomize");
2321 return src;
2322 } 2431 }
2323 2432
2433 /// <summary>
2434 /// Elements in the source list starting with 0 and then
2435 /// every i+stride. If the stride is negative then the scan
2436 /// is backwards producing an inverted result.
2437 /// Only those elements that are also in the specified
2438 /// range are included in the result.
2439 /// </summary>
2440
2324 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride) 2441 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
2325 { 2442 {
2443
2444 LSL_Types.list result = new LSL_Types.list();
2445 int[] si = new int[2];
2446 int[] ei = new int[2];
2447 bool twopass = false;
2448
2326 m_host.AddScriptLPS(1); 2449 m_host.AddScriptLPS(1);
2327 LSL_Types.list ret = new LSL_Types.list();
2328 //int s = stride;
2329 //if (s < 1)
2330 // s = 1;
2331 2450
2332 //int sc = s; 2451 // First step is always to deal with negative indices
2333 //for (int i = start; i < src.Count; i++) 2452
2334 //{ 2453 if(start < 0)
2335 // sc--; 2454 start = src.Length+start;
2336 // if (sc == 0) 2455 if(end < 0)
2337 // { 2456 end = src.Length+end;
2338 // sc = s; 2457
2339 // // Addthis 2458 // Out of bounds indices are OK, just trim them
2340 // ret.Add(src[i]); 2459 // accordingly
2341 // } 2460
2342 // if (i == end) 2461 if(start > src.Length)
2343 // break; 2462 start = src.Length;
2344 //} 2463
2345 NotImplemented("llList2ListStrided"); 2464 if(end > src.Length)
2346 return ret; 2465 end = src.Length;
2466
2467 // There may be one or two ranges to be considered
2468
2469 if(start != end)
2470 {
2471
2472 if(start <= end)
2473 {
2474 si[0] = start;
2475 ei[0] = end;
2476 }
2477 else
2478 {
2479 si[1] = start;
2480 ei[1] = src.Length;
2481 si[0] = 0;
2482 ei[0] = end;
2483 twopass = true;
2484 }
2485
2486 // The scan always starts from the beginning of the
2487 // source list, but members are only selected if they
2488 // fall within the specified sub-range. The specified
2489 // range values are inclusive.
2490 // A negative stride reverses the direction of the
2491 // scan producing an inverted list as a result.
2492
2493 if(stride == 0)
2494 stride = 1;
2495
2496 if(stride > 0)
2497 for(int i=0;i<src.Length;i+=stride)
2498 {
2499 if(i<=ei[0] && i>=si[0])
2500 result.Add(src.Data[i]);
2501 if(twopass && i>=si[1] && i<=ei[1])
2502 result.Add(src.Data[i]);
2503 }
2504 else if(stride < 0)
2505 for(int i=src.Length-1;i>=0;i+=stride)
2506 {
2507 if(i<=ei[0] && i>=si[0])
2508 result.Add(src.Data[i]);
2509 if(twopass && i>=si[1] && i<=ei[1])
2510 result.Add(src.Data[i]);
2511 }
2512 }
2513
2514 return result;
2515
2347 } 2516 }
2348 2517
2349 public LSL_Types.Vector3 llGetRegionCorner() 2518 public LSL_Types.Vector3 llGetRegionCorner()
@@ -2358,19 +2527,42 @@ namespace OpenSim.Region.ScriptEngine.Common
2358 return dest.GetSublist(0, start - 1) + src + dest.GetSublist(start, -1); 2527 return dest.GetSublist(0, start - 1) + src + dest.GetSublist(start, -1);
2359 } 2528 }
2360 2529
2530 /// <summary>
2531 /// Returns the index of the first occurrence of test
2532 /// in src.
2533 /// </summary>
2534
2361 public int llListFindList(LSL_Types.list src, LSL_Types.list test) 2535 public int llListFindList(LSL_Types.list src, LSL_Types.list test)
2362 { 2536 {
2537
2538 int index = -1;
2539 int length = src.Length - test.Length + 1;
2540
2363 m_host.AddScriptLPS(1); 2541 m_host.AddScriptLPS(1);
2364 //foreach (string s in test) 2542
2365 //{ 2543 // If either list is empty, do not match
2366 // for (int ci = 0; ci < src.Count; ci++) 2544
2367 // { 2545 if(src.Length != 0 && test.Length != 0)
2368 // if (s == src[ci]) 2546 {
2369 // return ci; 2547 for(int i=0; i< length; i++)
2370 // } 2548 {
2371 //} 2549 if(src.Data[i].Equals(test.Data[0]))
2372 NotImplemented("llListFindList"); 2550 {
2373 return -1; 2551 int j;
2552 for(j=1;j<test.Length;j++)
2553 if(!src.Data[i+j].Equals(test.Data[j]))
2554 break;
2555 if(j == test.Length)
2556 {
2557 index = i;
2558 break;
2559 }
2560 }
2561 }
2562 }
2563
2564 return index;
2565
2374 } 2566 }
2375 2567
2376 public string llGetObjectName() 2568 public string llGetObjectName()
@@ -2947,24 +3139,72 @@ namespace OpenSim.Region.ScriptEngine.Common
2947 NotImplemented("llVolumeDetect"); 3139 NotImplemented("llVolumeDetect");
2948 } 3140 }
2949 3141
3142 /// <summary>
3143 /// Reset the named script. The script must be present
3144 /// in the same prim.
3145 /// </summary>
3146
2950 public void llResetOtherScript(string name) 3147 public void llResetOtherScript(string name)
2951 { 3148 {
3149
3150 LLUUID item;
3151 ScriptManager sm;
3152 IScript script = null;
3153
2952 m_host.AddScriptLPS(1); 3154 m_host.AddScriptLPS(1);
2953 NotImplemented("llResetOtherScript"); 3155
3156 // These functions are supposed to be robust,
3157 // so get the state one step at a time.
3158
3159 if((item = ScriptByName(name)) != LLUUID.Zero)
3160 if((sm = m_ScriptEngine.m_ScriptManager) != null)
3161 sm.ResetScript(m_localID, item);
3162
3163 // Required by SL
3164
3165 if(script == null)
3166 ShoutError("llResetOtherScript: script "+name+" not found");
3167
3168 // If we didn;t find it, then it's safe to
3169 // assume it is not running.
3170
3171 return;
3172
2954 } 3173 }
2955 3174
2956 public int llGetScriptState(string name) 3175 public int llGetScriptState(string name)
2957 { 3176 {
3177
3178 LLUUID item;
3179 ScriptManager sm;
3180 IScript script = null;
3181
2958 m_host.AddScriptLPS(1); 3182 m_host.AddScriptLPS(1);
2959 3183
2960 //NotImplemented("llGetScriptState"); 3184 // These functions are supposed to be robust,
3185 // so get the state one step at a time.
3186
3187 if((item = ScriptByName(name)) != LLUUID.Zero)
3188 if((sm = m_ScriptEngine.m_ScriptManager) != null)
3189 if((script = sm.GetScript(m_localID, item)) != null)
3190 return script.Exec.Running?1:0;
3191
3192 // Required by SL
3193
3194 if(script == null)
3195 ShoutError("llGetScriptState: script "+name+" not found");
3196
3197 // If we didn;t find it, then it's safe to
3198 // assume it is not running.
3199
2961 return 0; 3200 return 0;
3201
2962 } 3202 }
2963 3203
2964 public void llRemoteLoadScript() 3204 public void llRemoteLoadScript()
2965 { 3205 {
2966 m_host.AddScriptLPS(1); 3206 m_host.AddScriptLPS(1);
2967 NotImplemented("llRemoteLoadScript"); 3207 ShoutError("llRemoteLoadScript: deprecated");
2968 } 3208 }
2969 3209
2970 public void llSetRemoteScriptAccessPin(int pin) 3210 public void llSetRemoteScriptAccessPin(int pin)
@@ -3880,7 +4120,7 @@ namespace OpenSim.Region.ScriptEngine.Common
3880 { 4120 {
3881 m_host.AddScriptLPS(1); 4121 m_host.AddScriptLPS(1);
3882 Int64 tmp = 0; 4122 Int64 tmp = 0;
3883 Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); 4123 Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp);
3884 return Convert.ToInt32(tmp); 4124 return Convert.ToInt32(tmp);
3885 } 4125 }
3886 4126
@@ -4237,18 +4477,19 @@ namespace OpenSim.Region.ScriptEngine.Common
4237 return ret; 4477 return ret;
4238 } 4478 }
4239 4479
4240 public string llStringTrim(string src, int type) 4480 public string llStringTrim(string src, int type)
4241 { 4481 {
4242 m_host.AddScriptLPS(1); 4482 m_host.AddScriptLPS(1);
4243 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); } 4483 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); }
4244 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); } 4484 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); }
4245 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM) { return src.Trim(); } 4485 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM) { return src.Trim(); }
4246 return src; 4486 return src;
4247 } 4487 }
4248 4488
4249 // 4489 //
4250 // OpenSim functions 4490 // OpenSim functions
4251 // 4491 //
4492
4252 public int osTerrainSetHeight(int x, int y, double val) 4493 public int osTerrainSetHeight(int x, int y, double val)
4253 { 4494 {
4254 m_host.AddScriptLPS(1); 4495 m_host.AddScriptLPS(1);
@@ -4413,6 +4654,21 @@ namespace OpenSim.Region.ScriptEngine.Common
4413 return false; 4654 return false;
4414 } 4655 }
4415 4656
4657 private LLUUID ScriptByName(string name)
4658 {
4659 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4660 {
4661 if(item.Type == 10 && item.Name == name)
4662 return item.ItemID;
4663 }
4664 return LLUUID.Zero;
4665 }
4666
4667 private void ShoutError(string msg)
4668 {
4669 llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL,msg);
4670 }
4671
4416 public void osSetPrimFloatOnWater(int floatYN) 4672 public void osSetPrimFloatOnWater(int floatYN)
4417 { 4673 {
4418 m_host.AddScriptLPS(1); 4674 m_host.AddScriptLPS(1);