diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
6 files changed, 197 insertions, 222 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index 9f829da..07cba60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -1,4 +1,31 @@ | |||
1 | using System; | 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; | ||
2 | using System.Reflection; | 29 | using System.Reflection; |
3 | using System.Collections; | 30 | using System.Collections; |
4 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
@@ -7,7 +34,7 @@ using OpenMetaverse; | |||
7 | using Nini.Config; | 34 | using Nini.Config; |
8 | using OpenSim; | 35 | using OpenSim; |
9 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
10 | using OpenSim.Region.CoreModules.World.Meta7Windlight; | 37 | using OpenSim.Region.CoreModules.World.LightShare; |
11 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
12 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
13 | using OpenSim.Region.ScriptEngine.Shared; | 40 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -92,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
92 | public LSL_List cmGetAvatarList() | 119 | public LSL_List cmGetAvatarList() |
93 | { | 120 | { |
94 | LSL_List result = new LSL_List(); | 121 | LSL_List result = new LSL_List(); |
95 | foreach (ScenePresence avatar in World.GetAvatars()) | 122 | World.ForEachScenePresence(delegate (ScenePresence avatar) |
96 | { | 123 | { |
97 | if (avatar.UUID != m_host.OwnerID) | 124 | if (avatar.UUID != m_host.OwnerID) |
98 | { | 125 | { |
@@ -103,7 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
103 | result.Add(avatar.Name); | 130 | result.Add(avatar.Name); |
104 | } | 131 | } |
105 | } | 132 | } |
106 | } | 133 | }); |
107 | return result; | 134 | return result; |
108 | } | 135 | } |
109 | 136 | ||
@@ -119,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | return new LSL_List(); | 146 | return new LSL_List(); |
120 | } | 147 | } |
121 | m_host.AddScriptLPS(1); | 148 | m_host.AddScriptLPS(1); |
122 | RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | 149 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; |
123 | 150 | ||
124 | LSL_List values = new LSL_List(); | 151 | LSL_List values = new LSL_List(); |
125 | int idx = 0; | 152 | int idx = 0; |
@@ -253,9 +280,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
253 | 280 | ||
254 | } | 281 | } |
255 | 282 | ||
256 | private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) | 283 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) |
257 | { | 284 | { |
258 | RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | 285 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); |
259 | 286 | ||
260 | LSL_List values = new LSL_List(); | 287 | LSL_List values = new LSL_List(); |
261 | int idx = 0; | 288 | int idx = 0; |
@@ -449,9 +476,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
449 | } | 476 | } |
450 | int success = 0; | 477 | int success = 0; |
451 | m_host.AddScriptLPS(1); | 478 | m_host.AddScriptLPS(1); |
452 | if (Meta7WindlightModule.EnableWindlight) | 479 | if (LightShareModule.EnableWindlight) |
453 | { | 480 | { |
454 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | 481 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
455 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | 482 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); |
456 | success = 1; | 483 | success = 1; |
457 | } | 484 | } |
@@ -481,9 +508,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
481 | } | 508 | } |
482 | int success = 0; | 509 | int success = 0; |
483 | m_host.AddScriptLPS(1); | 510 | m_host.AddScriptLPS(1); |
484 | if (Meta7WindlightModule.EnableWindlight) | 511 | if (LightShareModule.EnableWindlight) |
485 | { | 512 | { |
486 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | 513 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
487 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | 514 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); |
488 | success = 1; | 515 | success = 1; |
489 | } | 516 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 75dd615..228e9b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -39,7 +39,7 @@ using OpenMetaverse; | |||
39 | using OpenMetaverse.Packets; | 39 | using OpenMetaverse.Packets; |
40 | using OpenSim; | 40 | using OpenSim; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Communications.Cache; | 42 | |
43 | using OpenSim.Region.CoreModules; | 43 | using OpenSim.Region.CoreModules; |
44 | using OpenSim.Region.CoreModules.World.Land; | 44 | using OpenSim.Region.CoreModules.World.Land; |
45 | using OpenSim.Region.CoreModules.World.Terrain; | 45 | using OpenSim.Region.CoreModules.World.Terrain; |
@@ -53,9 +53,9 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | |||
53 | using OpenSim.Region.ScriptEngine.Interfaces; | 53 | using OpenSim.Region.ScriptEngine.Interfaces; |
54 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | 54 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; |
55 | using OpenSim.Services.Interfaces; | 55 | using OpenSim.Services.Interfaces; |
56 | |||
57 | using PrimType = OpenSim.Region.Framework.Scenes.PrimType; | ||
58 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 56 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
57 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
58 | using PrimType = OpenSim.Region.Framework.Scenes.PrimType; | ||
59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; | 59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; |
60 | 60 | ||
61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
@@ -917,10 +917,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
917 | public string resolveName(UUID objecUUID) | 917 | public string resolveName(UUID objecUUID) |
918 | { | 918 | { |
919 | // try avatar username surname | 919 | // try avatar username surname |
920 | CachedUserInfo profile = World.CommsManager.UserProfileCacheService.GetUserDetails(objecUUID); | 920 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, objecUUID); |
921 | if (profile != null && profile.UserProfile != null) | 921 | if (account != null) |
922 | { | 922 | { |
923 | string avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; | 923 | string avatarname = account.Name; |
924 | return avatarname; | 924 | return avatarname; |
925 | } | 925 | } |
926 | // try an scene object | 926 | // try an scene object |
@@ -3080,9 +3080,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3080 | 3080 | ||
3081 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3081 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
3082 | 3082 | ||
3083 | m_ScriptEngine.World.AttachObject(presence.ControllingClient, | 3083 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3084 | grp.LocalId, (uint)attachment, Quaternion.Identity, | 3084 | if (attachmentsModule != null) |
3085 | Vector3.Zero, false); | 3085 | attachmentsModule.AttachObject( |
3086 | presence.ControllingClient, grp.LocalId, | ||
3087 | (uint)attachment, Quaternion.Identity, Vector3.Zero, false); | ||
3086 | } | 3088 | } |
3087 | } | 3089 | } |
3088 | 3090 | ||
@@ -3119,8 +3121,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3119 | 3121 | ||
3120 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3122 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
3121 | 3123 | ||
3122 | m_ScriptEngine.World.DetachSingleAttachmentToInv(itemID, | 3124 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3123 | presence.ControllingClient); | 3125 | if (attachmentsModule != null) |
3126 | attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient); | ||
3124 | } | 3127 | } |
3125 | } | 3128 | } |
3126 | 3129 | ||
@@ -4096,13 +4099,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4096 | 4099 | ||
4097 | UUID uuid = (UUID)id; | 4100 | UUID uuid = (UUID)id; |
4098 | 4101 | ||
4099 | UserProfileData userProfile = | 4102 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
4100 | World.CommsManager.UserService.GetUserProfile(uuid); | ||
4101 | 4103 | ||
4102 | UserAgentData userAgent = | 4104 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4103 | World.CommsManager.UserService.GetAgentByUUID(uuid); | 4105 | PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos); |
4104 | 4106 | ||
4105 | if (userProfile == null || userAgent == null) | 4107 | if (pinfo == null) |
4106 | return UUID.Zero.ToString(); | 4108 | return UUID.Zero.ToString(); |
4107 | 4109 | ||
4108 | string reply = String.Empty; | 4110 | string reply = String.Empty; |
@@ -4111,17 +4113,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4111 | { | 4113 | { |
4112 | case 1: // DATA_ONLINE (0|1) | 4114 | case 1: // DATA_ONLINE (0|1) |
4113 | // TODO: implement fetching of this information | 4115 | // TODO: implement fetching of this information |
4114 | if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline) | 4116 | if (pinfo != null) |
4115 | reply = "1"; | 4117 | reply = "1"; |
4116 | else | 4118 | else |
4117 | reply = "0"; | 4119 | reply = "0"; |
4118 | break; | 4120 | break; |
4119 | case 2: // DATA_NAME (First Last) | 4121 | case 2: // DATA_NAME (First Last) |
4120 | reply = userProfile.FirstName + " " + userProfile.SurName; | 4122 | reply = account.FirstName + " " + account.LastName; |
4121 | break; | 4123 | break; |
4122 | case 3: // DATA_BORN (YYYY-MM-DD) | 4124 | case 3: // DATA_BORN (YYYY-MM-DD) |
4123 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | 4125 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); |
4124 | born = born.AddSeconds(userProfile.Created); | 4126 | born = born.AddSeconds(account.Created); |
4125 | reply = born.ToString("yyyy-MM-dd"); | 4127 | reply = born.ToString("yyyy-MM-dd"); |
4126 | break; | 4128 | break; |
4127 | case 4: // DATA_RATING (0,0,0,0,0,0) | 4129 | case 4: // DATA_RATING (0,0,0,0,0,0) |
@@ -4220,10 +4222,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4220 | ScriptSleep(5000); | 4222 | ScriptSleep(5000); |
4221 | } | 4223 | } |
4222 | 4224 | ||
4223 | public void llTextBox(string avatar, string message, int chat_channel) | 4225 | public void llTextBox(string agent, string message, int chatChannel) |
4224 | { | 4226 | { |
4227 | IDialogModule dm = World.RequestModuleInterface<IDialogModule>(); | ||
4228 | |||
4229 | if (dm == null) | ||
4230 | return; | ||
4231 | |||
4225 | m_host.AddScriptLPS(1); | 4232 | m_host.AddScriptLPS(1); |
4226 | NotImplemented("llTextBox"); | 4233 | UUID av = new UUID(); |
4234 | if (!UUID.TryParse(agent,out av)) | ||
4235 | { | ||
4236 | LSLError("First parameter to llDialog needs to be a key"); | ||
4237 | return; | ||
4238 | } | ||
4239 | |||
4240 | if (message == string.Empty) | ||
4241 | { | ||
4242 | ShoutError("Trying to use llTextBox with empty message."); | ||
4243 | } | ||
4244 | else if (message.Length > 512) | ||
4245 | { | ||
4246 | ShoutError("Trying to use llTextBox with message over 512 characters."); | ||
4247 | } | ||
4248 | else | ||
4249 | { | ||
4250 | dm.SendTextBoxToUser(av, message, chatChannel, m_host.Name, m_host.UUID, m_host.OwnerID); | ||
4251 | ScriptSleep(1000); | ||
4252 | } | ||
4227 | } | 4253 | } |
4228 | 4254 | ||
4229 | public void llModifyLand(int action, int brush) | 4255 | public void llModifyLand(int action, int brush) |
@@ -4238,6 +4264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4238 | 4264 | ||
4239 | public void llCollisionSound(string impact_sound, double impact_volume) | 4265 | public void llCollisionSound(string impact_sound, double impact_volume) |
4240 | { | 4266 | { |
4267 | |||
4241 | m_host.AddScriptLPS(1); | 4268 | m_host.AddScriptLPS(1); |
4242 | // TODO: Parameter check logic required. | 4269 | // TODO: Parameter check logic required. |
4243 | UUID soundId = UUID.Zero; | 4270 | UUID soundId = UUID.Zero; |
@@ -9091,17 +9118,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9091 | landObject.SetMediaUrl(url); | 9118 | landObject.SetMediaUrl(url); |
9092 | 9119 | ||
9093 | // now send to all (non-child) agents | 9120 | // now send to all (non-child) agents |
9094 | List<ScenePresence> agents = World.GetAvatars(); | 9121 | World.ForEachScenePresence(delegate(ScenePresence sp) |
9095 | foreach (ScenePresence agent in agents) | ||
9096 | { | 9122 | { |
9097 | agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, | 9123 | if (!sp.IsChildAgent) |
9098 | landData.MediaID, | 9124 | { |
9099 | landData.MediaAutoScale, | 9125 | sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, |
9100 | mediaType, | 9126 | landData.MediaID, |
9101 | description, | 9127 | landData.MediaAutoScale, |
9102 | width, height, | 9128 | mediaType, |
9103 | loop); | 9129 | description, |
9104 | } | 9130 | width, height, |
9131 | loop); | ||
9132 | } | ||
9133 | }); | ||
9105 | } | 9134 | } |
9106 | else if (!presence.IsChildAgent) | 9135 | else if (!presence.IsChildAgent) |
9107 | { | 9136 | { |
@@ -9122,13 +9151,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9122 | if (presence == null) | 9151 | if (presence == null) |
9123 | { | 9152 | { |
9124 | // send to all (non-child) agents | 9153 | // send to all (non-child) agents |
9125 | List<ScenePresence> agents = World.GetAvatars(); | 9154 | World.ForEachScenePresence(delegate(ScenePresence sp) |
9126 | foreach (ScenePresence agent in agents) | ||
9127 | { | 9155 | { |
9128 | agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? | 9156 | if (!sp.IsChildAgent) |
9129 | (ParcelMediaCommandEnum)commandToSend, | 9157 | { |
9130 | time); | 9158 | sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? |
9131 | } | 9159 | (ParcelMediaCommandEnum)commandToSend, |
9160 | time); | ||
9161 | } | ||
9162 | }); | ||
9132 | } | 9163 | } |
9133 | else if (!presence.IsChildAgent) | 9164 | else if (!presence.IsChildAgent) |
9134 | { | 9165 | { |
@@ -10160,90 +10191,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10160 | 10191 | ||
10161 | Notecard nc = new Notecard(); | 10192 | Notecard nc = new Notecard(); |
10162 | nc.lastRef = DateTime.Now; | 10193 | nc.lastRef = DateTime.Now; |
10163 | nc.text = ParseText(text.Replace("\r", "").Split('\n')); | 10194 | nc.text = SLUtil.ParseNotecardToList(text).ToArray(); |
10164 | m_Notecards[assetID] = nc; | 10195 | m_Notecards[assetID] = nc; |
10165 | } | 10196 | } |
10166 | } | 10197 | } |
10167 | 10198 | ||
10168 | protected static string[] ParseText(string[] input) | ||
10169 | { | ||
10170 | int idx = 0; | ||
10171 | int level = 0; | ||
10172 | List<string> output = new List<string>(); | ||
10173 | string[] words; | ||
10174 | |||
10175 | while (idx < input.Length) | ||
10176 | { | ||
10177 | if (input[idx] == "{") | ||
10178 | { | ||
10179 | level++; | ||
10180 | idx++; | ||
10181 | continue; | ||
10182 | } | ||
10183 | |||
10184 | if (input[idx]== "}") | ||
10185 | { | ||
10186 | level--; | ||
10187 | idx++; | ||
10188 | continue; | ||
10189 | } | ||
10190 | |||
10191 | switch (level) | ||
10192 | { | ||
10193 | case 0: | ||
10194 | words = input[idx].Split(' '); // Linden text ver | ||
10195 | // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard) | ||
10196 | if (words.Length < 3) | ||
10197 | return new String[0]; | ||
10198 | |||
10199 | int version = int.Parse(words[3]); | ||
10200 | if (version != 2) | ||
10201 | return new String[0]; | ||
10202 | break; | ||
10203 | case 1: | ||
10204 | words = input[idx].Split(' '); | ||
10205 | if (words[0] == "LLEmbeddedItems") | ||
10206 | break; | ||
10207 | if (words[0] == "Text") | ||
10208 | { | ||
10209 | int len = int.Parse(words[2]); | ||
10210 | idx++; | ||
10211 | |||
10212 | int count = -1; | ||
10213 | |||
10214 | while (count < len) | ||
10215 | { | ||
10216 | // int l = input[idx].Length; | ||
10217 | string ln = input[idx]; | ||
10218 | |||
10219 | int need = len-count-1; | ||
10220 | if (ln.Length > need) | ||
10221 | ln = ln.Substring(0, need); | ||
10222 | |||
10223 | output.Add(ln); | ||
10224 | count += ln.Length + 1; | ||
10225 | idx++; | ||
10226 | } | ||
10227 | |||
10228 | return output.ToArray(); | ||
10229 | } | ||
10230 | break; | ||
10231 | case 2: | ||
10232 | words = input[idx].Split(' '); // count | ||
10233 | if (words[0] == "count") | ||
10234 | { | ||
10235 | int c = int.Parse(words[1]); | ||
10236 | if (c > 0) | ||
10237 | return new String[0]; | ||
10238 | break; | ||
10239 | } | ||
10240 | break; | ||
10241 | } | ||
10242 | idx++; | ||
10243 | } | ||
10244 | return output.ToArray(); | ||
10245 | } | ||
10246 | |||
10247 | public static bool IsCached(UUID assetID) | 10199 | public static bool IsCached(UUID assetID) |
10248 | { | 10200 | { |
10249 | lock (m_Notecards) | 10201 | lock (m_Notecards) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1ddba1e..9474bab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -36,12 +36,11 @@ using OpenMetaverse; | |||
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenSim; | 37 | using OpenSim; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications.Cache; | 39 | |
40 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
41 | using OpenSim.Region.CoreModules.Avatar.NPC; | 41 | using OpenSim.Region.CoreModules.Avatar.NPC; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
45 | using OpenSim.Region.ScriptEngine.Shared; | 44 | using OpenSim.Region.ScriptEngine.Shared; |
46 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 45 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
47 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 46 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
@@ -607,21 +606,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
607 | // and convert the regionName to the target region | 606 | // and convert the regionName to the target region |
608 | if (regionName.Contains(".") && regionName.Contains(":")) | 607 | if (regionName.Contains(".") && regionName.Contains(":")) |
609 | { | 608 | { |
609 | List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1); | ||
610 | // Try to link the region | 610 | // Try to link the region |
611 | IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>(); | 611 | if (regions != null && regions.Count > 0) |
612 | if (hyperService != null) | ||
613 | { | 612 | { |
614 | GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient, | 613 | GridRegion regInfo = regions[0]; |
615 | regionName); | 614 | regionName = regInfo.RegionName; |
616 | // Get the region name | ||
617 | if (regInfo != null) | ||
618 | { | ||
619 | regionName = regInfo.RegionName; | ||
620 | } | ||
621 | else | ||
622 | { | ||
623 | // Might need to ping the client here in case of failure?? | ||
624 | } | ||
625 | } | 615 | } |
626 | } | 616 | } |
627 | presence.ControllingClient.SendTeleportLocationStart(); | 617 | presence.ControllingClient.SendTeleportLocationStart(); |
@@ -707,10 +697,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
707 | CheckThreatLevel(ThreatLevel.None, "osGetAgents"); | 697 | CheckThreatLevel(ThreatLevel.None, "osGetAgents"); |
708 | 698 | ||
709 | LSL_List result = new LSL_List(); | 699 | LSL_List result = new LSL_List(); |
710 | foreach (ScenePresence avatar in World.GetAvatars()) | 700 | World.ForEachScenePresence(delegate(ScenePresence sp) |
711 | { | 701 | { |
712 | result.Add(avatar.Name); | 702 | if (!sp.IsChildAgent) |
713 | } | 703 | result.Add(sp.Name); |
704 | }); | ||
714 | return result; | 705 | return result; |
715 | } | 706 | } |
716 | 707 | ||
@@ -1482,7 +1473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1482 | m_host.AddScriptLPS(1); | 1473 | m_host.AddScriptLPS(1); |
1483 | 1474 | ||
1484 | // Create new asset | 1475 | // Create new asset |
1485 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); | 1476 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); |
1486 | asset.Description = "Script Generated Notecard"; | 1477 | asset.Description = "Script Generated Notecard"; |
1487 | string notecardData = String.Empty; | 1478 | string notecardData = String.Empty; |
1488 | 1479 | ||
@@ -1695,15 +1686,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1695 | { | 1686 | { |
1696 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); | 1687 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); |
1697 | 1688 | ||
1698 | CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(firstname, lastname); | 1689 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); |
1699 | 1690 | if (null == account) | |
1700 | if (null == userInfo) | ||
1701 | { | 1691 | { |
1702 | return UUID.Zero.ToString(); | 1692 | return UUID.Zero.ToString(); |
1703 | } | 1693 | } |
1704 | else | 1694 | else |
1705 | { | 1695 | { |
1706 | return userInfo.UserProfile.ID.ToString(); | 1696 | return account.PrincipalID.ToString(); |
1707 | } | 1697 | } |
1708 | } | 1698 | } |
1709 | 1699 | ||
@@ -1714,15 +1704,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1714 | 1704 | ||
1715 | if (UUID.TryParse(id, out key)) | 1705 | if (UUID.TryParse(id, out key)) |
1716 | { | 1706 | { |
1717 | CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(key); | 1707 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); |
1718 | 1708 | if (null == account) | |
1719 | if (null == userInfo) | ||
1720 | { | 1709 | { |
1721 | return ""; | 1710 | return ""; |
1722 | } | 1711 | } |
1723 | else | 1712 | else |
1724 | { | 1713 | { |
1725 | return userInfo.UserProfile.Name; | 1714 | return account.Name; |
1726 | } | 1715 | } |
1727 | } | 1716 | } |
1728 | else | 1717 | else |
@@ -2001,19 +1990,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2001 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 1990 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2002 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 1991 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
2003 | { | 1992 | { |
2004 | foreach (ScenePresence presence in World.GetAvatars()) | 1993 | World.ForEachScenePresence(delegate(ScenePresence sp) |
2005 | { | 1994 | { |
2006 | if ((presence.Firstname == FirstName) && | 1995 | if (!sp.IsChildAgent && |
2007 | presence.Lastname == SurName) | 1996 | sp.Firstname == FirstName && |
1997 | sp.Lastname == SurName) | ||
2008 | { | 1998 | { |
2009 | // kick client... | 1999 | // kick client... |
2010 | if (alert != null) | 2000 | if (alert != null) |
2011 | presence.ControllingClient.Kick(alert); | 2001 | sp.ControllingClient.Kick(alert); |
2012 | 2002 | ||
2013 | // ...and close on our side | 2003 | // ...and close on our side |
2014 | presence.Scene.IncomingCloseAgent(presence.UUID); | 2004 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2015 | } | 2005 | } |
2016 | } | 2006 | }); |
2017 | } | 2007 | } |
2018 | } | 2008 | } |
2019 | 2009 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index b75a2e4..2296379 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -29,7 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Communications.Cache; | 32 | |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.ScriptEngine.Shared; | 34 | using OpenSim.Region.ScriptEngine.Shared; |
35 | using OpenSim.Region.ScriptEngine.Shared.Api; | 35 | using OpenSim.Region.ScriptEngine.Shared.Api; |
@@ -404,70 +404,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
404 | 404 | ||
405 | private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) | 405 | private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) |
406 | { | 406 | { |
407 | List<ScenePresence> presences; | ||
408 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); | 407 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); |
409 | 408 | ||
410 | // If this is an avatar sense by key try to get them directly | ||
411 | // rather than getting a list to scan through | ||
412 | if (ts.keyID != UUID.Zero) | ||
413 | { | ||
414 | ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); | ||
415 | if (p == null) | ||
416 | return sensedEntities; | ||
417 | presences = new List<ScenePresence>(); | ||
418 | presences.Add(p); | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences()); | ||
423 | } | ||
424 | |||
425 | // If nobody about quit fast | 409 | // If nobody about quit fast |
426 | if (presences.Count == 0) | 410 | if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0) |
427 | return sensedEntities; | 411 | return sensedEntities; |
428 | 412 | ||
429 | SceneObjectPart SensePoint = ts.host; | 413 | SceneObjectPart SensePoint = ts.host; |
430 | |||
431 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 414 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
432 | |||
433 | Quaternion q = SensePoint.RotationOffset; | 415 | Quaternion q = SensePoint.RotationOffset; |
434 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 416 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
435 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 417 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
436 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 418 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
437 | |||
438 | bool attached = (SensePoint.AttachmentPoint != 0); | 419 | bool attached = (SensePoint.AttachmentPoint != 0); |
439 | bool nameSearch = (ts.name != null && ts.name != ""); | ||
440 | Vector3 toRegionPos; | 420 | Vector3 toRegionPos; |
441 | double dis; | 421 | double dis; |
442 | 422 | ||
443 | for (int i = 0; i < presences.Count; i++) | 423 | Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence) |
444 | { | 424 | { |
445 | ScenePresence presence = presences[i]; | 425 | if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) |
446 | bool keep = true; | 426 | return; |
447 | 427 | ||
448 | if (presence.IsDeleted) | 428 | // if the object the script is in is attached and the avatar is the owner |
449 | continue; | 429 | // then this one is not wanted |
430 | if (attached && presence.UUID == SensePoint.OwnerID) | ||
431 | return; | ||
450 | 432 | ||
451 | if (presence.IsChildAgent) | ||
452 | keep = false; | ||
453 | toRegionPos = presence.AbsolutePosition; | 433 | toRegionPos = presence.AbsolutePosition; |
454 | |||
455 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); | 434 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); |
456 | 435 | ||
457 | // are they in range | 436 | // are they in range |
458 | if (keep && dis <= ts.range) | 437 | if (dis <= ts.range) |
459 | { | 438 | { |
460 | // if the object the script is in is attached and the avatar is the owner | ||
461 | // then this one is not wanted | ||
462 | if (attached && presence.UUID == SensePoint.OwnerID) | ||
463 | keep = false; | ||
464 | |||
465 | // check the name if needed | ||
466 | if (keep && nameSearch && ts.name != presence.Name) | ||
467 | keep = false; | ||
468 | |||
469 | // Are they in the required angle of view | 439 | // Are they in the required angle of view |
470 | if (keep && ts.arc < Math.PI) | 440 | if (ts.arc < Math.PI) |
471 | { | 441 | { |
472 | // not omni-directional. Can you see it ? | 442 | // not omni-directional. Can you see it ? |
473 | // vec forward_dir = llRot2Fwd(llGetRot()) | 443 | // vec forward_dir = llRot2Fwd(llGetRot()) |
@@ -488,26 +458,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
488 | catch | 458 | catch |
489 | { | 459 | { |
490 | } | 460 | } |
491 | if (ang_obj > ts.arc) keep = false; | 461 | if (ang_obj <= ts.arc) |
462 | { | ||
463 | sensedEntities.Add(new SensedEntity(dis, presence.UUID)); | ||
464 | } | ||
492 | } | 465 | } |
493 | } | 466 | } |
494 | else | 467 | }); |
495 | { | ||
496 | keep = false; | ||
497 | } | ||
498 | |||
499 | // Do not report gods, not even minor ones | ||
500 | if (keep && presence.GodLevel > 0.0) | ||
501 | keep = false; | ||
502 | |||
503 | if (keep) // add to list with distance | ||
504 | { | ||
505 | sensedEntities.Add(new SensedEntity(dis, presence.UUID)); | ||
506 | } | ||
507 | 468 | ||
508 | // If this is a search by name and we have just found it then no more to do | 469 | // If this is an avatar sense by key try to get them directly |
509 | if (nameSearch && ts.name == presence.Name) | 470 | // rather than getting a list to scan through |
471 | if (ts.keyID != UUID.Zero) | ||
472 | { | ||
473 | ScenePresence sp; | ||
474 | // Try direct lookup by UUID | ||
475 | if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp)) | ||
476 | return sensedEntities; | ||
477 | senseEntity(sp); | ||
478 | } | ||
479 | else if (ts.name != null && ts.name != "") | ||
480 | { | ||
481 | ScenePresence sp; | ||
482 | // Try lookup by name will return if/when found | ||
483 | if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp)) | ||
510 | return sensedEntities; | 484 | return sensedEntities; |
485 | senseEntity(sp); | ||
486 | } | ||
487 | else | ||
488 | { | ||
489 | m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity); | ||
511 | } | 490 | } |
512 | return sensedEntities; | 491 | return sensedEntities; |
513 | } | 492 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs index 6239726..fba27f9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -1,4 +1,31 @@ | |||
1 | using System.Collections; | 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; | ||
2 | using OpenSim.Region.ScriptEngine.Interfaces; | 29 | using OpenSim.Region.ScriptEngine.Interfaces; |
3 | 30 | ||
4 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs index 522c020..f94ef4a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | 70 | public const int WL_CLOUD_SCROLL_Y = 32; |
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | 71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; |
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | 72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; |
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | 73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; |
74 | public const int WL_SUN_MOON_POSITION = 36; | 74 | public const int WL_SUN_MOON_POSITION = 36; |
75 | 75 | ||
76 | } | 76 | } |