aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs49
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs229
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs56
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs122
4 files changed, 218 insertions, 238 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 @@
1using 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
28using System;
2using System.Reflection; 29using System.Reflection;
3using System.Collections; 30using System.Collections;
4using System.Collections.Generic; 31using System.Collections.Generic;
@@ -7,7 +34,7 @@ using OpenMetaverse;
7using Nini.Config; 34using Nini.Config;
8using OpenSim; 35using OpenSim;
9using OpenSim.Framework; 36using OpenSim.Framework;
10using OpenSim.Region.CoreModules.World.Meta7Windlight; 37using OpenSim.Region.CoreModules.World.LightShare;
11using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
12using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
13using OpenSim.Region.ScriptEngine.Shared; 40using 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..6ab3c62 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;
39using OpenMetaverse.Packets; 39using OpenMetaverse.Packets;
40using OpenSim; 40using OpenSim;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Communications.Cache; 42
43using OpenSim.Region.CoreModules; 43using OpenSim.Region.CoreModules;
44using OpenSim.Region.CoreModules.World.Land; 44using OpenSim.Region.CoreModules.World.Land;
45using OpenSim.Region.CoreModules.World.Terrain; 45using OpenSim.Region.CoreModules.World.Terrain;
@@ -53,9 +53,9 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
53using OpenSim.Region.ScriptEngine.Interfaces; 53using OpenSim.Region.ScriptEngine.Interfaces;
54using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 54using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
55using OpenSim.Services.Interfaces; 55using OpenSim.Services.Interfaces;
56
57using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
58using GridRegion = OpenSim.Services.Interfaces.GridRegion; 56using GridRegion = OpenSim.Services.Interfaces.GridRegion;
57using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
58using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
59using AssetLandmark = OpenSim.Framework.AssetLandmark; 59using AssetLandmark = OpenSim.Framework.AssetLandmark;
60 60
61using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 61using 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
@@ -2033,14 +2033,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2033 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); 2033 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
2034 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); 2034 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
2035 2035
2036 if (part.ParentGroup == null) 2036 if (part.ParentGroup.RootPart == part)
2037 {
2038 if ((targetPos.z < ground) && disable_underground_movement)
2039 targetPos.z = ground;
2040 LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos);
2041 part.UpdateOffSet(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
2042 }
2043 else if (part.ParentGroup.RootPart == part)
2044 { 2037 {
2045 if ((targetPos.z < ground) && disable_underground_movement) 2038 if ((targetPos.z < ground) && disable_underground_movement)
2046 targetPos.z = ground; 2039 targetPos.z = ground;
@@ -2050,7 +2043,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2050 } 2043 }
2051 else 2044 else
2052 { 2045 {
2053 //it's late... i think this is right ?
2054 if (llVecDist(new LSL_Vector(0,0,0), targetPos) <= 10.0f) 2046 if (llVecDist(new LSL_Vector(0,0,0), targetPos) <= 10.0f)
2055 { 2047 {
2056 part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); 2048 part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z);
@@ -3080,9 +3072,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3080 3072
3081 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3073 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3082 3074
3083 m_ScriptEngine.World.AttachObject(presence.ControllingClient, 3075 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3084 grp.LocalId, (uint)attachment, Quaternion.Identity, 3076 if (attachmentsModule != null)
3085 Vector3.Zero, false); 3077 attachmentsModule.AttachObject(
3078 presence.ControllingClient, grp.LocalId,
3079 (uint)attachment, Quaternion.Identity, Vector3.Zero, false);
3086 } 3080 }
3087 } 3081 }
3088 3082
@@ -3119,8 +3113,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3119 3113
3120 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3114 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3121 3115
3122 m_ScriptEngine.World.DetachSingleAttachmentToInv(itemID, 3116 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3123 presence.ControllingClient); 3117 if (attachmentsModule != null)
3118 attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient);
3124 } 3119 }
3125 } 3120 }
3126 3121
@@ -4002,9 +3997,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4002 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 3997 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4003 } 3998 }
4004 3999
4005 // check if destination is an avatar 4000 // check if destination is an object
4006 if (World.GetScenePresence(destId) != null) 4001 if (World.GetSceneObjectPart(destId) != null)
4002 {
4003 // destination is an object
4004 World.MoveTaskInventoryItem(destId, m_host, objId);
4005 }
4006 else
4007 { 4007 {
4008 ScenePresence presence = World.GetScenePresence(destId);
4009
4010 if (presence == null)
4011 {
4012 UserAccount account =
4013 World.UserAccountService.GetUserAccount(
4014 World.RegionInfo.ScopeID,
4015 destId);
4016
4017 if (account == null)
4018 {
4019 llSay(0, "Can't find destination "+destId.ToString());
4020 return;
4021 }
4022 }
4023
4008 // destination is an avatar 4024 // destination is an avatar
4009 InventoryItemBase agentItem = 4025 InventoryItemBase agentItem =
4010 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4026 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
@@ -4034,12 +4050,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4034 //This delay should only occur when giving inventory to avatars. 4050 //This delay should only occur when giving inventory to avatars.
4035 ScriptSleep(3000); 4051 ScriptSleep(3000);
4036 } 4052 }
4037 else
4038 {
4039 // destination is an object
4040 World.MoveTaskInventoryItem(destId, m_host, objId);
4041 }
4042
4043 } 4053 }
4044 4054
4045 [DebuggerNonUserCode] 4055 [DebuggerNonUserCode]
@@ -4096,13 +4106,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4096 4106
4097 UUID uuid = (UUID)id; 4107 UUID uuid = (UUID)id;
4098 4108
4099 UserProfileData userProfile = 4109 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
4100 World.CommsManager.UserService.GetUserProfile(uuid);
4101 4110
4102 UserAgentData userAgent = 4111 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4103 World.CommsManager.UserService.GetAgentByUUID(uuid); 4112 PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos);
4104 4113
4105 if (userProfile == null || userAgent == null) 4114 if (pinfo == null)
4106 return UUID.Zero.ToString(); 4115 return UUID.Zero.ToString();
4107 4116
4108 string reply = String.Empty; 4117 string reply = String.Empty;
@@ -4111,17 +4120,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4111 { 4120 {
4112 case 1: // DATA_ONLINE (0|1) 4121 case 1: // DATA_ONLINE (0|1)
4113 // TODO: implement fetching of this information 4122 // TODO: implement fetching of this information
4114 if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline) 4123 if (pinfo != null)
4115 reply = "1"; 4124 reply = "1";
4116 else 4125 else
4117 reply = "0"; 4126 reply = "0";
4118 break; 4127 break;
4119 case 2: // DATA_NAME (First Last) 4128 case 2: // DATA_NAME (First Last)
4120 reply = userProfile.FirstName + " " + userProfile.SurName; 4129 reply = account.FirstName + " " + account.LastName;
4121 break; 4130 break;
4122 case 3: // DATA_BORN (YYYY-MM-DD) 4131 case 3: // DATA_BORN (YYYY-MM-DD)
4123 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 4132 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
4124 born = born.AddSeconds(userProfile.Created); 4133 born = born.AddSeconds(account.Created);
4125 reply = born.ToString("yyyy-MM-dd"); 4134 reply = born.ToString("yyyy-MM-dd");
4126 break; 4135 break;
4127 case 4: // DATA_RATING (0,0,0,0,0,0) 4136 case 4: // DATA_RATING (0,0,0,0,0,0)
@@ -4220,10 +4229,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4220 ScriptSleep(5000); 4229 ScriptSleep(5000);
4221 } 4230 }
4222 4231
4223 public void llTextBox(string avatar, string message, int chat_channel) 4232 public void llTextBox(string agent, string message, int chatChannel)
4224 { 4233 {
4234 IDialogModule dm = World.RequestModuleInterface<IDialogModule>();
4235
4236 if (dm == null)
4237 return;
4238
4225 m_host.AddScriptLPS(1); 4239 m_host.AddScriptLPS(1);
4226 NotImplemented("llTextBox"); 4240 UUID av = new UUID();
4241 if (!UUID.TryParse(agent,out av))
4242 {
4243 LSLError("First parameter to llDialog needs to be a key");
4244 return;
4245 }
4246
4247 if (message == string.Empty)
4248 {
4249 ShoutError("Trying to use llTextBox with empty message.");
4250 }
4251 else if (message.Length > 512)
4252 {
4253 ShoutError("Trying to use llTextBox with message over 512 characters.");
4254 }
4255 else
4256 {
4257 dm.SendTextBoxToUser(av, message, chatChannel, m_host.Name, m_host.UUID, m_host.OwnerID);
4258 ScriptSleep(1000);
4259 }
4227 } 4260 }
4228 4261
4229 public void llModifyLand(int action, int brush) 4262 public void llModifyLand(int action, int brush)
@@ -4238,6 +4271,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4238 4271
4239 public void llCollisionSound(string impact_sound, double impact_volume) 4272 public void llCollisionSound(string impact_sound, double impact_volume)
4240 { 4273 {
4274
4241 m_host.AddScriptLPS(1); 4275 m_host.AddScriptLPS(1);
4242 // TODO: Parameter check logic required. 4276 // TODO: Parameter check logic required.
4243 UUID soundId = UUID.Zero; 4277 UUID soundId = UUID.Zero;
@@ -9091,17 +9125,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9091 landObject.SetMediaUrl(url); 9125 landObject.SetMediaUrl(url);
9092 9126
9093 // now send to all (non-child) agents 9127 // now send to all (non-child) agents
9094 List<ScenePresence> agents = World.GetAvatars(); 9128 World.ForEachScenePresence(delegate(ScenePresence sp)
9095 foreach (ScenePresence agent in agents)
9096 { 9129 {
9097 agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, 9130 if (!sp.IsChildAgent)
9098 landData.MediaID, 9131 {
9099 landData.MediaAutoScale, 9132 sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
9100 mediaType, 9133 landData.MediaID,
9101 description, 9134 landData.MediaAutoScale,
9102 width, height, 9135 mediaType,
9103 loop); 9136 description,
9104 } 9137 width, height,
9138 loop);
9139 }
9140 });
9105 } 9141 }
9106 else if (!presence.IsChildAgent) 9142 else if (!presence.IsChildAgent)
9107 { 9143 {
@@ -9122,13 +9158,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9122 if (presence == null) 9158 if (presence == null)
9123 { 9159 {
9124 // send to all (non-child) agents 9160 // send to all (non-child) agents
9125 List<ScenePresence> agents = World.GetAvatars(); 9161 World.ForEachScenePresence(delegate(ScenePresence sp)
9126 foreach (ScenePresence agent in agents)
9127 { 9162 {
9128 agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? 9163 if (!sp.IsChildAgent)
9129 (ParcelMediaCommandEnum)commandToSend, 9164 {
9130 time); 9165 sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
9131 } 9166 (ParcelMediaCommandEnum)commandToSend,
9167 time);
9168 }
9169 });
9132 } 9170 }
9133 else if (!presence.IsChildAgent) 9171 else if (!presence.IsChildAgent)
9134 { 9172 {
@@ -10160,90 +10198,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10160 10198
10161 Notecard nc = new Notecard(); 10199 Notecard nc = new Notecard();
10162 nc.lastRef = DateTime.Now; 10200 nc.lastRef = DateTime.Now;
10163 nc.text = ParseText(text.Replace("\r", "").Split('\n')); 10201 nc.text = SLUtil.ParseNotecardToList(text).ToArray();
10164 m_Notecards[assetID] = nc; 10202 m_Notecards[assetID] = nc;
10165 } 10203 }
10166 } 10204 }
10167 10205
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) 10206 public static bool IsCached(UUID assetID)
10248 { 10207 {
10249 lock (m_Notecards) 10208 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;
36using Nini.Config; 36using Nini.Config;
37using OpenSim; 37using OpenSim;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache; 39
40using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Region.CoreModules.Avatar.NPC; 41using OpenSim.Region.CoreModules.Avatar.NPC;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Hypergrid;
45using OpenSim.Region.ScriptEngine.Shared; 44using OpenSim.Region.ScriptEngine.Shared;
46using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 45using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
47using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 46using 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..d354fde 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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications.Cache; 32
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.ScriptEngine.Shared; 34using OpenSim.Region.ScriptEngine.Shared;
35using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
204 // Is the sensor type is AGENT and not SCRIPTED then include agents 204 // Is the sensor type is AGENT and not SCRIPTED then include agents
205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) 205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0)
206 { 206 {
207 sensedEntities.AddRange(doAgentSensor(ts)); 207 sensedEntities.AddRange(doAgentSensor(ts));
208 } 208 }
209 209
210 // If SCRIPTED or PASSIVE or ACTIVE check objects 210 // If SCRIPTED or PASSIVE or ACTIVE check objects
@@ -302,6 +302,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
302 float dz; 302 float dz;
303 303
304 Quaternion q = SensePoint.RotationOffset; 304 Quaternion q = SensePoint.RotationOffset;
305 if (SensePoint.ParentGroup.RootPart.IsAttachment)
306 {
307 // In attachments, the sensor cone always orients with the
308 // avatar rotation. This may include a nonzero elevation if
309 // in mouselook.
310
311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
312 fromRegionPos = avatar.AbsolutePosition;
313 q = avatar.Rotation;
314 }
305 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 315 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
306 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 316 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
307 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 317 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
@@ -404,70 +414,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
404 414
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 415 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 416 {
407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 417 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 418
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 419 // If nobody about quit fast
426 if (presences.Count == 0) 420 if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0)
427 return sensedEntities; 421 return sensedEntities;
428 422
429 SceneObjectPart SensePoint = ts.host; 423 SceneObjectPart SensePoint = ts.host;
430
431 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 424 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
432
433 Quaternion q = SensePoint.RotationOffset; 425 Quaternion q = SensePoint.RotationOffset;
426 if (SensePoint.ParentGroup.RootPart.IsAttachment)
427 {
428 // In attachments, the sensor cone always orients with the
429 // avatar rotation. This may include a nonzero elevation if
430 // in mouselook.
431
432 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
433 fromRegionPos = avatar.AbsolutePosition;
434 q = avatar.Rotation;
435 }
434 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 436 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); 437 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
436 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 438 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
437
438 bool attached = (SensePoint.AttachmentPoint != 0); 439 bool attached = (SensePoint.AttachmentPoint != 0);
439 bool nameSearch = (ts.name != null && ts.name != "");
440 Vector3 toRegionPos; 440 Vector3 toRegionPos;
441 double dis; 441 double dis;
442 442
443 for (int i = 0; i < presences.Count; i++) 443 Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
444 { 444 {
445 ScenePresence presence = presences[i]; 445 if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
446 bool keep = true; 446 return;
447
448 // if the object the script is in is attached and the avatar is the owner
449 // then this one is not wanted
450 if (attached && presence.UUID == SensePoint.OwnerID)
451 return;
447 452
448 if (presence.IsDeleted)
449 continue;
450
451 if (presence.IsChildAgent)
452 keep = false;
453 toRegionPos = presence.AbsolutePosition; 453 toRegionPos = presence.AbsolutePosition;
454
455 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); 454 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
456 455
457 // are they in range 456 // are they in range
458 if (keep && dis <= ts.range) 457 if (dis <= ts.range)
459 { 458 {
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 459 // Are they in the required angle of view
470 if (keep && ts.arc < Math.PI) 460 if (ts.arc < Math.PI)
471 { 461 {
472 // not omni-directional. Can you see it ? 462 // not omni-directional. Can you see it ?
473 // vec forward_dir = llRot2Fwd(llGetRot()) 463 // vec forward_dir = llRot2Fwd(llGetRot())
@@ -488,26 +478,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
488 catch 478 catch
489 { 479 {
490 } 480 }
491 if (ang_obj > ts.arc) keep = false; 481 if (ang_obj <= ts.arc)
482 {
483 sensedEntities.Add(new SensedEntity(dis, presence.UUID));
484 }
485 }
486 else
487 {
488 // If full circle is asked for, just add it
489 sensedEntities.Add(new SensedEntity(dis, presence.UUID));
492 } 490 }
493 } 491 }
494 else 492 });
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 493
508 // If this is a search by name and we have just found it then no more to do 494 // If this is an avatar sense by key try to get them directly
509 if (nameSearch && ts.name == presence.Name) 495 // rather than getting a list to scan through
496 if (ts.keyID != UUID.Zero)
497 {
498 ScenePresence sp;
499 // Try direct lookup by UUID
500 if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp))
510 return sensedEntities; 501 return sensedEntities;
502 senseEntity(sp);
503 }
504 else if (ts.name != null && ts.name != "")
505 {
506 ScenePresence sp;
507 // Try lookup by name will return if/when found
508 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
509 return sensedEntities;
510 senseEntity(sp);
511 }
512 else
513 {
514 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity);
511 } 515 }
512 return sensedEntities; 516 return sensedEntities;
513 } 517 }