diff options
author | Tedd Hansen | 2007-09-16 03:36:13 +0000 |
---|---|---|
committer | Tedd Hansen | 2007-09-16 03:36:13 +0000 |
commit | c654506b18947a40cc7ef5da37a9a57ebcf4811d (patch) | |
tree | 57b807ffb5f19856883a6aa7dfcdc8fb9d179fa5 | |
parent | Implemented: llStringToBase64, llBase64ToString, llXorBase64Strings, llXorBas... (diff) | |
download | opensim-SC_OLD-c654506b18947a40cc7ef5da37a9a57ebcf4811d.zip opensim-SC_OLD-c654506b18947a40cc7ef5da37a9a57ebcf4811d.tar.gz opensim-SC_OLD-c654506b18947a40cc7ef5da37a9a57ebcf4811d.tar.bz2 opensim-SC_OLD-c654506b18947a40cc7ef5da37a9a57ebcf4811d.tar.xz |
Implemented: llSetText, llResetScript
Implemented: llHTTPRequest (queue, thread, etc -- but not actuall call)
Diffstat (limited to '')
7 files changed, 330 insertions, 188 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 677f3ae..f7aa634 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs | |||
@@ -612,8 +612,8 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
612 | //wiki: integer llGetRegionFlags() | 612 | //wiki: integer llGetRegionFlags() |
613 | int llGetRegionFlags(); | 613 | int llGetRegionFlags(); |
614 | //wiki: string llXorBase64StringsCorrect(string str1, string str2) | 614 | //wiki: string llXorBase64StringsCorrect(string str1, string str2) |
615 | string llXorBase64StringsCorrect(string str1, string str2); | 615 | string llXorBase64StringsCorrect(string str1, string str2); |
616 | void llHTTPRequest(); | 616 | void llHTTPRequest(string url, List<string> parameters, string body); |
617 | //wiki: llResetLandBanList() | 617 | //wiki: llResetLandBanList() |
618 | void llResetLandBanList(); | 618 | void llResetLandBanList(); |
619 | //wiki: llResetLandPassList() | 619 | //wiki: llResetLandPassList() |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index c26c54e..996d3f9 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |||
@@ -96,13 +96,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
96 | AppDomainSetup ads = new AppDomainSetup(); | 96 | AppDomainSetup ads = new AppDomainSetup(); |
97 | ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; | 97 | ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; |
98 | ads.DisallowBindingRedirects = false; | 98 | ads.DisallowBindingRedirects = false; |
99 | ads.DisallowCodeDownload = true; | 99 | ads.DisallowCodeDownload = true; |
100 | ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;) | 100 | ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;) |
101 | ads.ShadowCopyFiles = "true"; // Enabled shadowing | 101 | ads.ShadowCopyFiles = "true"; // Enabled shadowing |
102 | ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; | 102 | ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; |
103 | 103 | ||
104 | AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads); | 104 | AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads); |
105 | Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); | 105 | Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); |
106 | AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll")); | 106 | AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll")); |
107 | 107 | ||
108 | // Return the new AppDomain | 108 | // Return the new AppDomain |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index ec6b962..61e6ff9 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | |||
@@ -18,8 +18,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
18 | dataTypes.Add("integer", "int"); | 18 | dataTypes.Add("integer", "int"); |
19 | dataTypes.Add("float", "double"); | 19 | dataTypes.Add("float", "double"); |
20 | dataTypes.Add("string", "string"); | 20 | dataTypes.Add("string", "string"); |
21 | dataTypes.Add("key", "string"); | 21 | dataTypes.Add("key", "string"); |
22 | dataTypes.Add("vector", "LSL_Types.Vector3"); | 22 | dataTypes.Add("vector", "LSL_Types.Vector3"); |
23 | dataTypes.Add("rotation", "LSL_Types.Quaternion"); | 23 | dataTypes.Add("rotation", "LSL_Types.Quaternion"); |
24 | dataTypes.Add("list", "list"); | 24 | dataTypes.Add("list", "list"); |
25 | dataTypes.Add("null", "null"); | 25 | dataTypes.Add("null", "null"); |
@@ -225,9 +225,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | // Add namespace, class name and inheritance | 228 | // Add namespace, class name and inheritance |
229 | 229 | ||
230 | Return = "" + | 230 | Return = "" + |
231 | "using OpenSim.Region.ScriptEngine.Common;"; | 231 | "using OpenSim.Region.ScriptEngine.Common;"; |
232 | //"using System; " + | 232 | //"using System; " + |
233 | //"using System.Collections.Generic; " + | 233 | //"using System.Collections.Generic; " + |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index 5f92e96..1294213 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | |||
@@ -45,7 +45,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | public LSL_BuiltIn_Commands_Interface m_LSL_Functions; | 48 | public LSL_BuiltIn_Commands_Interface m_LSL_Functions; |
49 | public string SourceCode = ""; | ||
49 | 50 | ||
50 | public LSL_BaseClass() | 51 | public LSL_BaseClass() |
51 | { | 52 | { |
@@ -452,8 +453,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
452 | public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); } | 453 | public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); } |
453 | public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); } | 454 | public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); } |
454 | public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); } | 455 | public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); } |
455 | public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } | 456 | public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } |
456 | public void llHTTPRequest() { m_LSL_Functions.llHTTPRequest(); } | 457 | public void llHTTPRequest(string url, List<string> parameters, string body) { m_LSL_Functions.llHTTPRequest(url, parameters, body); } |
457 | public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); } | 458 | public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); } |
458 | public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); } | 459 | public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); } |
459 | public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); } | 460 | public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 064ed4f..20f5d51 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs | |||
@@ -327,7 +327,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
327 | return src.Substring(start, end); | 327 | return src.Substring(start, end); |
328 | } | 328 | } |
329 | 329 | ||
330 | public string llDeleteSubString(string src, int start, int end) | 330 | public string llDeleteSubString(string src, int start, int end) |
331 | { | 331 | { |
332 | return src.Remove(start, end - start); | 332 | return src.Remove(start, end - start); |
333 | } | 333 | } |
@@ -431,7 +431,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
431 | public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } | 431 | public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } |
432 | public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } | 432 | public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } |
433 | 433 | ||
434 | public void llSetText(string text, LSL_Types.Vector3 color, double alpha) { NotImplemented("llSetText"); } | 434 | public void llSetText(string text, LSL_Types.Vector3 color, double alpha) |
435 | { | ||
436 | Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z); | ||
437 | m_host.SetText(text, av3, alpha); | ||
438 | } | ||
439 | |||
435 | 440 | ||
436 | public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } | 441 | public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } |
437 | public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } | 442 | public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } |
@@ -443,7 +448,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
443 | public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } | 448 | public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } |
444 | public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } | 449 | public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } |
445 | public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } | 450 | public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } |
446 | public void llResetScript() { } | 451 | public void llResetScript() |
452 | { | ||
453 | m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); | ||
454 | } | ||
447 | public void llMessageLinked(int linknum, int num, string str, string id) { } | 455 | public void llMessageLinked(int linknum, int num, string str, string id) { } |
448 | public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } | 456 | public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } |
449 | public void llPassCollisions(int pass) { } | 457 | public void llPassCollisions(int pass) { } |
@@ -482,7 +490,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
482 | 490 | ||
483 | public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } | 491 | public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } |
484 | 492 | ||
485 | public List<string> llListSort(List<string> src, int stride, int ascending) { | 493 | public List<string> llListSort(List<string> src, int stride, int ascending) |
494 | { | ||
486 | SortedList<string, List<string>> sorted = new SortedList<string, List<string>>(); | 495 | SortedList<string, List<string>> sorted = new SortedList<string, List<string>>(); |
487 | // Add chunks to an array | 496 | // Add chunks to an array |
488 | int s = stride; | 497 | int s = stride; |
@@ -497,7 +506,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
497 | if (c > s) | 506 | if (c > s) |
498 | { | 507 | { |
499 | sorted.Add(chunkString, chunk); | 508 | sorted.Add(chunkString, chunk); |
500 | chunkString = ""; | 509 | chunkString = ""; |
501 | chunk = new List<string>(); | 510 | chunk = new List<string>(); |
502 | c = 0; | 511 | c = 0; |
503 | } | 512 | } |
@@ -554,7 +563,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
554 | { | 563 | { |
555 | return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); | 564 | return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); |
556 | } | 565 | } |
557 | public LSL_Types.Quaternion llList2Rot(List<string> src, int index) { | 566 | public LSL_Types.Quaternion llList2Rot(List<string> src, int index) |
567 | { | ||
558 | return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); | 568 | return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); |
559 | } | 569 | } |
560 | public List<string> llList2List(List<string> src, int start, int end) | 570 | public List<string> llList2List(List<string> src, int start, int end) |
@@ -632,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
632 | if (chunk.Count > 0) | 642 | if (chunk.Count > 0) |
633 | tmp.Add(chunk); | 643 | tmp.Add(chunk); |
634 | 644 | ||
635 | // Decreate array back into a list | 645 | // Decreate (<- what kind of word is that? :D ) array back into a list |
636 | int rnd; | 646 | int rnd; |
637 | List<string> ret = new List<string>(); | 647 | List<string> ret = new List<string>(); |
638 | while (tmp.Count > 0) | 648 | while (tmp.Count > 0) |
@@ -649,7 +659,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
649 | 659 | ||
650 | 660 | ||
651 | } | 661 | } |
652 | public List<string> llList2ListStrided(List<string> src, int start, int end, int stride) | 662 | public List<string> llList2ListStrided(List<string> src, int start, int end, int stride) |
653 | { | 663 | { |
654 | List<string> ret = new List<string>(); | 664 | List<string> ret = new List<string>(); |
655 | int s = stride; | 665 | int s = stride; |
@@ -657,9 +667,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
657 | s = 1; | 667 | s = 1; |
658 | 668 | ||
659 | int sc = s; | 669 | int sc = s; |
660 | for (int i = start; i < src.Count; i++) { | 670 | for (int i = start; i < src.Count; i++) |
671 | { | ||
661 | sc--; | 672 | sc--; |
662 | if (sc ==0) { | 673 | if (sc == 0) |
674 | { | ||
663 | sc = s; | 675 | sc = s; |
664 | // Addthis | 676 | // Addthis |
665 | ret.Add(src[i]); | 677 | ret.Add(src[i]); |
@@ -795,7 +807,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
795 | } | 807 | } |
796 | 808 | ||
797 | public void llSetPrimitiveParams(List<string> rules) { NotImplemented("llSetPrimitiveParams"); } | 809 | public void llSetPrimitiveParams(List<string> rules) { NotImplemented("llSetPrimitiveParams"); } |
798 | public string llStringToBase64(string str) { | 810 | public string llStringToBase64(string str) |
811 | { | ||
799 | 812 | ||
800 | try | 813 | try |
801 | { | 814 | { |
@@ -808,14 +821,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
808 | { | 821 | { |
809 | throw new Exception("Error in base64Encode" + e.Message); | 822 | throw new Exception("Error in base64Encode" + e.Message); |
810 | } | 823 | } |
811 | } | 824 | } |
812 | 825 | ||
813 | public string llBase64ToString(string str) { | 826 | public string llBase64ToString(string str) |
827 | { | ||
814 | System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); | 828 | System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); |
815 | System.Text.Decoder utf8Decode = encoder.GetDecoder(); | 829 | System.Text.Decoder utf8Decode = encoder.GetDecoder(); |
816 | try | 830 | try |
817 | { | 831 | { |
818 | 832 | ||
819 | byte[] todecode_byte = Convert.FromBase64String(str); | 833 | byte[] todecode_byte = Convert.FromBase64String(str); |
820 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); | 834 | int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); |
821 | char[] decoded_char = new char[charCount]; | 835 | char[] decoded_char = new char[charCount]; |
@@ -861,11 +875,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
861 | public List<string> llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List<string>(); } | 875 | public List<string> llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List<string>(); } |
862 | public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } | 876 | public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } |
863 | public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } | 877 | public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } |
864 | public string llIntegerToBase64(int number) { | 878 | public string llIntegerToBase64(int number) |
865 | NotImplemented("llIntegerToBase64"); return ""; | 879 | { |
880 | NotImplemented("llIntegerToBase64"); return ""; | ||
866 | } | 881 | } |
867 | public int llBase64ToInteger(string str) { | 882 | public int llBase64ToInteger(string str) |
868 | NotImplemented("llBase64ToInteger"); return 0; | 883 | { |
884 | NotImplemented("llBase64ToInteger"); return 0; | ||
869 | } | 885 | } |
870 | 886 | ||
871 | public double llGetGMTclock() | 887 | public double llGetGMTclock() |
@@ -957,7 +973,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
957 | 973 | ||
958 | public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } | 974 | public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } |
959 | public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } | 975 | public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } |
960 | public string llXorBase64StringsCorrect(string str1, string str2) { | 976 | public string llXorBase64StringsCorrect(string str1, string str2) |
977 | { | ||
961 | string ret = ""; | 978 | string ret = ""; |
962 | string src1 = llBase64ToString(str1); | 979 | string src1 = llBase64ToString(str1); |
963 | string src2 = llBase64ToString(str2); | 980 | string src2 = llBase64ToString(str2); |
@@ -972,7 +989,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler | |||
972 | } | 989 | } |
973 | return llStringToBase64(ret); | 990 | return llStringToBase64(ret); |
974 | } | 991 | } |
975 | public void llHTTPRequest() { NotImplemented("llHTTPRequest"); } | 992 | public void llHTTPRequest(string url, List<string> parameters, string body) |
993 | { | ||
994 | m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body); | ||
995 | } | ||
976 | public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } | 996 | public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } |
977 | public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } | 997 | public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } |
978 | public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } | 998 | public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index af8a62e..a45de1e 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | |||
@@ -1,148 +1,262 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Threading; | 4 | using System.Threading; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | 6 | using OpenSim.Region.ScriptEngine.Common; | |
7 | namespace OpenSim.Region.ScriptEngine.DotNetEngine | 7 | |
8 | { | 8 | namespace OpenSim.Region.ScriptEngine.DotNetEngine |
9 | /// <summary> | 9 | { |
10 | /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. | 10 | /// <summary> |
11 | /// </summary> | 11 | /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. |
12 | class LSLLongCmdHandler | 12 | /// </summary> |
13 | { | 13 | class LSLLongCmdHandler |
14 | private Thread cmdHandlerThread; | 14 | { |
15 | private int cmdHandlerThreadCycleSleepms = 100; | 15 | private Thread cmdHandlerThread; |
16 | 16 | private int cmdHandlerThreadCycleSleepms = 100; | |
17 | private ScriptEngine m_ScriptEngine; | 17 | |
18 | public LSLLongCmdHandler(ScriptEngine _ScriptEngine) | 18 | private ScriptEngine m_ScriptEngine; |
19 | { | 19 | public LSLLongCmdHandler(ScriptEngine _ScriptEngine) |
20 | m_ScriptEngine = _ScriptEngine; | 20 | { |
21 | 21 | m_ScriptEngine = _ScriptEngine; | |
22 | // Start the thread that will be doing the work | 22 | |
23 | cmdHandlerThread = new Thread(CmdHandlerThreadLoop); | 23 | // Start the thread that will be doing the work |
24 | cmdHandlerThread.Name = "CmdHandlerThread"; | 24 | cmdHandlerThread = new Thread(CmdHandlerThreadLoop); |
25 | cmdHandlerThread.Priority = ThreadPriority.BelowNormal; | 25 | cmdHandlerThread.Name = "CmdHandlerThread"; |
26 | cmdHandlerThread.IsBackground = true; | 26 | cmdHandlerThread.Priority = ThreadPriority.BelowNormal; |
27 | cmdHandlerThread.Start(); | 27 | cmdHandlerThread.IsBackground = true; |
28 | } | 28 | cmdHandlerThread.Start(); |
29 | ~LSLLongCmdHandler() | 29 | } |
30 | { | 30 | ~LSLLongCmdHandler() |
31 | // Shut down thread | 31 | { |
32 | try | 32 | // Shut down thread |
33 | { | 33 | try |
34 | if (cmdHandlerThread != null) | 34 | { |
35 | { | 35 | if (cmdHandlerThread != null) |
36 | if (cmdHandlerThread.IsAlive == true) | 36 | { |
37 | { | 37 | if (cmdHandlerThread.IsAlive == true) |
38 | cmdHandlerThread.Abort(); | 38 | { |
39 | cmdHandlerThread.Join(); | 39 | cmdHandlerThread.Abort(); |
40 | } | 40 | cmdHandlerThread.Join(); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | catch { } | 43 | } |
44 | } | 44 | catch { } |
45 | 45 | } | |
46 | private void CmdHandlerThreadLoop() | 46 | |
47 | { | 47 | private void CmdHandlerThreadLoop() |
48 | while (true) | 48 | { |
49 | { | 49 | while (true) |
50 | // Check timers | 50 | { |
51 | CheckTimerEvents(); | 51 | // Check timers |
52 | 52 | CheckTimerEvents(); | |
53 | // Sleep before next cycle | 53 | // Check HttpRequests |
54 | Thread.Sleep(cmdHandlerThreadCycleSleepms); | 54 | CheckHttpRequests(); |
55 | } | 55 | |
56 | } | 56 | // Sleep before next cycle |
57 | 57 | Thread.Sleep(cmdHandlerThreadCycleSleepms); | |
58 | /// <summary> | 58 | } |
59 | /// Remove a specific script (and all its pending commands) | 59 | } |
60 | /// </summary> | 60 | |
61 | /// <param name="m_localID"></param> | 61 | /// <summary> |
62 | /// <param name="m_itemID"></param> | 62 | /// Remove a specific script (and all its pending commands) |
63 | public void RemoveScript(uint m_localID, LLUUID m_itemID) | 63 | /// </summary> |
64 | { | 64 | /// <param name="m_localID"></param> |
65 | // Remove a specific script | 65 | /// <param name="m_itemID"></param> |
66 | 66 | public void RemoveScript(uint localID, LLUUID itemID) | |
67 | // Remove from: Timers | 67 | { |
68 | UnSetTimerEvents(m_localID, m_itemID); | 68 | // Remove a specific script |
69 | } | 69 | |
70 | 70 | // Remove from: Timers | |
71 | 71 | UnSetTimerEvents(localID, itemID); | |
72 | // | 72 | // Remove from: HttpRequest |
73 | // TIMER | 73 | StopHttpRequest(localID, itemID); |
74 | // | 74 | } |
75 | private class TimerClass | 75 | |
76 | { | 76 | #region TIMER |
77 | public uint localID; | 77 | |
78 | public LLUUID itemID; | 78 | // |
79 | public double interval; | 79 | // TIMER |
80 | public DateTime next; | 80 | // |
81 | } | 81 | private class TimerClass |
82 | private List<TimerClass> Timers = new List<TimerClass>(); | 82 | { |
83 | private object ListLock = new object(); | 83 | public uint localID; |
84 | public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) | 84 | public LLUUID itemID; |
85 | { | 85 | public double interval; |
86 | Console.WriteLine("SetTimerEvent"); | 86 | public DateTime next; |
87 | 87 | } | |
88 | // Always remove first, in case this is a re-set | 88 | private List<TimerClass> Timers = new List<TimerClass>(); |
89 | UnSetTimerEvents(m_localID, m_itemID); | 89 | private object TimerListLock = new object(); |
90 | if (sec == 0) // Disabling timer | 90 | public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) |
91 | return; | 91 | { |
92 | 92 | Console.WriteLine("SetTimerEvent"); | |
93 | // Add to timer | 93 | |
94 | TimerClass ts = new TimerClass(); | 94 | // Always remove first, in case this is a re-set |
95 | ts.localID = m_localID; | 95 | UnSetTimerEvents(m_localID, m_itemID); |
96 | ts.itemID = m_itemID; | 96 | if (sec == 0) // Disabling timer |
97 | ts.interval = sec; | 97 | return; |
98 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 98 | |
99 | lock (ListLock) | 99 | // Add to timer |
100 | { | 100 | TimerClass ts = new TimerClass(); |
101 | Timers.Add(ts); | 101 | ts.localID = m_localID; |
102 | } | 102 | ts.itemID = m_itemID; |
103 | } | 103 | ts.interval = sec; |
104 | public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) | 104 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
105 | { | 105 | lock (TimerListLock) |
106 | // Remove from timer | 106 | { |
107 | lock (ListLock) | 107 | Timers.Add(ts); |
108 | { | 108 | } |
109 | List<TimerClass> NewTimers = new List<TimerClass>(); | 109 | } |
110 | foreach (TimerClass ts in Timers) | 110 | public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) |
111 | { | 111 | { |
112 | if (ts.localID != m_localID && ts.itemID != m_itemID) | 112 | // Remove from timer |
113 | { | 113 | lock (TimerListLock) |
114 | NewTimers.Add(ts); | 114 | { |
115 | } | 115 | List<TimerClass> NewTimers = new List<TimerClass>(); |
116 | } | 116 | foreach (TimerClass ts in Timers) |
117 | Timers.Clear(); | 117 | { |
118 | Timers = NewTimers; | 118 | if (ts.localID != m_localID && ts.itemID != m_itemID) |
119 | } | 119 | { |
120 | } | 120 | NewTimers.Add(ts); |
121 | public void CheckTimerEvents() | 121 | } |
122 | { | 122 | } |
123 | // Nothing to do here? | 123 | Timers.Clear(); |
124 | if (Timers.Count == 0) | 124 | Timers = NewTimers; |
125 | return; | 125 | } |
126 | 126 | } | |
127 | lock (ListLock) | 127 | public void CheckTimerEvents() |
128 | { | 128 | { |
129 | 129 | // Nothing to do here? | |
130 | // Go through all timers | 130 | if (Timers.Count == 0) |
131 | foreach (TimerClass ts in Timers) | 131 | return; |
132 | { | 132 | |
133 | // Time has passed? | 133 | lock (TimerListLock) |
134 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | 134 | { |
135 | { | 135 | |
136 | // Add it to queue | 136 | // Go through all timers |
137 | m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); | 137 | foreach (TimerClass ts in Timers) |
138 | // set next interval | 138 | { |
139 | 139 | // Time has passed? | |
140 | 140 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | |
141 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 141 | { |
142 | } | 142 | // Add it to queue |
143 | } | 143 | m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); |
144 | } // lock | 144 | // set next interval |
145 | } | 145 | |
146 | 146 | ||
147 | } | 147 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
148 | } | 148 | } |
149 | } | ||
150 | } // lock | ||
151 | } | ||
152 | #endregion | ||
153 | |||
154 | #region HTTP REQUEST | ||
155 | |||
156 | // | ||
157 | // HTTP REAQUEST | ||
158 | // | ||
159 | private class HttpClass | ||
160 | { | ||
161 | public uint localID; | ||
162 | public LLUUID itemID; | ||
163 | public string url; | ||
164 | public List<string> parameters; | ||
165 | public string body; | ||
166 | public DateTime next; | ||
167 | |||
168 | public string response_request_id; | ||
169 | public int response_status; | ||
170 | public List<string> response_metadata; | ||
171 | public string response_body; | ||
172 | |||
173 | public void SendRequest() | ||
174 | { | ||
175 | // TODO: SEND REQUEST!!! | ||
176 | } | ||
177 | public void Stop() | ||
178 | { | ||
179 | // TODO: Cancel any ongoing request | ||
180 | } | ||
181 | public bool CheckResponse() | ||
182 | { | ||
183 | // TODO: Check if we got a response yet, return true if so -- false if not | ||
184 | return true; | ||
185 | |||
186 | // TODO: If we got a response, set the following then return true | ||
187 | //response_request_id | ||
188 | //response_status | ||
189 | //response_metadata | ||
190 | //response_body | ||
191 | |||
192 | } | ||
193 | } | ||
194 | private List<HttpClass> HttpRequests = new List<HttpClass>(); | ||
195 | private object HttpListLock = new object(); | ||
196 | public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) | ||
197 | { | ||
198 | Console.WriteLine("StartHttpRequest"); | ||
199 | |||
200 | HttpClass htc = new HttpClass(); | ||
201 | htc.localID = localID; | ||
202 | htc.itemID = itemID; | ||
203 | htc.url = url; | ||
204 | htc.parameters = parameters; | ||
205 | htc.body = body; | ||
206 | lock (HttpListLock) | ||
207 | { | ||
208 | |||
209 | //ADD REQUEST | ||
210 | HttpRequests.Add(htc); | ||
211 | } | ||
212 | } | ||
213 | public void StopHttpRequest(uint m_localID, LLUUID m_itemID) | ||
214 | { | ||
215 | // Remove from list | ||
216 | lock (HttpListLock) | ||
217 | { | ||
218 | List<HttpClass> NewHttpList = new List<HttpClass>(); | ||
219 | foreach (HttpClass ts in HttpRequests) | ||
220 | { | ||
221 | if (ts.localID != m_localID && ts.itemID != m_itemID) | ||
222 | { | ||
223 | // Keeping this one | ||
224 | NewHttpList.Add(ts); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | // Shutting this one down | ||
229 | ts.Stop(); | ||
230 | } | ||
231 | } | ||
232 | HttpRequests.Clear(); | ||
233 | HttpRequests = NewHttpList; | ||
234 | } | ||
235 | } | ||
236 | public void CheckHttpRequests() | ||
237 | { | ||
238 | // Nothing to do here? | ||
239 | if (HttpRequests.Count == 0) | ||
240 | return; | ||
241 | |||
242 | lock (HttpListLock) | ||
243 | { | ||
244 | foreach (HttpClass ts in HttpRequests) | ||
245 | { | ||
246 | |||
247 | if (ts.CheckResponse() == true) | ||
248 | { | ||
249 | // Add it to event queue | ||
250 | //key request_id, integer status, list metadata, string body | ||
251 | object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; | ||
252 | m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); | ||
253 | // Now stop it | ||
254 | StopHttpRequest(ts.localID, ts.itemID); | ||
255 | } | ||
256 | } | ||
257 | } // lock | ||
258 | } | ||
259 | #endregion | ||
260 | |||
261 | } | ||
262 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index c521d47..20300c0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -221,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
221 | 221 | ||
222 | } | 222 | } |
223 | #endregion | 223 | #endregion |
224 | #region Start/Stop script | 224 | #region Start/Stop/Reset script |
225 | /// <summary> | 225 | /// <summary> |
226 | /// Fetches, loads and hooks up a script to an objects events | 226 | /// Fetches, loads and hooks up a script to an objects events |
227 | /// </summary> | 227 | /// </summary> |
@@ -246,6 +246,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
246 | ls.localID = localID; | 246 | ls.localID = localID; |
247 | ls.itemID = itemID; | 247 | ls.itemID = itemID; |
248 | unloadQueue.Enqueue(ls); | 248 | unloadQueue.Enqueue(ls); |
249 | } | ||
250 | public void ResetScript(uint localID, LLUUID itemID) | ||
251 | { | ||
252 | string script = GetScript(localID, itemID).SourceCode; | ||
253 | StopScript(localID, itemID); | ||
254 | StartScript(localID, itemID, script); | ||
249 | } | 255 | } |
250 | 256 | ||
251 | private void _StartScript(uint localID, LLUUID itemID, string Script) | 257 | private void _StartScript(uint localID, LLUUID itemID, string Script) |
@@ -255,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
255 | 261 | ||
256 | // We will initialize and start the script. | 262 | // We will initialize and start the script. |
257 | // It will be up to the script itself to hook up the correct events. | 263 | // It will be up to the script itself to hook up the correct events. |
258 | string FileName = ""; | 264 | string ScriptSource = ""; |
259 | 265 | ||
260 | SceneObjectPart m_host = World.GetSceneObjectPart(localID); | 266 | SceneObjectPart m_host = World.GetSceneObjectPart(localID); |
261 | 267 | ||
@@ -268,10 +274,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
268 | // Create a new instance of the compiler (currently we don't want reuse) | 274 | // Create a new instance of the compiler (currently we don't want reuse) |
269 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); | 275 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); |
270 | // Compile (We assume LSL) | 276 | // Compile (We assume LSL) |
271 | FileName = LSLCompiler.CompileFromLSLText(Script); | 277 | ScriptSource = LSLCompiler.CompileFromLSLText(Script); |
272 | //Console.WriteLine("Compilation of " + FileName + " done"); | 278 | //Console.WriteLine("Compilation of " + FileName + " done"); |
273 | // * Insert yield into code | 279 | // * Insert yield into code |
274 | FileName = ProcessYield(FileName); | 280 | ScriptSource = ProcessYield(ScriptSource); |
275 | 281 | ||
276 | 282 | ||
277 | #if DEBUG | 283 | #if DEBUG |
@@ -279,11 +285,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
279 | before = GC.GetTotalMemory(true); | 285 | before = GC.GetTotalMemory(true); |
280 | #endif | 286 | #endif |
281 | LSL_BaseClass CompiledScript; | 287 | LSL_BaseClass CompiledScript; |
282 | CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(FileName); | 288 | CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); |
283 | #if DEBUG | 289 | #if DEBUG |
284 | Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); | 290 | Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); |
285 | #endif | 291 | #endif |
286 | 292 | ||
293 | CompiledScript.SourceCode = ScriptSource; | ||
287 | // Add it to our script memstruct | 294 | // Add it to our script memstruct |
288 | SetScript(localID, itemID, CompiledScript); | 295 | SetScript(localID, itemID, CompiledScript); |
289 | 296 | ||