diff options
author | KittoFlora | 2009-11-15 22:20:51 +0100 |
---|---|---|
committer | KittoFlora | 2009-11-15 22:20:51 +0100 |
commit | ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee (patch) | |
tree | e218f290178d98e63aa8ab6aef46c1715195c32e /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' into vehicles (diff) | |
parent | Make GroupRootUpdate be a terse update. This method is not used by opensim (i... (diff) | |
download | opensim-SC_OLD-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.zip opensim-SC_OLD-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.gz opensim-SC_OLD-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.bz2 opensim-SC_OLD-ba77f0c2ac9e41d7c8ca00ddf4b68bc4f25deaee.tar.xz |
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
8 files changed, 357 insertions, 46 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs new file mode 100644 index 0000000..d4facdd --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -0,0 +1,134 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Runtime.Remoting.Lifetime; | ||
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
42 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
44 | |||
45 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
46 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
47 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
48 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
49 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
50 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
51 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
52 | |||
53 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
54 | { | ||
55 | [Serializable] | ||
56 | public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi | ||
57 | { | ||
58 | internal IScriptEngine m_ScriptEngine; | ||
59 | internal SceneObjectPart m_host; | ||
60 | internal uint m_localID; | ||
61 | internal UUID m_itemID; | ||
62 | internal bool m_MODFunctionsEnabled = false; | ||
63 | internal IScriptModuleComms m_comms = null; | ||
64 | |||
65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
66 | { | ||
67 | m_ScriptEngine = ScriptEngine; | ||
68 | m_host = host; | ||
69 | m_localID = localID; | ||
70 | m_itemID = itemID; | ||
71 | |||
72 | if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) | ||
73 | m_MODFunctionsEnabled = true; | ||
74 | |||
75 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
76 | if (m_comms == null) | ||
77 | m_MODFunctionsEnabled = false; | ||
78 | } | ||
79 | |||
80 | public override Object InitializeLifetimeService() | ||
81 | { | ||
82 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
83 | |||
84 | if (lease.CurrentState == LeaseState.Initial) | ||
85 | { | ||
86 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
87 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
88 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
89 | } | ||
90 | return lease; | ||
91 | } | ||
92 | |||
93 | public Scene World | ||
94 | { | ||
95 | get { return m_ScriptEngine.World; } | ||
96 | } | ||
97 | |||
98 | internal void MODError(string msg) | ||
99 | { | ||
100 | throw new Exception("MOD Runtime Error: " + msg); | ||
101 | } | ||
102 | |||
103 | // | ||
104 | //Dumps an error message on the debug console. | ||
105 | // | ||
106 | |||
107 | internal void MODShoutError(string message) | ||
108 | { | ||
109 | if (message.Length > 1023) | ||
110 | message = message.Substring(0, 1023); | ||
111 | |||
112 | World.SimChat(Utils.StringToBytes(message), | ||
113 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
114 | |||
115 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
116 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
117 | } | ||
118 | |||
119 | public string modSendCommand(string module, string command, string k) | ||
120 | { | ||
121 | if (!m_MODFunctionsEnabled) | ||
122 | { | ||
123 | MODShoutError("Module command functions not enabled"); | ||
124 | return UUID.Zero.ToString();; | ||
125 | } | ||
126 | |||
127 | UUID req = UUID.Random(); | ||
128 | |||
129 | m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); | ||
130 | |||
131 | return req.ToString(); | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 52396b6..3ffcff0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
199 | //Dumps an error message on the debug console. | 199 | //Dumps an error message on the debug console. |
200 | // | 200 | // |
201 | 201 | ||
202 | internal void OSSLShoutError(string message) | 202 | internal void OSSLShoutError(string message) |
203 | { | 203 | { |
204 | if (message.Length > 1023) | 204 | if (message.Length > 1023) |
205 | message = message.Substring(0, 1023); | 205 | message = message.Substring(0, 1023); |
@@ -384,7 +384,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | m_host.AddScriptLPS(1); | 384 | m_host.AddScriptLPS(1); |
385 | if (World.Entities.ContainsKey(target)) | 385 | if (World.Entities.ContainsKey(target)) |
386 | { | 386 | { |
387 | World.Entities[target].Rotation = rotation; | 387 | EntityBase entity; |
388 | if (World.Entities.TryGetValue(target, out entity)) | ||
389 | { | ||
390 | if (entity is SceneObjectGroup) | ||
391 | ((SceneObjectGroup)entity).Rotation = rotation; | ||
392 | else if (entity is ScenePresence) | ||
393 | ((ScenePresence)entity).Rotation = rotation; | ||
394 | } | ||
388 | } | 395 | } |
389 | else | 396 | else |
390 | { | 397 | { |
@@ -1169,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1169 | 1176 | ||
1170 | land.SetMediaUrl(url); | 1177 | land.SetMediaUrl(url); |
1171 | } | 1178 | } |
1172 | 1179 | ||
1173 | public void osSetParcelSIPAddress(string SIPAddress) | 1180 | public void osSetParcelSIPAddress(string SIPAddress) |
1174 | { | 1181 | { |
1175 | // What actually is the difference to the LL function? | 1182 | // What actually is the difference to the LL function? |
@@ -1177,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1177 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); | 1184 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); |
1178 | 1185 | ||
1179 | m_host.AddScriptLPS(1); | 1186 | m_host.AddScriptLPS(1); |
1180 | 1187 | ||
1181 | 1188 | ||
1182 | ILandObject land | 1189 | ILandObject land |
1183 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 1190 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); |
@@ -1187,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1187 | OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); | 1194 | OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); |
1188 | return; | 1195 | return; |
1189 | } | 1196 | } |
1190 | 1197 | ||
1191 | // get the voice module | 1198 | // get the voice module |
1192 | IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>(); | 1199 | IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>(); |
1193 | 1200 | ||
1194 | if (voiceModule != null) | 1201 | if (voiceModule != null) |
1195 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); | 1202 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); |
1196 | else | 1203 | else |
1197 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); | 1204 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); |
1198 | 1205 | ||
1199 | 1206 | ||
1200 | } | 1207 | } |
1201 | 1208 | ||
1202 | public string osGetScriptEngineName() | 1209 | public string osGetScriptEngineName() |
@@ -1476,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1476 | m_host.AddScriptLPS(1); | 1483 | m_host.AddScriptLPS(1); |
1477 | 1484 | ||
1478 | // Create new asset | 1485 | // Create new asset |
1479 | AssetBase asset = new AssetBase(); | 1486 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); |
1480 | asset.Name = notecardName; | ||
1481 | asset.Description = "Script Generated Notecard"; | 1487 | asset.Description = "Script Generated Notecard"; |
1482 | asset.Type = 7; | 1488 | string notecardData = String.Empty; |
1483 | asset.FullID = UUID.Random(); | ||
1484 | string notecardData = ""; | ||
1485 | 1489 | ||
1486 | for (int i = 0; i < contents.Length; i++) { | 1490 | for (int i = 0; i < contents.Length; i++) { |
1487 | notecardData += contents.GetLSLStringItem(i) + "\n"; | 1491 | notecardData += contents.GetLSLStringItem(i) + "\n"; |
@@ -1521,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1521 | } | 1525 | } |
1522 | 1526 | ||
1523 | 1527 | ||
1524 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1528 | /*Instead of using the LSL Dataserver event to pull notecard data, |
1525 | this will simply read the requested line and return its data as a string. | 1529 | this will simply read the requested line and return its data as a string. |
1526 | 1530 | ||
1527 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1531 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1528 | may be dangerous and unreliable while running in grid mode. | 1532 | may be dangerous and unreliable while running in grid mode. |
1529 | */ | 1533 | */ |
1530 | public string osGetNotecardLine(string name, int line) | 1534 | public string osGetNotecardLine(string name, int line) |
@@ -1572,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1572 | 1576 | ||
1573 | } | 1577 | } |
1574 | 1578 | ||
1575 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, | 1579 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, |
1576 | this will simply read the entire notecard and return its data as a string. | 1580 | this will simply read the entire notecard and return its data as a string. |
1577 | 1581 | ||
1578 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1582 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1579 | may be dangerous and unreliable while running in grid mode. | 1583 | may be dangerous and unreliable while running in grid mode. |
1580 | */ | 1584 | */ |
1581 | 1585 | ||
@@ -1630,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1630 | 1634 | ||
1631 | } | 1635 | } |
1632 | 1636 | ||
1633 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1637 | /*Instead of using the LSL Dataserver event to pull notecard data, |
1634 | this will simply read the number of note card lines and return this data as an integer. | 1638 | this will simply read the number of note card lines and return this data as an integer. |
1635 | 1639 | ||
1636 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1640 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1637 | may be dangerous and unreliable while running in grid mode. | 1641 | may be dangerous and unreliable while running in grid mode. |
1638 | */ | 1642 | */ |
1639 | 1643 | ||
@@ -1833,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1833 | 1837 | ||
1834 | return World.RegionInfo.RegionSettings.LoadedCreationID; | 1838 | return World.RegionInfo.RegionSettings.LoadedCreationID; |
1835 | } | 1839 | } |
1836 | 1840 | ||
1837 | // Threat level is 'Low' because certain users could possibly be tricked into | 1841 | // Threat level is 'Low' because certain users could possibly be tricked into |
1838 | // dropping an unverified script into one of their own objects, which could | 1842 | // dropping an unverified script into one of their own objects, which could |
1839 | // then gather the physical construction details of the object and transmit it | 1843 | // then gather the physical construction details of the object and transmit it |
@@ -1857,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1857 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) | 1861 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) |
1858 | { | 1862 | { |
1859 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 1863 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
1860 | //QueueUserWorkItem | 1864 | //QueueUserWorkItem |
1861 | 1865 | ||
1862 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 1866 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
1863 | if (module != null) | 1867 | if (module != null) |
@@ -1906,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1906 | module.DeleteNPC(new UUID(npc.m_string), World); | 1910 | module.DeleteNPC(new UUID(npc.m_string), World); |
1907 | } | 1911 | } |
1908 | } | 1912 | } |
1913 | |||
1914 | /// <summary> | ||
1915 | /// Get current region's map texture UUID | ||
1916 | /// </summary> | ||
1917 | /// <returns></returns> | ||
1918 | public LSL_Key osGetMapTexture() | ||
1919 | { | ||
1920 | CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); | ||
1921 | return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); | ||
1922 | } | ||
1923 | |||
1924 | /// <summary> | ||
1925 | /// Get a region's map texture UUID by region UUID or name. | ||
1926 | /// </summary> | ||
1927 | /// <param name="regionName"></param> | ||
1928 | /// <returns></returns> | ||
1929 | public LSL_Key osGetRegionMapTexture(string regionName) | ||
1930 | { | ||
1931 | CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); | ||
1932 | Scene scene = m_ScriptEngine.World; | ||
1933 | UUID key = UUID.Zero; | ||
1934 | GridRegion region; | ||
1935 | |||
1936 | //If string is a key, use it. Otherwise, try to locate region by name. | ||
1937 | if (UUID.TryParse(regionName, out key)) | ||
1938 | region = scene.GridService.GetRegionByUUID(UUID.Zero, key); | ||
1939 | else | ||
1940 | region = scene.GridService.GetRegionByName(UUID.Zero, regionName); | ||
1941 | |||
1942 | // If region was found, return the regions map texture key. | ||
1943 | if (region != null) | ||
1944 | key = region.TerrainImage; | ||
1945 | |||
1946 | ScriptSleep(1000); | ||
1947 | |||
1948 | return key.ToString(); | ||
1949 | } | ||
1909 | } | 1950 | } |
1910 | } | 1951 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs new file mode 100644 index 0000000..e08eca5 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | |||
@@ -0,0 +1,46 @@ | |||
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 | |||
28 | using System.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface IMOD_Api | ||
42 | { | ||
43 | //Module functions | ||
44 | string modSendCommand(string modules, string command, string k); | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d8d3c31..2a403bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
79 | 79 | ||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
@@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
127 | string osGetScriptEngineName(); | 127 | string osGetScriptEngineName(); |
128 | string osGetSimulatorVersion(); | 128 | string osGetSimulatorVersion(); |
129 | Hashtable osParseJSON(string JSON); | 129 | Hashtable osParseJSON(string JSON); |
130 | 130 | ||
131 | void osMessageObject(key objectUUID,string message); | 131 | void osMessageObject(key objectUUID,string message); |
132 | 132 | ||
133 | void osMakeNotecard(string notecardName, LSL_Types.list contents); | 133 | void osMakeNotecard(string notecardName, LSL_Types.list contents); |
@@ -138,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
138 | 138 | ||
139 | string osAvatarName2Key(string firstname, string lastname); | 139 | string osAvatarName2Key(string firstname, string lastname); |
140 | string osKey2Name(string id); | 140 | string osKey2Name(string id); |
141 | 141 | ||
142 | // Grid Info Functions | 142 | // Grid Info Functions |
143 | string osGetGridNick(); | 143 | string osGetGridNick(); |
144 | string osGetGridName(); | 144 | string osGetGridName(); |
@@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
151 | string osLoadedCreationDate(); | 151 | string osLoadedCreationDate(); |
152 | string osLoadedCreationTime(); | 152 | string osLoadedCreationTime(); |
153 | string osLoadedCreationID(); | 153 | string osLoadedCreationID(); |
154 | 154 | ||
155 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); | 155 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); |
156 | 156 | ||
157 | 157 | ||
@@ -160,5 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
160 | void osNpcSay(key npc, string message); | 160 | void osNpcSay(key npc, string message); |
161 | void osNpcRemove(key npc); | 161 | void osNpcRemove(key npc); |
162 | 162 | ||
163 | key osGetMapTexture(); | ||
164 | key osGetRegionMapTexture(string regionName); | ||
163 | } | 165 | } |
164 | } | 166 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs new file mode 100644 index 0000000..6525c76 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | |||
@@ -0,0 +1,66 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public IMOD_Api m_MOD_Functions; | ||
52 | |||
53 | public void ApiTypeMOD(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is IMOD_Api)) | ||
56 | return; | ||
57 | |||
58 | m_MOD_Functions = (IMOD_Api)api; | ||
59 | } | ||
60 | |||
61 | public string modSendCommand(string module, string command, string k) | ||
62 | { | ||
63 | return m_MOD_Functions.modSendCommand(module, command, k); | ||
64 | } | ||
65 | } | ||
66 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 8dcb1f5..4928e90 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
94 | { | 94 | { |
95 | return m_OSSL_Functions.osWindActiveModelPluginName(); | 95 | return m_OSSL_Functions.osWindActiveModelPluginName(); |
96 | } | 96 | } |
97 | 97 | ||
98 | // Not yet plugged in as available OSSL functions, so commented out | 98 | // Not yet plugged in as available OSSL functions, so commented out |
99 | // void osWindParamSet(string plugin, string param, float value) | 99 | // void osWindParamSet(string plugin, string param, float value) |
100 | // { | 100 | // { |
@@ -138,14 +138,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
138 | public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, | 138 | public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, |
139 | bool blend, int disp, int timer, int alpha, int face) | 139 | bool blend, int disp, int timer, int alpha, int face) |
140 | { | 140 | { |
141 | return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, | 141 | return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, |
142 | blend, disp, timer, alpha, face); | 142 | blend, disp, timer, alpha, face); |
143 | } | 143 | } |
144 | 144 | ||
145 | public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, | 145 | public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, |
146 | bool blend, int disp, int timer, int alpha, int face) | 146 | bool blend, int disp, int timer, int alpha, int face) |
147 | { | 147 | { |
148 | return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, | 148 | return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, |
149 | blend, disp, timer, alpha, face); | 149 | blend, disp, timer, alpha, face); |
150 | } | 150 | } |
151 | 151 | ||
@@ -183,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
183 | { | 183 | { |
184 | m_OSSL_Functions.osSetParcelMediaURL(url); | 184 | m_OSSL_Functions.osSetParcelMediaURL(url); |
185 | } | 185 | } |
186 | 186 | ||
187 | public void osSetParcelSIPAddress(string SIPAddress) | 187 | public void osSetParcelSIPAddress(string SIPAddress) |
188 | { | 188 | { |
189 | m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); | 189 | m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); |
@@ -211,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
211 | m_OSSL_Functions.osTeleportAgent(agent, position, lookat); | 211 | m_OSSL_Functions.osTeleportAgent(agent, position, lookat); |
212 | } | 212 | } |
213 | 213 | ||
214 | // Avatar info functions | 214 | // Avatar info functions |
215 | public string osGetAgentIP(string agent) | 215 | public string osGetAgentIP(string agent) |
216 | { | 216 | { |
217 | return m_OSSL_Functions.osGetAgentIP(agent); | 217 | return m_OSSL_Functions.osGetAgentIP(agent); |
@@ -326,17 +326,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
326 | { | 326 | { |
327 | return m_OSSL_Functions.osGetScriptEngineName(); | 327 | return m_OSSL_Functions.osGetScriptEngineName(); |
328 | } | 328 | } |
329 | 329 | ||
330 | public string osGetSimulatorVersion() | 330 | public string osGetSimulatorVersion() |
331 | { | 331 | { |
332 | return m_OSSL_Functions.osGetSimulatorVersion(); | 332 | return m_OSSL_Functions.osGetSimulatorVersion(); |
333 | } | 333 | } |
334 | 334 | ||
335 | public Hashtable osParseJSON(string JSON) | 335 | public Hashtable osParseJSON(string JSON) |
336 | { | 336 | { |
337 | return m_OSSL_Functions.osParseJSON(JSON); | 337 | return m_OSSL_Functions.osParseJSON(JSON); |
338 | } | 338 | } |
339 | 339 | ||
340 | public void osMessageObject(key objectUUID,string message) | 340 | public void osMessageObject(key objectUUID,string message) |
341 | { | 341 | { |
342 | m_OSSL_Functions.osMessageObject(objectUUID,message); | 342 | m_OSSL_Functions.osMessageObject(objectUUID,message); |
@@ -412,7 +412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
412 | { | 412 | { |
413 | return m_OSSL_Functions.osLoadedCreationID(); | 413 | return m_OSSL_Functions.osLoadedCreationID(); |
414 | } | 414 | } |
415 | 415 | ||
416 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 416 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
417 | { | 417 | { |
418 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); | 418 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); |
@@ -622,5 +622,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
622 | } | 622 | } |
623 | } | 623 | } |
624 | } | 624 | } |
625 | |||
626 | public key osGetMapTexture() | ||
627 | { | ||
628 | return m_OSSL_Functions.osGetMapTexture(); | ||
629 | } | ||
630 | |||
631 | public key osGetRegionMapTexture(string regionName) | ||
632 | { | ||
633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); | ||
634 | } | ||
625 | } | 635 | } |
626 | } | 636 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index feff86a..98bbc68 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -20,6 +20,7 @@ | |||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
23 | <File name="./MOD_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
23 | <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
24 | <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 25 | <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
25 | <File name="./ScriptSponsor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 26 | <File name="./ScriptSponsor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b0fce75..a60c0ba 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -51,7 +51,6 @@ using OpenSim.Region.ScriptEngine.Shared.Instance; | |||
51 | using OpenSim.Region.ScriptEngine.Interfaces; | 51 | using OpenSim.Region.ScriptEngine.Interfaces; |
52 | 52 | ||
53 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | 53 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; |
54 | using Parallel = OpenSim.Framework.Parallel; | ||
55 | 54 | ||
56 | namespace OpenSim.Region.ScriptEngine.XEngine | 55 | namespace OpenSim.Region.ScriptEngine.XEngine |
57 | { | 56 | { |
@@ -494,7 +493,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
494 | 493 | ||
495 | if (m_CurrentCompile == null) | 494 | if (m_CurrentCompile == null) |
496 | { | 495 | { |
497 | m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); | 496 | // NOTE: Although we use a lockless queue, the lock here |
497 | // is required. It ensures that there are never two | ||
498 | // compile threads running, which, due to a race | ||
499 | // conndition, might otherwise happen | ||
500 | // | ||
501 | lock (m_CompileQueue) | ||
502 | { | ||
503 | if (m_CurrentCompile == null) | ||
504 | m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); | ||
505 | } | ||
498 | } | 506 | } |
499 | } | 507 | } |
500 | } | 508 | } |
@@ -514,16 +522,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
514 | } | 522 | } |
515 | } | 523 | } |
516 | 524 | ||
517 | List<object[]> compiles = new List<object[]>(); | ||
518 | object[] o; | 525 | object[] o; |
519 | while (m_CompileQueue.Dequeue(out o)) | 526 | while (m_CompileQueue.Dequeue(out o)) |
527 | DoOnRezScript(o); | ||
528 | |||
529 | // NOTE: Despite having a lockless queue, this lock is required | ||
530 | // to make sure there is never no compile thread while there | ||
531 | // are still scripts to compile. This could otherwise happen | ||
532 | // due to a race condition | ||
533 | // | ||
534 | lock (m_CompileQueue) | ||
520 | { | 535 | { |
521 | compiles.Add(o); | 536 | m_CurrentCompile = null; |
522 | } | 537 | } |
523 | |||
524 | Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); }); | ||
525 | |||
526 | m_CurrentCompile = null; | ||
527 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | 538 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, |
528 | m_ScriptErrorMessage); | 539 | m_ScriptErrorMessage); |
529 | m_ScriptFailCount = 0; | 540 | m_ScriptFailCount = 0; |