aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs49
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs188
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs56
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs104
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs249
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs18
9 files changed, 358 insertions, 340 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index ae148a9..9f6ea35 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -81,6 +81,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
81 81
82 void PostEvent(EventParams data); 82 void PostEvent(EventParams data);
83 83
84 void Suspend();
85 void Resume();
86
84 /// <summary> 87 /// <summary>
85 /// Process the next event queued for this script 88 /// Process the next event queued for this script
86 /// </summary> 89 /// </summary>
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..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;
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
@@ -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;
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..4d7ead6 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;
@@ -302,6 +302,15 @@ 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 q = avatar.Rotation;
313 }
305 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 314 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); 315 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
307 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 316 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
@@ -404,70 +413,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
404 413
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 414 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 415 {
407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 416 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 417
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 418 // If nobody about quit fast
426 if (presences.Count == 0) 419 if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0)
427 return sensedEntities; 420 return sensedEntities;
428 421
429 SceneObjectPart SensePoint = ts.host; 422 SceneObjectPart SensePoint = ts.host;
430
431 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 423 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
432
433 Quaternion q = SensePoint.RotationOffset; 424 Quaternion q = SensePoint.RotationOffset;
434 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 425 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); 426 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
436 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 427 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
437
438 bool attached = (SensePoint.AttachmentPoint != 0); 428 bool attached = (SensePoint.AttachmentPoint != 0);
439 bool nameSearch = (ts.name != null && ts.name != "");
440 Vector3 toRegionPos; 429 Vector3 toRegionPos;
441 double dis; 430 double dis;
442 431
443 for (int i = 0; i < presences.Count; i++) 432 Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
444 { 433 {
445 ScenePresence presence = presences[i]; 434 if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
446 bool keep = true; 435 return;
436
437 // if the object the script is in is attached and the avatar is the owner
438 // then this one is not wanted
439 if (attached && presence.UUID == SensePoint.OwnerID)
440 return;
447 441
448 if (presence.IsDeleted)
449 continue;
450
451 if (presence.IsChildAgent)
452 keep = false;
453 toRegionPos = presence.AbsolutePosition; 442 toRegionPos = presence.AbsolutePosition;
454
455 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); 443 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
456 444
457 // are they in range 445 // are they in range
458 if (keep && dis <= ts.range) 446 if (dis <= ts.range)
459 { 447 {
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 448 // Are they in the required angle of view
470 if (keep && ts.arc < Math.PI) 449 if (ts.arc < Math.PI)
471 { 450 {
472 // not omni-directional. Can you see it ? 451 // not omni-directional. Can you see it ?
473 // vec forward_dir = llRot2Fwd(llGetRot()) 452 // vec forward_dir = llRot2Fwd(llGetRot())
@@ -488,26 +467,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
488 catch 467 catch
489 { 468 {
490 } 469 }
491 if (ang_obj > ts.arc) keep = false; 470 if (ang_obj <= ts.arc)
471 {
472 sensedEntities.Add(new SensedEntity(dis, presence.UUID));
473 }
492 } 474 }
493 } 475 }
494 else 476 });
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 477
508 // If this is a search by name and we have just found it then no more to do 478 // If this is an avatar sense by key try to get them directly
509 if (nameSearch && ts.name == presence.Name) 479 // rather than getting a list to scan through
480 if (ts.keyID != UUID.Zero)
481 {
482 ScenePresence sp;
483 // Try direct lookup by UUID
484 if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp))
485 return sensedEntities;
486 senseEntity(sp);
487 }
488 else if (ts.name != null && ts.name != "")
489 {
490 ScenePresence sp;
491 // Try lookup by name will return if/when found
492 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
510 return sensedEntities; 493 return sensedEntities;
494 senseEntity(sp);
495 }
496 else
497 {
498 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity);
511 } 499 }
512 return sensedEntities; 500 return sensedEntities;
513 } 501 }
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 @@
1using 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
28using System.Collections;
2using OpenSim.Region.ScriptEngine.Interfaces; 29using OpenSim.Region.ScriptEngine.Interfaces;
3 30
4using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 31using 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 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 6ecafd4..b348403 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -96,6 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
96 private bool m_startedFromSavedState; 96 private bool m_startedFromSavedState;
97 private UUID m_CurrentStateHash; 97 private UUID m_CurrentStateHash;
98 private UUID m_RegionID; 98 private UUID m_RegionID;
99 private bool m_Suspended = false;
99 100
100 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 101 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
101 m_LineMap; 102 m_LineMap;
@@ -640,158 +641,160 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
640 /// <returns></returns> 641 /// <returns></returns>
641 public object EventProcessor() 642 public object EventProcessor()
642 { 643 {
644 EventParams data = null;
643 645
644 EventParams data = null; 646 lock (m_EventQueue)
645
646 lock (m_EventQueue)
647 {
648 lock (m_Script)
649 { 647 {
650 data = (EventParams) m_EventQueue.Dequeue(); 648 if (m_Suspended)
651 if (data == null) // Shouldn't happen 649 return 0;
650
651 lock (m_Script)
652 { 652 {
653 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) 653 data = (EventParams) m_EventQueue.Dequeue();
654 if (data == null) // Shouldn't happen
654 { 655 {
655 m_CurrentResult = m_Engine.QueueEventHandler(this); 656 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
657 {
658 m_CurrentResult = m_Engine.QueueEventHandler(this);
659 }
660 else
661 {
662 m_CurrentResult = null;
663 }
664 return 0;
656 } 665 }
657 else 666
667 if (data.EventName == "timer")
668 m_TimerQueued = false;
669 if (data.EventName == "control")
658 { 670 {
659 m_CurrentResult = null; 671 if (m_ControlEventsInQueue > 0)
672 m_ControlEventsInQueue--;
660 } 673 }
661 return 0; 674 if (data.EventName == "collision")
662 } 675 m_CollisionInQueue = false;
663
664 if (data.EventName == "timer")
665 m_TimerQueued = false;
666 if (data.EventName == "control")
667 {
668 if (m_ControlEventsInQueue > 0)
669 m_ControlEventsInQueue--;
670 } 676 }
671 if (data.EventName == "collision")
672 m_CollisionInQueue = false;
673 } 677 }
674 } 678 lock(m_Script)
675 lock(m_Script) 679 {
676 { 680
677 681 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
678 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
679 682
680 m_DetectParams = data.DetectParams; 683 m_DetectParams = data.DetectParams;
681 684
682 if (data.EventName == "state") // Hardcoded state change 685 if (data.EventName == "state") // Hardcoded state change
683 {
684// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
685// m_PrimName, m_ScriptName, data.Params[0].ToString());
686 m_State=data.Params[0].ToString();
687 AsyncCommandManager.RemoveScript(m_Engine,
688 m_LocalID, m_ItemID);
689
690 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
691 m_LocalID);
692 if (part != null)
693 {
694 part.SetScriptEvents(m_ItemID,
695 (int)m_Script.GetStateEventFlags(State));
696 }
697 }
698 else
699 {
700 if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
701 data.EventName == "control") // Don't freeze avies!
702 { 686 {
687 // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
688 // m_PrimName, m_ScriptName, data.Params[0].ToString());
689 m_State=data.Params[0].ToString();
690 AsyncCommandManager.RemoveScript(m_Engine,
691 m_LocalID, m_ItemID);
692
703 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 693 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
704 m_LocalID); 694 m_LocalID);
705 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", 695 if (part != null)
706 // m_PrimName, m_ScriptName, data.EventName, m_State); 696 {
707 697 part.SetScriptEvents(m_ItemID,
708 try 698 (int)m_Script.GetStateEventFlags(State));
699 }
700 }
701 else
702 {
703 if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
704 data.EventName == "control") // Don't freeze avies!
709 { 705 {
710 m_CurrentEvent = data.EventName; 706 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
711 m_EventStart = DateTime.Now; 707 m_LocalID);
712 m_InEvent = true; 708 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
709 // m_PrimName, m_ScriptName, data.EventName, m_State);
713 710
714 m_Script.ExecuteEvent(State, data.EventName, data.Params); 711 try
712 {
713 m_CurrentEvent = data.EventName;
714 m_EventStart = DateTime.Now;
715 m_InEvent = true;
715 716
716 m_InEvent = false; 717 m_Script.ExecuteEvent(State, data.EventName, data.Params);
717 m_CurrentEvent = String.Empty;
718 718
719 if (m_SaveState) 719 m_InEvent = false;
720 { 720 m_CurrentEvent = String.Empty;
721 // This will be the very first event we deliver
722 // (state_entry) in default state
723 //
724 721
725 SaveState(m_Assembly); 722 if (m_SaveState)
723 {
724 // This will be the very first event we deliver
725 // (state_entry) in default state
726 //
726 727
727 m_SaveState = false; 728 SaveState(m_Assembly);
728 }
729 }
730 catch (Exception e)
731 {
732 // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
733 m_InEvent = false;
734 m_CurrentEvent = String.Empty;
735 729
736 if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) 730 m_SaveState = false;
731 }
732 }
733 catch (Exception e)
737 { 734 {
738 try 735 // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
736 m_InEvent = false;
737 m_CurrentEvent = String.Empty;
738
739 if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
739 { 740 {
740 // DISPLAY ERROR INWORLD 741 try
741 string text = FormatException(e); 742 {
742 743 // DISPLAY ERROR INWORLD
743 if (text.Length > 1000) 744 string text = FormatException(e);
744 text = text.Substring(0, 1000); 745
745 m_Engine.World.SimChat(Utils.StringToBytes(text), 746 if (text.Length > 1000)
746 ChatTypeEnum.DebugChannel, 2147483647, 747 text = text.Substring(0, 1000);
747 part.AbsolutePosition, 748 m_Engine.World.SimChat(Utils.StringToBytes(text),
748 part.Name, part.UUID, false); 749 ChatTypeEnum.DebugChannel, 2147483647,
750 part.AbsolutePosition,
751 part.Name, part.UUID, false);
752 }
753 catch (Exception)
754 {
755 }
756 // catch (Exception e2) // LEGIT: User Scripting
757 // {
758 // m_log.Error("[SCRIPT]: "+
759 // "Error displaying error in-world: " +
760 // e2.ToString());
761 // m_log.Error("[SCRIPT]: " +
762 // "Errormessage: Error compiling script:\r\n" +
763 // e.ToString());
764 // }
749 } 765 }
750 catch (Exception) 766 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
751 { 767 {
768 m_InSelfDelete = true;
769 if (part != null && part.ParentGroup != null)
770 m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
771 }
772 else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
773 {
774 m_InSelfDelete = true;
775 if (part != null && part.ParentGroup != null)
776 part.Inventory.RemoveInventoryItem(m_ItemID);
752 } 777 }
753 // catch (Exception e2) // LEGIT: User Scripting
754 // {
755 // m_log.Error("[SCRIPT]: "+
756 // "Error displaying error in-world: " +
757 // e2.ToString());
758 // m_log.Error("[SCRIPT]: " +
759 // "Errormessage: Error compiling script:\r\n" +
760 // e.ToString());
761 // }
762 }
763 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
764 {
765 m_InSelfDelete = true;
766 if (part != null && part.ParentGroup != null)
767 m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
768 }
769 else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
770 {
771 m_InSelfDelete = true;
772 if (part != null && part.ParentGroup != null)
773 part.Inventory.RemoveInventoryItem(m_ItemID);
774 } 778 }
775 } 779 }
776 } 780 }
777 }
778 781
779 lock (m_EventQueue) 782 lock (m_EventQueue)
780 {
781 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
782 {
783 m_CurrentResult = m_Engine.QueueEventHandler(this);
784 }
785 else
786 { 783 {
787 m_CurrentResult = null; 784 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
785 {
786 m_CurrentResult = m_Engine.QueueEventHandler(this);
787 }
788 else
789 {
790 m_CurrentResult = null;
791 }
788 } 792 }
789 }
790 793
791 m_DetectParams = null; 794 m_DetectParams = null;
792 795
793 return 0; 796 return 0;
794 } 797 }
795 } 798 }
796 799
797 public int EventTime() 800 public int EventTime()
@@ -1018,5 +1021,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1018 { 1021 {
1019 get { return m_RegionID; } 1022 get { return m_RegionID; }
1020 } 1023 }
1024
1025 public void Suspend()
1026 {
1027 m_Suspended = true;
1028 }
1029
1030 public void Resume()
1031 {
1032 m_Suspended = false;
1033 }
1021 } 1034 }
1022} 1035}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 35d57d8..463b052 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1570,5 +1570,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1570 return new ArrayList(); 1570 return new ArrayList();
1571 } 1571 }
1572 } 1572 }
1573
1574 public void SuspendScript(UUID itemID)
1575 {
1576 IScriptInstance instance = GetInstance(itemID);
1577 if (instance == null)
1578 return;
1579
1580 instance.Suspend();
1581 }
1582
1583 public void ResumeScript(UUID itemID)
1584 {
1585 IScriptInstance instance = GetInstance(itemID);
1586 if (instance == null)
1587 return;
1588
1589 instance.Resume();
1590 }
1573 } 1591 }
1574} 1592}