From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../Api/Implementation/AsyncCommandManager.cs | 123 +- .../Shared/Api/Implementation/CM_Api.cs | 129 + .../Shared/Api/Implementation/LSL_Api.cs | 5966 ++++++++++++++------ .../Shared/Api/Implementation/LS_Api.cs | 18 +- .../Shared/Api/Implementation/MOD_Api.cs | 84 +- .../Shared/Api/Implementation/OSSL_Api.cs | 2065 +++++-- .../Api/Implementation/Plugins/SensorRepeat.cs | 62 +- .../Shared/Api/Implementation/Plugins/Timer.cs | 34 +- .../Api/Implementation/Properties/AssemblyInfo.cs | 10 +- .../ScriptEngine/Shared/Api/Interface/ICM_Api.cs | 46 + .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 24 +- .../ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | 2 +- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 50 +- .../ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | 71 + .../ScriptEngine/Shared/Api/Runtime/Executor.cs | 2 + .../Shared/Api/Runtime/LSL_Constants.cs | 79 +- .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 113 +- .../ScriptEngine/Shared/Api/Runtime/LS_Stub.cs | 21 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 173 +- ...nSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | 48 - .../Shared/Api/Runtime/Properties/AssemblyInfo.cs | 8 +- .../ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 2 + .../Region/ScriptEngine/Shared/AssemblyResolver.cs | 2 +- .../Shared/CodeTools/CSCodeGenerator.cs | 584 +- .../Shared/CodeTools/CSReservedWords.cs | 2 +- .../ScriptEngine/Shared/CodeTools/Compiler.cs | 230 +- .../Shared/CodeTools/ICodeConverter.cs | 3 + .../Shared/CodeTools/LSL2CSCodeTransformer.cs | 2 +- .../Shared/CodeTools/Properties/AssemblyInfo.cs | 10 +- .../Shared/CodeTools/Tests/CSCodeGeneratorTest.cs | 2 +- .../Shared/CodeTools/Tests/CompilerTest.cs | 13 +- .../Shared/CodeTools/Tests/LSL_EventTests.cs | 24 +- .../ScriptEngine/Shared/CodeTools/lsl.lexer.cs | 6 +- .../ScriptEngine/Shared/CodeTools/lsl.parser.cs | 1710 +++--- OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 91 +- .../Shared/Instance/Properties/AssemblyInfo.cs | 10 +- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 205 +- .../Shared/Instance/ScriptSerializer.cs | 1 + .../Shared/Instance/Tests/CoopTerminationTests.cs | 76 +- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 172 +- .../ScriptEngine/Shared/Properties/AssemblyInfo.cs | 8 +- .../Shared/Tests/LSL_ApiAvatarTests.cs | 2 + .../ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs | 25 +- .../Shared/Tests/LSL_ApiInventoryTests.cs | 21 +- .../Shared/Tests/LSL_ApiLinkingTests.cs | 4 +- .../ScriptEngine/Shared/Tests/LSL_ApiListTests.cs | 4 +- .../Shared/Tests/LSL_ApiNotecardTests.cs | 8 +- .../Shared/Tests/LSL_ApiObjectTests.cs | 28 +- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 10 +- .../Shared/Tests/LSL_TypesTestLSLFloat.cs | 2 +- .../Shared/Tests/LSL_TypesTestLSLInteger.cs | 2 +- .../Shared/Tests/LSL_TypesTestLSLString.cs | 2 +- .../ScriptEngine/Shared/Tests/LSL_TypesTestList.cs | 2 + .../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 4 +- 54 files changed, 8267 insertions(+), 4128 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs delete mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 036cb5d..e01d2e4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -28,9 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Reflection; using System.Threading; -using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Monitoring; @@ -39,6 +37,8 @@ using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; +using System.Reflection; +using log4net; namespace OpenSim.Region.ScriptEngine.Shared.Api { @@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private static Thread cmdHandlerThread; private static int cmdHandlerThreadCycleSleepms; - + private static int numInstances; /// /// Lock for reading/writing static components of AsyncCommandManager. /// @@ -81,64 +81,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Dataserver DataserverPlugin { - get - { + get + { lock (staticLock) - return m_Dataserver[m_ScriptEngine]; + return m_Dataserver[m_ScriptEngine]; } } public Timer TimerPlugin { - get - { + get + { lock (staticLock) - return m_Timer[m_ScriptEngine]; + return m_Timer[m_ScriptEngine]; } } public HttpRequest HttpRequestPlugin { - get - { + get + { lock (staticLock) - return m_HttpRequest[m_ScriptEngine]; + return m_HttpRequest[m_ScriptEngine]; } } public Listener ListenerPlugin { - get - { + get + { lock (staticLock) - return m_Listener[m_ScriptEngine]; + return m_Listener[m_ScriptEngine]; } } public SensorRepeat SensorRepeatPlugin { - get - { + get + { lock (staticLock) - return m_SensorRepeat[m_ScriptEngine]; + return m_SensorRepeat[m_ScriptEngine]; } } public XmlRequest XmlRequestPlugin { - get - { + get + { lock (staticLock) - return m_XmlRequest[m_ScriptEngine]; + return m_XmlRequest[m_ScriptEngine]; } } public IScriptEngine[] ScriptEngines { - get - { + get + { lock (staticLock) - return m_ScriptEngines.ToArray(); + return m_ScriptEngines.ToArray(); } } @@ -172,18 +172,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!m_XmlRequest.ContainsKey(m_ScriptEngine)) m_XmlRequest[m_ScriptEngine] = new XmlRequest(this); - StartThread(); - } - } - - private static void StartThread() - { - if (cmdHandlerThread == null) - { - // Start the thread that will be doing the work - cmdHandlerThread - = WorkManager.StartThread( + numInstances++; + if (cmdHandlerThread == null) + { + cmdHandlerThread = WorkManager.StartThread( CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true, true); + } } } @@ -194,25 +188,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api cmdHandlerThreadCycleSleepms = 100; } +/* ~AsyncCommandManager() { // Shut down thread -// try -// { -// if (cmdHandlerThread != null) -// { -// if (cmdHandlerThread.IsAlive == true) -// { -// cmdHandlerThread.Abort(); -// //cmdHandlerThread.Join(); -// } -// } -// } -// catch -// { -// } - } + try + { + lock (staticLock) + { + numInstances--; + if(numInstances > 0) + return; + if (cmdHandlerThread != null) + { + if (cmdHandlerThread.IsAlive == true) + { + cmdHandlerThread.Abort(); + //cmdHandlerThread.Join(); + cmdHandlerThread = null; + } + } + } + } + catch + { + } + } +*/ /// /// Main loop for the manager thread /// @@ -223,11 +226,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { Thread.Sleep(cmdHandlerThreadCycleSleepms); - + Watchdog.UpdateThread(); DoOneCmdHandlerPass(); - Watchdog.UpdateThread(); } + catch ( System.Threading.ThreadAbortException) { } catch (Exception e) { m_log.Error("[ASYNC COMMAND MANAGER]: Exception in command handler pass: ", e); @@ -240,24 +243,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lock (staticLock) { // Check HttpRequests - m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); + try { m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests(); } catch {} // Check XMLRPCRequests - m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); + try { m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests(); } catch {} foreach (IScriptEngine s in m_ScriptEngines) { // Check Listeners - m_Listener[s].CheckListeners(); + try { m_Listener[s].CheckListeners(); } catch {} + // Check timers - m_Timer[s].CheckTimerEvents(); + try { m_Timer[s].CheckTimerEvents(); } catch {} // Check Sensors - m_SensorRepeat[s].CheckSenseRepeaterEvents(); + try { m_SensorRepeat[s].CheckSenseRepeaterEvents(); } catch {} // Check dataserver - m_Dataserver[s].ExpireRequests(); + try { m_Dataserver[s].ExpireRequests(); } catch {} } } } @@ -269,6 +273,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID) { + // Remove a specific script // m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID); lock (staticLock) @@ -282,7 +287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Remove from: HttpRequest IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface(); if (iHttpReq != null) - iHttpReq.StopHttpRequestsForScript(itemID); + iHttpReq.StopHttpRequest(localID, itemID); IWorldComm comms = engine.World.RequestModuleInterface(); if (comms != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..3509968 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs @@ -0,0 +1,129 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Threading; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Remoting.Lifetime; +using OpenMetaverse; +using Nini.Config; +using OpenSim; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.World.LightShare; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; +using OpenSim.Services.Interfaces; + +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; + +namespace OpenSim.Region.ScriptEngine.Shared.Api +{ + [Serializable] + public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi + { + internal IScriptEngine m_ScriptEngine; + internal SceneObjectPart m_host; + internal TaskInventoryItem m_item; + internal bool m_CMFunctionsEnabled = false; + + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) + { + m_ScriptEngine = ScriptEngine; + m_host = host; + m_item = item; + + if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) + m_CMFunctionsEnabled = true; + } + + public override Object InitializeLifetimeService() + { + ILease lease = (ILease)base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.FromMinutes(0); +// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); +// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); + } + return lease; + } + + public Scene World + { + get { return m_ScriptEngine.World; } + } + + public string cmDetectedCountry(int number) + { + m_host.AddScriptLPS(1); + if(!m_CMFunctionsEnabled) + return String.Empty; + if(World.UserAccountService == null) + return String.Empty; + DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); + if (detectedParams == null) + return String.Empty; + UUID key = detectedParams.Key; + if(key == UUID.Zero) + return String.Empty; + UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); + return account.UserCountry; + } + + public string cmGetAgentCountry(LSL_Key key) + { + if(! m_CMFunctionsEnabled) + return ""; + if(World.UserAccountService == null) + return String.Empty; + if (!World.Permissions.IsGod(m_host.OwnerID)) + return String.Empty; + + UUID uuid; + + if (!UUID.TryParse(key, out uuid)) + return String.Empty; + + UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); + return account.UserCountry; + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1399880..bac1468 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.Specialized; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; @@ -35,10 +36,12 @@ using System.Runtime.Remoting.Lifetime; using System.Text; using System.Threading; using System.Text.RegularExpressions; +using System.Timers; using Nini.Config; using log4net; using OpenMetaverse; using OpenMetaverse.Assets; +using OpenMetaverse.StructuredData; // LitJson is hidden on this using OpenMetaverse.Packets; using OpenMetaverse.Rendering; using OpenSim; @@ -49,6 +52,7 @@ using OpenSim.Region.CoreModules.World.Land; using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Animation; using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.PhysicsModules.SharedBase; @@ -72,6 +76,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using System.Reflection; +using Timer = System.Timers.Timer; using System.Linq; using PermissionMask = OpenSim.Framework.PermissionMask; @@ -98,30 +103,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected SceneObjectPart m_host; /// - /// Used for script sleeps when we are using co-operative script termination. - /// - /// null if co-operative script termination is not active - /// /// The item that hosts this script /// protected TaskInventoryItem m_item; protected bool throwErrorOnNotImplemented = false; protected AsyncCommandManager AsyncCommands = null; + protected float m_ScriptDelayFactor = 1.0f; protected float m_ScriptDistanceFactor = 1.0f; protected float m_MinTimerInterval = 0.5f; protected float m_recoilScaleFactor = 0.0f; - protected DateTime m_timer = DateTime.Now; + protected double m_timer = Util.GetTimeStampMS(); protected bool m_waitingForScriptAnswer = false; protected bool m_automaticLinkPermission = false; protected IMessageTransferModule m_TransferModule = null; protected int m_notecardLineReadCharsMax = 255; protected int m_scriptConsoleChannel = 0; protected bool m_scriptConsoleChannelEnabled = false; + protected bool m_debuggerSafe = false; protected IUrlModule m_UrlModule = null; + protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. + protected int m_sleepMsOnSetTexture = 200; + protected int m_sleepMsOnSetLinkTexture = 200; + protected int m_sleepMsOnScaleTexture = 200; + protected int m_sleepMsOnOffsetTexture = 200; + protected int m_sleepMsOnRotateTexture = 200; + protected int m_sleepMsOnSetPos = 200; + protected int m_sleepMsOnSetRot = 200; + protected int m_sleepMsOnSetLocalRot = 200; + protected int m_sleepMsOnPreloadSound = 1000; + protected int m_sleepMsOnMakeExplosion = 100; + protected int m_sleepMsOnMakeFountain = 100; + protected int m_sleepMsOnMakeSmoke = 100; + protected int m_sleepMsOnMakeFire = 100; + protected int m_sleepMsOnRezAtRoot = 100; + protected int m_sleepMsOnInstantMessage = 2000; + protected int m_sleepMsOnEmail = 20000; + protected int m_sleepMsOnCreateLink = 1000; + protected int m_sleepMsOnGiveInventory = 3000; + protected int m_sleepMsOnRequestAgentData = 100; + protected int m_sleepMsOnRequestInventoryData = 1000; + protected int m_sleepMsOnSetDamage = 5000; + protected int m_sleepMsOnTextBox = 1000; + protected int m_sleepMsOnAdjustSoundVolume = 100; + protected int m_sleepMsOnEjectFromLand = 5000; + protected int m_sleepMsOnAddToLandPassList = 100; + protected int m_sleepMsOnDialog = 1000; + protected int m_sleepMsOnRemoteLoadScript = 3000; + protected int m_sleepMsOnRemoteLoadScriptPin = 3000; + protected int m_sleepMsOnOpenRemoteDataChannel = 1000; + protected int m_sleepMsOnSendRemoteData = 3000; + protected int m_sleepMsOnRemoteDataReply = 3000; + protected int m_sleepMsOnCloseRemoteDataChannel = 1000; + protected int m_sleepMsOnSetPrimitiveParams = 200; + protected int m_sleepMsOnSetLinkPrimitiveParams = 200; + protected int m_sleepMsOnXorBase64Strings = 300; + protected int m_sleepMsOnSetParcelMusicURL = 2000; + protected int m_sleepMsOnGetPrimMediaParams = 1000; + protected int m_sleepMsOnGetLinkMedia = 1000; + protected int m_sleepMsOnSetPrimMediaParams = 1000; + protected int m_sleepMsOnSetLinkMedia = 1000; + protected int m_sleepMsOnClearPrimMedia = 1000; + protected int m_sleepMsOnClearLinkMedia = 1000; + protected int m_sleepMsOnRequestSimulatorData = 1000; + protected int m_sleepMsOnLoadURL = 10000; + protected int m_sleepMsOnParcelMediaCommandList = 2000; + protected int m_sleepMsOnParcelMediaQuery = 2000; + protected int m_sleepMsOnModPow = 1000; + protected int m_sleepMsOnSetPrimURL = 2000; + protected int m_sleepMsOnRefreshPrimURL = 20000; + protected int m_sleepMsOnMapDestination = 1000; + protected int m_sleepMsOnAddToLandBanList = 100; + protected int m_sleepMsOnRemoveFromLandPassList = 100; + protected int m_sleepMsOnRemoveFromLandBanList = 100; + protected int m_sleepMsOnResetLandBanList = 100; + protected int m_sleepMsOnResetLandPassList = 100; + protected int m_sleepMsOnGetParcelPrimOwners = 2000; + protected int m_sleepMsOnGetNumberOfNotecardLines = 100; + protected int m_sleepMsOnGetNotecardLine = 100; protected string m_internalObjectHost = "lsl.opensim.local"; protected bool m_restrictEmail = false; protected ISoundModule m_SoundModule = null; @@ -172,7 +234,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected int m_maxHitsPerPrimInCastRay = 16; protected int m_maxHitsPerObjectInCastRay = 16; protected bool m_detectExitsInCastRay = false; - protected bool m_filterPartsInCastRay = false; protected bool m_doAttachmentsInCastRay = false; protected int m_msThrottleInCastRay = 200; protected int m_msPerRegionInCastRay = 40; @@ -183,6 +244,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected bool m_useMeshCacheInCastRay = true; protected static Dictionary m_cachedMeshes = new Dictionary(); +// protected Timer m_ShoutSayTimer; + protected int m_SayShoutCount = 0; + DateTime m_lastSayShoutCheck; + + private Dictionary MovementAnimationsForLSL = + new Dictionary { + {"CROUCH", "Crouching"}, + {"CROUCHWALK", "CrouchWalking"}, + {"FALLDOWN", "Falling Down"}, + {"FLY", "Flying"}, + {"FLYSLOW", "FlyingSlow"}, + {"HOVER", "Hovering"}, + {"HOVER_UP", "Hovering Up"}, + {"HOVER_DOWN", "Hovering Down"}, + {"JUMP", "Jumping"}, + {"LAND", "Landing"}, + {"PREJUMP", "PreJumping"}, + {"RUN", "Running"}, + {"SIT","Sitting"}, + {"SITGROUND","Sitting on Ground"}, + {"STAND", "Standing"}, + {"STANDUP", "Standing Up"}, + {"STRIDE","Striding"}, + {"SOFT_LAND", "Soft Landing"}, + {"TURNLEFT", "Turning Left"}, + {"TURNRIGHT", "Turning Right"}, + {"WALK", "Walking"} + }; + //An array of HTTP/1.1 headers that are not allowed to be used //as custom headers by llHTTPRequest. private string[] HttpStandardHeaders = @@ -203,9 +293,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void Initialize( IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) { + m_lastSayShoutCheck = DateTime.UtcNow; + m_ScriptEngine = scriptEngine; m_host = host; m_item = item; + m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); LoadConfig(); @@ -228,6 +321,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (seConfig != null) { + m_ScriptDelayFactor = + seConfig.GetFloat("ScriptDelayFactor", m_ScriptDelayFactor); m_ScriptDistanceFactor = seConfig.GetFloat("ScriptDistanceLimitFactor", m_ScriptDistanceFactor); m_MinTimerInterval = @@ -296,7 +391,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_maxHitsPerPrimInCastRay = lslConfig.GetInt("MaxHitsPerPrimInLlCastRay", m_maxHitsPerPrimInCastRay); m_maxHitsPerObjectInCastRay = lslConfig.GetInt("MaxHitsPerObjectInLlCastRay", m_maxHitsPerObjectInCastRay); m_detectExitsInCastRay = lslConfig.GetBoolean("DetectExitHitsInLlCastRay", m_detectExitsInCastRay); - m_filterPartsInCastRay = lslConfig.GetBoolean("FilterPartsInLlCastRay", m_filterPartsInCastRay); m_doAttachmentsInCastRay = lslConfig.GetBoolean("DoAttachmentsInLlCastRay", m_doAttachmentsInCastRay); m_msThrottleInCastRay = lslConfig.GetInt("ThrottleTimeInMsInLlCastRay", m_msThrottleInCastRay); m_msPerRegionInCastRay = lslConfig.GetInt("AvailableTimeInMsPerRegionInLlCastRay", m_msPerRegionInCastRay); @@ -307,7 +401,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } IConfig smtpConfig = seConfigSource.Configs["SMTP"]; - if (smtpConfig != null) + if (smtpConfig != null) { // there's an smtp config, so load in the snooze time. EMAIL_PAUSE_TIME = smtpConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); @@ -315,6 +409,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_internalObjectHost = smtpConfig.GetString("internal_object_host", m_internalObjectHost); } } + m_sleepMsOnEmail = EMAIL_PAUSE_TIME * 1000; } public override Object InitializeLifetimeService() @@ -330,6 +425,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return lease; } + protected SceneObjectPart MonitoringObject() + { + UUID m = m_host.ParentGroup.MonitoringObject; + if (m == UUID.Zero) + return null; + + SceneObjectPart p = m_ScriptEngine.World.GetSceneObjectPart(m); + if (p == null) + m_host.ParentGroup.MonitoringObject = UUID.Zero; + + return p; + } + + protected virtual void ScriptSleep(int delay) + { + delay = (int)((float)delay * m_ScriptDelayFactor); + if (delay == 0) + return; + + Sleep(delay); + } + protected virtual void Sleep(int delay) { if (m_item == null) // Some unit tests don't set this @@ -351,6 +468,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api get { return m_ScriptEngine.World; } } + [DebuggerNonUserCode] public void state(string newState) { m_ScriptEngine.SetState(m_item.ItemID, newState); @@ -360,6 +478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Reset the named script. The script must be present /// in the same prim. /// + [DebuggerNonUserCode] public void llResetScript() { m_host.AddScriptLPS(1); @@ -376,12 +495,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID item; - m_host.AddScriptLPS(1); - - if ((item = GetScriptByName(name)) != UUID.Zero) - m_ScriptEngine.ResetScript(item); - else + if ((item = GetScriptByName(name)) == UUID.Zero) + { + m_host.AddScriptLPS(1); Error("llResetOtherScript", "Can't find script '" + name + "'"); + return; + } + if(item == m_item.ItemID) + llResetScript(); + else + { + m_host.AddScriptLPS(1); + m_ScriptEngine.ResetScript(item); + } } public LSL_Integer llGetScriptState(string name) @@ -414,7 +540,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((item = GetScriptByName(name)) != UUID.Zero) { - m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); + m_ScriptEngine.SetScriptState(item, run == 0 ? false : true, item == m_item.ItemID); } else { @@ -422,6 +548,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public List GetLinkAvatars(int linkType) + { + List ret = new List(); + if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + return ret; + + // List avs = m_host.ParentGroup.GetLinkedAvatars(); + // this needs check + List avs = m_host.ParentGroup.GetSittingAvatars(); + switch (linkType) + { + case ScriptBaseClass.LINK_SET: + return avs; + + case ScriptBaseClass.LINK_ROOT: + return ret; + + case ScriptBaseClass.LINK_ALL_OTHERS: + return avs; + + case ScriptBaseClass.LINK_ALL_CHILDREN: + return avs; + + case ScriptBaseClass.LINK_THIS: + return ret; + + default: + if (linkType < 0) + return ret; + + int partCount = m_host.ParentGroup.GetPartCount(); + + if (linkType <= partCount) + { + return ret; + } + else + { + linkType = linkType - partCount; + if (linkType > avs.Count) + { + return ret; + } + else + { + ret.Add(avs[linkType-1]); + return ret; + } + } + } + } + /// /// Get a given link entity from a linkset (linked objects and any sitting avatars). /// @@ -501,7 +679,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public static List GetLinkParts(SceneObjectPart part, int linkType) { List ret = new List(); - ret.Add(part); + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return ret; switch (linkType) { @@ -509,7 +688,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new List(part.ParentGroup.Parts); case ScriptBaseClass.LINK_ROOT: - ret = new List(); ret.Add(part.ParentGroup.RootPart); return ret; @@ -529,16 +707,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ret; case ScriptBaseClass.LINK_THIS: + ret.Add(part); return ret; default: if (linkType < 0) - return new List(); + return ret; SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); if (target == null) - return new List(); - ret = new List(); + return ret; ret.Add(target); return ret; } @@ -648,8 +826,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llFrand(double mag) { m_host.AddScriptLPS(1); - - return Util.RandomClass.NextDouble() * mag; + lock (Util.RandomClass) + { + return Util.RandomClass.NextDouble() * mag; + } } public LSL_Integer llFloor(double f) @@ -700,31 +880,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - /// - /// Convert an LSL rotation to a Euler vector. - /// - /// - /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf - /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 - /// - /// - /// - public LSL_Vector llRot2Euler(LSL_Rotation r) + // Utility function for llRot2Euler + + public LSL_Vector llRot2Euler(LSL_Rotation q1) { m_host.AddScriptLPS(1); + LSL_Vector eul = new LSL_Vector(); - LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. - double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. - if (m == 0.0) return new LSL_Vector(); - double x = Math.Atan2(-v.y, v.z); - double sin = v.x / m; - if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. - double y = Math.Asin(sin); - // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation - v = new LSL_Vector(1.0, 0.0, 0.0) * ((r * new LSL_Rotation(Math.Sin(-x / 2.0), 0.0, 0.0, Math.Cos(-x / 2.0))) * new LSL_Rotation(0.0, Math.Sin(-y / 2.0), 0.0, Math.Cos(-y / 2.0))); - double z = Math.Atan2(v.y, v.x); - - return new LSL_Vector(x, y, z); + double sqw = q1.s*q1.s; + double sqx = q1.x*q1.x; + double sqy = q1.z*q1.z; + double sqz = q1.y*q1.y; + double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor + double test = q1.x*q1.z + q1.y*q1.s; + if (test > 0.4999*unit) { // singularity at north pole + eul.z = 2 * Math.Atan2(q1.x,q1.s); + eul.y = Math.PI/2; + eul.x = 0; + return eul; + } + if (test < -0.4999*unit) { // singularity at south pole + eul.z = -2 * Math.Atan2(q1.x,q1.s); + eul.y = -Math.PI/2; + eul.x = 0; + return eul; + } + eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); + eul.y = Math.Asin(2*test/unit); + eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); + return eul; } /* From wiki: @@ -777,18 +961,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); double x,y,z,s; - - double c1 = Math.Cos(v.x * 0.5); - double c2 = Math.Cos(v.y * 0.5); - double c3 = Math.Cos(v.z * 0.5); - double s1 = Math.Sin(v.x * 0.5); - double s2 = Math.Sin(v.y * 0.5); - double s3 = Math.Sin(v.z * 0.5); - - x = s1 * c2 * c3 + c1 * s2 * s3; - y = c1 * s2 * c3 - s1 * c2 * s3; - z = s1 * s2 * c3 + c1 * c2 * s3; - s = c1 * c2 * c3 - s1 * s2 * s3; + v.x *= 0.5; + v.y *= 0.5; + v.z *= 0.5; + double c1 = Math.Cos(v.x); + double c2 = Math.Cos(v.y); + double c1c2 = c1 * c2; + double s1 = Math.Sin(v.x); + double s2 = Math.Sin(v.y); + double s1s2 = s1 * s2; + double c1s2 = c1 * s2; + double s1c2 = s1 * c2; + double c3 = Math.Cos(v.z); + double s3 = Math.Sin(v.z); + + x = s1c2 * c3 + c1s2 * s3; + y = c1s2 * c3 - s1c2 * s3; + z = s1s2 * c3 + c1c2 * s3; + s = c1c2 * c3 - s1s2 * s3; return new LSL_Rotation(x, y, z, s); } @@ -926,75 +1116,74 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { //A and B should both be normalized m_host.AddScriptLPS(1); - LSL_Rotation rotBetween; - // Check for zero vectors. If either is zero, return zero rotation. Otherwise, - // continue calculation. - if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) + /* This method is more accurate than the SL one, and thus causes problems + for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. + + double dotProduct = LSL_Vector.Dot(a, b); + LSL_Vector crossProduct = LSL_Vector.Cross(a, b); + double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); + double angle = Math.Acos(dotProduct / magProduct); + LSL_Vector axis = LSL_Vector.Norm(crossProduct); + double s = Math.Sin(angle / 2); + + double x = axis.x * s; + double y = axis.y * s; + double z = axis.z * s; + double w = Math.Cos(angle / 2); + + if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) + return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); + + return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); + */ + + // This method mimics the 180 errors found in SL + // See www.euclideanspace.com... angleBetween + LSL_Vector vec_a = a; + LSL_Vector vec_b = b; + + // Eliminate zero length + LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); + LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); + if (vec_a_mag < 0.00001 || + vec_b_mag < 0.00001) { - rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); + return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); } - else + + // Normalize + vec_a = llVecNorm(vec_a); + vec_b = llVecNorm(vec_b); + + // Calculate axis and rotation angle + LSL_Vector axis = vec_a % vec_b; + LSL_Float cos_theta = vec_a * vec_b; + + // Check if parallel + if (cos_theta > 0.99999) { - a = LSL_Vector.Norm(a); - b = LSL_Vector.Norm(b); - double dotProduct = LSL_Vector.Dot(a, b); - // There are two degenerate cases possible. These are for vectors 180 or - // 0 degrees apart. These have to be detected and handled individually. - // - // Check for vectors 180 degrees apart. - // A dot product of -1 would mean the angle between vectors is 180 degrees. - if (dotProduct < -0.9999999f) - { - // First assume X axis is orthogonal to the vectors. - LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); - orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); - // Check for near zero vector. A very small non-zero number here will create - // a rotation in an undesired direction. - if (LSL_Vector.Mag(orthoVector) > 0.0001) - { - rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); - } - // If the magnitude of the vector was near zero, then assume the X axis is not - // orthogonal and use the Z axis instead. - else - { - // Set 180 z rotation. - rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); - } - } - // Check for parallel vectors. - // A dot product of 1 would mean the angle between vectors is 0 degrees. - else if (dotProduct > 0.9999999f) - { - // Set zero rotation. - rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); - } - else - { - // All special checks have been performed so get the axis of rotation. - LSL_Vector crossProduct = LSL_Vector.Cross(a, b); - // Quarternion s value is the length of the unit vector + dot product. - double qs = 1.0 + dotProduct; - rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); - // Normalize the rotation. - double mag = LSL_Rotation.Mag(rotBetween); - // We shouldn't have to worry about a divide by zero here. The qs value will be - // non-zero because we already know if we're here, then the dotProduct is not -1 so - // qs will not be zero. Also, we've already handled the input vectors being zero so the - // crossProduct vector should also not be zero. - rotBetween.x = rotBetween.x / mag; - rotBetween.y = rotBetween.y / mag; - rotBetween.z = rotBetween.z / mag; - rotBetween.s = rotBetween.s / mag; - // Check for undefined values and set zero rotation if any found. This code might not actually be required - // any longer since zero vectors are checked for at the top. - if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) - { - rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); - } - } + return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); + } + + // Check if anti-parallel + else if (cos_theta < -0.99999) + { + LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); + if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); + return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); + } + else // other rotation + { + LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; + axis = llVecNorm(axis); + double x, y, z, s, t; + s = Math.Cos(theta); + t = Math.Sin(theta); + x = axis.x * t; + y = axis.y * t; + z = axis.z * t; + return new LSL_Rotation(x,y,z,s); } - return rotBetween; } public void llWhisper(int channelID, string text) @@ -1012,10 +1201,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); } + private void CheckSayShoutTime() + { + DateTime now = DateTime.UtcNow; + if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec + { + m_lastSayShoutCheck = now; + m_SayShoutCount = 0; + } + else + m_SayShoutCount++; + } + public void llSay(int channelID, string text) { m_host.AddScriptLPS(1); + if (channelID == 0) +// m_SayShoutCount++; + CheckSayShoutTime(); + + if (m_SayShoutCount >= 11) + ScriptSleep(2000); + if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) { Console.WriteLine(text); @@ -1038,6 +1246,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + if (channelID == 0) +// m_SayShoutCount++; + CheckSayShoutTime(); + + if (m_SayShoutCount >= 11) + ScriptSleep(2000); + if (text.Length > 1023) text = text.Substring(0, 1023); @@ -1062,8 +1277,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.Region, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); + // debug channel is also sent to avatars + if (channelID == ScriptBaseClass.DEBUG_CHANNEL) + { + World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.Shout, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); + + } IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) @@ -1078,16 +1298,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (channel == ScriptBaseClass.DEBUG_CHANNEL) - { return; - } UUID TargetID; UUID.TryParse(target, out TargetID); - World.SimChatToAgent(TargetID, Utils.StringToBytes(msg), - channel, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); @@ -1346,10 +1561,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return detectedParams.TouchUV; } + [DebuggerNonUserCode] public virtual void llDie() { m_host.AddScriptLPS(1); - throw new SelfDeleteException(); + if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); } public LSL_Float llGround(LSL_Vector offset) @@ -1420,6 +1636,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetStatus(int status, int value) { + if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + return; m_host.AddScriptLPS(1); int statusrotationaxis = 0; @@ -1431,18 +1649,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectGroup group = m_host.ParentGroup; bool allow = true; + int maxprims = World.m_linksetPhysCapacity; + bool checkShape = (maxprims > 0 && group.PrimCount > maxprims); + foreach (SceneObjectPart part in group.Parts) { + if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) + continue; + if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys) { allow = false; break; } + if (checkShape) + { + if (--maxprims < 0) + { + allow = false; + break; + } + } } if (!allow) return; + if (m_host.ParentGroup.RootPart.PhysActor != null && + m_host.ParentGroup.RootPart.PhysActor.IsPhysical) + return; + m_host.ScriptSetPhysicsStatus(true); } else @@ -1586,6 +1822,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return 0; } + public LSL_Integer llScaleByFactor(double scaling_factor) + { + m_host.AddScriptLPS(1); + SceneObjectGroup group = m_host.ParentGroup; + + if(scaling_factor < 1e-6) + return ScriptBaseClass.FALSE; + if(scaling_factor > 1e6) + return ScriptBaseClass.FALSE; + + if (group == null || group.IsDeleted || group.inTransit) + return ScriptBaseClass.FALSE; + + if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) + return ScriptBaseClass.FALSE; + + if (group.RootPart.KeyframeMotion != null) + return ScriptBaseClass.FALSE; + + if(group.GroupResize(scaling_factor)) + return ScriptBaseClass.TRUE; + else + return ScriptBaseClass.FALSE; + } + + public LSL_Float llGetMaxScaleFactor() + { + m_host.AddScriptLPS(1); + SceneObjectGroup group = m_host.ParentGroup; + + if (group == null || group.IsDeleted || group.inTransit) + return 1.0f; + + return (LSL_Float)group.GetMaxGroupResizeScale(); + } + + public LSL_Float llGetMinScaleFactor() + { + m_host.AddScriptLPS(1); + SceneObjectGroup group = m_host.ParentGroup; + + if (group == null || group.IsDeleted || group.inTransit) + return 1.0f; + + return (LSL_Float)group.GetMinGroupResizeScale(); + } + public void llSetScale(LSL_Vector scale) { m_host.AddScriptLPS(1); @@ -1641,6 +1924,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + SetColor(m_host, color, face); + } + + protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + + Primitive.TextureEntry tex = part.Shape.Textures; + int nsides = GetNumberOfSides(part); + Color4 texcolor; + + if (face >= 0 && face < nsides) + { + texcolor = tex.CreateFace((uint)face).RGBA; + texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); + tex.FaceTextures[face].RGBA = texcolor; + part.UpdateTextureEntry(tex.GetBytes()); + return; + } + else if (face == ScriptBaseClass.ALL_SIDES) + { + for (uint i = 0; i < nsides; i++) + { + if (tex.FaceTextures[i] != null) + { + texcolor = tex.FaceTextures[i].RGBA; + texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); + tex.FaceTextures[i].RGBA = texcolor; + } + texcolor = tex.DefaultTexture.RGBA; + texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); + texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); + texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); + tex.DefaultTexture.RGBA = texcolor; + } + part.UpdateTextureEntry(tex.GetBytes()); + return; + } + if (face == ScriptBaseClass.ALL_SIDES) face = SceneObjectPart.ALL_SIDES; @@ -1714,15 +2041,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } +/* + public void llSetContentType(LSL_Key id, LSL_Integer content_type) + { + if (m_UrlModule != null) + { + string type = "text.plain"; + if (content_type == (int)ScriptBaseClass.CONTENT_TYPE_HTML) + type = "text/html"; + + m_UrlModule.HttpContentType(new UUID(id),type); + } + } +*/ public void SetTexGen(SceneObjectPart part, int face,int style) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; MappingType textype; textype = MappingType.Default; if (style == (int)ScriptBaseClass.PRIM_TEXGEN_PLANAR) textype = MappingType.Planar; - if (face >= 0 && face < GetNumberOfSides(part)) + int nsides = GetNumberOfSides(part); + + if (face >= 0 && face < nsides) { tex.CreateFace((uint) face); tex.FaceTextures[face].TexMapType = textype; @@ -1731,7 +2076,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (uint i = 0; i < GetNumberOfSides(part); i++) + for (uint i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -1746,8 +2091,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void SetGlow(SceneObjectPart part, int face, float glow) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + int nsides = GetNumberOfSides(part); + + if (face >= 0 && face < nsides) { tex.CreateFace((uint) face); tex.FaceTextures[face].Glow = glow; @@ -1756,7 +2106,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (uint i = 0; i < GetNumberOfSides(part); i++) + for (uint i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -1771,6 +2121,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; Shininess sval = new Shininess(); @@ -1793,8 +2145,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; } + int nsides = GetNumberOfSides(part); + Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { tex.CreateFace((uint) face); tex.FaceTextures[face].Shiny = sval; @@ -1804,7 +2158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (uint i = 0; i < GetNumberOfSides(part); i++) + for (uint i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -1821,8 +2175,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void SetFullBright(SceneObjectPart part, int face, bool bright) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + + int nsides = GetNumberOfSides(part); Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { tex.CreateFace((uint) face); tex.FaceTextures[face].Fullbright = bright; @@ -1831,7 +2189,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (uint i = 0; i < GetNumberOfSides(part); i++) + for (uint i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -1854,15 +2212,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected LSL_Float GetAlpha(SceneObjectPart part, int face) { Primitive.TextureEntry tex = part.Shape.Textures; + int nsides = GetNumberOfSides(part); if (face == ScriptBaseClass.ALL_SIDES) { int i; double sum = 0.0; - for (i = 0 ; i < GetNumberOfSides(part); i++) + for (i = 0 ; i < nsides; i++) sum += (double)tex.GetFace((uint)i).RGBA.A; return sum; } - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { return (double)tex.GetFace((uint)face).RGBA.A; } @@ -1881,16 +2240,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List parts = GetLinkParts(linknumber); - - foreach (SceneObjectPart part in parts) - SetAlpha(part, alpha, face); + if (parts.Count > 0) + { + try + { + foreach (SceneObjectPart part in parts) + SetAlpha(part, alpha, face); + } + finally { } + } } protected void SetAlpha(SceneObjectPart part, double alpha, int face) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; + int nsides = GetNumberOfSides(part); Color4 texcolor; - if (face >= 0 && face < GetNumberOfSides(part)) + + if (face >= 0 && face < nsides) { texcolor = tex.CreateFace((uint)face).RGBA; texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); @@ -1900,7 +2270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (int i = 0; i < GetNumberOfSides(part); i++) + for (int i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -1940,7 +2310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, float wind, float tension, LSL_Vector Force) { - if (part == null) + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; if (flexi) @@ -1981,7 +2351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) { - if (part == null) + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; if (light) @@ -2014,11 +2384,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntry tex = part.Shape.Textures; Color4 texcolor; LSL_Vector rgb = new LSL_Vector(); + int nsides = GetNumberOfSides(part); + if (face == ScriptBaseClass.ALL_SIDES) { int i; - - for (i = 0 ; i < GetNumberOfSides(part); i++) + for (i = 0; i < nsides; i++) { texcolor = tex.GetFace((uint)i).RGBA; rgb.x += texcolor.R; @@ -2026,14 +2397,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rgb.z += texcolor.B; } - rgb.x /= (float)GetNumberOfSides(part); - rgb.y /= (float)GetNumberOfSides(part); - rgb.z /= (float)GetNumberOfSides(part); + float invnsides = 1.0f / (float)nsides; + + rgb.x *= invnsides; + rgb.y *= invnsides; + rgb.z *= invnsides; return rgb; } - - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { texcolor = tex.GetFace((uint)face).RGBA; rgb.x = texcolor.R; @@ -2052,6 +2424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); SetTexture(m_host, texture, face); + ScriptSleep(m_sleepMsOnSetTexture); } public void llSetLinkTexture(int linknumber, string texture, int face) @@ -2059,13 +2432,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List parts = GetLinkParts(linknumber); - - foreach (SceneObjectPart part in parts) - SetTexture(part, texture, face); + if (parts.Count > 0) + { + try + { + foreach (SceneObjectPart part in parts) + SetTexture(part, texture, face); + } + finally { } + } + ScriptSleep(m_sleepMsOnSetLinkTexture); } protected void SetTexture(SceneObjectPart part, string texture, int face) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + UUID textureID = new UUID(); textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); @@ -2075,9 +2458,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + Primitive.TextureEntry tex = part.Shape.Textures; + int nsides = GetNumberOfSides(part); - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.TextureID = textureID; @@ -2087,7 +2472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else if (face == ScriptBaseClass.ALL_SIDES) { - for (uint i = 0; i < GetNumberOfSides(part); i++) + for (uint i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -2105,12 +2490,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); ScaleTexture(m_host, u, v, face); + ScriptSleep(m_sleepMsOnScaleTexture); } protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + int nsides = GetNumberOfSides(part); + + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.RepeatU = (float)u; @@ -2121,7 +2512,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (face == ScriptBaseClass.ALL_SIDES) { - for (int i = 0; i < GetNumberOfSides(part); i++) + for (int i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -2140,12 +2531,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); OffsetTexture(m_host, u, v, face); + ScriptSleep(m_sleepMsOnOffsetTexture); } protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + int nsides = GetNumberOfSides(part); + + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.OffsetU = (float)u; @@ -2156,7 +2553,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (face == ScriptBaseClass.ALL_SIDES) { - for (int i = 0; i < GetNumberOfSides(part); i++) + for (int i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -2175,12 +2572,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); RotateTexture(m_host, rotation, face); + ScriptSleep(m_sleepMsOnRotateTexture); } protected void RotateTexture(SceneObjectPart part, double rotation, int face) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + Primitive.TextureEntry tex = part.Shape.Textures; - if (face >= 0 && face < GetNumberOfSides(part)) + int nsides = GetNumberOfSides(part); + + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); texface.Rotation = (float)rotation; @@ -2190,7 +2593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (face == ScriptBaseClass.ALL_SIDES) { - for (int i = 0; i < GetNumberOfSides(part); i++) + for (int i = 0; i < nsides; i++) { if (tex.FaceTextures[i] != null) { @@ -2212,12 +2615,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected LSL_String GetTexture(SceneObjectPart part, int face) { Primitive.TextureEntry tex = part.Shape.Textures; + int nsides = GetNumberOfSides(part); + if (face == ScriptBaseClass.ALL_SIDES) { face = 0; } - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface; texface = tex.GetFace((uint)face); @@ -2248,6 +2653,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); SetPos(m_host, pos, true); + + ScriptSleep(m_sleepMsOnSetPos); } /// @@ -2278,7 +2685,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. pos.x > (World.RegionInfo.RegionSizeX + 10) || // return FALSE if more than 10 meters into a east-adjacent region. pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. - pos.y > (World.RegionInfo.RegionSizeY + 10) // return FALSE if more than 10 meters into a north-adjacent region. + pos.y > (World.RegionInfo.RegionSizeY + 10) || // return FALSE if more than 10 meters into a north-adjacent region. + pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m ) ) { @@ -2317,7 +2725,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return end; } - protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos) + protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos, bool adjust) { if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return fromPos; @@ -2333,9 +2741,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) targetPos.z = ground; } - LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); + if (adjust) + return SetPosAdjust(fromPos, targetPos); - return real_vec; + return targetPos; } /// @@ -2346,27 +2755,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// if TRUE, will cap the distance to 10m. protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) { - // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted || part.ParentGroup.inTransit) + return; + + LSL_Vector currentPos = GetPartLocalPos(part); + LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); - float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); - bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); if (part.ParentGroup.RootPart == part) { - if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) - targetPos.z = ground; SceneObjectGroup parent = part.ParentGroup; - parent.UpdateGroupPosition(!adjust ? targetPos : - SetPosAdjust(currentPos, targetPos)); + if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos)) + return; + parent.UpdateGroupPosition((Vector3)toPos); } else { - part.OffsetPosition = !adjust ? targetPos : - SetPosAdjust(currentPos, targetPos); - SceneObjectGroup parent = part.ParentGroup; - parent.HasGroupChanged = true; - parent.ScheduleGroupForTerseUpdate(); + part.OffsetPosition = (Vector3)toPos; +// SceneObjectGroup parent = part.ParentGroup; +// parent.HasGroupChanged = true; +// parent.ScheduleGroupForTerseUpdate(); + part.ScheduleTerseUpdate(); } } @@ -2395,13 +2805,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { if (part.ParentGroup.IsAttachment) - { pos = part.AttachedPos; - } else - { pos = part.AbsolutePosition; - } } // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); @@ -2414,7 +2820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // try to let this work as in SL... - if (m_host.ParentID == 0) + if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(m_host, rot); @@ -2428,35 +2834,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); } } + + ScriptSleep(m_sleepMsOnSetRot); } public void llSetLocalRot(LSL_Rotation rot) { m_host.AddScriptLPS(1); SetRot(m_host, rot); + ScriptSleep(m_sleepMsOnSetLocalRot); } protected void SetRot(SceneObjectPart part, Quaternion rot) { - part.UpdateRotation(rot); - // Update rotation does not move the object in the physics scene if it's a linkset. - -//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type -// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; - - // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line - // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt - // It's perfectly okay when the object is not an active physical body though. - // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against - // but only if the object is not physial and active. This is important for rotating doors. - // without the absoluteposition = absoluteposition happening, the doors do not move in the physics - // scene + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + + bool isroot = (part == part.ParentGroup.RootPart); + bool isphys; + PhysicsActor pa = part.PhysActor; - if (pa != null && !pa.IsPhysical) + // keep using physactor ideia of isphysical + // it should be SOP ideia of that + // not much of a issue with ubOde + if (pa != null && pa.IsPhysical) + isphys = true; + else + isphys = false; + + // SL doesn't let scripts rotate root of physical linksets + if (isroot && isphys) + return; + + part.UpdateRotation(rot); + + // Update rotation does not move the object in the physics engine if it's a non physical linkset + // so do a nasty update of parts positions if is a root part rotation + if (isroot && pa != null) // with if above implies non physical root part { part.ParentGroup.ResetChildPrimPhysicsPositions(); } + else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part + { + // List sittingavas = part.ParentGroup.GetLinkedAvatars(); + List sittingavas = part.ParentGroup.GetSittingAvatars(); + if (sittingavas.Count > 0) + { + foreach (ScenePresence av in sittingavas) + { + if (isroot || part.LocalId == av.ParentID) + av.SendTerseUpdateToAllClients(); + } + } + } } /// @@ -2473,6 +2904,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); Quaternion q = m_host.GetWorldRotation(); + + if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0) + { + ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); + if (avatar != null) + { + if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) + q = avatar.CameraRotation * q; // Mouselook + else + q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate + } + } + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } @@ -2500,14 +2944,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Rotation(q); } - return new LSL_Rotation(part.GetWorldRotation()); + q = part.GetWorldRotation(); + if (part.ParentGroup.AttachmentPoint != 0) + { + ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); + if (avatar != null) + { + if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) + q = avatar.CameraRotation * q; // Mouselook + else + q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate + } + } + + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } public LSL_Rotation llGetLocalRot() { - m_host.AddScriptLPS(1); + return GetPartLocalRot(m_host); + } - return new LSL_Rotation(m_host.RotationOffset); + private LSL_Rotation GetPartLocalRot(SceneObjectPart part) + { + m_host.AddScriptLPS(1); + Quaternion rot = part.RotationOffset; + return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); } public void llSetForce(LSL_Vector force, int local) @@ -2537,32 +2999,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return force; } - public void llSetVelocity(LSL_Vector velocity, int local) + public void llSetVelocity(LSL_Vector vel, int local) { m_host.AddScriptLPS(1); - - if (!m_host.ParentGroup.IsDeleted) - { - if (local != 0) - velocity *= llGetRot(); - - m_host.ParentGroup.RootPart.Velocity = velocity; - } + m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); } - public void llSetAngularVelocity(LSL_Vector angularVelocity, int local) + public void llSetAngularVelocity(LSL_Vector avel, int local) { m_host.AddScriptLPS(1); - - if (!m_host.ParentGroup.IsDeleted) - { - if (local != 0) - angularVelocity *= llGetRot(); - - m_host.ParentGroup.RootPart.AngularVelocity = angularVelocity; - } + m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); } - public LSL_Integer llTarget(LSL_Vector position, double range) { m_host.AddScriptLPS(1); @@ -2613,16 +3060,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.ApplyImpulse(v, local != 0); } + public void llApplyRotationalImpulse(LSL_Vector force, int local) { m_host.AddScriptLPS(1); - m_host.ApplyAngularImpulse(force, local != 0); + m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); } public void llSetTorque(LSL_Vector torque, int local) { m_host.AddScriptLPS(1); - m_host.SetAngularImpulse(torque, local != 0); + m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); } public LSL_Vector llGetTorque() @@ -2639,20 +3087,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api llSetTorque(torque, local); } + public LSL_Vector llGetVel() { m_host.AddScriptLPS(1); - Vector3 vel; + Vector3 vel = Vector3.Zero; if (m_host.ParentGroup.IsAttachment) { ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); - vel = avatar.GetWorldVelocity(); + if (avatar != null) + vel = avatar.GetWorldVelocity(); } else { - vel = m_host.Velocity; + vel = m_host.ParentGroup.RootPart.Velocity; } return new LSL_Vector(vel); @@ -2668,8 +3118,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetOmega() { m_host.AddScriptLPS(1); - - return new LSL_Vector(m_host.AngularVelocity); + Vector3 avel = m_host.AngularVelocity; + return new LSL_Vector(avel.X, avel.Y, avel.Z); } public LSL_Float llGetTimeOfDay() @@ -2687,22 +3137,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetTime() { m_host.AddScriptLPS(1); - TimeSpan ScriptTime = DateTime.Now - m_timer; - return (double)(ScriptTime.TotalMilliseconds / 1000); + double ScriptTime = Util.GetTimeStampMS() - m_timer; + return (float)Math.Round((ScriptTime / 1000.0), 3); } public void llResetTime() { m_host.AddScriptLPS(1); - m_timer = DateTime.Now; + m_timer = Util.GetTimeStampMS(); } public LSL_Float llGetAndResetTime() { m_host.AddScriptLPS(1); - TimeSpan ScriptTime = DateTime.Now - m_timer; - m_timer = DateTime.Now; - return (double)(ScriptTime.TotalMilliseconds / 1000); + double now = Util.GetTimeStampMS(); + double ScriptTime = now - m_timer; + m_timer = now; + return (float)Math.Round((ScriptTime / 1000.0), 3); } public void llSound(string sound, double volume, int queue, int loop) @@ -2722,8 +3173,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_SoundModule.SendSound( m_host.UUID, - ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), - volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None, + ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), + volume, false, 0, 0, false, false); } } @@ -2734,7 +3185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), - volume, 20, false); + volume, 20, false,false); } } @@ -2744,16 +3195,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_SoundModule != null) { m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), - volume, 20, true); + volume, 20, true, false); } } public void llLoopSoundSlave(string sound, double volume) { m_host.AddScriptLPS(1); - lock (m_host.ParentGroup.LoopSoundSlavePrims) + if (m_SoundModule != null) { - m_host.ParentGroup.LoopSoundSlavePrims.Add(m_host); + m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), + volume, 20, false, true); } } @@ -2795,6 +3247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0); + ScriptSleep(m_sleepMsOnPreloadSound); } /// @@ -3027,7 +3480,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return src.ToLower(); } - public void llGiveMoney(string destination, int amount) + public LSL_Integer llGiveMoney(string destination, int amount) { Util.FireAndForget(x => { @@ -3058,69 +3511,86 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + string reason; money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); + + m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero, out reason); }, null, "LSL_Api.llGiveMoney"); + + return 0; } public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { m_host.AddScriptLPS(1); Deprecated("llMakeExplosion", "Use llParticleSystem instead"); + ScriptSleep(m_sleepMsOnMakeExplosion); } public void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset) { m_host.AddScriptLPS(1); Deprecated("llMakeFountain", "Use llParticleSystem instead"); + ScriptSleep(m_sleepMsOnMakeFountain); } public void llMakeSmoke(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { m_host.AddScriptLPS(1); Deprecated("llMakeSmoke", "Use llParticleSystem instead"); + ScriptSleep(m_sleepMsOnMakeSmoke); } public void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { m_host.AddScriptLPS(1); Deprecated("llMakeFire", "Use llParticleSystem instead"); + ScriptSleep(m_sleepMsOnMakeFire); } public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) { + doObjectRez(inventory, pos, vel, rot, param, true); + } + + public void doObjectRez(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param, bool atRoot) + { m_host.AddScriptLPS(1); + if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) + return; - Util.FireAndForget(x => - { - if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) - return; + float dist = (float)llVecDist(llGetPos(), pos); - float dist = (float)llVecDist(llGetPos(), pos); + if (dist > m_ScriptDistanceFactor * 10.0f) + return; - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); - if (item == null) - { - Error("llRezAtRoot", "Can't find object '" + inventory + "'"); - return; - } + if (item == null) + { + Error("llRez(AtRoot/Object)", "Can't find object '" + inventory + "'"); + return; + } - if (item.InvType != (int)InventoryType.Object) - { - Error("llRezAtRoot", "Can't create requested object; object is missing from database"); - return; - } + if (item.InvType != (int)InventoryType.Object) + { + Error("llRez(AtRoot/Object)", "Can't create requested object; object is missing from database"); + return; + } - // need the magnitude later - // float velmag = (float)Util.GetMagnitude(llvel); + Util.FireAndForget(x => + { - List new_groups = World.RezObject(m_host, item, pos, rot, vel, param); + Quaternion wrot = rot; + wrot.Normalize(); + List new_groups = World.RezObject(m_host, item, pos, wrot, vel, param, atRoot); // If either of these are null, then there was an unknown error. if (new_groups == null) return; + bool notAttachment = !m_host.ParentGroup.IsAttachment; + foreach (SceneObjectGroup group in new_groups) { // objects rezzed with this method are die_at_edge by default. @@ -3134,58 +3604,79 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api group.RootPart.UUID.ToString()) }, new DetectParams[0])); - float groupmass = group.GetMass(); + if (notAttachment) + { + float groupmass = group.GetMass(); - PhysicsActor pa = group.RootPart.PhysActor; + PhysicsActor pa = group.RootPart.PhysActor; - //Recoil. - if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) - { - Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; - if (recoil != Vector3.Zero) + //Recoil. + if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) { - llApplyImpulse(recoil, 0); + Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; + if (recoil != Vector3.Zero) + { + llApplyImpulse(recoil, 0); + } } } - // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) - } - }, null, "LSL_Api.llRezAtRoot"); + } + }, null, "LSL_Api.doObjectRez"); + + //ScriptSleep((int)((groupmass * velmag) / 10)); + ScriptSleep(m_sleepMsOnRezAtRoot); } public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) { - llRezAtRoot(inventory, pos, vel, rot, param); + doObjectRez(inventory, pos, vel, rot, param, false); } public void llLookAt(LSL_Vector target, double strength, double damping) { m_host.AddScriptLPS(1); - // Determine where we are looking from + + // Get the normalized vector to the target LSL_Vector from = llGetPos(); - // normalized direction to target + // normalized direction to target LSL_Vector dir = llVecNorm(target - from); + // use vertical to help compute left axis - LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0); +// LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0); // find normalized left axis parallel to horizon - LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir)); +// LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir)); + + LSL_Vector left = new LSL_Vector(-dir.y, dir.x, 0.0f); + left = llVecNorm(left); // make up orthogonal to left and dir - up = LSL_Vector.Cross(dir, left); + LSL_Vector up = LSL_Vector.Cross(dir, left); // compute rotation based on orthogonal axes + // and rotate so Z points to target with X below horizont LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up); - // Per discussion with Melanie, for non-physical objects llLookAt appears to simply - // set the rotation of the object, copy that behavior - PhysicsActor pa = m_host.PhysActor; + SceneObjectGroup sog = m_host.ParentGroup; + if(sog == null || sog.IsDeleted) + return; - if (m_host.ParentGroup.IsAttachment || strength == 0 || pa == null || !pa.IsPhysical) + if (!sog.UsesPhysics || sog.IsAttachment) { - llSetRot(rot); + // Do nothing if either value is 0 (this has been checked in SL) + if (strength <= 0.0 || damping <= 0.0) + return; + + llSetLocalRot(rot); } else { - m_host.StartLookAt(rot, (float)strength, (float)damping); + if (strength == 0) + { + llSetLocalRot(rot); + return; + } + + sog.StartLookAt(rot, (float)strength, (float)damping); } } @@ -3231,22 +3722,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - if (m_host.IsRoot) - { + // new SL always returns object mass +// if (m_host.IsRoot) +// { return m_host.ParentGroup.GetMass(); - } - else - { - return m_host.GetMass(); - } +// } +// else +// { +// return m_host.GetMass(); +// } } } public LSL_Float llGetMassMKS() { - // this is what the wiki says it does! - // http://wiki.secondlife.com/wiki/LlGetMassMKS - return llGetMass() * 100.0; + return 100f * llGetMass(); } public void llCollisionFilter(string name, string id, int accept) @@ -3296,7 +3786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // Unregister controls from Presence presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); - // Remove Take Control permission. + // Remove Take Control permission. m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; } } @@ -3355,9 +3845,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); -// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) -// return; - if (m_item.PermsGranter != m_host.OwnerID) return; @@ -3401,6 +3888,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llInstantMessage(string user, string message) { m_host.AddScriptLPS(1); + UUID result; + if (!UUID.TryParse(user, out result) || result == UUID.Zero) + { + Error("llInstantMessage","An invalid key was passed to llInstantMessage"); + ScriptSleep(2000); + return; + } // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent, @@ -3411,31 +3905,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // TODO: figure out values for client, fromSession, and imSessionID // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); + UUID friendTransactionID = UUID.Random(); + + //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); GridInstantMessage msg = new GridInstantMessage(); msg.fromAgentID = new Guid(m_host.OwnerID.ToString()); // fromAgentID.Guid; msg.toAgentID = new Guid(user); // toAgentID.Guid; msg.imSessionID = new Guid(m_host.UUID.ToString()); // This is the item we're mucking with here -// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); -// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); - msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; - //if (client != null) - //{ - msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; - //} - //else - //{ - // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it - //} - // Cap the message length at 1024. + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; + if (message != null && message.Length > 1024) msg.message = message.Substring(0, 1024); else msg.message = message; - msg.dialog = (byte)19; // messgage from script ??? // dialog; + msg.dialog = (byte)19; // MessageFromObject msg.fromGroup = false;// fromGroup; msg.offline = (byte)0; //offline; - msg.ParentEstateID = 0; //ParentEstateID; + msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; msg.Position = new Vector3(m_host.AbsolutePosition); msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; @@ -3452,6 +3940,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); } + + ScriptSleep(m_sleepMsOnInstantMessage); } public void llEmail(string address, string subject, string message) @@ -3489,6 +3979,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } emailModule.SendEmail(m_host.UUID, address, subject, message); + ScriptSleep(m_sleepMsOnEmail); } public void llGetNextEmail(string address, string subject) @@ -3551,25 +4042,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.PhysActor != null) + PIDHoverType hoverType = PIDHoverType.Ground; + if (water != 0) { - PIDHoverType hoverType = PIDHoverType.Ground; - if (water != 0) - { - hoverType = PIDHoverType.GroundAndWater; - } - - m_host.SetHoverHeight((float)height, hoverType, (float)tau); + hoverType = PIDHoverType.GroundAndWater; } + m_host.SetHoverHeight((float)height, hoverType, (float)tau); } public void llStopHover() { m_host.AddScriptLPS(1); - if (m_host.PhysActor != null) - { - m_host.SetHoverHeight(0f, PIDHoverType.Ground, 0f); - } + m_host.SetHoverHeight(0f, PIDHoverType.Ground, 0f); } public void llMinEventDelay(double delay) @@ -3598,15 +4082,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior - PhysicsActor pa = m_host.PhysActor; + SceneObjectGroup sog = m_host.ParentGroup; + if(sog == null || sog.IsDeleted) + return; - if (strength == 0 || pa == null || !pa.IsPhysical) + if (strength == 0 || !sog.UsesPhysics || sog.IsAttachment) { llSetLocalRot(target); } else { - m_host.RotLookAt(target, (float)strength, (float)damping); + sog.RotLookAt(target, (float)strength, (float)damping); } } @@ -3735,7 +4221,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | ScriptBaseClass.PERMISSION_TRACK_CAMERA | - ScriptBaseClass.PERMISSION_ATTACH; + ScriptBaseClass.PERMISSION_ATTACH | + ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS; } else { @@ -3752,15 +4239,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (World.GetExtraSetting("auto_grant_attach_perms") == "true") implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; } + if (World.GetExtraSetting("auto_grant_all_perms") == "true") + { + implicitPerms = perm; + } } if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = perm; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; + m_host.TaskInventory[m_item.ItemID].PermsMask = perm; + m_host.TaskInventory.LockItemsForWrite(false); m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( "run_time_permissions", new Object[] { @@ -3771,7 +4261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } ScenePresence presence = World.GetScenePresence(agentID); - + if (presence != null) { // If permissions are being requested from an NPC and were not implicitly granted above then @@ -3804,11 +4294,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!m_waitingForScriptAnswer) { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = 0; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; + m_host.TaskInventory[m_item.ItemID].PermsMask = 0; + m_host.TaskInventory.LockItemsForWrite(false); presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; m_waitingForScriptAnswer=true; @@ -3837,14 +4326,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); - lock (m_host.TaskInventory) - { - m_host.TaskInventory[m_item.ItemID].PermsMask = answer; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[m_item.ItemID].PermsMask = answer; + m_host.TaskInventory.LockItemsForWrite(false); - m_ScriptEngine.PostScriptEvent( - m_item.ItemID, - new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); + m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( + "run_time_permissions", new Object[] { + new LSL_Integer(answer) }, + new DetectParams[0])); } public LSL_String llGetPermissionsKey() @@ -3883,15 +4372,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLinkColor(int linknumber, LSL_Vector color, int face) { List parts = GetLinkParts(linknumber); - - foreach (SceneObjectPart part in parts) - part.SetFaceColorAlpha(face, color, null); + if (parts.Count > 0) + { + try + { + foreach (SceneObjectPart part in parts) + part.SetFaceColorAlpha(face, color, null); + } + finally { } + } } public void llCreateLink(string target, int parent) { m_host.AddScriptLPS(1); + UUID targetID; + + if (!UUID.TryParse(target, out targetID)) + return; + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { @@ -3907,9 +4407,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID targetID; if (!UUID.TryParse(target, out targetID)) - return; + return; SceneObjectPart targetPart = World.GetSceneObjectPart((UUID)targetID); + if (targetPart == null) + return; if (targetPart.ParentGroup.AttachmentPoint != 0) return; // Fail silently if attached @@ -3919,24 +4421,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectGroup parentPrim = null, childPrim = null; - if (targetPart != null) + if (parent != 0) { - if (parent != 0) - { - parentPrim = m_host.ParentGroup; - childPrim = targetPart.ParentGroup; - } - else - { - parentPrim = targetPart.ParentGroup; - childPrim = m_host.ParentGroup; - } - - // Required for linking - childPrim.RootPart.ClearUpdateSchedule(); - parentPrim.LinkToGroup(childPrim, true); + parentPrim = m_host.ParentGroup; + childPrim = targetPart.ParentGroup; + } + else + { + parentPrim = targetPart.ParentGroup; + childPrim = m_host.ParentGroup; } + // Required for linking + childPrim.RootPart.ClearUpdateSchedule(); + parentPrim.LinkToGroup(childPrim, true); + + parentPrim.TriggerScriptChangedEvent(Changed.LINK); parentPrim.RootPart.CreateSelected = true; parentPrim.HasGroupChanged = true; @@ -3949,6 +4449,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (client != null) parentPrim.SendPropertiesToClient(client); + + ScriptSleep(m_sleepMsOnCreateLink); } public void llBreakLink(int linknum) @@ -4005,10 +4507,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Restructuring Multiple Prims. List parts = new List(parentPrim.Parts); parts.Remove(parentPrim.RootPart); - foreach (SceneObjectPart part in parts) + if (parts.Count > 0) { - parentPrim.DelinkFromGroup(part.LocalId, true); - } + try + { + foreach (SceneObjectPart part in parts) + { + parentPrim.DelinkFromGroup(part.LocalId, true); + } + } + finally { } + } + parentPrim.HasGroupChanged = true; parentPrim.ScheduleGroupForFullUpdate(); parentPrim.TriggerScriptChangedEvent(Changed.LINK); @@ -4017,12 +4527,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { SceneObjectPart newRoot = parts[0]; parts.Remove(newRoot); - foreach (SceneObjectPart part in parts) + + try { - // Required for linking - part.ClearUpdateSchedule(); - newRoot.ParentGroup.LinkToGroup(part.ParentGroup); + foreach (SceneObjectPart part in parts) + { + part.ClearUpdateSchedule(); + newRoot.ParentGroup.LinkToGroup(part.ParentGroup); + } } + finally { } + newRoot.ParentGroup.HasGroupChanged = true; newRoot.ParentGroup.ScheduleGroupForFullUpdate(); } @@ -4043,13 +4558,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 + TaskInventoryItem item = m_item; + + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { - Error("llBreakAllLinks", "PERMISSION_CHANGE_LINKS permission not set"); + Error("llBreakAllLinks","Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); return; } - BreakAllLinks(); } @@ -4074,13 +4590,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLinkKey(int linknum) { m_host.AddScriptLPS(1); + SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); + if (part != null) + { + return part.UUID.ToString(); + } + else + { + if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) + { + linknum -= (m_host.ParentGroup.PrimCount) + 1; - ISceneEntity entity = GetLinkEntity(m_host, linknum); + if (linknum < 0) + return UUID.Zero.ToString(); - if (entity != null) - return entity.UUID.ToString(); - else - return ScriptBaseClass.NULL_KEY; + List avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); + if (avatars.Count > linknum) + { + return avatars[linknum].UUID.ToString(); + } + } + return UUID.Zero.ToString(); + } } /// @@ -4139,17 +4670,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); int count = 0; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Type == type || type == -1) { - if (inv.Value.Type == type || type == -1) - { - count = count + 1; - } + count = count + 1; } } + m_host.TaskInventory.LockItemsForRead(false); return count; } @@ -4158,16 +4688,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); ArrayList keys = new ArrayList(); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Type == type || type == -1) { - if (inv.Value.Type == type || type == -1) - { - keys.Add(inv.Value.Name); - } + keys.Add(inv.Value.Name); } } + m_host.TaskInventory.LockItemsForRead(false); if (keys.Count == 0) { @@ -4237,35 +4766,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + // destination is an avatar string message; InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId, out message); if (agentItem == null) { - llSay(0, message); + llSay(0, message); return; } - if (m_TransferModule != null) - { - byte[] bucket = new byte[1]; - bucket[0] = (byte)item.Type; + byte[] bucket = new byte[1]; + bucket[0] = (byte)item.Type; + //byte[] objBytes = agentItem.ID.GetBytes(); + //Array.Copy(objBytes, 0, bucket, 1, 16); + + GridInstantMessage msg = new GridInstantMessage(World, + m_host.OwnerID, m_host.Name, destId, + (byte)InstantMessageDialog.TaskInventoryOffered, + false, item.Name+". "+m_host.Name+" is located at "+ + World.RegionInfo.RegionName+" "+ + m_host.AbsolutePosition.ToString(), + agentItem.ID, true, m_host.AbsolutePosition, + bucket, true); - GridInstantMessage msg = new GridInstantMessage(World, - m_host.OwnerID, m_host.Name, destId, - (byte)InstantMessageDialog.TaskInventoryOffered, - false, item.Name+". "+m_host.Name+" is located at "+ - World.RegionInfo.RegionName+" "+ - m_host.AbsolutePosition.ToString(), - agentItem.ID, true, m_host.AbsolutePosition, - bucket, true); + ScenePresence sp; - m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + if (World.TryGetScenePresence(destId, out sp)) + { + sp.ControllingClient.SendInstantMessage(msg); + } + else + { + if (m_TransferModule != null) + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); } + + //This delay should only occur when giving inventory to avatars. + ScriptSleep(m_sleepMsOnGiveInventory); } } + [DebuggerNonUserCode] public void llRemoveInventory(string name) { m_host.AddScriptLPS(1); @@ -4285,20 +4828,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); Vector3 av3 = Util.Clip(color, 0.0f, 1.0f); - if (text.Length > 254) - text = text.Remove(254); - byte[] data; - do - { - data = Util.UTF8.GetBytes(text); - if (data.Length > 254) - text = text.Substring(0, text.Length - 1); - } while (data.Length > 254); - + data = Util.StringToBytes256(text); + text = Util.UTF8.GetString(data); m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); - //m_host.ParentGroup.HasGroupChanged = true; - //m_host.ParentGroup.ScheduleGroupForFullUpdate(); } public LSL_Float llWater(LSL_Vector offset) @@ -4320,14 +4853,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - UUID uuid = (UUID)id; - PresenceInfo pinfo = null; - UserAccount account; - - UserInfoCacheEntry ce; - - lock (m_userInfoCache) + UUID uuid; + if (UUID.TryParse(id, out uuid)) { + PresenceInfo pinfo = null; + UserAccount account; + + UserInfoCacheEntry ce; if (!m_userInfoCache.TryGetValue(uuid, out ce)) { account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); @@ -4353,7 +4885,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ce.time = Util.EnvironmentTickCount(); ce.account = account; ce.pinfo = pinfo; - m_userInfoCache[uuid] = ce; } else @@ -4362,77 +4893,78 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return UUID.Zero.ToString(); account = ce.account; + pinfo = ce.pinfo; + } - if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) - >= LlRequestAgentDataCacheTimeoutMs) + if (Util.EnvironmentTickCount() < ce.time || + (Util.EnvironmentTickCount() - ce.time) >= LlRequestAgentDataCacheTimeoutMs) + { + PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); + if (pinfos != null && pinfos.Length > 0) { - PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); - if (pinfos != null && pinfos.Length > 0) + foreach (PresenceInfo p in pinfos) { - foreach (PresenceInfo p in pinfos) + if (p.RegionID != UUID.Zero) { - if (p.RegionID != UUID.Zero) - { - pinfo = p; - } + pinfo = p; } } - else - { - pinfo = null; - } - - ce.time = Util.EnvironmentTickCount(); - ce.pinfo = pinfo; } else - { - pinfo = ce.pinfo; - } + pinfo = null; + + ce.time = Util.EnvironmentTickCount(); + ce.pinfo = pinfo; } - } - string reply = String.Empty; + string reply = String.Empty; - switch (data) - { - case ScriptBaseClass.DATA_ONLINE: - if (pinfo != null && pinfo.RegionID != UUID.Zero) - reply = "1"; - else - reply = "0"; - break; - case ScriptBaseClass.DATA_NAME: // (First Last) - reply = account.FirstName + " " + account.LastName; - break; - case ScriptBaseClass.DATA_BORN: // (YYYY-MM-DD) - DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); - born = born.AddSeconds(account.Created); - reply = born.ToString("yyyy-MM-dd"); - break; - case ScriptBaseClass.DATA_RATING: // (0,0,0,0,0,0) - reply = "0,0,0,0,0,0"; - break; - case 7: // DATA_USERLEVEL (integer). This is not available in LL and so has no constant. - reply = account.UserLevel.ToString(); - break; - case ScriptBaseClass.DATA_PAYINFO: // (0|1|2|3) - reply = "0"; - break; - default: - return UUID.Zero.ToString(); // Raise no event - } + switch (data) + { + case ScriptBaseClass.DATA_ONLINE: // DATA_ONLINE (0|1) + if (pinfo != null && pinfo.RegionID != UUID.Zero) + reply = "1"; + else + reply = "0"; + break; + case ScriptBaseClass.DATA_NAME: // DATA_NAME (First Last) + reply = account.FirstName + " " + account.LastName; + break; + case ScriptBaseClass.DATA_BORN: // DATA_BORN (YYYY-MM-DD) + DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); + born = born.AddSeconds(account.Created); + reply = born.ToString("yyyy-MM-dd"); + break; + case ScriptBaseClass.DATA_RATING: // DATA_RATING (0,0,0,0,0,0) + reply = "0,0,0,0,0,0"; + break; + case 7: // DATA_USERLEVEL (integer). This is not available in LL and so has no constant. + reply = account.UserLevel.ToString(); + break; + case ScriptBaseClass.DATA_PAYINFO: // DATA_PAYINFO (0|1|2|3) + reply = "0"; + break; + default: + return UUID.Zero.ToString(); // Raise no event + } - UUID rq = UUID.Random(); + UUID rq = UUID.Random(); - UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_host.LocalId, - m_item.ItemID, rq.ToString()); + UUID tid = AsyncCommands. + DataserverPlugin.RegisterRequest(m_host.LocalId, + m_item.ItemID, rq.ToString()); - AsyncCommands. - DataserverPlugin.DataserverReply(rq.ToString(), reply); + AsyncCommands. + DataserverPlugin.DataserverReply(rq.ToString(), reply); - return tid.ToString(); + ScriptSleep(m_sleepMsOnRequestAgentData); + return tid.ToString(); + } + else + { + Error("llRequestAgentData","Invalid UUID passed to llRequestAgentData."); + } + return ""; } public LSL_String llRequestInventoryData(string name) @@ -4464,10 +4996,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api reply); }); + ScriptSleep(m_sleepMsOnRequestInventoryData); return tid.ToString(); } } + ScriptSleep(m_sleepMsOnRequestInventoryData); return String.Empty; } @@ -4484,15 +5018,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(agent, out agentId)) { ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null) + if (presence != null && presence.PresenceType != PresenceType.Npc) { + // agent must not be a god + if (presence.GodController.UserLevel >= 200) return; + // agent must be over the owners land if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) { - World.TeleportClientHome(agentId, presence.ControllingClient); + if (!World.TeleportClientHome(agentId, presence.ControllingClient)) + { + // They can't be teleported home for some reason + GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6")); + if (regionInfo != null) + { + World.RequestTeleportLocation( + presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, + (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); + } + } } } } + + ScriptSleep(m_sleepMsOnSetDamage); } public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt) @@ -4505,20 +5054,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScenePresence presence = World.GetScenePresence(agentId); if (presence != null && presence.PresenceType != PresenceType.Npc) { - // agent must not be a god - if (presence.GodLevel >= 200) return; - if (destination == String.Empty) destination = World.RegionInfo.RegionName; - // agent must be over the owners land - if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) + if (m_item.PermsGranter == agentId) + { + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) + { + DoLLTeleport(presence, destination, targetPos, targetLookAt); + } + } + + // agent must be wearing the object + if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) { DoLLTeleport(presence, destination, targetPos, targetLookAt); } - else // or must be wearing the prim + else { - if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) + // agent must not be a god + if (presence.IsViewerUIGod) return; + + // agent must be over the owners land + ILandObject agentLand = World.LandChannel.GetLandObject(presence.AbsolutePosition); + ILandObject objectLand = World.LandChannel.GetLandObject(m_host.AbsolutePosition); + if (m_host.OwnerID == objectLand.LandData.OwnerID && m_host.OwnerID == agentLand.LandData.OwnerID) { DoLLTeleport(presence, destination, targetPos, targetLookAt); } @@ -4536,23 +5096,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(agent, out agentId)) { + // This function is owner only! + if (m_host.OwnerID != agentId) + return; + ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null && presence.PresenceType != PresenceType.Npc) + + if (presence == null || presence.PresenceType == PresenceType.Npc) + return; + + // Can't TP sitting avatars + if (presence.ParentID != 0) // Sitting + return; + + if (m_item.PermsGranter == agentId) { - // agent must not be a god - if (presence.GodLevel >= 200) return; + // If attached using llAttachToAvatarTemp, cowardly refuse + if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.ParentGroup.FromItemID == UUID.Zero) + return; - // agent must be over the owners land - if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) - { - World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); - } - else // or must be wearing the prim + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) { - if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) - { - World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); - } + World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); } } } @@ -4601,13 +5166,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { Error("llTextBox", "Empty message"); } - else if (message.Length > 512) + else if (Encoding.UTF8.GetByteCount(message) > 512) { - Error("llTextBox", "Message more than 512 characters"); + Error("llTextBox", "Message longer than 512 bytes"); } else { dm.SendTextBoxToUser(av, message, chatChannel, m_host.Name, m_host.UUID, m_host.OwnerID); + ScriptSleep(m_sleepMsOnTextBox); } } @@ -4625,9 +5191,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + if(impact_sound == "") + { + m_host.CollisionSoundVolume = (float)impact_volume; + m_host.CollisionSound = m_host.invalidCollisionSoundUUID; + m_host.CollisionSoundType = -1; // disable all sounds + m_host.aggregateScriptEvents(); + return; + } + // TODO: Parameter check logic required. - m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); - m_host.CollisionSoundVolume = (float)impact_volume; + UUID soundId = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); + if(soundId != UUID.Zero) + { + m_host.CollisionSound = soundId; + m_host.CollisionSoundVolume = (float)impact_volume; + m_host.CollisionSoundType = 1; + } + else + m_host.CollisionSoundType = -1; + + m_host.aggregateScriptEvents(); } public LSL_String llGetAnimation(string id) @@ -4641,14 +5225,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.RegionHandle == presence.RegionHandle) { - Dictionary animationstateNames = DefaultAvatarAnimations.AnimStateNames; - if (presence != null) { - AnimationSet currentAnims = presence.Animator.Animations; - string currentAnimationState = String.Empty; - if (animationstateNames.TryGetValue(currentAnims.ImplicitDefaultAnimation.AnimID, out currentAnimationState)) - return currentAnimationState; +// if (presence.SitGround) +// return "Sitting on Ground"; +// if (presence.ParentID != 0 || presence.ParentUUID != UUID.Zero) +// return "Sitting"; + + string movementAnimation = presence.Animator.CurrentMovementAnimation; + string lslMovementAnimation; + + if (MovementAnimationsForLSL.TryGetValue(movementAnimation, out lslMovementAnimation)) + return lslMovementAnimation; } } @@ -4712,7 +5300,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; // Pushee is in GodMode this pushing object isn't owned by them - if (avatar.GodLevel > 0 && m_host.OwnerID != targetID) + if (avatar.IsViewerUIGod && m_host.OwnerID != targetID) return; pusheeav = avatar; @@ -4796,7 +5384,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { float distance = (PusheePos - m_host.AbsolutePosition).Length(); float distance_term = distance * distance * distance; // Script Energy - float pusher_mass = m_host.GetMass(); + // use total object mass and not part + float pusher_mass = m_host.ParentGroup.GetMass(); float PUSH_ATTENUATION_DISTANCE = 17f; float PUSH_ATTENUATION_SCALE = 5f; @@ -4831,7 +5420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (local != 0) { - applied_linear_impulse *= m_host.GetWorldRotation(); +// applied_linear_impulse *= m_host.GetWorldRotation(); + applied_linear_impulse *= pusheeav.GetWorldRotation(); } pa.AddForce(applied_linear_impulse, true); @@ -4891,20 +5481,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - return GetNumberOfSides(m_host); + return m_host.GetNumberOfSides(); } protected int GetNumberOfSides(SceneObjectPart part) { - int sides = part.GetNumberOfSides(); - - if (part.GetPrimType() == PrimType.SPHERE && part.Shape.ProfileHollow > 0) - { - // Make up for a bug where LSL shows 4 sides rather than 2 - sides += 2; - } - - return sides; + return part.GetNumberOfSides(); } @@ -4959,20 +5541,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (Math.Abs(rot.s) > 1) // normalization needed - rot.Normalize(); + rot.Normalize(); double s = Math.Sqrt(1 - rot.s * rot.s); - if (s < 0.001) - { - return new LSL_Vector(1, 0, 0); - } - else - { - double invS = 1.0 / s; - if (rot.s < 0) invS = -invS; - return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); - } + if (s < 1e-8) + return new LSL_Vector(0, 0, 0); + + double invS = 1.0 / s; + if (rot.s < 0) + invS = -invS; + return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); } @@ -4981,11 +5559,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (Math.Abs(rot.s) > 1) // normalization needed - rot.Normalize(); + rot.Normalize(); double angle = 2 * Math.Acos(rot.s); - if (angle > Math.PI) + if (angle > Math.PI) angle = 2 * Math.PI - angle; return angle; @@ -5185,43 +5762,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (src == null) - { - return 0; - } - else - { - return src.Length; - } + return src.Length; } public LSL_Integer llList2Integer(LSL_List src, int index) { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } + if (index >= src.Length || index < 0) - { return 0; - } + + object item = src.Data[index]; // Vectors & Rotations always return zero in SL, but // keys don't always return zero, it seems to be a bit complex. - else if (src.Data[index] is LSL_Vector || - src.Data[index] is LSL_Rotation) - { + if (item is LSL_Vector || item is LSL_Rotation) return 0; - } + try { - - if (src.Data[index] is LSL_Integer) - return (LSL_Integer)src.Data[index]; - else if (src.Data[index] is LSL_Float) - return Convert.ToInt32(((LSL_Float)src.Data[index]).value); - return new LSL_Integer(src.Data[index].ToString()); + if (item is LSL_Integer) + return (LSL_Integer)item; + else if (item is LSL_Float) + return Convert.ToInt32(((LSL_Float)item).value);; + return new LSL_Integer(item.ToString()); } catch (FormatException) { @@ -5233,38 +5799,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } + if (index >= src.Length || index < 0) - { - return 0.0; - } + return 0; + + object item = src.Data[index]; // Vectors & Rotations always return zero in SL - else if (src.Data[index] is LSL_Vector || - src.Data[index] is LSL_Rotation) - { + if(item is LSL_Vector || item is LSL_Rotation) return 0; - } + // valid keys seem to get parsed as integers then converted to floats - else + if (item is LSL_Key) { UUID uuidt; - if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt)) - { - return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value); - } + string s = item.ToString(); + if(UUID.TryParse(s, out uuidt)) + return Convert.ToDouble(new LSL_Integer(s).value); +// we can't do this because a string is also a LSL_Key for now :( +// else +// return 0; } + try { - if (src.Data[index] is LSL_Integer) - return Convert.ToDouble(((LSL_Integer)src.Data[index]).value); - else if (src.Data[index] is LSL_Float) - return Convert.ToDouble(((LSL_Float)src.Data[index]).value); - else if (src.Data[index] is LSL_String) - return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); - return Convert.ToDouble(src.Data[index]); + if (item is LSL_Integer) + return Convert.ToDouble(((LSL_Integer)item).value); + else if (item is LSL_Float) + return Convert.ToDouble(((LSL_Float)item).value); + else if (item is LSL_String) + { + string str = ((LSL_String)item).m_string; + Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); + if (m != Match.Empty) + { + str = m.Value; + double d = 0.0; + if (!Double.TryParse(str, out d)) + return 0.0; + return d; + } + return 0.0; + } + return Convert.ToDouble(item); } catch (FormatException) { @@ -5276,13 +5854,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } + if (index >= src.Length || index < 0) - { return String.Empty; - } + return src.Data[index].ToString(); } @@ -5290,14 +5866,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } if (index >= src.Length || index < 0) - { - return ""; - } + return String.Empty; + + object item = src.Data[index]; // SL spits out an empty string for types other than key & string // At the time of patching, LSL_Key is currently LSL_String, @@ -5306,31 +5880,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // as it's own struct // NOTE: 3rd case is needed because a NULL_KEY comes through as // type 'obj' and wrongly returns "" - else if (!(src.Data[index] is LSL_String || - src.Data[index] is LSL_Key || - src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) + if (!(item is LSL_String || + item is LSL_Key || + item.ToString() == "00000000-0000-0000-0000-000000000000")) { - return ""; + return String.Empty; } - return src.Data[index].ToString(); + return item.ToString(); } public LSL_Vector llList2Vector(LSL_List src, int index) { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } + if (index >= src.Length || index < 0) - { return new LSL_Vector(0, 0, 0); - } - if (src.Data[index].GetType() == typeof(LSL_Vector)) - { - return (LSL_Vector)src.Data[index]; - } + + object item = src.Data[index]; + + if (item.GetType() == typeof(LSL_Vector)) + return (LSL_Vector)item; // SL spits always out ZERO_VECTOR for anything other than // strings or vectors. Although keys always return ZERO_VECTOR, @@ -5338,28 +5910,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // a string, a key as string and a string that by coincidence // is a string, so we're going to leave that up to the // LSL_Vector constructor. - else if (!(src.Data[index] is LSL_String || - src.Data[index] is LSL_Vector)) - { - return new LSL_Vector(0, 0, 0); - } - else - { - return new LSL_Vector(src.Data[index].ToString()); - } + if(item is LSL_Vector) + return (LSL_Vector) item; + + if (item is LSL_String) + return new LSL_Vector(item.ToString()); + + return new LSL_Vector(0, 0, 0); } public LSL_Rotation llList2Rot(LSL_List src, int index) { m_host.AddScriptLPS(1); if (index < 0) - { index = src.Length + index; - } + if (index >= src.Length || index < 0) - { return new LSL_Rotation(0, 0, 0, 1); - } + + object item = src.Data[index]; // SL spits always out ZERO_ROTATION for anything other than // strings or vectors. Although keys always return ZERO_ROTATION, @@ -5367,19 +5936,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // a string, a key as string and a string that by coincidence // is a string, so we're going to leave that up to the // LSL_Rotation constructor. - else if (!(src.Data[index] is LSL_String || - src.Data[index] is LSL_Rotation)) - { - return new LSL_Rotation(0, 0, 0, 1); - } - else if (src.Data[index].GetType() == typeof(LSL_Rotation)) - { - return (LSL_Rotation)src.Data[index]; - } - else - { + + if (item.GetType() == typeof(LSL_Rotation)) + return (LSL_Rotation)item; + + if (item is LSL_String) return new LSL_Rotation(src.Data[index].ToString()); - } + + return new LSL_Rotation(0, 0, 0, 1); } public LSL_List llList2List(LSL_List src, int start, int end) @@ -5567,7 +6131,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - else { + else + { object[] array = new object[src.Length]; Array.Copy(src.Data, 0, array, 0, src.Length); result = new LSL_List(array); @@ -5674,7 +6239,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetRegionAgentCount() { m_host.AddScriptLPS(1); - return new LSL_Integer(World.GetRootAgentCount()); + + int count = 0; + World.ForEachRootScenePresence(delegate(ScenePresence sp) { + count++; + }); + + return new LSL_Integer(count); } public LSL_Vector llGetRegionCorner() @@ -5742,10 +6313,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IUrlModule UrlModule = World.RequestModuleInterface(); return UrlModule.ExternalHostNameForLSL; } + else if (name == "region_max_prims") + { + return World.RegionInfo.ObjectCapacity.ToString(); + } + else if (name == "region_object_bonus") + { + return World.RegionInfo.RegionSettings.ObjectBonus.ToString(); + } else { return ""; } + } /// @@ -5821,17 +6401,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { for (int i = 0; i < length; i++) { + int needle = llGetListEntryType(test, 0).value; + int haystack = llGetListEntryType(src, i).value; + // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code // and so the comparison fails even if the LSL_Integer conceptually has the same value. // Therefore, here we test Equals on both the source and destination objects. // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). - if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) + if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))) { int j; for (j = 1; j < test.Length; j++) - if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) + { + needle = llGetListEntryType(test, j).value; + haystack = llGetListEntryType(src, i+j).value; + + if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))) break; + } if (j == test.Length) { @@ -5869,64 +6457,61 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - // edge will be used to pass the Region Coordinates offset - // we want to check for a neighboring sim - LSL_Vector edge = new LSL_Vector(0, 0, 0); + if(dir.x == 0 && dir.y == 0) + return 1; // SL wiki + + float rsx = World.RegionInfo.RegionSizeX; + float rsy = World.RegionInfo.RegionSizeY; + + // can understand what sl does if position is not in region, so do something :) + float px = (float)Util.Clamp(pos.x, 0.5, rsx - 0.5); + float py = (float)Util.Clamp(pos.y, 0.5, rsy - 0.5); + + float ex, ey; if (dir.x == 0) { - if (dir.y == 0) - { - // Direction vector is 0,0 so return - // false since we're staying in the sim - return 0; - } - else - { - // Y is the only valid direction - edge.y = dir.y / Math.Abs(dir.y); - } + ex = px; + ey = dir.y > 0 ? rsy + 1.0f : -1.0f; + } + else if(dir.y == 0) + { + ex = dir.x > 0 ? rsx + 1.0f : -1.0f; + ey = py; } else { - LSL_Float mag; - if (dir.x > 0) - { - mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x; - } - else - { - mag = (pos.x/dir.x); - } - - mag = Math.Abs(mag); + float dx = (float) dir.x; + float dy = (float) dir.y; - edge.y = pos.y + (dir.y * mag); + float t1 = dx * dx + dy * dy; + t1 = (float)Math.Sqrt(t1); + dx /= t1; + dy /= t1; - if (edge.y > World.RegionInfo.RegionSizeY || edge.y < 0) - { - // Y goes out of bounds first - edge.y = dir.y / Math.Abs(dir.y); - } + if(dx > 0) + t1 = (rsx + 1f - px)/dx; else - { - // X goes out of bounds first or its a corner exit - edge.y = 0; - edge.x = dir.x / Math.Abs(dir.x); - } - } + t1 = -(px + 1f)/dx; - List neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID); + float t2; + if(dy > 0) + t2 = (rsy + 1f - py)/dy; + else + t2 = -(py + 1f)/dy; - uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; - uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; + if(t1 > t2) + t1 = t2; - foreach (GridRegion sri in neighbors) - { - if (sri.RegionCoordX == neighborX && sri.RegionCoordY == neighborY) - return 0; + ex = px + t1 * dx; + ey = py + t1 * dy; } + ex += World.RegionInfo.WorldLocX; + ey += World.RegionInfo.WorldLocY; + + if(World.GridService.GetRegionByPosition(World.RegionInfo.ScopeID, (int)ex, (int)ey) != null) + return 0; return 1; } @@ -5980,6 +6565,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_AWAY; } + UUID busy = new UUID("efcf670c-2d18-8128-973a-034ebc806b67"); + UUID[] anims = agent.Animator.GetAnimationArray(); + if (Array.Exists(anims, a => { return a == busy; })) + { + flags |= ScriptBaseClass.AGENT_BUSY; + } + // seems to get unset, even if in mouselook, when avatar is sitting on a prim??? if ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) { @@ -6027,6 +6619,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_SITTING; } + if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0) + { + flags |= ScriptBaseClass.AGENT_MALE; + } + return flags; } @@ -6056,11 +6653,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// AGENT_LIST_PARCEL - all in the same parcel as the scripted object /// AGENT_LIST_PARCEL_OWNER - all in any parcel owned by the owner of the /// current parcel. + /// AGENT_LIST_EXCLUDENPC ignore NPCs (bit mask) /// public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options) { m_host.AddScriptLPS(1); + // do our bit masks part + bool noNPC = (scope & ScriptBaseClass.AGENT_LIST_EXCLUDENPC) !=0; + + // remove bit masks part + scope &= ~ ScriptBaseClass.AGENT_LIST_EXCLUDENPC; + // the constants are 1, 2 and 4 so bits are being set, but you // get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4 bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION; @@ -6101,8 +6705,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.ForEachRootScenePresence( delegate (ScenePresence ssp) { + if(noNPC && ssp.IsNPC) + return; + // Gods are not listed in SL - if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent) + if (!ssp.IsDeleted && !ssp.IsViewerUIGod && !ssp.IsChildAgent) { if (!regionWide) { @@ -6135,6 +6742,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); m_host.AdjustSoundGain(volume); + ScriptSleep(m_sleepMsOnAdjustSoundVolume); } public void llSetSoundRadius(double radius) @@ -6180,11 +6788,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List parts = GetLinkParts(linknumber); - foreach (SceneObjectPart part in parts) + try { - SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); + foreach (SceneObjectPart part in parts) + { + SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); + } } - } + finally + { + } + } private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate) { @@ -6236,10 +6850,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.OwnerID == land.LandData.OwnerID) { - World.TeleportClientHome(agentID, presence.ControllingClient); + Vector3 p = World.GetNearestAllowedPosition(presence, land); + presence.TeleportOnEject(p); + presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); } } } + ScriptSleep(m_sleepMsOnEjectFromLand); + } + + public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) + { + return ParseString2List(str, separators, in_spacers, false); } public LSL_Integer llOverMyLand(string id) @@ -6294,26 +6916,59 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - agentSize = GetAgentSize(avatar); +// agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); + Vector3 s = avatar.Appearance.AvatarSize; + agentSize = new LSL_Vector(s.X, s.Y, s.Z); } - return agentSize; } - public LSL_Integer llSameGroup(string agent) + public LSL_Integer llSameGroup(string id) { m_host.AddScriptLPS(1); - UUID agentId = new UUID(); - if (!UUID.TryParse(agent, out agentId)) - return new LSL_Integer(0); - ScenePresence presence = World.GetScenePresence(agentId); - if (presence == null || presence.IsChildAgent) // Return flase for child agents + UUID uuid = new UUID(); + if (!UUID.TryParse(id, out uuid)) return new LSL_Integer(0); - IClientAPI client = presence.ControllingClient; - if (m_host.GroupID == client.ActiveGroupId) + + // Check if it's a group key + if (uuid == m_host.ParentGroup.RootPart.GroupID) return new LSL_Integer(1); - else + + // Handle object case + SceneObjectPart part = World.GetSceneObjectPart(uuid); + if (part != null) + { + + if(part.ParentGroup.IsAttachment) + { + uuid = part.ParentGroup.AttachedAvatar; + } + else + { + // This will handle both deed and non-deed and also the no + // group case + if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID) + return new LSL_Integer(1); + + return new LSL_Integer(0); + } + } + + // Handle the case where id names an avatar + ScenePresence presence = World.GetScenePresence(uuid); + if (presence != null) + { + if (presence.IsChildAgent) + return new LSL_Integer(0); + + IClientAPI client = presence.ControllingClient; + if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId) + return new LSL_Integer(1); + return new LSL_Integer(0); + } + + return new LSL_Integer(0); } public void llUnSit(string id) @@ -6441,6 +7096,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return m_host.ParentGroup.AttachmentPoint; } + public LSL_List llGetAttachedList(string id) + { + m_host.AddScriptLPS(1); + + ScenePresence av = World.GetScenePresence((UUID)id); + + if (av == null || av.IsDeleted) + return new LSL_List("NOT_FOUND"); + + if (av.IsChildAgent || av.IsInTransit) + return new LSL_List("NOT_ON_REGION"); + + LSL_List AttachmentsList = new LSL_List(); + List Attachments; + + Attachments = av.GetAttachments(); + + foreach (SceneObjectGroup Attachment in Attachments) + { + if(Attachment.HasPrivateAttachmentPoint) + continue; + AttachmentsList.Add(new LSL_Key(Attachment.UUID.ToString())); + } + + return AttachmentsList; + } + public virtual LSL_Integer llGetFreeMemory() { m_host.AddScriptLPS(1); @@ -7127,6 +7809,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) { + // LSL quaternions can normalize to 0, normal Quaternions can't. + if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) + rot.s = 1; // ZERO_ROTATION = 0,0,0,1 + part.SitTargetPosition = offset; part.SitTargetOrientation = rot; part.ParentGroup.HasGroupChanged = true; @@ -7166,11 +7852,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if(linknum == ScriptBaseClass.LINK_SET || - linknum == ScriptBaseClass.LINK_ALL_CHILDREN || - linknum == ScriptBaseClass.LINK_ALL_OTHERS) return UUID.Zero.ToString(); + linknum == ScriptBaseClass.LINK_ALL_CHILDREN || + linknum == ScriptBaseClass.LINK_ALL_OTHERS || + linknum == 0) + return UUID.Zero.ToString(); List parts = GetLinkParts(linknum); - if (parts.Count == 0) return UUID.Zero.ToString(); + if (parts.Count == 0) + return UUID.Zero.ToString(); return parts[0].SitTargetAvatar.ToString(); } @@ -7181,7 +7870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManagePasses, false)) { int expires = 0; if (hours != 0) @@ -7214,6 +7903,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } + ScriptSleep(m_sleepMsOnAddToLandPassList); } public void llSetTouchText(string text) @@ -7295,7 +7985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llScriptDanger(LSL_Vector pos) { m_host.AddScriptLPS(1); - bool result = World.ScriptDanger(m_host.LocalId, pos); + bool result = World.LSLScriptDanger(m_host, pos); if (result) { return 1; @@ -7304,7 +7994,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return 0; } - } public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel) @@ -7321,35 +8010,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Error("llDialog", "First parameter must be a key"); return; } - if (buttons.Length < 1) + + int length = buttons.Length; + if (length < 1) { Error("llDialog", "At least 1 button must be shown"); return; } - if (buttons.Length > 12) + if (length > 12) { Error("llDialog", "No more than 12 buttons can be shown"); return; } - string[] buts = new string[buttons.Length]; - for (int i = 0; i < buttons.Length; i++) + + if (message == string.Empty) + { + Error("llDialog", "Empty message"); + } + else if (Encoding.UTF8.GetByteCount(message) > 512) + { + Error("llDialog", "Message longer than 512 bytes"); + } + + string[] buts = new string[length]; + for (int i = 0; i < length; i++) { if (buttons.Data[i].ToString() == String.Empty) { Error("llDialog", "Button label cannot be blank"); return; } +/* if (buttons.Data[i].ToString().Length > 24) { Error("llDialog", "Button label cannot be longer than 24 characters"); return; } +*/ buts[i] = buttons.Data[i].ToString(); } dm.SendDialogToUser( av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts); + + ScriptSleep(m_sleepMsOnDialog); } public void llVolumeDetect(int detect) @@ -7364,6 +8069,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); Deprecated("llRemoteLoadScript", "Use llRemoteLoadScriptPin instead"); + ScriptSleep(m_sleepMsOnRemoteLoadScript); } public void llSetRemoteScriptAccessPin(int pin) @@ -7400,8 +8106,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - // the rest of the permission checks are done in RezScript, so check the pin there as well - World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); + SceneObjectPart dest = World.GetSceneObjectPart(destId); + if (dest != null) + { + if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) + { + // the rest of the permission checks are done in RezScript, so check the pin there as well + World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); + + if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0) + m_host.Inventory.RemoveInventoryItem(item.ItemID); + } + } + // this will cause the delay even if the script pin or permissions were wrong - seems ok + ScriptSleep(m_sleepMsOnRemoteLoadScriptPin); } public void llOpenRemoteDataChannel() @@ -7432,12 +8150,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj, new DetectParams[0])); } + ScriptSleep(m_sleepMsOnOpenRemoteDataChannel); } public LSL_String llSendRemoteData(string channel, string dest, int idata, string sdata) { m_host.AddScriptLPS(1); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); + ScriptSleep(m_sleepMsOnSendRemoteData); if (xmlrpcMod == null) return ""; return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString(); @@ -7449,6 +8169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null) xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata); + ScriptSleep(m_sleepMsOnRemoteDataReply); } public void llCloseRemoteDataChannel(string channel) @@ -7464,24 +8185,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null) xmlrpcMod.CloseXMLRPCChannel((UUID)channel); + ScriptSleep(m_sleepMsOnCloseRemoteDataChannel); } public LSL_String llMD5String(string src, int nonce) { m_host.AddScriptLPS(1); - return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); + return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); } public LSL_String llSHA1String(string src) { m_host.AddScriptLPS(1); - return Util.SHA1Hash(src).ToLower(); + return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); } protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return shapeBlock; if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && @@ -7586,6 +8310,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Prim type box, cylinder and prism. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; @@ -7639,6 +8366,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Prim type sphere. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); @@ -7685,6 +8415,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Prim type torus, tube and ring. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; @@ -7820,6 +8553,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Prim type sculpt. protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return; + ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); UUID sculptId; @@ -7842,7 +8578,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) { // default - type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; + type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; } part.Shape.SetSculptProperties((byte)type, sculptId); @@ -7855,6 +8591,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); SetLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams"); + + ScriptSleep(m_sleepMsOnSetPrimitiveParams); } public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) @@ -7862,6 +8600,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); + + ScriptSleep(m_sleepMsOnSetLinkPrimitiveParams); } public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) @@ -7871,9 +8611,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); } - protected void SetLinkPrimParams(int linknumber, LSL_List rules, string originFunc) + private void SetLinkPrimParams(int linknumber, LSL_List rules, string originFunc) { - SetEntityParams(GetLinkEntities(linknumber), rules, originFunc); + List parts = new List(); + List prims = GetLinkParts(linknumber); + List avatars = GetLinkAvatars(linknumber); + foreach (SceneObjectPart p in prims) + parts.Add(p); + foreach (ScenePresence p in avatars) + parts.Add(p); + + LSL_List remaining = new LSL_List(); + uint rulesParsed = 0; + + if (parts.Count > 0) + { + foreach (object part in parts) + { + if (part is SceneObjectPart) + remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); + else + remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); + } + + while (remaining.Length > 2) + { + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + parts.Clear(); + prims = GetLinkParts(linknumber); + avatars = GetLinkAvatars(linknumber); + foreach (SceneObjectPart p in prims) + parts.Add(p); + foreach (ScenePresence p in avatars) + parts.Add(p); + + remaining = new LSL_List(); + foreach (object part in parts) + { + if (part is SceneObjectPart) + remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); + else + remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); + } + } + } } protected void SetEntityParams(List entities, LSL_List rules, string originFunc) @@ -8052,11 +8834,81 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_List llGetPhysicsMaterial() + { + LSL_List result = new LSL_List(); + + result.Add(new LSL_Float(m_host.GravityModifier)); + result.Add(new LSL_Float(m_host.Restitution)); + result.Add(new LSL_Float(m_host.Friction)); + result.Add(new LSL_Float(m_host.Density)); + + return result; + } + + private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, + float material_density, float material_friction, + float material_restitution, float material_gravity_modifier) + { + ExtraPhysicsData physdata = new ExtraPhysicsData(); + physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; + physdata.Density = part.Density; + physdata.Friction = part.Friction; + physdata.Bounce = part.Restitution; + physdata.GravitationModifier = part.GravityModifier; + + if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) + physdata.Density = material_density; + if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) + physdata.Friction = material_friction; + if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) + physdata.Bounce = material_restitution; + if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) + physdata.GravitationModifier = material_gravity_modifier; + + part.UpdateExtraPhysics(physdata); + } + + public void llSetPhysicsMaterial(int material_bits, + LSL_Float material_gravity_modifier, LSL_Float material_restitution, + LSL_Float material_friction, LSL_Float material_density) + { + SetPhysicsMaterial(m_host, material_bits, (float)material_density, (float)material_friction, (float)material_restitution, (float)material_gravity_modifier); + } + + // vector up using libomv (c&p from sop ) + // vector up rotated by r + private Vector3 Zrot(Quaternion r) + { + double x, y, z, m; + + m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; + if (Math.Abs(1.0 - m) > 0.000001) + { + m = 1.0 / Math.Sqrt(m); + r.X *= (float)m; + r.Y *= (float)m; + r.Z *= (float)m; + r.W *= (float)m; + } + + x = 2 * (r.X * r.Z + r.Y * r.W); + y = 2 * (-r.X * r.W + r.Y * r.Z); + z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; + + return new Vector3((float)x, (float)y, (float)z); + } + protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return new LSL_List(); + int idx = 0; int idxStart = 0; + SceneObjectGroup parentgrp = part.ParentGroup; + bool positionChanged = false; LSL_Vector currentPosition = GetPartLocalPos(part); @@ -8092,8 +8944,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POS_LOCAL: arg #{1} - parameter 1 must be vector", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } + if (part.IsRoot && !part.ParentGroup.IsAttachment) + currentPosition = GetSetPosTarget(part, v, currentPosition, true); + else + currentPosition = GetSetPosTarget(part, v, currentPosition, false); positionChanged = true; - currentPosition = GetSetPosTarget(part, v, currentPosition); break; case ScriptBaseClass.PRIM_SIZE: @@ -8118,7 +8973,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_List(); } // try to let this work as in SL... - if (part.ParentID == 0) + if (part.ParentID == 0 || (part.ParentGroup != null && part == part.ParentGroup.RootPart)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, q); @@ -9119,7 +9974,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; - case ScriptBaseClass.PRIM_TEMP_ON_REZ: + case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: + if (remain < 5) + return new LSL_List(); + + int material_bits = rules.GetLSLIntegerItem(idx++); + float material_density = (float)rules.GetLSLFloatItem(idx++); + float material_friction = (float)rules.GetLSLFloatItem(idx++); + float material_restitution = (float)rules.GetLSLFloatItem(idx++); + float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); + + SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); + + break; + + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) return new LSL_List(); string temp = rules.Data[idx++].ToString(); @@ -9290,6 +10159,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateSlice((float)slice.x, (float)slice.y); break; + case ScriptBaseClass.PRIM_SIT_TARGET: + if (remain < 3) + return new LSL_List(); + + int active; + try + { + active = rules.GetLSLIntegerItem(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 1 must be integer", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + LSL_Vector offset; + try + { + offset = rules.GetVector3Item(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + LSL_Rotation sitrot; + try + { + sitrot = rules.GetQuaternionItem(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 3 must be rotation", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + + // not SL compatible since we don't have a independent flag to control active target but use the values of offset and rotation + if(active == 1) + { + if(offset.x == 0 && offset.y == 0 && offset.z == 0 && sitrot.s == 1.0) + offset.z = 1e-5f; // hack + SitTarget(part,offset,sitrot); + } + else if(active == 0) + SitTarget(part, Vector3.Zero , Quaternion.Identity); + + break; + case ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return new LSL_List(); @@ -9313,14 +10229,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part.ParentGroup.RootPart == part) { SceneObjectGroup parent = part.ParentGroup; - parent.UpdateGroupPosition(currentPosition); +// Util.FireAndForget(delegate(object x) { + parent.UpdateGroupPosition(currentPosition); +// }); } else { part.OffsetPosition = currentPosition; - SceneObjectGroup parent = part.ParentGroup; - parent.HasGroupChanged = true; - parent.ScheduleGroupForTerseUpdate(); +// SceneObjectGroup parent = part.ParentGroup; +// parent.HasGroupChanged = true; +// parent.ScheduleGroupForTerseUpdate(); + part.ScheduleTerseUpdate(); } } } @@ -9368,7 +10287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } break; - case ScriptBaseClass.PRIM_ROTATION: + case ScriptBaseClass.PRIM_ROTATION: if (remain < 1) return new LSL_List(); @@ -9387,7 +10306,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectPart parentPart = sp.ParentPart; if (parentPart != null) - sp.Rotation = m_host.GetWorldRotation() * inRot; + sp.Rotation = m_host.GetWorldRotation() * inRot; break; @@ -9431,7 +10350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api catch (InvalidCastException e) { Error( - originFunc, + originFunc, string.Format("Error running rule #{0}: arg #{1} - ", rulesParsed, idx - idxStart) + e.Message); } @@ -9472,9 +10391,104 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llXorBase64Strings(string str1, string str2) { + int padding = 0; + + string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + ScriptSleep(300); m_host.AddScriptLPS(1); - Deprecated("llXorBase64Strings", "Use llXorBase64 instead"); - return String.Empty; + + if (str1 == String.Empty) + return String.Empty; + if (str2 == String.Empty) + return str1; + + int len = str2.Length; + if ((len % 4) != 0) // LL is EVIL!!!! + { + while (str2.EndsWith("=")) + str2 = str2.Substring(0, str2.Length - 1); + + len = str2.Length; + int mod = len % 4; + + if (mod == 1) + str2 = str2.Substring(0, str2.Length - 1); + else if (mod == 2) + str2 += "=="; + else if (mod == 3) + str2 += "="; + } + + byte[] data1; + byte[] data2; + try + { + data1 = Convert.FromBase64String(str1); + data2 = Convert.FromBase64String(str2); + } + catch (Exception) + { + return new LSL_String(String.Empty); + } + + // For cases where the decoded length of s2 is greater + // than the decoded length of s1, simply perform a normal + // decode and XOR + // + /* + if (data2.Length >= data1.Length) + { + for (int pos = 0 ; pos < data1.Length ; pos++ ) + data1[pos] ^= data2[pos]; + + return Convert.ToBase64String(data1); + } + */ + + // Remove padding + while (str1.EndsWith("=")) + { + str1 = str1.Substring(0, str1.Length - 1); + padding++; + } + while (str2.EndsWith("=")) + str2 = str2.Substring(0, str2.Length - 1); + + byte[] d1 = new byte[str1.Length]; + byte[] d2 = new byte[str2.Length]; + + for (int i = 0 ; i < str1.Length ; i++) + { + int idx = b64.IndexOf(str1.Substring(i, 1)); + if (idx == -1) + idx = 0; + d1[i] = (byte)idx; + } + + for (int i = 0 ; i < str2.Length ; i++) + { + int idx = b64.IndexOf(str2.Substring(i, 1)); + if (idx == -1) + idx = 0; + d2[i] = (byte)idx; + } + + string output = String.Empty; + + for (int pos = 0 ; pos < d1.Length ; pos++) + output += b64[d1[pos] ^ d2[pos % d2.Length]]; + + // Here's a funny thing: LL blithely violate the base64 + // standard pretty much everywhere. Here, padding is + // added only if the first input string had it, rather + // than when the data actually needs it. This can result + // in invalid base64 being returned. Go figure. + + while (padding-- > 0) + output += "="; + + return output; } public void llRemoteDataSetRegion() @@ -9520,6 +10534,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; land.SetMusicUrl(url); + + ScriptSleep(m_sleepMsOnSetParcelMusicURL); } public LSL_String llGetParcelMusicURL() @@ -9615,188 +10631,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetBoundingBox(string obj) { m_host.AddScriptLPS(1); - - // Get target avatar if non-seated avatar or attachment, or prim and object UUID objID = UUID.Zero; - UUID.TryParse(obj, out objID); - ScenePresence agent = World.GetScenePresence(objID); - if (agent != null) - { - if (agent.ParentPart != null) - { - objID = agent.ParentPart.UUID; - agent = null; - } - } - SceneObjectGroup group = null; - SceneObjectPart target = World.GetSceneObjectPart(objID); - if (target != null) - { - group = target.ParentGroup; - if (group.IsAttachment) { - objID = group.AttachedAvatar; - agent = World.GetScenePresence(objID); - group = null; - target = null; - } - } - - // Initialize but break if no target LSL_List result = new LSL_List(); - int groupCount = 0; - int partCount = 0; - int vertexCount = 0; - if (target == null && agent == null) + + // If the ID is not valid, return null result + if (!UUID.TryParse(obj, out objID)) { result.Add(new LSL_Vector()); result.Add(new LSL_Vector()); - if (m_addStatsInGetBoundingBox) - result.Add(new LSL_Vector((float)groupCount, (float)partCount, (float)vertexCount)); return result; } - Vector3 minPosition = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); - Vector3 maxPosition = new Vector3(float.MinValue, float.MinValue, float.MinValue); - // Try to get a mesher - IRendering primMesher = null; - List renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); - if (renderers.Count > 0) - primMesher = RenderingLoader.LoadRenderer(renderers[0]); + // Check if this is an attached prim. If so, replace + // the UUID with the avatar UUID and report it's bounding box + SceneObjectPart part = World.GetSceneObjectPart(objID); + if (part != null && part.ParentGroup.IsAttachment) + objID = part.ParentGroup.AttachedAvatar; - // Get bounding box of just avatar, seated or not - if (agent != null) - { - bool hasParent = false; - Vector3 lower; - Vector3 upper; - BoundingBoxOfScenePresence(agent, out lower, out upper); - Vector3 offset = Vector3.Zero; - - // Since local bounding box unrotated and untilted, keep it simple - AddBoundingBoxOfSimpleBox(lower, upper, offset, agent.Rotation, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - partCount++; - groupCount++; - - // Return lower and upper bounding box corners - result.Add(new LSL_Vector(minPosition)); - result.Add(new LSL_Vector(maxPosition)); - if (m_addStatsInGetBoundingBox) - result.Add(new LSL_Vector((float)groupCount, (float)partCount, (float)vertexCount)); - return result; - } - // Get bounding box of object including seated avatars - else if (group != null) + // Find out if this is an avatar ID. If so, return it's box + ScenePresence presence = World.GetScenePresence(objID); + if (presence != null) { - // Merge bounding boxes of all parts (prims and mesh) - foreach (SceneObjectPart part in group.Parts) - { - bool hasParent = (!part.IsRoot); - // When requested or if no mesher, keep it simple - if (m_useSimpleBoxesInGetBoundingBox || primMesher == null) - { - AddBoundingBoxOfSimpleBox(part.Scale * -0.5f, part.Scale * 0.5f, part.OffsetPosition, part.RotationOffset, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - } - // Do the full mounty - else - { - Primitive omvPrim = part.Shape.ToOmvPrimitive(part.OffsetPosition, part.RotationOffset); - byte[] sculptAsset = null; - if (omvPrim.Sculpt != null) - sculptAsset = World.AssetService.GetData(omvPrim.Sculpt.SculptTexture.ToString()); - - // When part is mesh - // Quirk: Only imports as incompletely populated faceted mesh object, so needs an own handler. - if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type == SculptType.Mesh && sculptAsset != null) - { - AssetMesh meshAsset = new AssetMesh(omvPrim.Sculpt.SculptTexture, sculptAsset); - FacetedMesh mesh = null; - FacetedMesh.TryDecodeFromAsset(omvPrim, meshAsset, DetailLevel.Highest, out mesh); - meshAsset = null; - if (mesh != null) - { - AddBoundingBoxOfFacetedMesh(mesh, omvPrim, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - mesh = null; - } - } - - // When part is sculpt - // Quirk: Generated sculpt mesh is about 2.8% smaller in X and Y than visual sculpt. - else if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type != SculptType.Mesh && sculptAsset != null) - { - IJ2KDecoder imgDecoder = World.RequestModuleInterface(); - if (imgDecoder != null) - { - Image sculpt = imgDecoder.DecodeToImage(sculptAsset); - if (sculpt != null) - { - SimpleMesh mesh = primMesher.GenerateSimpleSculptMesh(omvPrim, (Bitmap)sculpt, DetailLevel.Medium); - sculpt.Dispose(); - if (mesh != null) - { - AddBoundingBoxOfSimpleMesh(mesh, omvPrim, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - mesh = null; - } - } - } - } + // As per LSL Wiki, there is no difference between sitting + // and standing avatar since server 1.36 + LSL_Vector lower; + LSL_Vector upper; - // When part is prim - else if (omvPrim.Sculpt == null) - { - SimpleMesh mesh = primMesher.GenerateSimpleMesh(omvPrim, DetailLevel.Medium); - if (mesh != null) - { - AddBoundingBoxOfSimpleMesh(mesh, omvPrim, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - mesh = null; - } - } - - // When all else fails, try fallback to simple box - else - { - AddBoundingBoxOfSimpleBox(part.Scale * -0.5f, part.Scale * 0.5f, part.OffsetPosition, part.RotationOffset, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - } - } - partCount++; - } - } - - // Merge bounding boxes of seated avatars - foreach (ScenePresence sp in group.GetSittingAvatars()) - { - Vector3 lower; - Vector3 upper; - BoundingBoxOfScenePresence(sp, out lower, out upper); - Vector3 offset = sp.OffsetPosition; + Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; - bool hasParent = true; - // When requested or if no mesher, keep it simple - if (m_useSimpleBoxesInGetBoundingBox || primMesher == null) + if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID + == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) +/* { - AddBoundingBoxOfSimpleBox(lower, upper, offset, sp.Rotation, hasParent, ref minPosition, ref maxPosition, ref vertexCount); + // This is for ground sitting avatars + float height = presence.Appearance.AvatarHeight / 2.66666667f; + lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); + upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); } - // Do the full mounty else { - // Prim shapes don't do center offsets, so add it here. - offset = offset + (lower + upper) * 0.5f * sp.Rotation; - Primitive omvPrim = MakeOpenMetaversePrim(upper - lower, offset, sp.Rotation, ScriptBaseClass.PRIM_TYPE_SPHERE); - SimpleMesh mesh = primMesher.GenerateSimpleMesh(omvPrim, DetailLevel.Medium); - AddBoundingBoxOfSimpleMesh(mesh, omvPrim, hasParent, ref minPosition, ref maxPosition, ref vertexCount); - mesh = null; + // This is for standing/flying avatars + float height = presence.Appearance.AvatarHeight / 2.0f; + lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); + upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); } - partCount++; + + // Adjust to the documented error offsets (see LSL Wiki) + lower += new LSL_Vector(0.05f, 0.05f, 0.05f); + upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); +*/ + { + // This is for ground sitting avatars TODO! + lower = new LSL_Vector(-box.X - 0.1125, -box.Y, box.Z * -1.0f); + upper = new LSL_Vector(box.X + 0.1125, box.Y, box.Z * -1.0f); + } + else + { + // This is for standing/flying avatars + lower = new LSL_Vector(-box.X, -box.Y, -box.Z); + upper = new LSL_Vector(box.X, box.Y, box.Z); + } + + if (lower.x > upper.x) + lower.x = upper.x; + if (lower.y > upper.y) + lower.y = upper.y; + if (lower.z > upper.z) + lower.z = upper.z; + + result.Add(lower); + result.Add(upper); + return result; } - groupCount++; + part = World.GetSceneObjectPart(objID); + // Currently only works for single prims without a sitting avatar + if (part != null) + { + float minX; + float maxX; + float minY; + float maxY; + float minZ; + float maxZ; - // Return lower and upper bounding box corners - result.Add(new LSL_Vector(minPosition)); - result.Add(new LSL_Vector(maxPosition)); - if (m_addStatsInGetBoundingBox) - result.Add(new LSL_Vector((float)groupCount, (float)partCount, (float)vertexCount)); + // This BBox is in sim coordinates, with the offset being + // a contained point. + Vector3[] offsets = Scene.GetCombinedBoundingBox(new List { part.ParentGroup }, + out minX, out maxX, out minY, out maxY, out minZ, out maxZ); + + minX -= offsets[0].X; + maxX -= offsets[0].X; + minY -= offsets[0].Y; + maxY -= offsets[0].Y; + minZ -= offsets[0].Z; + maxZ -= offsets[0].Z; + + LSL_Vector lower; + LSL_Vector upper; + + // Adjust to the documented error offsets (see LSL Wiki) + lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); + upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); + + if (lower.x > upper.x) + lower.x = upper.x; + if (lower.y > upper.y) + lower.y = upper.y; + if (lower.z > upper.z) + lower.z = upper.z; + + result.Add(lower); + result.Add(upper); + return result; + } - primMesher = null; + // Not found so return empty values + result.Add(new LSL_Vector()); + result.Add(new LSL_Vector()); return result; } @@ -9836,430 +10788,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - /// - /// Helper to approximate a part with a simple box. - /// - private void AddBoundingBoxOfSimpleBox(Vector3 corner1, Vector3 corner2, Vector3 offset, Quaternion rotation, bool hasParent, ref Vector3 lower, ref Vector3 upper, ref int count) - { - // Parse the 8 box corners - for (int i = 0; i < 8; i++) - { - // Calculate each box corner - Vector3 position = corner1; - if ((i & 1) != 0) - position.X = corner2.X; - if ((i & 2) != 0) - position.Y = corner2.Y; - if ((i & 4) != 0) - position.Z = corner2.Z; - // Rotate part unless part is root - if (hasParent) - position = position * rotation; - position = position + offset; - // Adjust lower and upper bounding box corners if needed - lower = Vector3.Min(lower, position); - upper = Vector3.Max(upper, position); - count++; - } - } - - /// - /// Helper to parse a meshed prim and needed especially - /// for accuracy with tortured prims and sculpts. - /// - private void AddBoundingBoxOfSimpleMesh(SimpleMesh mesh, Primitive prim, bool hasParent, ref Vector3 lower, ref Vector3 upper, ref int count) - { - // Quirk: A meshed box contains 10 instead of the 8 necessary vertices. - if (mesh != null) - { - // Parse each vertex in mesh - foreach (Vertex vertex in mesh.Vertices) - { - Vector3 position = vertex.Position; - position = position * prim.Scale; - // Rotate part unless part is root - if (hasParent) - position = position * prim.Rotation; - position = position + prim.Position; - // Adjust lower and upper bounding box corners if needed - lower = Vector3.Min(lower, position); - upper = Vector3.Max(upper, position); - count++; - } - } - } - - /// - /// Helper to parse mesh because no method exists - /// to parse mesh assets to SimpleMesh. - /// - private void AddBoundingBoxOfFacetedMesh(FacetedMesh mesh, Primitive prim, bool hasParent, ref Vector3 lower, ref Vector3 upper, ref int count) - { - if (mesh != null) - { - // Parse each face in mesh - // since vertex array isn't populated. - // This parses each unique vertex 3-6 times. - foreach (Face face in mesh.Faces) - { - // Parse each vertex in face - foreach (Vertex vertex in face.Vertices) - { - Vector3 position = vertex.Position; - position = position * prim.Scale; - // Rotate part unless part is root - if (hasParent) - position = position * prim.Rotation; - position = position + prim.Position; - // Adjust lower and upper bounding box corners if needed - lower = Vector3.Min(lower, position); - upper = Vector3.Max(upper, position); - count++; - } - } - } - } - - /// - /// Helper to make up an OpenMetaverse prim - /// needed to create mesh from parts. - /// - private Primitive MakeOpenMetaversePrim(Vector3 scale, Vector3 position, Quaternion rotation, int primType) - { - // Initialize and set common parameters - Primitive prim = new OpenMetaverse.Primitive(); - prim.Scale = scale; - prim.Position = position; - prim.Rotation = rotation; - prim.PrimData.PathShearX = 0.0f; - prim.PrimData.PathShearY = 0.0f; - prim.PrimData.PathBegin = 0.0f; - prim.PrimData.PathEnd = 1.0f; - prim.PrimData.PathScaleX = 1.0f; - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.PathTaperX = 0.0f; - prim.PrimData.PathTaperY = 0.0f; - prim.PrimData.PathTwistBegin = 0.0f; - prim.PrimData.PathTwist = 0.0f; - prim.PrimData.ProfileBegin = 0.0f; - prim.PrimData.ProfileEnd = 1.0f; - prim.PrimData.ProfileHollow = 0.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)1; - prim.PrimData.ProfileHole = (HoleType)0; - prim.PrimData.PathCurve = (PathCurve)16; - prim.PrimData.PathRadiusOffset = 0.0f; - prim.PrimData.PathRevolutions = 1.0f; - prim.PrimData.PathSkew = 0.0f; - prim.PrimData.PCode = OpenMetaverse.PCode.Prim; - prim.PrimData.State = (byte)0; - - // Set type specific parameters - switch (primType) - { - // Set specific parameters for box - case ScriptBaseClass.PRIM_TYPE_BOX: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)1; - prim.PrimData.PathCurve = (PathCurve)16; - break; - // Set specific parameters for cylinder - case ScriptBaseClass.PRIM_TYPE_CYLINDER: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)0; - prim.PrimData.PathCurve = (PathCurve)16; - break; - // Set specific parameters for prism - case ScriptBaseClass.PRIM_TYPE_PRISM: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)3; - prim.PrimData.PathCurve = (PathCurve)16; - break; - // Set specific parameters for sphere - case ScriptBaseClass.PRIM_TYPE_SPHERE: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)5; - prim.PrimData.PathCurve = (PathCurve)32; - break; - // Set specific parameters for torus - case ScriptBaseClass.PRIM_TYPE_TORUS: - prim.PrimData.PathScaleY = 0.5f; - prim.PrimData.ProfileCurve = (ProfileCurve)0; - prim.PrimData.PathCurve = (PathCurve)32; - break; - // Set specific parameters for tube - case ScriptBaseClass.PRIM_TYPE_TUBE: - prim.PrimData.PathScaleY = 0.5f; - prim.PrimData.ProfileCurve = (ProfileCurve)1; - prim.PrimData.PathCurve = (PathCurve)32; - break; - // Set specific parameters for ring - case ScriptBaseClass.PRIM_TYPE_RING: - prim.PrimData.PathScaleY = 0.5f; - prim.PrimData.ProfileCurve = (ProfileCurve)3; - prim.PrimData.PathCurve = (PathCurve)32; - break; - // Set specific parameters for sculpt - case ScriptBaseClass.PRIM_TYPE_SCULPT: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)5; - prim.PrimData.PathCurve = (PathCurve)32; - break; - // Default to specific parameters for box - default: - prim.PrimData.PathScaleY = 1.0f; - prim.PrimData.ProfileCurve = (ProfileCurve)1; - prim.PrimData.PathCurve = (PathCurve)16; - break; - } - - return prim; - } - /// - /// Implementation of llGetGeometricCenter according to SL 2015-04-30. - /// http://wiki.secondlife.com/wiki/LlGetGeometricCenter - /// Returns the average position offset of all linked parts, - /// including the root prim and seated avatars, - /// relative to the root prim in local coordinates. - /// public LSL_Vector llGetGeometricCenter() { - // Subtract whatever position the root prim has to make it zero - Vector3 offset = m_host.ParentGroup.RootPart.OffsetPosition * -1.0f; - - // Add all prim/part position offsets - foreach (SceneObjectPart part in m_host.ParentGroup.Parts) - offset = offset + part.OffsetPosition; - // Add all avatar/scene presence position offsets - foreach (ScenePresence sp in m_host.ParentGroup.GetSittingAvatars()) - offset = offset + sp.OffsetPosition; - - // Calculate and return the average offset - offset = offset / (float)(m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount()); - return new LSL_Vector(offset); + return new LSL_Vector(m_host.GetGeometricCenter()); } - public LSL_List GetEntityParams(ISceneEntity entity, LSL_List rules) + public LSL_List llGetPrimitiveParams(LSL_List rules) { - LSL_List result = new LSL_List(); - LSL_List remaining; - - while (true) - { -// m_log.DebugFormat( -// "[LSL API]: GetEntityParams has {0} rules with scene entity named {1}", -// rules.Length, entity != null ? entity.Name : "NULL"); - - if (entity == null) - return result; + m_host.AddScriptLPS(1); - if (entity is SceneObjectPart) - remaining = GetPrimParams((SceneObjectPart)entity, rules, ref result); - else - remaining = GetAgentParams((ScenePresence)entity, rules, ref result); + LSL_List result = new LSL_List(); - if (remaining == null || remaining.Length < 2) - return result; + LSL_List remaining = GetPrimParams(m_host, rules, ref result); + while ((object)remaining != null && remaining.Length > 2) + { int linknumber = remaining.GetLSLIntegerItem(0); rules = remaining.GetSublist(1, -1); - entity = GetLinkEntity(m_host, linknumber); - } - } + List parts = GetLinkParts(linknumber); - public LSL_List llGetPrimitiveParams(LSL_List rules) - { - m_host.AddScriptLPS(1); + foreach (SceneObjectPart part in parts) + remaining = GetPrimParams(part, rules, ref result); + } - return GetEntityParams(m_host, rules); + return result; } public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) { m_host.AddScriptLPS(1); - return GetEntityParams(GetLinkEntity(m_host, linknumber), rules); - } + // acording to SL wiki this must indicate a single link number or link_root or link_this. + // keep other options as before - public LSL_Vector GetAgentSize(ScenePresence sp) - { - return new LSL_Vector(0.45, 0.6, sp.Appearance.AvatarHeight); - } + List parts; + List avatars; - /// - /// Gets params for a seated avatar in a linkset. - /// - /// - /// - /// - /// - public LSL_List GetAgentParams(ScenePresence sp, LSL_List rules, ref LSL_List res) - { - int idx = 0; - while (idx < rules.Length) + LSL_List res = new LSL_List(); + LSL_List remaining = new LSL_List(); + + while (rules.Length > 0) { - int code = (int)rules.GetLSLIntegerItem(idx++); - int remain = rules.Length-idx; + parts = GetLinkParts(linknumber); + avatars = GetLinkAvatars(linknumber); - switch (code) + remaining = new LSL_List(); + foreach (SceneObjectPart part in parts) { - case (int)ScriptBaseClass.PRIM_MATERIAL: - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MATERIAL_FLESH)); - break; - - case (int)ScriptBaseClass.PRIM_PHYSICS: - res.Add(ScriptBaseClass.FALSE); - break; - - case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: - res.Add(ScriptBaseClass.FALSE); - break; - - case (int)ScriptBaseClass.PRIM_PHANTOM: - res.Add(ScriptBaseClass.FALSE); - break; - - case (int)ScriptBaseClass.PRIM_POSITION: - res.Add(new LSL_Vector(sp.AbsolutePosition)); - break; - - case (int)ScriptBaseClass.PRIM_SIZE: - res.Add(GetAgentSize(sp)); - break; - - case (int)ScriptBaseClass.PRIM_ROTATION: - res.Add(sp.GetWorldRotation()); - break; - - case (int)ScriptBaseClass.PRIM_TYPE: - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); - res.Add(new LSL_Vector(0, 1, 0)); - res.Add(new LSL_Float(0)); - res.Add(new LSL_Vector(0, 0, 0)); - res.Add(new LSL_Vector(1, 1, 0)); - res.Add(new LSL_Vector(0, 0, 0)); - break; - - case (int)ScriptBaseClass.PRIM_TEXTURE: - if (remain < 1) - return new LSL_List(); - - int face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(new LSL_String("")); - res.Add(ScriptBaseClass.ZERO_VECTOR); - res.Add(ScriptBaseClass.ZERO_VECTOR); - res.Add(new LSL_Float(0)); - break; - - case (int)ScriptBaseClass.PRIM_COLOR: - if (remain < 1) - return new LSL_List(); - - face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(ScriptBaseClass.ZERO_VECTOR); - res.Add(new LSL_Float(0)); - break; - - case (int)ScriptBaseClass.PRIM_BUMP_SHINY: - if (remain < 1) - return new LSL_List(); - - face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(ScriptBaseClass.PRIM_SHINY_NONE); - res.Add(ScriptBaseClass.PRIM_BUMP_NONE); - break; - - case (int)ScriptBaseClass.PRIM_FULLBRIGHT: - if (remain < 1) - return new LSL_List(); - - face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(ScriptBaseClass.FALSE); - break; - - case (int)ScriptBaseClass.PRIM_FLEXIBLE: - res.Add(ScriptBaseClass.FALSE); - res.Add(new LSL_Integer(0)); - res.Add(new LSL_Float(0)); - res.Add(new LSL_Float(0)); - res.Add(new LSL_Float(0)); - res.Add(new LSL_Float(0)); - res.Add(ScriptBaseClass.ZERO_VECTOR); - break; - - case (int)ScriptBaseClass.PRIM_TEXGEN: - if (remain < 1) - return new LSL_List(); - - face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(ScriptBaseClass.PRIM_TEXGEN_DEFAULT); - break; - - case (int)ScriptBaseClass.PRIM_POINT_LIGHT: - res.Add(ScriptBaseClass.FALSE); - res.Add(ScriptBaseClass.ZERO_VECTOR); - res.Add(ScriptBaseClass.ZERO_VECTOR); - break; - - case (int)ScriptBaseClass.PRIM_GLOW: - if (remain < 1) - return new LSL_List(); - - face = (int)rules.GetLSLIntegerItem(idx++); - if (face > 21) - break; - - res.Add(new LSL_Float(0)); - break; - - case (int)ScriptBaseClass.PRIM_TEXT: - res.Add(new LSL_String("")); - res.Add(ScriptBaseClass.ZERO_VECTOR); - res.Add(new LSL_Float(1)); - break; - - case (int)ScriptBaseClass.PRIM_ROT_LOCAL: - res.Add(new LSL_Rotation(sp.Rotation)); - break; - - case (int)ScriptBaseClass.PRIM_POS_LOCAL: - res.Add(new LSL_Vector(sp.OffsetPosition)); - break; - - case (int)ScriptBaseClass.PRIM_SLICE: - res.Add(new LSL_Vector(0, 1, 0)); - break; - - case (int)ScriptBaseClass.PRIM_LINK_TARGET: - if(remain < 3) - return new LSL_List(); + remaining = GetPrimParams(part, rules, ref res); + } + foreach (ScenePresence avatar in avatars) + { + remaining = GetPrimParams(avatar, rules, ref res); + } - return rules.GetSublist(idx, -1); + if (remaining.Length > 0) + { + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); } + else + break; } - return new LSL_List(); + return res; } public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) { int idx = 0; + int face; + Primitive.TextureEntry tex; + int nsides = GetNumberOfSides(part); + while (idx < rules.Length) { int code = (int)rules.GetLSLIntegerItem(idx++); @@ -10293,19 +10895,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_POSITION: - LSL_Vector v = new LSL_Vector(part.AbsolutePosition); - - // For some reason, the part.AbsolutePosition.* values do not change if the - // linkset is rotated; they always reflect the child prim's world position - // as though the linkset is unrotated. This is incompatible behavior with SL's - // implementation, so will break scripts imported from there (not to mention it - // makes it more difficult to determine a child prim's actual inworld position). - if (!part.IsRoot) - { - LSL_Vector rootPos = new LSL_Vector(m_host.ParentGroup.AbsolutePosition); - v = ((v - rootPos) * llGetRootRotation()) + rootPos; - } - + LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, + part.AbsolutePosition.Y, + part.AbsolutePosition.Z); res.Add(v); break; @@ -10410,11 +11002,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (remain < 1) return new LSL_List(); - int face = (int)rules.GetLSLIntegerItem(idx++); - Primitive.TextureEntry tex = part.Shape.Textures; + face = (int)rules.GetLSLIntegerItem(idx++); + tex = part.Shape.Textures; + if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0 ; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); @@ -10430,7 +11023,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); @@ -10450,13 +11043,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (remain < 1) return new LSL_List(); - face=(int)rules.GetLSLIntegerItem(idx++); - + face = (int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; Color4 texcolor; + if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0 ; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { texcolor = tex.GetFace((uint)face).RGBA; res.Add(new LSL_Vector(texcolor.R, @@ -10476,61 +11069,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + { if (remain < 1) return new LSL_List(); - face=(int)rules.GetLSLIntegerItem(idx++); - + face = (int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; + int shiny; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - // Convert Shininess to PRIM_SHINY_* - res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); - // PRIM_BUMP_* - res.Add(new LSL_Integer((int)texface.Bump)); + Shininess shinyness = tex.GetFace((uint)face).Shiny; + if (shinyness == Shininess.High) + { + shiny = ScriptBaseClass.PRIM_SHINY_HIGH; + } + else if (shinyness == Shininess.Medium) + { + shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; + } + else if (shinyness == Shininess.Low) + { + shiny = ScriptBaseClass.PRIM_SHINY_LOW; + } + else + { + shiny = ScriptBaseClass.PRIM_SHINY_NONE; + } + res.Add(new LSL_Integer(shiny)); + res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); } } else { - if (face >= 0 && face < GetNumberOfSides(part)) + Shininess shinyness = tex.GetFace((uint)face).Shiny; + if (shinyness == Shininess.High) { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - // Convert Shininess to PRIM_SHINY_* - res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); - // PRIM_BUMP_* - res.Add(new LSL_Integer((int)texface.Bump)); + shiny = ScriptBaseClass.PRIM_SHINY_HIGH; + } + else if (shinyness == Shininess.Medium) + { + shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; + } + else if (shinyness == Shininess.Low) + { + shiny = ScriptBaseClass.PRIM_SHINY_LOW; + } + else + { + shiny = ScriptBaseClass.PRIM_SHINY_NONE; } + res.Add(new LSL_Integer(shiny)); + res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); } break; - + } case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + { if (remain < 1) return new LSL_List(); face = (int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; + int fullbright; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); - } - } - else - { - if (face >= 0 && face < GetNumberOfSides(part)) + if (tex.GetFace((uint)face).Fullbright == true) + { + fullbright = ScriptBaseClass.TRUE; + } + else + { + fullbright = ScriptBaseClass.FALSE; + } + res.Add(new LSL_Integer(fullbright)); + } + } + else + { + if (tex.GetFace((uint)face).Fullbright == true) { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); + fullbright = ScriptBaseClass.TRUE; + } + else + { + fullbright = ScriptBaseClass.FALSE; } + res.Add(new LSL_Integer(fullbright)); } break; - + } case (int)ScriptBaseClass.PRIM_FLEXIBLE: PrimitiveBaseShape shape = part.Shape; @@ -10549,27 +11181,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_TEXGEN: + // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) if (remain < 1) return new LSL_List(); - face=(int)rules.GetLSLIntegerItem(idx++); + face = (int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { - MappingType texgen = tex.GetFace((uint)face).TexMapType; - // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. - res.Add(new LSL_Integer((uint)texgen >> 1)); + if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } } } else { - if (face >= 0 && face < GetNumberOfSides(part)) + if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); + } + else { - MappingType texgen = tex.GetFace((uint)face).TexMapType; - res.Add(new LSL_Integer((uint)texgen >> 1)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); } } break; @@ -10593,24 +11234,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (remain < 1) return new LSL_List(); - face=(int)rules.GetLSLIntegerItem(idx++); + face = (int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; + float primglow; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0; face < GetNumberOfSides(part); face++) + for (face = 0; face < nsides; face++) { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - res.Add(new LSL_Float(texface.Glow)); + primglow = tex.GetFace((uint)face).Glow; + res.Add(new LSL_Float(primglow)); } } else { - if (face >= 0 && face < GetNumberOfSides(part)) - { - Primitive.TextureEntryFace texface = tex.GetFace((uint)face); - res.Add(new LSL_Float(texface.Glow)); - } + primglow = tex.GetFace((uint)face).Glow; + res.Add(new LSL_Float(primglow)); } break; @@ -10620,17 +11259,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api res.Add(new LSL_Vector(textColor.R, textColor.G, textColor.B)); - res.Add(new LSL_Float(1.0 - textColor.A)); + res.Add(new LSL_Float(textColor.A)); break; + case (int)ScriptBaseClass.PRIM_NAME: res.Add(new LSL_String(part.Name)); break; + case (int)ScriptBaseClass.PRIM_DESC: res.Add(new LSL_String(part.Description)); break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: res.Add(new LSL_Rotation(part.RotationOffset)); break; + case (int)ScriptBaseClass.PRIM_POS_LOCAL: res.Add(new LSL_Vector(GetPartLocalPos(part))); break; @@ -10643,6 +11285,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api 0 )); break; + + case (int)ScriptBaseClass.PRIM_OMEGA: + // this may return values diferent from SL since we don't handle set the same way + float gain = 1.0f; // we don't use gain and don't store it + Vector3 axis = part.AngularVelocity; + float spin = axis.Length(); + if(spin < 1.0e-6) + { + axis = Vector3.Zero; + gain = 0.0f; + spin = 0.0f; + } + else + { + axis = axis * (1.0f/spin); + } + + res.Add(new LSL_Vector(axis.X, + axis.Y, + axis.Z)); + res.Add(new LSL_Float(spin)); + res.Add(new LSL_Float(gain)); + break; + + case (int)ScriptBaseClass.PRIM_SIT_TARGET: + if(part.IsSitTargetSet) + { + res.Add(new LSL_Integer(1)); + res.Add(new LSL_Vector(part.SitTargetPosition)); + res.Add(new LSL_Rotation(part.SitTargetOrientation)); + } + else + { + res.Add(new LSL_Integer(0)); + res.Add(new LSL_Vector(Vector3.Zero)); + res.Add(new LSL_Rotation(Quaternion.Identity)); + } + break; + + case (int)ScriptBaseClass.PRIM_NORMAL: + case (int)ScriptBaseClass.PRIM_SPECULAR: + case (int)ScriptBaseClass.PRIM_ALPHA_MODE: + if (remain < 1) + return new LSL_List(); + + face = (int)rules.GetLSLIntegerItem(idx++); + tex = part.Shape.Textures; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < nsides; face++) + { + Primitive.TextureEntryFace texface = tex.GetFace((uint)face); + getLSLFaceMaterial(ref res, code, part, texface); + } + } + else + { + if (face >= 0 && face < nsides) + { + Primitive.TextureEntryFace texface = tex.GetFace((uint)face); + getLSLFaceMaterial(ref res, code, part, texface); + } + } + break; + case (int)ScriptBaseClass.PRIM_LINK_TARGET: // TODO: Should be issuing a runtime script warning in this case. @@ -10656,15 +11363,120 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_List(); } +/* + private string filterTextureUUIDbyRights(UUID origID, SceneObjectPart part, bool checkTaskInventory, bool returnInvName) + { + if(checkTaskInventory) + { + lock (part.TaskInventory) + { + foreach (KeyValuePair inv in part.TaskInventory) + { + if (inv.Value.AssetID == origID) + { + if(inv.Value.InvType == (int)InventoryType.Texture) + { + if(returnInvName) + return inv.Value.Name; + else + return origID.ToString(); + } + else + return UUID.Zero.ToString(); + } + } + } + } + + if(World.Permissions.CanEditObject(m_host.ParentGroup.UUID, m_host.ParentGroup.RootPart.OwnerID)) + return origID.ToString(); + + return UUID.Zero.ToString(); + } +*/ + private void getLSLFaceMaterial(ref LSL_List res, int code, SceneObjectPart part, Primitive.TextureEntryFace texface) + { + UUID matID = texface.MaterialID; + if(matID != UUID.Zero) + { + AssetBase MatAsset = World.AssetService.Get(matID.ToString()); + if(MatAsset != null) + { + Byte[] data = MatAsset.Data; + OSDMap osdmat = (OSDMap)OSDParser.DeserializeLLSDXml(data); + if(osdmat != null && osdmat.ContainsKey("NormMap")) + { + string mapIDstr; + FaceMaterial mat = new FaceMaterial(matID, osdmat); + if(code == ScriptBaseClass.PRIM_NORMAL) + { +// mapIDstr = filterTextureUUIDbyRights(mat.NormalMapID, part, true, false); + mapIDstr = mat.NormalMapID.ToString(); + res.Add(new LSL_String(mapIDstr)); + res.Add(new LSL_Vector(mat.NormalRepeatX, mat.NormalRepeatY, 0)); + res.Add(new LSL_Vector(mat.NormalOffsetX, mat.NormalOffsetY, 0)); + res.Add(new LSL_Float(mat.NormalRotation)); + } + else if(code == ScriptBaseClass.PRIM_SPECULAR ) + { +// mapIDstr = filterTextureUUIDbyRights(mat.SpecularMapID, part, true, false); + const float colorScale = 1.0f/255f; + mapIDstr = mat.SpecularMapID.ToString(); + res.Add(new LSL_String(mapIDstr)); + res.Add(new LSL_Vector(mat.SpecularRepeatX, mat.SpecularRepeatY, 0)); + res.Add(new LSL_Vector(mat.SpecularOffsetX, mat.SpecularOffsetY, 0)); + res.Add(new LSL_Float(mat.SpecularRotation)); + res.Add(new LSL_Vector(mat.SpecularLightColor.R * colorScale, + mat.SpecularLightColor.G * colorScale, + mat.SpecularLightColor.B * colorScale)); + res.Add(new LSL_Integer(mat.SpecularLightExponent)); + res.Add(new LSL_Integer(mat.EnvironmentIntensity)); + } + else if(code == ScriptBaseClass.PRIM_ALPHA_MODE) + { + res.Add(new LSL_Integer(mat.DiffuseAlphaMode)); + res.Add(new LSL_Integer(mat.AlphaMaskCutoff)); + } + return; + } + } + matID = UUID.Zero; + } + if(matID == UUID.Zero) + { + if(code == (int)ScriptBaseClass.PRIM_NORMAL || code == (int)ScriptBaseClass.PRIM_SPECULAR ) + { + res.Add(new LSL_String(UUID.Zero.ToString())); + res.Add(new LSL_Vector(1.0, 1.0, 0)); + res.Add(new LSL_Vector(0, 0, 0)); + res.Add(new LSL_Float(0)); + + if(code == (int)ScriptBaseClass.PRIM_SPECULAR) + { + res.Add(new LSL_Vector(1.0, 1.0, 1.0)); + res.Add(new LSL_Integer(51)); + res.Add(new LSL_Integer(0)); + } + } + else if(code == (int)ScriptBaseClass.PRIM_ALPHA_MODE) + { + res.Add(new LSL_Integer(1)); + res.Add(new LSL_Integer(0)); + } + } + } + public LSL_List llGetPrimMediaParams(int face, LSL_List rules) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnGetPrimMediaParams); return GetPrimMediaParams(m_host, face, rules); } public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnGetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); else if (link == ScriptBaseClass.LINK_THIS) @@ -10784,12 +11596,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnSetPrimMediaParams); return SetPrimMediaParams(m_host, face, rules); } public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnSetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); else if (link == ScriptBaseClass.LINK_THIS) @@ -10908,12 +11722,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llClearPrimMedia(LSL_Integer face) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnClearPrimMedia); return ClearPrimMedia(m_host, face); } public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face) { m_host.AddScriptLPS(1); + ScriptSleep(m_sleepMsOnClearLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return ClearPrimMedia(m_host.ParentGroup.RootPart, face); else if (link == ScriptBaseClass.LINK_THIS) @@ -11237,8 +12053,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // The function returns an ordered list // representing the tokens found in the supplied // sources string. If two successive tokenizers - // are encountered, then a NULL entry is added - // to the list. + // are encountered, then a null-string entry is + // added to the list. // // It is a precondition that the source and // toekizer lisst are non-null. If they are null, @@ -11246,7 +12062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // while their lengths are being determined. // // A small amount of working memoryis required - // of approximately 8*#tokenizers. + // of approximately 8*#tokenizers + 8*srcstrlen. // // There are many ways in which this function // can be implemented, this implementation is @@ -11262,155 +12078,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // and eliminates redundant tokenizers as soon // as is possible. // - // The implementation tries to avoid any copying - // of arrays or other objects. + // The implementation tries to minimize temporary + // garbage generation. // - private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) + public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) { - int beginning = 0; - int srclen = src.Length; - int seplen = separators.Length; - object[] separray = separators.Data; - int spclen = spacers.Length; - object[] spcarray = spacers.Data; - int mlen = seplen+spclen; - - int[] offset = new int[mlen+1]; - bool[] active = new bool[mlen]; - - int best; - int j; - - // Initial capacity reduces resize cost + return ParseString2List(src, separators, spacers, true); + } - LSL_List tokens = new LSL_List(); + private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) + { + int srclen = src.Length; + int seplen = separators.Length; + object[] separray = separators.Data; + int spclen = spacers.Length; + object[] spcarray = spacers.Data; + int dellen = 0; + string[] delarray = new string[seplen+spclen]; - // All entries are initially valid + int outlen = 0; + string[] outarray = new string[srclen*2+1]; - for (int i = 0; i < mlen; i++) - active[i] = true; + int i, j; + string d; - offset[mlen] = srclen; + m_host.AddScriptLPS(1); - while (beginning < srclen) + /* + * Convert separator and spacer lists to C# strings. + * Also filter out null strings so we don't hang. + */ + for (i = 0; i < seplen; i ++) { + d = separray[i].ToString(); + if (d.Length > 0) + { + delarray[dellen++] = d; + } + } + seplen = dellen; - best = mlen; // as bad as it gets + for (i = 0; i < spclen; i ++) + { + d = spcarray[i].ToString(); + if (d.Length > 0) + { + delarray[dellen++] = d; + } + } - // Scan for separators + /* + * Scan through source string from beginning to end. + */ + for (i = 0;;) + { - for (j = 0; j < seplen; j++) + /* + * Find earliest delimeter in src starting at i (if any). + */ + int earliestDel = -1; + int earliestSrc = srclen; + string earliestStr = null; + for (j = 0; j < dellen; j ++) { - if (separray[j].ToString() == String.Empty) - active[j] = false; - - if (active[j]) + d = delarray[j]; + if (d != null) { - // scan all of the markers - if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) + int index = src.IndexOf(d, i); + if (index < 0) { - // not present at all - active[j] = false; + delarray[j] = null; // delim nowhere in src, don't check it anymore } - else + else if (index < earliestSrc) { - // present and correct - if (offset[j] < offset[best]) - { - // closest so far - best = j; - if (offset[best] == beginning) - break; - } + earliestSrc = index; // where delimeter starts in source string + earliestDel = j; // where delimeter is in delarray[] + earliestStr = d; // the delimeter string from delarray[] + if (index == i) break; // can't do any better than found at beg of string } } } - // Scan for spacers - - if (offset[best] != beginning) + /* + * Output source string starting at i through start of earliest delimeter. + */ + if (keepNulls || (earliestSrc > i)) { - for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) - { - if (spcarray[j-seplen].ToString() == String.Empty) - active[j] = false; - - if (active[j]) - { - // scan all of the markers - if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) - { - // not present at all - active[j] = false; - } - else - { - // present and correct - if (offset[j] < offset[best]) - { - // closest so far - best = j; - } - } - } - } + outarray[outlen++] = src.Substring(i, earliestSrc - i); } - // This is the normal exit from the scanning loop + /* + * If no delimeter found at or after i, we're done scanning. + */ + if (earliestDel < 0) break; - if (best == mlen) + /* + * If delimeter was a spacer, output the spacer. + */ + if (earliestDel >= seplen) { - // no markers were found on this pass - // so we're pretty much done - if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) - tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); - break; + outarray[outlen++] = earliestStr; } - // Otherwise we just add the newly delimited token - // and recalculate where the search should continue. - if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) - tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); - - if (best < seplen) - { - beginning = offset[best] + (separray[best].ToString()).Length; - } - else - { - beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; - string str = spcarray[best - seplen].ToString(); - if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) - tokens.Add(new LSL_String(str)); - } + /* + * Look at rest of src string following delimeter. + */ + i = earliestSrc + earliestStr.Length; } - // This an awkward an not very intuitive boundary case. If the - // last substring is a tokenizer, then there is an implied trailing - // null list entry. Hopefully the single comparison will not be too - // arduous. Alternatively the 'break' could be replced with a return - // but that's shabby programming. - - if ((beginning == srclen) && (keepNulls)) + /* + * Make up an exact-sized output array suitable for an LSL_List object. + */ + object[] outlist = new object[outlen]; + for (i = 0; i < outlen; i ++) { - if (srclen != 0) - tokens.Add(new LSL_String("")); + outlist[i] = new LSL_String(outarray[i]); } - - return tokens; - } - - public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) - { - m_host.AddScriptLPS(1); - return this.ParseString(src, separators, spacers, false); - } - - public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) - { - m_host.AddScriptLPS(1); - return this.ParseString(src, separators, spacers, true); + return new LSL_List(outlist); } public LSL_Integer llGetObjectPermMask(int mask) @@ -11453,7 +12238,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) { - if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) + if (World.Permissions.IsAdministrator(m_host.OwnerID)) { if (mask == ScriptBaseClass.MASK_BASE)//0 { @@ -11515,7 +12300,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) { - if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) + if (World.Permissions.IsAdministrator(m_host.OwnerID)) { TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); @@ -11574,7 +12359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (m_UrlModule != null) - return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); + return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, null).ToString(); return UUID.Zero.ToString(); } @@ -11600,6 +12385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.DATA_SIM_POS: if (info == null) { + ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); } @@ -11646,6 +12432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.DATA_SIM_RATING: if (info == null) { + ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); } int access = info.Maturity; @@ -11660,14 +12447,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case ScriptBaseClass.DATA_SIM_RELEASE: if (ossl != null) - { -//// TODO - double check this. - if (!ossl.CheckThreatLevel(ThreatLevel.High, "llRequestSimulatorData")) - return UUID.Zero.ToString(); // Raise no event - } + ossl.CheckThreatLevel(ThreatLevel.High, "llRequestSimulatorData"); reply = "OpenSim"; break; default: + ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); // Raise no event } UUID rq = UUID.Random(); @@ -11678,6 +12462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands. DataserverPlugin.DataserverReply(rq.ToString(), reply); + ScriptSleep(m_sleepMsOnRequestSimulatorData); return tid.ToString(); } catch(Exception) @@ -11692,7 +12477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_UrlModule != null) - return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString(); + return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, null).ToString(); return UUID.Zero.ToString(); } @@ -11708,31 +12493,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID key = new UUID(); if (UUID.TryParse(id, out key)) { - try - { - SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); - if (obj != null) - return (double)obj.GetMass(); - // the object is null so the key is for an avatar - ScenePresence avatar = World.GetScenePresence(key); - if (avatar != null) - if (avatar.IsChildAgent) - // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass - // child agents have a mass of 1.0 - return 1; - else - return (double)avatar.GetMass(); - } - catch (KeyNotFoundException) + // return total object mass + SceneObjectPart part = World.GetSceneObjectPart(key); + if (part != null) + return part.ParentGroup.GetMass(); + + // the object is null so the key is for an avatar + ScenePresence avatar = World.GetScenePresence(key); + if (avatar != null) { - return 0; // The Object/Agent not in the region so just return zero + if (avatar.IsChildAgent) + { + // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass + // child agents have a mass of 1.0 + return 1; + } + else + { + return (double)avatar.GetMass(); + } } } return 0; } /// - /// illListReplaceList removes the sub-list defined by the inclusive indices + /// llListReplaceList removes the sub-list defined by the inclusive indices /// start and end and inserts the src list in its place. The inclusive /// nature of the indices means that at least one element must be deleted /// if the indices are within the bounds of the existing list. I.e. 2,2 @@ -11789,16 +12575,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // based upon end. Note that if end exceeds the upper // bound in this case, the entire destination list // is removed. - else + else if (start == 0) { if (end + 1 < dest.Length) - { return src + dest.GetSublist(end + 1, -1); - } else - { return src; - } + } + else // Start < 0 + { + if (end + 1 < dest.Length) + return dest.GetSublist(end + 1, -1); + else + return new LSL_List(); } } // Finally, if start > end, we strip away a prefix and @@ -11821,6 +12610,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (null != dm) dm.SendUrlToUser( new UUID(avatar_id), m_host.Name, m_host.UUID, m_host.OwnerID, false, message, url); + + ScriptSleep(m_sleepMsOnLoadURL); } public void llParcelMediaCommandList(LSL_List commandList) @@ -11833,7 +12624,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // according to the docs, this command only works if script owner and land owner are the same // lets add estate owners and gods, too, and use the generic permission check. ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return; + if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia, false)) return; bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? byte loop = 0; @@ -12051,18 +12842,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sp.currentParcelUUID == landData.GlobalID) { sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? - (ParcelMediaCommandEnum)commandToSend, - time); + (ParcelMediaCommandEnum)commandToSend, time); } }); } else if (!presence.IsChildAgent) { presence.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? - (ParcelMediaCommandEnum)commandToSend, - time); + (ParcelMediaCommandEnum)commandToSend, time); } } + ScriptSleep(m_sleepMsOnParcelMediaCommandList); } public LSL_List llParcelMediaQuery(LSL_List aList) @@ -12076,7 +12866,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (aList.Data[i] != null) { - switch ((ParcelMediaCommandEnum) aList.Data[i]) + switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) { case ParcelMediaCommandEnum.Url: list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); @@ -12102,6 +12892,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + ScriptSleep(m_sleepMsOnParcelMediaQuery); return list; } @@ -12110,6 +12901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); Int64 tmp = 0; Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); + ScriptSleep(m_sleepMsOnModPow); return Convert.ToInt32(tmp); } @@ -12131,15 +12923,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (quick_pay_buttons.Data.Length < 4) { - Error("llSetPayPrice", "List must have at least 4 elements"); - return; + int x; + for (x=quick_pay_buttons.Data.Length; x<= 4; x++) + { + quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); + } } - m_host.ParentGroup.RootPart.PayPrice[0]=price; - - m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; - m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; - m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; - m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; + int[] nPrice = new int[5]; + nPrice[0] = price; + nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); + nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); + nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); + nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); + m_host.ParentGroup.RootPart.PayPrice = nPrice; m_host.ParentGroup.HasGroupChanged = true; } @@ -12156,7 +12952,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Vector3.Zero; } - ScenePresence presence = World.GetScenePresence(m_host.OwnerID); +// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); if (presence != null) { LSL_Vector pos = new LSL_Vector(presence.CameraPosition); @@ -12179,7 +12976,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Quaternion.Identity; } - ScenePresence presence = World.GetScenePresence(m_host.OwnerID); +// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); if (presence != null) { return new LSL_Rotation(presence.CameraRotation); @@ -12192,12 +12990,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead"); + ScriptSleep(m_sleepMsOnSetPrimURL); } public void llRefreshPrimURL() { m_host.AddScriptLPS(1); Deprecated("llRefreshPrimURL"); + ScriptSleep(m_sleepMsOnRefreshPrimURL); } public LSL_String llEscapeURL(string url) @@ -12230,7 +13030,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); - if (detectedParams == null) return; // only works on the first detected avatar + if (detectedParams == null) + { + if (m_host.ParentGroup.IsAttachment == true) + { + detectedParams = new DetectParams(); + detectedParams.Key = m_host.OwnerID; + } + else + { + return; + } + } ScenePresence avatar = World.GetScenePresence(detectedParams.Key); if (avatar != null) @@ -12238,6 +13049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, pos, lookAt); } + ScriptSleep(m_sleepMsOnMapDestination); } public void llAddToLandBanList(string avatar, double hours) @@ -12245,7 +13057,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) { int expires = 0; if (hours != 0) @@ -12278,6 +13090,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } + ScriptSleep(m_sleepMsOnAddToLandBanList); } public void llRemoveFromLandPassList(string avatar) @@ -12285,7 +13098,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManagePasses, false)) { if (UUID.TryParse(avatar, out key)) { @@ -12304,6 +13117,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + ScriptSleep(m_sleepMsOnRemoveFromLandPassList); } public void llRemoveFromLandBanList(string avatar) @@ -12311,7 +13125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) { if (UUID.TryParse(avatar, out key)) { @@ -12330,6 +13144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + ScriptSleep(m_sleepMsOnRemoveFromLandBanList); } public void llSetCameraParams(LSL_List rules) @@ -12542,19 +13357,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llXorBase64StringsCorrect(string str1, string str2) { m_host.AddScriptLPS(1); - string ret = String.Empty; - string src1 = llBase64ToString(str1); - string src2 = llBase64ToString(str2); - int c = 0; - for (int i = 0; i < src1.Length; i++) + + if (str1 == String.Empty) + return String.Empty; + if (str2 == String.Empty) + return str1; + + int len = str2.Length; + if ((len % 4) != 0) // LL is EVIL!!!! + { + while (str2.EndsWith("=")) + str2 = str2.Substring(0, str2.Length - 1); + + len = str2.Length; + int mod = len % 4; + + if (mod == 1) + str2 = str2.Substring(0, str2.Length - 1); + else if (mod == 2) + str2 += "=="; + else if (mod == 3) + str2 += "="; + } + + byte[] data1; + byte[] data2; + try + { + data1 = Convert.FromBase64String(str1); + data2 = Convert.FromBase64String(str2); + } + catch (Exception) + { + return new LSL_String(String.Empty); + } + + byte[] d2 = new Byte[data1.Length]; + int pos = 0; + + if (data1.Length <= data2.Length) + { + Array.Copy(data2, 0, d2, 0, data1.Length); + } + else { - ret += (char) (src1[i] ^ src2[c]); + while (pos < data1.Length) + { + len = data1.Length - pos; + if (len > data2.Length) + len = data2.Length; - c++; - if (c >= src2.Length) - c = 0; + Array.Copy(data2, 0, d2, pos, len); + pos += len; + } } - return llStringToBase64(ret); + + for (pos = 0 ; pos < data1.Length ; pos++ ) + data1[pos] ^= d2[pos]; + + return Convert.ToBase64String(data1); } public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) @@ -12570,6 +13431,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List param = new List(); bool ok; Int32 flag; + int nCustomHeaders = 0; for (int i = 0; i < parameters.Data.Length; i += 2) { @@ -12596,6 +13458,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Second Life documentation for llHTTPRequest. for (int count = 1; count <= 8; ++count) { + if(nCustomHeaders >= 8) + { + Error("llHTTPRequest", "Max number of custom headers is 8, excess ignored"); + break; + } + //Enough parameters remaining for (another) header? if (parameters.Data.Length - i < 2) { @@ -12610,15 +13478,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api param.Add(parameters.Data[i].ToString()); param.Add(parameters.Data[i+1].ToString()); + nCustomHeaders++; //Have we reached the end of the list of headers? //End is marked by a string with a single digit. - if (i+2 >= parameters.Data.Length || - Char.IsDigit(parameters.Data[i].ToString()[0])) + if (i + 2 >= parameters.Data.Length || + Char.IsDigit(parameters.Data[i + 2].ToString()[0])) { break; } - i += 2; } } @@ -12658,16 +13526,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (userAgent != null) httpHeaders["User-Agent"] = userAgent; + // See if the URL contains any header hacks + string[] urlParts = url.Split(new char[] {'\n'}); + if (urlParts.Length > 1) + { + // Iterate the passed headers and parse them + for (int i = 1 ; i < urlParts.Length ; i++ ) + { + // The rest of those would be added to the body in SL. + // Let's not do that. + if (urlParts[i] == String.Empty) + break; + + // See if this could be a valid header + string[] headerParts = urlParts[i].Split(new char[] {':'}, 2); + if (headerParts.Length != 2) + continue; + + string headerName = headerParts[0].Trim(); + string headerValue = headerParts[1].Trim(); + + // Filter out headers that could be used to abuse + // another system or cloak the request + if (headerName.ToLower() == "x-secondlife-shard" || + headerName.ToLower() == "x-secondlife-object-name" || + headerName.ToLower() == "x-secondlife-object-key" || + headerName.ToLower() == "x-secondlife-region" || + headerName.ToLower() == "x-secondlife-local-position" || + headerName.ToLower() == "x-secondlife-local-velocity" || + headerName.ToLower() == "x-secondlife-local-rotation" || + headerName.ToLower() == "x-secondlife-owner-name" || + headerName.ToLower() == "x-secondlife-owner-key" || + headerName.ToLower() == "connection" || + headerName.ToLower() == "content-length" || + headerName.ToLower() == "from" || + headerName.ToLower() == "host" || + headerName.ToLower() == "proxy-authorization" || + headerName.ToLower() == "referer" || + headerName.ToLower() == "trailer" || + headerName.ToLower() == "transfer-encoding" || + headerName.ToLower() == "via" || + headerName.ToLower() == "authorization") + continue; + + httpHeaders[headerName] = headerValue; + } + + // Finally, strip any protocol specifier from the URL + url = urlParts[0].Trim(); + int idx = url.IndexOf(" HTTP/"); + if (idx != -1) + url = url.Substring(0, idx); + } + string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; Regex r = new Regex(authregex); int[] gnums = r.GetGroupNumbers(); Match m = r.Match(url); - if (m.Success) { - for (int i = 1; i < gnums.Length; i++) { + if (m.Success) + { + for (int i = 1; i < gnums.Length; i++) + { //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; //CaptureCollection cc = g.Captures; } - if (m.Groups.Count == 5) { + if (m.Groups.Count == 5) + { httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); url = m.Groups[1].ToString() + m.Groups[4].ToString(); } @@ -12712,6 +13636,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + ScriptSleep(m_sleepMsOnResetLandBanList); } public void llResetLandPassList() @@ -12728,6 +13653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + ScriptSleep(m_sleepMsOnResetLandPassList); } public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) @@ -12785,6 +13711,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_Integer(detectedParams.Value)); } } + ScriptSleep(m_sleepMsOnGetParcelPrimOwners); return ret; } @@ -12871,6 +13798,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List ret = new LSL_List(); UUID key = new UUID(); + + if (UUID.TryParse(id, out key)) { ScenePresence av = World.GetScenePresence(key); @@ -12888,13 +13817,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_String("")); break; case ScriptBaseClass.OBJECT_POS: - ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); - break; - case ScriptBaseClass.OBJECT_ROT: - ret.Add(new LSL_Rotation(av.GetWorldRotation())); + Vector3 avpos; + + if (av.ParentID != 0 && av.ParentPart != null && + av.ParentPart.ParentGroup != null && av.ParentPart.ParentGroup.RootPart != null ) + { + avpos = av.OffsetPosition; + + if(!av.LegacySitOffsets) + { + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); + avpos -= sitOffset; + } + + SceneObjectPart sitRoot = av.ParentPart.ParentGroup.RootPart; + avpos = sitRoot.GetWorldPosition() + avpos * sitRoot.GetWorldRotation(); + } + else + avpos = av.AbsolutePosition; + + ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); + break; + case ScriptBaseClass.OBJECT_ROT: + Quaternion avrot = av.GetWorldRotation(); + ret.Add(new LSL_Rotation(avrot)); break; case ScriptBaseClass.OBJECT_VELOCITY: - ret.Add(new LSL_Vector(av.GetWorldVelocity())); + Vector3 avvel = av.GetWorldVelocity(); + ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z)); break; case ScriptBaseClass.OBJECT_OWNER: ret.Add(new LSL_String(id)); @@ -12976,6 +13926,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.OBJECT_LAST_OWNER_ID: ret.Add(new LSL_Key(ScriptBaseClass.NULL_KEY)); break; + case ScriptBaseClass.OBJECT_CLICK_ACTION: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_OMEGA: + ret.Add(new LSL_Vector(Vector3.Zero)); + break; + case ScriptBaseClass.OBJECT_PRIM_COUNT: + List Attachments = av.GetAttachments(); + int count = 0; + try + { + foreach (SceneObjectGroup Attachment in Attachments) + count += Attachment.PrimCount; + } catch { }; + ret.Add(new LSL_Integer(count)); + break; + case ScriptBaseClass.OBJECT_TOTAL_INVENTORY_COUNT: + List invAttachments = av.GetAttachments(); + int invcount = 0; + try + { + foreach (SceneObjectGroup Attachment in invAttachments) + { + SceneObjectPart[] parts = Attachment.Parts; + int nparts = parts.Count(); + for(int i = 0; i < nparts; i++) + invcount += parts[i].Inventory.Count; + } + } catch { }; + ret.Add(new LSL_Integer(invcount)); + break; + case ScriptBaseClass.OBJECT_REZZER_KEY: + ret.Add(new LSL_Key(id)); + break; + case ScriptBaseClass.OBJECT_GROUP_TAG: + ret.Add(new LSL_String(av.Grouptitle)); + break; + case ScriptBaseClass.OBJECT_TEMP_ATTACHED: + ret.Add(new LSL_Integer(0)); + break; default: // Invalid or unhandled constant. ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); @@ -13000,7 +13990,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_String(obj.Description)); break; case ScriptBaseClass.OBJECT_POS: - ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); + Vector3 opos = obj.AbsolutePosition; + ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); break; case ScriptBaseClass.OBJECT_ROT: Quaternion rot = Quaternion.Identity; @@ -13036,7 +14027,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - vel = obj.Velocity; + vel = obj.Velocity; } ret.Add(vel); @@ -13073,9 +14064,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // The value returned in SL for normal prims is prim count ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); break; - // The following 3 costs I have intentionaly coded to return zero. They are part of - // "Land Impact" calculations. These calculations are probably not applicable - // to OpenSim and are not yet complete in SL + + // costs below may need to be diferent for root parts, need to check case ScriptBaseClass.OBJECT_SERVER_COST: // The linden calculation is here // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight @@ -13083,16 +14073,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_Float(0)); break; case ScriptBaseClass.OBJECT_STREAMING_COST: - // The linden calculation is here - // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost - // The value returned in SL for normal prims looks like the prim count * 0.06 - ret.Add(new LSL_Float(0)); + // The value returned in SL for normal prims is prim count * 0.06 + ret.Add(new LSL_Float(obj.StreamingCost)); break; case ScriptBaseClass.OBJECT_PHYSICS_COST: - // The linden calculation is here - // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics - // The value returned in SL for normal prims looks like the prim count - ret.Add(new LSL_Float(0)); + // The value returned in SL for normal prims is prim count + ret.Add(new LSL_Float(obj.PhysicsCost)); break; case ScriptBaseClass.OBJECT_CHARACTER_TIME: // Pathfinding ret.Add(new LSL_Float(0)); @@ -13152,6 +14138,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.OBJECT_LAST_OWNER_ID: ret.Add(new LSL_Key(obj.ParentGroup.LastOwnerID.ToString())); break; + case ScriptBaseClass.OBJECT_CLICK_ACTION: + ret.Add(new LSL_Integer(obj.ClickAction)); + break; + case ScriptBaseClass.OBJECT_OMEGA: + ret.Add(new LSL_Vector(obj.AngularVelocity)); + break; + case ScriptBaseClass.OBJECT_PRIM_COUNT: + ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); + break; + case ScriptBaseClass.OBJECT_TOTAL_INVENTORY_COUNT: + SceneObjectPart[] parts = obj.ParentGroup.Parts; + int nparts = parts.Count(); + int count = 0; + for(int i = 0; i < nparts; i++) + count += parts[i].Inventory.Count; + ret.Add(new LSL_Integer(count)); + break; + case ScriptBaseClass.OBJECT_REZZER_KEY: + ret.Add(new LSL_Key(obj.ParentGroup.RezzerID.ToString())); + break; + case ScriptBaseClass.OBJECT_GROUP_TAG: + ret.Add(new LSL_String(String.Empty)); + break; + case ScriptBaseClass.OBJECT_TEMP_ATTACHED: + if (obj.ParentGroup.AttachmentPoint != 0 && obj.ParentGroup.FromItemID == UUID.Zero) + { + ret.Add(new LSL_Integer(1)); + } + else + { + ret.Add(new LSL_Integer(0)); + } + break; default: // Invalid or unhandled constant. ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); @@ -13286,6 +14305,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(assetID).ToString()); + ScriptSleep(m_sleepMsOnGetNumberOfNotecardLines); return tid.ToString(); } @@ -13301,6 +14321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(id).ToString()); }); + ScriptSleep(m_sleepMsOnGetNumberOfNotecardLines); return tid.ToString(); } @@ -13336,6 +14357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands.DataserverPlugin.DataserverReply( reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); + ScriptSleep(m_sleepMsOnGetNotecardLine); return tid.ToString(); } @@ -13354,6 +14376,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); }); + ScriptSleep(m_sleepMsOnGetNotecardLine); return tid.ToString(); } @@ -13371,12 +14394,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules) { - SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); + SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); + + LSL_List result = new LSL_List(); if (obj != null && obj.OwnerID == m_host.OwnerID) - return GetEntityParams(obj, rules); + { + LSL_List remaining = GetPrimParams(obj, rules, ref result); - return new LSL_List(); + while (remaining.Length > 2) + { + int linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1, -1); + List parts = GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = GetPrimParams(part, rules, ref result); + } + } + + return result; } public void print(string str) @@ -13390,6 +14427,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) + { + List parts = GetLinkParts(link); + if (parts.Count < 1) + return 0; + + return GetNumberOfSides(parts[0]); + } + private string Name2Username(string name) { string[] parts = name.Split(new char[] {' '}); @@ -13432,7 +14478,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rq.ToString(); } - +/* + private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) + { + m_SayShoutCount = 0; + } +*/ private struct Tri { public Vector3 p1; @@ -13453,18 +14504,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return false; } - private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd) + private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd, bool skipPhys) { List contacts = new List(); Vector3 ab = rayEnd - rayStart; + float ablen = ab.Length(); World.ForEachScenePresence(delegate(ScenePresence sp) { + if(skipPhys && sp.PhysicsActor != null) + return; + Vector3 ac = sp.AbsolutePosition - rayStart; -// Vector3 bc = sp.AbsolutePosition - rayEnd; - double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); + double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / ablen); if (d > 1.5) return; @@ -13581,9 +14635,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ContactResult result = new ContactResult (); result.ConsumerID = group.LocalId; - result.Depth = intersection.distance; +// result.Depth = intersection.distance; result.Normal = intersection.normal; result.Pos = intersection.ipoint; + result.Depth = Vector3.Mag(rayStart - result.Pos); contacts.Add(result); }); @@ -13716,6 +14771,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return contacts[0]; } +/* + // not done: + private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght) + { + ContactResult[] contacts = null; + World.ForEachSOG(delegate(SceneObjectGroup group) + { + if (m_host.ParentGroup == group) + return; + + if (group.IsAttachment) + return; + + if(group.RootPart.PhysActor != null) + return; + + contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght); + }); + return contacts; + } +*/ public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) { @@ -13731,7 +14807,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 rayEnd = end; Vector3 dir = rayEnd - rayStart; - float dist = Vector3.Mag(dir); + float dist = dir.Length(); int count = 1; bool detectPhantom = false; @@ -13760,17 +14836,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); - if (World.SupportsRayCastFiltered()) { if (dist == 0) return list; - RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull; + RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; if (checkTerrain) rayfilter |= RayFilterFlags.land; -// if (checkAgents) -// rayfilter |= RayFilterFlags.agent; + if (checkAgents) + rayfilter |= RayFilterFlags.agent; if (checkPhysical) rayfilter |= RayFilterFlags.physical; if (checkNonPhysical) @@ -13796,16 +14871,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (physresults == null) { - list.Add(new LSL_Integer(-3)); // timeout error - return list; +// list.Add(new LSL_Integer(-3)); // timeout error +// return list; + results = new List(); } - - results = (List)physresults; + else + results = (List)physresults; // for now physics doesn't detect sitted avatars so do it outside physics if (checkAgents) { - ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); + ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, true); foreach (ContactResult r in agentHits) results.Add(r); } @@ -13821,12 +14897,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (ContactResult r in objectHits) results.Add(r); } + // Double check this because of current ODE distance problems + if (checkTerrain && dist > 60) + { + bool skipGroundCheck = false; + + foreach (ContactResult c in results) + { + if (c.ConsumerID == 0) // Physics gave us a ground collision + skipGroundCheck = true; + } + + if (!skipGroundCheck) + { + float tmp = dir.X * dir.X + dir.Y * dir.Y; + if(tmp > 2500) + { + ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); + if (groundContact != null) + results.Add((ContactResult)groundContact); + } + } + } } else { if (checkAgents) { - ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); + ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, false); foreach (ContactResult r in agentHits) results.Add(r); } @@ -13841,13 +14939,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api results.Add(objectHits[iter]); } } - } - if (checkTerrain) - { - ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); - if (groundContact != null) - results.Add((ContactResult)groundContact); + if (checkTerrain) + { + ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); + if (groundContact != null) + results.Add((ContactResult)groundContact); + } } results.Sort(delegate(ContactResult a, ContactResult b) @@ -13908,10 +15006,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } list.Add(new LSL_Integer(values)); - return list; } + /// /// Implementation of llCastRay similar to SL 2015-04-21. /// http://wiki.secondlife.com/wiki/LlCastRay @@ -13935,7 +15033,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID userId = UUID.Zero; int msAvailable = 0; // Throttle per owner when attachment or "vehicle" (sat upon) - if (m_host.ParentGroup.IsAttachment || m_host.ParentGroup.GetSittingAvatars().Count > 0) + if (m_host.ParentGroup.IsAttachment || m_host.ParentGroup.GetSittingAvatarsCount() > 0) { userId = m_host.OwnerID; msAvailable = m_msPerAvatarInCastRay; @@ -13968,13 +15066,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api msAvailable -= m_castRayCalls[i].UsedMs; } } - } - // Return failure if not enough available time - if (msAvailable < m_msMinInCastRay) - { - result.Add(new LSL_Integer(ScriptBaseClass.RCERR_CAST_TIME_EXCEEDED)); - return result; + // Return failure if not enough available time + if (msAvailable < m_msMinInCastRay) + { + result.Add(new LSL_Integer(ScriptBaseClass.RCERR_CAST_TIME_EXCEEDED)); + return result; + } } // Initialize @@ -13987,7 +15085,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int rejectTypes = 0; int dataFlags = 0; int maxHits = 1; - bool detectPhantom = false; + bool notdetectPhantom = true; for (int i = 0; i < options.Length; i += 2) { if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES) @@ -13997,7 +15095,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS) maxHits = options.GetLSLIntegerItem(i + 1); else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM) - detectPhantom = (options.GetLSLIntegerItem(i + 1) != 0); + notdetectPhantom = (options.GetLSLIntegerItem(i + 1) == 0); } if (maxHits > m_maxHitsInCastRay) maxHits = m_maxHitsInCastRay; @@ -14027,157 +15125,153 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.ForEachSOG( delegate(SceneObjectGroup group) { + if(group.IsDeleted || group.RootPart == null) + return; // Check group filters unless part filters are configured - bool isPhysical = (group.RootPart != null && group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical); + bool isPhysical = (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical); bool isNonphysical = !isPhysical; bool isPhantom = group.IsPhantom || group.IsVolumeDetect; bool isAttachment = group.IsAttachment; - bool doGroup = true; if (isPhysical && rejectPhysical) - doGroup = false; + return; if (isNonphysical && rejectNonphysical) - doGroup = false; - if (isPhantom && detectPhantom) - doGroup = true; - if (m_filterPartsInCastRay) - doGroup = true; + return; + if (isPhantom && notdetectPhantom) + return; if (isAttachment && !m_doAttachmentsInCastRay) - doGroup = false; + return; + // Parse object/group if passed filters - if (doGroup) + // Iterate over all prims/parts in object/group + foreach(SceneObjectPart part in group.Parts) { - // Iterate over all prims/parts in object/group - foreach(SceneObjectPart part in group.Parts) + // ignore PhysicsShapeType.None as physics engines do + // or we will get into trouble in future + if(part.PhysicsShapeType == (byte)PhysicsShapeType.None) + continue; + isPhysical = (part.PhysActor != null && part.PhysActor.IsPhysical); + isNonphysical = !isPhysical; + isPhantom = ((part.Flags & PrimFlags.Phantom) != 0) || + (part.VolumeDetectActive); + + if (isPhysical && rejectPhysical) + continue; + if (isNonphysical && rejectNonphysical) + continue; + if (isPhantom && notdetectPhantom) + continue; + + // Parse prim/part and project ray if passed filters + Vector3 scalePart = part.Scale; + Vector3 posPart = part.GetWorldPosition(); + Quaternion rotPart = part.GetWorldRotation(); + Quaternion rotPartInv = Quaternion.Inverse(rotPart); + Vector3 pos1RayProj = ((pos1Ray - posPart) * rotPartInv) / scalePart; + Vector3 pos2RayProj = ((pos2Ray - posPart) * rotPartInv) / scalePart; + + // Filter parts by shape bounding boxes + Vector3 shapeBoxMax = new Vector3(0.5f, 0.5f, 0.5f); + if (!part.Shape.SculptEntry) + shapeBoxMax = shapeBoxMax * (new Vector3(m_primSafetyCoeffX, m_primSafetyCoeffY, m_primSafetyCoeffZ)); + shapeBoxMax = shapeBoxMax + (new Vector3(tol, tol, tol)); + if (RayIntersectsShapeBox(pos1RayProj, pos2RayProj, shapeBoxMax)) { - // Check part filters if configured - if (m_filterPartsInCastRay) - { - isPhysical = (part.PhysActor != null && part.PhysActor.IsPhysical); - isNonphysical = !isPhysical; - isPhantom = ((part.Flags & PrimFlags.Phantom) != 0) || (part.VolumeDetectActive); - bool doPart = true; - if (isPhysical && rejectPhysical) - doPart = false; - if (isNonphysical && rejectNonphysical) - doPart = false; - if (isPhantom && detectPhantom) - doPart = true; - if (!doPart) - continue; - } - - // Parse prim/part and project ray if passed filters - Vector3 scalePart = part.Scale; - Vector3 posPart = part.GetWorldPosition(); - Quaternion rotPart = part.GetWorldRotation(); - Quaternion rotPartInv = Quaternion.Inverse(rotPart); - Vector3 pos1RayProj = ((pos1Ray - posPart) * rotPartInv) / scalePart; - Vector3 pos2RayProj = ((pos2Ray - posPart) * rotPartInv) / scalePart; - - // Filter parts by shape bounding boxes - Vector3 shapeBoxMax = new Vector3(0.5f, 0.5f, 0.5f); - if (!part.Shape.SculptEntry) - shapeBoxMax = shapeBoxMax * (new Vector3(m_primSafetyCoeffX, m_primSafetyCoeffY, m_primSafetyCoeffZ)); - shapeBoxMax = shapeBoxMax + (new Vector3(tol, tol, tol)); - if (RayIntersectsShapeBox(pos1RayProj, pos2RayProj, shapeBoxMax)) - { - // Prepare data needed to check for ray hits - RayTrans rayTrans = new RayTrans(); - rayTrans.PartId = part.UUID; - rayTrans.GroupId = part.ParentGroup.UUID; - rayTrans.Link = group.PrimCount > 1 ? part.LinkNum : 0; - rayTrans.ScalePart = scalePart; - rayTrans.PositionPart = posPart; - rayTrans.RotationPart = rotPart; - rayTrans.ShapeNeedsEnds = true; - rayTrans.Position1Ray = pos1Ray; - rayTrans.Position1RayProj = pos1RayProj; - rayTrans.VectorRayProj = pos2RayProj - pos1RayProj; - - // Get detail level depending on type - int lod = 0; - // Mesh detail level - if (part.Shape.SculptEntry && part.Shape.SculptType == (byte)SculptType.Mesh) - lod = (int)m_meshLodInCastRay; - // Sculpt detail level - else if (part.Shape.SculptEntry && part.Shape.SculptType == (byte)SculptType.Mesh) - lod = (int)m_sculptLodInCastRay; - // Shape detail level - else if (!part.Shape.SculptEntry) - lod = (int)m_primLodInCastRay; - - // Try to get cached mesh if configured - ulong meshKey = 0; - FacetedMesh mesh = null; - if (m_useMeshCacheInCastRay) + // Prepare data needed to check for ray hits + RayTrans rayTrans = new RayTrans(); + rayTrans.PartId = part.UUID; + rayTrans.GroupId = part.ParentGroup.UUID; + rayTrans.Link = group.PrimCount > 1 ? part.LinkNum : 0; + rayTrans.ScalePart = scalePart; + rayTrans.PositionPart = posPart; + rayTrans.RotationPart = rotPart; + rayTrans.ShapeNeedsEnds = true; + rayTrans.Position1Ray = pos1Ray; + rayTrans.Position1RayProj = pos1RayProj; + rayTrans.VectorRayProj = pos2RayProj - pos1RayProj; + + // Get detail level depending on type + int lod = 0; + // Mesh detail level + if (part.Shape.SculptEntry && part.Shape.SculptType == (byte)SculptType.Mesh) + lod = (int)m_meshLodInCastRay; + // Sculpt detail level + else if (part.Shape.SculptEntry && part.Shape.SculptType == (byte)SculptType.Mesh) + lod = (int)m_sculptLodInCastRay; + // Shape detail level + else if (!part.Shape.SculptEntry) + lod = (int)m_primLodInCastRay; + + // Try to get cached mesh if configured + ulong meshKey = 0; + FacetedMesh mesh = null; + if (m_useMeshCacheInCastRay) + { + meshKey = part.Shape.GetMeshKey(Vector3.One, (float)(4 << lod)); + lock (m_cachedMeshes) { - meshKey = part.Shape.GetMeshKey(Vector3.One, (float)(4 << lod)); - lock (m_cachedMeshes) - { - m_cachedMeshes.TryGetValue(meshKey, out mesh); - } + m_cachedMeshes.TryGetValue(meshKey, out mesh); } + } - // Create mesh if no cached mesh - if (mesh == null) + // Create mesh if no cached mesh + if (mesh == null) + { + // Make an OMV prim to be able to mesh part + Primitive omvPrim = part.Shape.ToOmvPrimitive(posPart, rotPart); + byte[] sculptAsset = null; + if (omvPrim.Sculpt != null) + sculptAsset = World.AssetService.GetData(omvPrim.Sculpt.SculptTexture.ToString()); + + // When part is mesh, get mesh + if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type == SculptType.Mesh && sculptAsset != null) { - // Make an OMV prim to be able to mesh part - Primitive omvPrim = part.Shape.ToOmvPrimitive(posPart, rotPart); - byte[] sculptAsset = null; - if (omvPrim.Sculpt != null) - sculptAsset = World.AssetService.GetData(omvPrim.Sculpt.SculptTexture.ToString()); - - // When part is mesh, get mesh - if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type == SculptType.Mesh && sculptAsset != null) - { - AssetMesh meshAsset = new AssetMesh(omvPrim.Sculpt.SculptTexture, sculptAsset); - FacetedMesh.TryDecodeFromAsset(omvPrim, meshAsset, m_meshLodInCastRay, out mesh); - meshAsset = null; - } + AssetMesh meshAsset = new AssetMesh(omvPrim.Sculpt.SculptTexture, sculptAsset); + FacetedMesh.TryDecodeFromAsset(omvPrim, meshAsset, m_meshLodInCastRay, out mesh); + meshAsset = null; + } - // When part is sculpt, create mesh - // Quirk: Generated sculpt mesh is about 2.8% smaller in X and Y than visual sculpt. - else if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type != SculptType.Mesh && sculptAsset != null) + // When part is sculpt, create mesh + // Quirk: Generated sculpt mesh is about 2.8% smaller in X and Y than visual sculpt. + else if (omvPrim.Sculpt != null && omvPrim.Sculpt.Type != SculptType.Mesh && sculptAsset != null) + { + IJ2KDecoder imgDecoder = World.RequestModuleInterface(); + if (imgDecoder != null) { - IJ2KDecoder imgDecoder = World.RequestModuleInterface(); - if (imgDecoder != null) + Image sculpt = imgDecoder.DecodeToImage(sculptAsset); + if (sculpt != null) { - Image sculpt = imgDecoder.DecodeToImage(sculptAsset); - if (sculpt != null) - { - mesh = primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt, m_sculptLodInCastRay); - sculpt.Dispose(); - } + mesh = primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt, m_sculptLodInCastRay); + sculpt.Dispose(); } - } - - // When part is shape, create mesh - else if (omvPrim.Sculpt == null) - { - if ( - omvPrim.PrimData.PathBegin == 0.0 && omvPrim.PrimData.PathEnd == 1.0 && - omvPrim.PrimData.PathTaperX == 0.0 && omvPrim.PrimData.PathTaperY == 0.0 && - omvPrim.PrimData.PathSkew == 0.0 && - omvPrim.PrimData.PathTwist - omvPrim.PrimData.PathTwistBegin == 0.0 - ) - rayTrans.ShapeNeedsEnds = false; - mesh = primMesher.GenerateFacetedMesh(omvPrim, m_primLodInCastRay); } + } + + // When part is shape, create mesh + else if (omvPrim.Sculpt == null) + { + if ( + omvPrim.PrimData.PathBegin == 0.0 && omvPrim.PrimData.PathEnd == 1.0 && + omvPrim.PrimData.PathTaperX == 0.0 && omvPrim.PrimData.PathTaperY == 0.0 && + omvPrim.PrimData.PathSkew == 0.0 && + omvPrim.PrimData.PathTwist - omvPrim.PrimData.PathTwistBegin == 0.0 + ) + rayTrans.ShapeNeedsEnds = false; + mesh = primMesher.GenerateFacetedMesh(omvPrim, m_primLodInCastRay); + } - // Cache mesh if configured - if (m_useMeshCacheInCastRay && mesh != null) + // Cache mesh if configured + if (m_useMeshCacheInCastRay && mesh != null) + { + lock(m_cachedMeshes) { - lock(m_cachedMeshes) - { - if (!m_cachedMeshes.ContainsKey(meshKey)) - m_cachedMeshes.Add(meshKey, mesh); - } + if (!m_cachedMeshes.ContainsKey(meshKey)) + m_cachedMeshes.Add(meshKey, mesh); } } - // Check mesh for ray hits - AddRayInFacetedMesh(mesh, rayTrans, ref rayHits); - mesh = null; } + // Check mesh for ray hits + AddRayInFacetedMesh(mesh, rayTrans, ref rayHits); + mesh = null; } } } @@ -14362,13 +15456,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Add to throttle data stopWatch.Stop(); - CastRayCall castRayCall = new CastRayCall(); - castRayCall.RegionId = regionId; - castRayCall.UserId = userId; - castRayCall.CalledMs = calledMs; - castRayCall.UsedMs = (int)stopWatch.ElapsedMilliseconds; lock (m_castRayCalls) { + CastRayCall castRayCall = new CastRayCall(); + castRayCall.RegionId = regionId; + castRayCall.UserId = userId; + castRayCall.CalledMs = calledMs; + castRayCall.UsedMs = (int)stopWatch.ElapsedMilliseconds; m_castRayCalls.Add(castRayCall); } @@ -14813,7 +15907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: if (!isAccount) return 0; if (estate.HasAccess(id)) return 1; - if (estate.IsBanned(id)) + if (estate.IsBanned(id, World.GetUserFlags(id))) estate.RemoveBan(id); estate.AddEstateUser(id); break; @@ -14832,14 +15926,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: if (!isAccount) return 0; - if (estate.IsBanned(id)) return 1; + if (estate.IsBanned(id, World.GetUserFlags(id))) return 1; EstateBan ban = new EstateBan(); ban.EstateID = estate.EstateID; ban.BannedUserID = id; estate.AddBan(ban); break; case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: - if (!isAccount || !estate.IsBanned(id)) return 0; + if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0; estate.RemoveBan(id); break; default: return 0; @@ -14898,13 +15992,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCollisionSprite(string impact_sprite) { m_host.AddScriptLPS(1); - NotImplemented("llCollisionSprite"); + // Viewer 2.0 broke this and it's likely LL has no intention + // of fixing it. Therefore, letting this be a NOP seems appropriate. } public void llGodLikeRezObject(string inventory, LSL_Vector pos) { m_host.AddScriptLPS(1); - NotImplemented("llGodLikeRezObject"); + + if (!World.Permissions.IsGod(m_host.OwnerID)) + NotImplemented("llGodLikeRezObject"); + + AssetBase rezAsset = World.AssetService.Get(inventory); + if (rezAsset == null) + { + llSay(0, "Asset not found"); + return; + } + + SceneObjectGroup group = null; + + try + { + string xmlData = Utils.BytesToString(rezAsset.Data); + group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + } + catch + { + llSay(0, "Asset not found"); + return; + } + + if (group == null) + { + llSay(0, "Asset not found"); + return; + } + + group.RootPart.AttachedPos = group.AbsolutePosition; + + group.ResetIDs(); + + Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); + group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); + group.ScheduleGroupForFullUpdate(); + + // objects rezzed with this method are die_at_edge by default. + group.RootPart.SetDieAtEdge(true); + + group.ResumeScripts(); + + m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( + "object_rez", new Object[] { + new LSL_String( + group.RootPart.UUID.ToString()) }, + new DetectParams[0])); } public LSL_String llTransferLindenDollars(string destination, int amount) @@ -14918,6 +16061,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { + if (amount <= 0) + { + replydata = "INVALID_AMOUNT"; + return; + } + TaskInventoryItem item = m_item; if (item == null) { @@ -14925,6 +16074,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + if (m_host.OwnerID == m_host.GroupID) + { + replydata = "GROUP_OWNED"; + return; + } + m_host.AddScriptLPS(1); if (item.PermsGranter == UUID.Zero) @@ -14947,6 +16102,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, toID); + if (account == null) + { + replydata = "LINDENDOLLAR_ENTITYDOESNOTEXIST"; + return; + } + IMoneyModule money = World.RequestModuleInterface(); if (money == null) @@ -14955,8 +16117,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - bool result = money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); + string reason; + bool result = money.ObjectGiveMoney( m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, txn, out reason); if (result) { @@ -14964,7 +16126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - replydata = "LINDENDOLLAR_INSUFFICIENTFUNDS"; + replydata = reason; } finally { @@ -14981,6 +16143,1366 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } #endregion + + + protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) + { + //This is a special version of SetPrimParams to deal with avatars which are sitting on the linkset. + + int idx = 0; + int idxStart = 0; + + bool positionChanged = false; + try + { + while (idx < rules.Length) + { + ++rulesParsed; + int code = rules.GetLSLIntegerItem(idx++); + + int remain = rules.Length - idx; + idxStart = idx; + + switch (code) + { + case (int)ScriptBaseClass.PRIM_POSITION: + case (int)ScriptBaseClass.PRIM_POS_LOCAL: + { + if (remain < 1) + return new LSL_List(); + + LSL_Vector v; + v = rules.GetVector3Item(idx++); + + if(!av.LegacySitOffsets) + { + LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); + + v = v + 2 * sitOffset; + } + + av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); + positionChanged = true; + } + break; + + case (int)ScriptBaseClass.PRIM_ROTATION: + { + if (remain < 1) + return new LSL_List(); + + Quaternion r; + r = rules.GetQuaternionItem(idx++); + + av.Rotation = m_host.GetWorldRotation() * r; + positionChanged = true; + } + break; + + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + { + if (remain < 1) + return new LSL_List(); + + LSL_Rotation r; + r = rules.GetQuaternionItem(idx++); + + av.Rotation = r; + positionChanged = true; + } + break; + + // parse rest doing nothing but number of parameters error check + case (int)ScriptBaseClass.PRIM_SIZE: + case (int)ScriptBaseClass.PRIM_MATERIAL: + case (int)ScriptBaseClass.PRIM_PHANTOM: + case (int)ScriptBaseClass.PRIM_PHYSICS: + case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + case (int)ScriptBaseClass.PRIM_NAME: + case (int)ScriptBaseClass.PRIM_DESC: + if (remain < 1) + return new LSL_List(); + idx++; + break; + + case (int)ScriptBaseClass.PRIM_GLOW: + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + case (int)ScriptBaseClass.PRIM_TEXGEN: + if (remain < 2) + return new LSL_List(); + idx += 2; + break; + + case (int)ScriptBaseClass.PRIM_TYPE: + if (remain < 3) + return new LSL_List(); + code = (int)rules.GetLSLIntegerItem(idx++); + remain = rules.Length - idx; + switch (code) + { + case (int)ScriptBaseClass.PRIM_TYPE_BOX: + case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: + case (int)ScriptBaseClass.PRIM_TYPE_PRISM: + if (remain < 6) + return new LSL_List(); + idx += 6; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: + if (remain < 5) + return new LSL_List(); + idx += 5; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_TORUS: + case (int)ScriptBaseClass.PRIM_TYPE_TUBE: + case (int)ScriptBaseClass.PRIM_TYPE_RING: + if (remain < 11) + return new LSL_List(); + idx += 11; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: + if (remain < 2) + return new LSL_List(); + idx += 2; + break; + } + break; + + case (int)ScriptBaseClass.PRIM_COLOR: + case (int)ScriptBaseClass.PRIM_TEXT: + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + case (int)ScriptBaseClass.PRIM_OMEGA: + case (int)ScriptBaseClass.PRIM_SIT_TARGET: + if (remain < 3) + return new LSL_List(); + idx += 3; + break; + + case (int)ScriptBaseClass.PRIM_TEXTURE: + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: + if (remain < 5) + return new LSL_List(); + idx += 5; + break; + + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + if (remain < 7) + return new LSL_List(); + + idx += 7; + break; + + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return new LSL_List(); + + return rules.GetSublist(idx, -1); + } + } + } + catch (InvalidCastException e) + { + Error(originFunc,string.Format( + " error running rule #{0}: arg #{1} {2}", + rulesParsed, idx - idxStart, e.Message)); + } + finally + { + if (positionChanged) + av.SendTerseUpdateToAllClients(); + } + return new LSL_List(); + } + + public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res) + { + // avatars case + // replies as SL wiki + +// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed + SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? + + int idx = 0; + while (idx < rules.Length) + { + int code = (int)rules.GetLSLIntegerItem(idx++); + int remain = rules.Length - idx; + + switch (code) + { + case (int)ScriptBaseClass.PRIM_MATERIAL: + res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); + break; + + case (int)ScriptBaseClass.PRIM_PHYSICS: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_PHANTOM: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_POSITION: + Vector3 pos; + + if (sitPart.ParentGroup.RootPart != null) + { + pos = avatar.OffsetPosition; + + if(!avatar.LegacySitOffsets) + { + Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); + pos -= sitOffset; + } + + SceneObjectPart sitroot = sitPart.ParentGroup.RootPart; + pos = sitroot.AbsolutePosition + pos * sitroot.GetWorldRotation(); + } + else + pos = avatar.AbsolutePosition; + + res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); + break; + + case (int)ScriptBaseClass.PRIM_SIZE: + Vector3 s = avatar.Appearance.AvatarSize; + res.Add(new LSL_Vector(s.X, s.Y, s.Z)); + + break; + + case (int)ScriptBaseClass.PRIM_ROTATION: + res.Add(new LSL_Rotation(avatar.GetWorldRotation())); + break; + + case (int)ScriptBaseClass.PRIM_TYPE: + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); + res.Add(new LSL_Vector(0f,1.0f,0f)); + res.Add(new LSL_Float(0.0f)); + res.Add(new LSL_Vector(0, 0, 0)); + res.Add(new LSL_Vector(1.0f,1.0f,0f)); + res.Add(new LSL_Vector(0, 0, 0)); + break; + + case (int)ScriptBaseClass.PRIM_TEXTURE: + if (remain < 1) + return new LSL_List(); + + int face = (int)rules.GetLSLIntegerItem(idx++); + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0.0)); + } + } + else + { + if (face >= 0 && face < 21) + { + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0.0)); + } + } + break; + + case (int)ScriptBaseClass.PRIM_COLOR: + if (remain < 1) + return new LSL_List(); + + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0)); + } + } + else + { + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0)); + } + break; + + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + if (remain < 1) + return new LSL_List(); + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); + } + break; + + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + if (remain < 1) + return new LSL_List(); + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); + } + break; + + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + res.Add(new LSL_Integer(0)); + res.Add(new LSL_Integer(0));// softness + res.Add(new LSL_Float(0.0f)); // gravity + res.Add(new LSL_Float(0.0f)); // friction + res.Add(new LSL_Float(0.0f)); // wind + res.Add(new LSL_Float(0.0f)); // tension + res.Add(new LSL_Vector(0f,0f,0f)); + break; + + case (int)ScriptBaseClass.PRIM_TEXGEN: + // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) + if (remain < 1) + return new LSL_List(); + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + break; + + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + res.Add(new LSL_Integer(0)); + res.Add(new LSL_Vector(0f,0f,0f)); + res.Add(new LSL_Float(0f)); // intensity + res.Add(new LSL_Float(0f)); // radius + res.Add(new LSL_Float(0f)); // falloff + break; + + case (int)ScriptBaseClass.PRIM_GLOW: + if (remain < 1) + return new LSL_List(); + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Float(0f)); + } + } + else + { + res.Add(new LSL_Float(0f)); + } + break; + + case (int)ScriptBaseClass.PRIM_TEXT: + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0f,0f,0f)); + res.Add(new LSL_Float(1.0f)); + break; + + case (int)ScriptBaseClass.PRIM_NAME: + res.Add(new LSL_String(avatar.Name)); + break; + + case (int)ScriptBaseClass.PRIM_DESC: + res.Add(new LSL_String("")); + break; + + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + Quaternion lrot = avatar.Rotation; + res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); + break; + + case (int)ScriptBaseClass.PRIM_POS_LOCAL: + Vector3 lpos = avatar.OffsetPosition; + + if(!avatar.LegacySitOffsets) + { + Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); + lpos -= lsitOffset; + } + + res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); + break; + + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return new LSL_List(); + + return rules.GetSublist(idx, -1); + } + } + + return new LSL_List(); + } + + public void llSetAnimationOverride(LSL_String animState, LSL_String anim) + { + string state = String.Empty; + + foreach (KeyValuePair kvp in MovementAnimationsForLSL) + { + if (kvp.Value.ToLower() == ((string)animState).ToLower()) + { + state = kvp.Key; + break; + } + } + + if (state == String.Empty) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "Invalid animation state " + animState); + return; + } + + if (m_item.PermsGranter == UUID.Zero) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return; + } + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS) == 0) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return; + } + + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); + + if (presence == null) + return; + + UUID animID; + + animID = ScriptUtils.GetAssetIdFromItemName(m_host, anim, (int)AssetType.Animation); + + if (animID == UUID.Zero) + { + String animupper = ((string)anim).ToUpperInvariant(); + DefaultAvatarAnimations.AnimsUUID.TryGetValue(animupper, out animID); + } + + if (animID == UUID.Zero) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "Animation not found"); + return; + } + + presence.SetAnimationOverride(state, animID); + } + + public void llResetAnimationOverride(LSL_String animState) + { + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); + if (presence == null) + return; + + if (m_item.PermsGranter == UUID.Zero) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return; + } + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS) == 0) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return; + } + + if (animState == "ALL") + { + presence.SetAnimationOverride("ALL", UUID.Zero); + return; + } + + string state = String.Empty; + + foreach (KeyValuePair kvp in MovementAnimationsForLSL) + { + if (kvp.Value.ToLower() == ((string)animState).ToLower()) + { + state = kvp.Key; + break; + } + } + + if (state == String.Empty) + { + return; + } + + presence.SetAnimationOverride(state, UUID.Zero); + } + + public LSL_String llGetAnimationOverride(LSL_String animState) + { + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); + if (presence == null) + return String.Empty; + + if (m_item.PermsGranter == UUID.Zero) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return String.Empty; + } + + if ((m_item.PermsMask & (ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION)) == 0) + { + llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); + return String.Empty; + } + + string state = String.Empty; + + foreach (KeyValuePair kvp in MovementAnimationsForLSL) + { + if (kvp.Value.ToLower() == ((string)animState).ToLower()) + { + state = kvp.Key; + break; + } + } + + if (state == String.Empty) + { + return String.Empty; + } + + UUID animID = presence.GetAnimationOverride(state); + if (animID == UUID.Zero) + return animState; + + foreach (KeyValuePair kvp in DefaultAvatarAnimations.AnimsUUID) + { + if (kvp.Value == animID) + return kvp.Key.ToLower(); + } + + foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) + { + if (item.AssetID == animID) + return item.Name; + } + + return String.Empty; + } + + public LSL_List llJson2List(LSL_String json) + { + if(String.IsNullOrEmpty(json)) + return new LSL_List(); + if(json == "[]") + return new LSL_List(); + if(json == "{}") + return new LSL_List(); + char first = ((string)json)[0]; + + if(first != '[' && first !='{') + { + // we already have a single element + LSL_List l = new LSL_List(); + l.Add(json); + return l; + } + + LitJson.JsonData jsdata; + try + { + jsdata = LitJson.JsonMapper.ToObject(json); + } + catch (Exception e) + { + string m = e.Message; // debug point + return json; + } + try + { + return JsonParseTop(jsdata); + } + catch (Exception e) + { + string m = e.Message; // debug point + return (LSL_String)ScriptBaseClass.JSON_INVALID; + } + } + + private LSL_List JsonParseTop(LitJson.JsonData elem) + { + LSL_List retl = new LSL_List(); + if(elem == null) + retl.Add((LSL_String)ScriptBaseClass.JSON_NULL); + + LitJson.JsonType elemType = elem.GetJsonType(); + switch (elemType) + { + case LitJson.JsonType.Int: + retl.Add(new LSL_Integer((int)elem)); + return retl; + case LitJson.JsonType.Boolean: + retl.Add((LSL_String)((bool)elem ? ScriptBaseClass.JSON_TRUE : ScriptBaseClass.JSON_FALSE)); + return retl; + case LitJson.JsonType.Double: + retl.Add(new LSL_Float((double)elem)); + return retl; + case LitJson.JsonType.None: + retl.Add((LSL_String)ScriptBaseClass.JSON_NULL); + return retl; + case LitJson.JsonType.String: + retl.Add(new LSL_String((string)elem)); + return retl; + case LitJson.JsonType.Array: + foreach (LitJson.JsonData subelem in elem) + retl.Add(JsonParseTopNodes(subelem)); + return retl; + case LitJson.JsonType.Object: + IDictionaryEnumerator e = ((IOrderedDictionary)elem).GetEnumerator(); + while (e.MoveNext()) + { + retl.Add(new LSL_String((string)e.Key)); + retl.Add(JsonParseTopNodes((LitJson.JsonData)e.Value)); + } + return retl; + default: + throw new Exception(ScriptBaseClass.JSON_INVALID); + } + } + + private object JsonParseTopNodes(LitJson.JsonData elem) + { + if(elem == null) + return ((LSL_String)ScriptBaseClass.JSON_NULL); + + LitJson.JsonType elemType = elem.GetJsonType(); + switch (elemType) + { + case LitJson.JsonType.Int: + return (new LSL_Integer((int)elem)); + case LitJson.JsonType.Boolean: + return ((bool)elem ? (LSL_String)ScriptBaseClass.JSON_TRUE : (LSL_String)ScriptBaseClass.JSON_FALSE); + case LitJson.JsonType.Double: + return (new LSL_Float((double)elem)); + case LitJson.JsonType.None: + return ((LSL_String)ScriptBaseClass.JSON_NULL); + case LitJson.JsonType.String: + return (new LSL_String((string)elem)); + case LitJson.JsonType.Array: + case LitJson.JsonType.Object: + string s = LitJson.JsonMapper.ToJson(elem); + return (LSL_String)s; + default: + throw new Exception(ScriptBaseClass.JSON_INVALID); + } + } + + public LSL_String llList2Json(LSL_String type, LSL_List values) + { + try + { + StringBuilder sb = new StringBuilder(); + if (type == ScriptBaseClass.JSON_ARRAY) + { + sb.Append("["); + int i= 0; + foreach (object o in values.Data) + { + sb.Append(ListToJson(o)); + if((i++) < values.Data.Length - 1) + sb.Append(","); + } + sb.Append("]"); + return (LSL_String)sb.ToString();; + } + else if (type == ScriptBaseClass.JSON_OBJECT) + { + sb.Append("{"); + for (int i = 0; i < values.Data.Length; i += 2) + { + if (!(values.Data[i] is LSL_String)) + return ScriptBaseClass.JSON_INVALID; + string key = ((LSL_String)values.Data[i]).m_string; + key = EscapeForJSON(key, true); + sb.Append(key); + sb.Append(":"); + sb.Append(ListToJson(values.Data[i+1])); + if(i < values.Data.Length - 2) + sb.Append(","); + } + sb.Append("}"); + return (LSL_String)sb.ToString(); + } + return ScriptBaseClass.JSON_INVALID; + } + catch + { + return ScriptBaseClass.JSON_INVALID; + } + } + + private string ListToJson(object o) + { + if (o is LSL_Float || o is double) + { + double float_val; + if (o is double) + float_val = ((double)o); + else + float_val = ((LSL_Float)o).value; + + if(double.IsInfinity(float_val)) + return "\"Inf\""; + if(double.IsNaN(float_val)) + return "\"NaN\""; + + return ((LSL_Float)float_val).ToString(); + } + if (o is LSL_Integer || o is int) + { + int i; + if (o is int) + i = ((int)o); + else + i = ((LSL_Integer)o).value; + return i.ToString(); + } + if (o is LSL_Rotation) + { + StringBuilder sb = new StringBuilder(128); + sb.Append("\""); + LSL_Rotation r = (LSL_Rotation)o; + sb.Append(r.ToString()); + sb.Append("\""); + return sb.ToString(); + } + if (o is LSL_Vector) + { + StringBuilder sb = new StringBuilder(128); + sb.Append("\""); + LSL_Vector v = (LSL_Vector)o; + sb.Append(v.ToString()); + sb.Append("\""); + return sb.ToString(); + } + if (o is LSL_String || o is string) + { + string str; + if (o is string) + str = ((string)o); + else + str = ((LSL_String)o).m_string; + + if(str == ScriptBaseClass.JSON_TRUE || str == "true") + return "true"; + if(str == ScriptBaseClass.JSON_FALSE ||str == "false") + return "false"; + if(str == ScriptBaseClass.JSON_NULL || str == "null") + return "null"; + str.Trim(); + if (str[0] == '{') + return str; + if (str[0] == '[') + return str; + return EscapeForJSON(str, true); + } + throw new IndexOutOfRangeException(); + } + + private string EscapeForJSON(string s, bool AddOuter) + { + int i; + char c; + String t; + int len = s.Length; + + StringBuilder sb = new StringBuilder(len + 64); + if(AddOuter) + sb.Append("\""); + + for (i = 0; i < len; i++) + { + c = s[i]; + switch (c) + { + case '\\': + case '"': + case '/': + sb.Append('\\'); + sb.Append(c); + break; + case '\b': + sb.Append("\\b"); + break; + case '\t': + sb.Append("\\t"); + break; + case '\n': + sb.Append("\\n"); + break; + case '\f': + sb.Append("\\f"); + break; + case '\r': + sb.Append("\\r"); + break; + default: + if (c < ' ') + { + t = "000" + String.Format("X", c); + sb.Append("\\u" + t.Substring(t.Length - 4)); + } + else + { + sb.Append(c); + } + break; + } + } + if(AddOuter) + sb.Append("\""); + return sb.ToString(); + } + + public LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value) + { + bool noSpecifiers = specifiers.Length == 0; + LitJson.JsonData workData; + try + { + if(noSpecifiers) + specifiers.Add(new LSL_Integer(0)); + + if(!String.IsNullOrEmpty(json)) + workData = LitJson.JsonMapper.ToObject(json); + else + { + workData = new LitJson.JsonData(); + workData.SetJsonType(LitJson.JsonType.Array); + } + } + catch (Exception e) + { + string m = e.Message; // debug point + return ScriptBaseClass.JSON_INVALID; + } + try + { + LitJson.JsonData replace = JsonSetSpecific(workData, specifiers, 0, value); + if(replace != null) + workData = replace; + } + catch (Exception e) + { + string m = e.Message; // debug point + return ScriptBaseClass.JSON_INVALID; + } + + try + { + string r = LitJson.JsonMapper.ToJson(workData); + if(noSpecifiers) + r = r.Substring(1,r.Length -2); // strip leading and trailing brakets + return r; + } + catch (Exception e) + { + string m = e.Message; // debug point + } + return ScriptBaseClass.JSON_INVALID; + } + + private LitJson.JsonData JsonSetSpecific(LitJson.JsonData elem, LSL_List specifiers, int level, LSL_String val) + { + object spec = specifiers.Data[level]; + if(spec is LSL_String) + spec = ((LSL_String)spec).m_string; + else if (spec is LSL_Integer) + spec = ((LSL_Integer)spec).value; + + if(!(spec is string || spec is int)) + throw new IndexOutOfRangeException(); + + int speclen = specifiers.Data.Length - 1; + + bool hasvalue = false; + LitJson.JsonData value = null; + + LitJson.JsonType elemType = elem.GetJsonType(); + if (elemType == LitJson.JsonType.Array) + { + if (spec is int) + { + int v = (int)spec; + int c = elem.Count; + if(v < 0 || (v != 0 && v > c)) + throw new IndexOutOfRangeException(); + if(v == c) + elem.Add(JsonBuildRestOfSpec(specifiers, level + 1, val)); + else + { + hasvalue = true; + value = elem[v]; + } + } + else if (spec is string) + { + if((string)spec == ScriptBaseClass.JSON_APPEND) + elem.Add(JsonBuildRestOfSpec(specifiers, level + 1, val)); + else if(elem.Count < 2) + { + // our initial guess of array was wrong + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Object); + IOrderedDictionary no = newdata as IOrderedDictionary; + no.Add((string)spec,JsonBuildRestOfSpec(specifiers, level + 1, val)); + return newdata; + } + } + } + else if (elemType == LitJson.JsonType.Object) + { + if (spec is string) + { + IOrderedDictionary e = elem as IOrderedDictionary; + string key = (string)spec; + if(e.Contains(key)) + { + hasvalue = true; + value = (LitJson.JsonData)e[key]; + } + else + e.Add(key, JsonBuildRestOfSpec(specifiers, level + 1, val)); + } + else if(spec is int && (int)spec == 0) + { + //we are replacing a object by a array + LitJson.JsonData newData = new LitJson.JsonData(); + newData.SetJsonType(LitJson.JsonType.Array); + newData.Add(JsonBuildRestOfSpec(specifiers, level + 1, val)); + return newData; + } + } + else + { + LitJson.JsonData newData = JsonBuildRestOfSpec(specifiers, level, val); + return newData; + } + + if (hasvalue) + { + if (level < speclen) + { + LitJson.JsonData replace = JsonSetSpecific(value, specifiers, level + 1, val); + if(replace != null) + { + if(elemType == LitJson.JsonType.Array) + { + if(spec is int) + elem[(int)spec] = replace; + else if( spec is string) + { + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Object); + IOrderedDictionary no = newdata as IOrderedDictionary; + no.Add((string)spec, replace); + return newdata; + } + } + else if(elemType == LitJson.JsonType.Object) + { + if(spec is string) + elem[(string)spec] = replace; + else if(spec is int && (int)spec == 0) + { + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Array); + newdata.Add(replace); + return newdata; + } + } + } + return null; + } + else if(speclen == level) + { + if(val == ScriptBaseClass.JSON_DELETE) + { + if(elemType == LitJson.JsonType.Array) + { + if(spec is int) + { + IList el = elem as IList; + el.RemoveAt((int)spec); + } + } + else if(elemType == LitJson.JsonType.Object) + { + if(spec is string) + { + IOrderedDictionary eo = elem as IOrderedDictionary; + eo.Remove((string) spec); + } + } + return null; + } + + LitJson.JsonData newval = null; + float num; + if(val == null || val == ScriptBaseClass.JSON_NULL || val == "null") + newval = null; + else if(val == ScriptBaseClass.JSON_TRUE || val == "true") + newval = new LitJson.JsonData(true); + else if(val == ScriptBaseClass.JSON_FALSE || val == "false") + newval = new LitJson.JsonData(false); + else if(float.TryParse(val, out num)) + { + // assuming we are at en.us already + if(num - (int)num == 0.0f && !val.Contains(".")) + newval = new LitJson.JsonData((int)num); + else + { + num = (float)Math.Round(num,6); + newval = new LitJson.JsonData((double)num); + } + } + else + { + string str = val.m_string; + newval = new LitJson.JsonData(str); + } + + if(elemType == LitJson.JsonType.Array) + { + if(spec is int) + elem[(int)spec] = newval; + else if( spec is string) + { + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Object); + IOrderedDictionary no = newdata as IOrderedDictionary; + no.Add((string)spec,newval); + return newdata; + } + } + else if(elemType == LitJson.JsonType.Object) + { + if(spec is string) + elem[(string)spec] = newval; + else if(spec is int && (int)spec == 0) + { + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Array); + newdata.Add(newval); + return newdata; + } + } + } + } + if(val == ScriptBaseClass.JSON_DELETE) + throw new IndexOutOfRangeException(); + return null; + } + + private LitJson.JsonData JsonBuildRestOfSpec(LSL_List specifiers, int level, LSL_String val) + { + object spec = level >= specifiers.Data.Length ? null : specifiers.Data[level]; + // 20131224 not used object specNext = i+1 >= specifiers.Data.Length ? null : specifiers.Data[i+1]; + + float num; + if (spec == null) + { + if(val == null || val == ScriptBaseClass.JSON_NULL || val == "null") + return null; + if(val == ScriptBaseClass.JSON_DELETE) + throw new IndexOutOfRangeException(); + if(val == ScriptBaseClass.JSON_TRUE || val == "true") + return new LitJson.JsonData(true); + if(val == ScriptBaseClass.JSON_FALSE || val == "false") + return new LitJson.JsonData(false); + if(val == null || val == ScriptBaseClass.JSON_NULL || val == "null") + return null; + if(float.TryParse(val, out num)) + { + // assuming we are at en.us already + if(num - (int)num == 0.0f && !val.Contains(".")) + return new LitJson.JsonData((int)num); + else + { + num = (float)Math.Round(num,6); + return new LitJson.JsonData(num); + } + } + else + { + string str = val.m_string; + return new LitJson.JsonData(str); + } + throw new IndexOutOfRangeException(); + } + + if(spec is LSL_String) + spec = ((LSL_String)spec).m_string; + else if (spec is LSL_Integer) + spec = ((LSL_Integer)spec).value; + + if (spec is int || + (spec is string && ((string)spec) == ScriptBaseClass.JSON_APPEND) ) + { + if(spec is int && (int)spec != 0) + throw new IndexOutOfRangeException(); + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Array); + newdata.Add(JsonBuildRestOfSpec(specifiers, level + 1, val)); + return newdata; + } + else if (spec is string) + { + LitJson.JsonData newdata = new LitJson.JsonData(); + newdata.SetJsonType(LitJson.JsonType.Object); + IOrderedDictionary no = newdata as IOrderedDictionary; + no.Add((string)spec,JsonBuildRestOfSpec(specifiers, level + 1, val)); + return newdata; + } + throw new IndexOutOfRangeException(); + } + + private bool JsonFind(LitJson.JsonData elem, LSL_List specifiers, int level, out LitJson.JsonData value) + { + value = null; + if(elem == null) + return false; + + object spec; + spec = specifiers.Data[level]; + + bool haveVal = false; + LitJson.JsonData next = null; + + if (elem.GetJsonType() == LitJson.JsonType.Array) + { + if (spec is LSL_Integer) + { + int indx = (LSL_Integer)spec; + if(indx >= 0 && indx < elem.Count) + { + haveVal = true; + next = (LitJson.JsonData)elem[indx]; + } + } + } + else if (elem.GetJsonType() == LitJson.JsonType.Object) + { + if (spec is LSL_String) + { + IOrderedDictionary e = elem as IOrderedDictionary; + string key = (LSL_String)spec; + if(e.Contains(key)) + { + haveVal = true; + next = (LitJson.JsonData)e[key]; + } + } + } + + if (haveVal) + { + if(level == specifiers.Data.Length - 1) + { + value = next; + return true; + } + + level++; + if(next == null) + return false; + + LitJson.JsonType nextType = next.GetJsonType(); + if(nextType != LitJson.JsonType.Object && nextType != LitJson.JsonType.Array) + return false; + + return JsonFind(next, specifiers, level, out value); + } + return false; + } + + public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers) + { + if(String.IsNullOrWhiteSpace(json)) + return ScriptBaseClass.JSON_INVALID; + + if(specifiers.Length > 0 && (json == "{}" || json == "[]")) + return ScriptBaseClass.JSON_INVALID; + + char first = ((string)json)[0]; + if((first != '[' && first !='{')) + { + if(specifiers.Length > 0) + return ScriptBaseClass.JSON_INVALID; + json = "[" + json + "]"; // could handle single element case.. but easier like this + specifiers.Add((LSL_Integer)0); + } + + LitJson.JsonData jsonData; + try + { + jsonData = LitJson.JsonMapper.ToObject(json); + } + catch (Exception e) + { + string m = e.Message; // debug point + return ScriptBaseClass.JSON_INVALID; + } + + LitJson.JsonData elem = null; + if(specifiers.Length == 0) + elem = jsonData; + else + { + if(!JsonFind(jsonData, specifiers, 0, out elem)) + return ScriptBaseClass.JSON_INVALID; + } + return JsonElementToString(elem); + } + + private LSL_String JsonElementToString(LitJson.JsonData elem) + { + if(elem == null) + return ScriptBaseClass.JSON_NULL; + + LitJson.JsonType elemType = elem.GetJsonType(); + switch(elemType) + { + case LitJson.JsonType.Array: + return new LSL_String(LitJson.JsonMapper.ToJson(elem)); + case LitJson.JsonType.Boolean: + return new LSL_String((bool)elem ? ScriptBaseClass.JSON_TRUE : ScriptBaseClass.JSON_FALSE); + case LitJson.JsonType.Double: + double d= (double)elem; + string sd = String.Format(Culture.FormatProvider, "{0:0.0#####}",d); + return new LSL_String(sd); + case LitJson.JsonType.Int: + int i = (int)elem; + return new LSL_String(i.ToString()); + case LitJson.JsonType.Long: + long l = (long)elem; + return new LSL_String(l.ToString()); + case LitJson.JsonType.Object: + return new LSL_String(LitJson.JsonMapper.ToJson(elem)); + case LitJson.JsonType.String: + string s = (string)elem; + return new LSL_String(s); + case LitJson.JsonType.None: + return ScriptBaseClass.JSON_NULL; + default: + return ScriptBaseClass.JSON_INVALID; + } + } + + public LSL_String llJsonValueType(LSL_String json, LSL_List specifiers) + { + if(String.IsNullOrWhiteSpace(json)) + return ScriptBaseClass.JSON_INVALID; + + if(specifiers.Length > 0 && (json == "{}" || json == "[]")) + return ScriptBaseClass.JSON_INVALID; + + char first = ((string)json)[0]; + if((first != '[' && first !='{')) + { + if(specifiers.Length > 0) + return ScriptBaseClass.JSON_INVALID; + json = "[" + json + "]"; // could handle single element case.. but easier like this + specifiers.Add((LSL_Integer)0); + } + + LitJson.JsonData jsonData; + try + { + jsonData = LitJson.JsonMapper.ToObject(json); + } + catch (Exception e) + { + string m = e.Message; // debug point + return ScriptBaseClass.JSON_INVALID; + } + + LitJson.JsonData elem = null; + if(specifiers.Length == 0) + elem = jsonData; + else + { + if(!JsonFind(jsonData, specifiers, 0, out elem)) + return ScriptBaseClass.JSON_INVALID; + } + + if(elem == null) + return ScriptBaseClass.JSON_NULL; + + LitJson.JsonType elemType = elem.GetJsonType(); + switch(elemType) + { + case LitJson.JsonType.Array: + return ScriptBaseClass.JSON_ARRAY; + case LitJson.JsonType.Boolean: + return (bool)elem ? ScriptBaseClass.JSON_TRUE : ScriptBaseClass.JSON_FALSE; + case LitJson.JsonType.Double: + case LitJson.JsonType.Int: + case LitJson.JsonType.Long: + return ScriptBaseClass.JSON_NUMBER; + case LitJson.JsonType.Object: + return ScriptBaseClass.JSON_OBJECT; + case LitJson.JsonType.String: + string s = (string)elem; + if(s == ScriptBaseClass.JSON_NULL) + return ScriptBaseClass.JSON_NULL; + if(s == ScriptBaseClass.JSON_TRUE) + return ScriptBaseClass.JSON_TRUE; + if(s == ScriptBaseClass.JSON_FALSE) + return ScriptBaseClass.JSON_FALSE; + return ScriptBaseClass.JSON_STRING; + case LitJson.JsonType.None: + return ScriptBaseClass.JSON_NULL; + default: + return ScriptBaseClass.JSON_INVALID; + } + } } public class NotecardCache diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index e5e43f8..238fefb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -295,7 +295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: idx++; - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); try { wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); @@ -721,7 +721,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { ScenePresence sp = World.GetScenePresence(m_host.OwnerID); - if (sp == null || sp.GodLevel < 200) + if (sp == null || !sp.IsViewerUIGod) { LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); return 0; @@ -768,7 +768,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { ScenePresence sp = World.GetScenePresence(m_host.OwnerID); - if (sp == null || sp.GodLevel < 200) + if (sp == null || !sp.IsViewerUIGod) { LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); return; @@ -799,7 +799,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { ScenePresence sp = World.GetScenePresence(m_host.OwnerID); - if (sp == null || sp.GodLevel < 200) + if (sp == null || !sp.IsViewerUIGod) { LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); return 0; @@ -831,6 +831,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } return success; - } + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 1458c95..692bec0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -107,14 +107,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Dumps an error message on the debug console. /// /// - internal void MODShoutError(string message) + internal void MODShoutError(string message) { if (message.Length > 1023) message = message.Substring(0, 1023); World.SimChat( Utils.StringToBytes(message), - ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, + ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); @@ -122,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } /// - /// + /// /// /// The name of the function to invoke /// List of parameters @@ -130,13 +130,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void modInvokeN(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); - if (returntype != typeof(string)) + if (returntype != typeof(void)) MODError(String.Format("return type mismatch for {0}",fname)); modInvoke(fname,parms); @@ -145,9 +145,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String modInvokeS(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -161,9 +161,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer modInvokeI(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -173,13 +173,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int result = (int)modInvoke(fname,parms); return new LSL_Integer(result); } - + public LSL_Float modInvokeF(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -193,9 +193,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key modInvokeK(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -209,9 +209,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector modInvokeV(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -225,9 +225,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation modInvokeR(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -241,9 +241,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List modInvokeL(string fname, params object[] parms) { // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type returntype = m_comms.LookupReturnType(fname); @@ -308,27 +308,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // m_log.DebugFormat( -// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", -// fname, -// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), +// "[MOD API]: Invoking dynamic function {0}, args '{1}' with {2} return type", +// fname, +// string.Join(",", Array.ConvertAll(parms, o => o.ToString())), // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); Type[] signature = m_comms.LookupTypeSignature(fname); if (signature.Length != parms.Length) MODError(String.Format("wrong number of parameters to function {0}",fname)); - + object[] convertedParms = new object[parms.Length]; for (int i = 0; i < parms.Length; i++) convertedParms[i] = ConvertFromLSL(parms[i], signature[i], fname); // now call the function, the contract with the function is that it will always return // non-null but don't trust it completely - try + try { object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms); if (result != null) return result; + Type returntype = m_comms.LookupReturnType(fname); + if (returntype == typeof(void)) + return null; + MODError(String.Format("Invocation of {0} failed; null return value",fname)); } catch (Exception e) @@ -338,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return null; } - + /// /// Send a command to functions registered on an event /// @@ -361,8 +365,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// protected object ConvertFromLSL(object lslparm, Type type, string fname) { + + if(lslparm.GetType() == type) + return lslparm; + // ---------- String ---------- - if (lslparm is LSL_String) + else if (lslparm is LSL_String) { if (type == typeof(string)) return (string)(LSL_String)lslparm; @@ -421,7 +429,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api for (int i = 0; i < plist.Length; i++) { if (plist[i] is LSL_String) - result[i] = (string)(LSL_String)plist[i]; + result[i] = (string)(LSL_String)plist[i]; else if (plist[i] is LSL_Integer) result[i] = (int)(LSL_Integer)plist[i]; // The int check exists because of the many plain old int script constants in ScriptBase which @@ -443,7 +451,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return result; } } - + MODError(String.Format("{0}: parameter type mismatch; expecting {1}, type(parm)={2}", fname, type.Name, lslparm.GetType())); return null; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 83aa245..6e28fe0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -45,6 +45,7 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; @@ -138,8 +139,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal TaskInventoryItem m_item; internal bool m_OSFunctionsEnabled = false; internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; + internal float m_ScriptDelayFactor = 1.0f; + internal float m_ScriptDistanceFactor = 1.0f; + internal bool m_debuggerSafe = false; internal Dictionary m_FunctionPerms = new Dictionary(); - protected IUrlModule m_UrlModule = null; public void Initialize( @@ -148,6 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_ScriptEngine = scriptEngine; m_host = host; m_item = item; + m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); @@ -157,6 +161,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED"); } + m_ScriptDelayFactor = + m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); + m_ScriptDistanceFactor = + m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f); + string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow"); switch (risk) { @@ -187,7 +196,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api default: break; } - } + } public override Object InitializeLifetimeService() { @@ -209,7 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal void OSSLError(string msg) { - OSSLShoutError("OSSL Runtime Error: " + msg); + if (m_debuggerSafe) + { + OSSLShoutError(msg); + } + else + { + throw new ScriptException("OSSL Runtime Error: " + msg); + } } /// @@ -244,22 +260,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); } - // Returns of the function is allowed. Throws a script exception if not allowed. - public bool CheckThreatLevel(ThreatLevel level, string function) + // Returns if OSSL is enabled. Throws a script exception if OSSL is not allowed.. + // for safe funtions always active + public void CheckThreatLevel() { + m_host.AddScriptLPS(1); if (!m_OSFunctionsEnabled) - { - OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); - return false; - } + OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws + } + + // Returns if the function is allowed. Throws a script exception if not allowed. + public void CheckThreatLevel(ThreatLevel level, string function) + { + m_host.AddScriptLPS(1); + if (!m_OSFunctionsEnabled) + OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws string reasonWhyNot = CheckThreatLevelTest(level, function); if (!String.IsNullOrEmpty(reasonWhyNot)) { OSSLError(reasonWhyNot); - return false; } - return true; } // Check to see if function is allowed. Returns an empty string if function permitted @@ -299,7 +320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (string id in ids) { string current = id.Trim(); - if (current.ToUpper() == "PARCEL_GROUP_MEMBER" || current.ToUpper() == "PARCEL_OWNER" || current.ToUpper() == "ESTATE_MANAGER" || current.ToUpper() == "ESTATE_OWNER") + if (current.ToUpper() == "PARCEL_GROUP_MEMBER" || current.ToUpper() == "PARCEL_OWNER" || current.ToUpper() == "ESTATE_MANAGER" || current.ToUpper() == "ESTATE_OWNER" || current.ToUpper() == "ACTIVE_GOD" || current.ToUpper() == "GRID_GOD" || current.ToUpper() == "GOD") { if (!perms.AllowedOwnerClasses.Contains(current)) perms.AllowedOwnerClasses.Add(current.ToUpper()); @@ -404,6 +425,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + + //Only grid gods may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("GRID_GOD")) + { + if (World.Permissions.IsGridGod(ownerID)) + { + return String.Empty; + } + } + + //Any god may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("GOD")) + { + if (World.Permissions.IsAdministrator(ownerID)) + { + return String.Empty; + } + } + + //Only active gods may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ACTIVE_GOD")) + { + ScenePresence sp = World.GetScenePresence(ownerID); + if (sp != null && !sp.IsDeleted && sp.IsGod) + { + return String.Empty; + } + } + if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) return( String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", @@ -425,16 +475,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLShoutError(string.Format("Use of function {0} is deprecated. Use {1} instead.", function, replacement)); } + protected void ScriptSleep(int delay) + { + delay = (int)((float)delay * m_ScriptDelayFactor); + if (delay == 0) + return; + System.Threading.Thread.Sleep(delay); + } + public LSL_Integer osSetTerrainHeight(int x, int y, double val) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight")) return 0; + CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); return SetTerrainHeight(x, y, val); } public LSL_Integer osTerrainSetHeight(int x, int y, double val) { - if (!CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight")) return 0; + CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); return SetTerrainHeight(x, y, val); @@ -442,8 +500,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private LSL_Integer SetTerrainHeight(int x, int y, double val) { - m_host.AddScriptLPS(1); - if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) OSSLError("osSetTerrainHeight: Coordinate out of bounds"); @@ -460,18 +516,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetTerrainHeight(int x, int y) { + CheckThreatLevel(); return GetTerrainHeight(x, y); } public LSL_Float osTerrainGetHeight(int x, int y) { + CheckThreatLevel(); OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); return GetTerrainHeight(x, y); } private LSL_Float GetTerrainHeight(int x, int y) { - m_host.AddScriptLPS(1); if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) OSSLError("osGetTerrainHeight: Coordinate out of bounds"); @@ -480,8 +537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTerrainFlush() { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush"); ITerrainModule terrainModule = World.RequestModuleInterface(); if (terrainModule != null) terrainModule.TaintTerrain(); @@ -495,31 +551,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // The underlying functionality is fixed, since the security // as such is sound // - if (!CheckThreatLevel(ThreatLevel.High, "osRegionRestart")) return 0; + CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); IRestartModule restartModule = World.RequestModuleInterface(); - m_host.AddScriptLPS(1); if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) { if (seconds < 15) { - restartModule.AbortRestart("Restart aborted"); + restartModule.AbortRestart("Region restart has been aborted\n"); return 1; } - List times = new List(); - while (seconds > 0) + RegionRestart(seconds, String.Empty); + return 1; + } + else + { + return 0; + } + } + + public int osRegionRestart(double seconds, string msg) + { + CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); + + IRestartModule restartModule = World.RequestModuleInterface(); + if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) + { + if (seconds < 15) { - times.Add((int)seconds); - if (seconds > 300) - seconds -= 120; - else if (seconds > 30) - seconds -= 30; - else - seconds -= 15; + restartModule.AbortRestart("Region restart has been aborted\n"); + return 1; } - restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + RegionRestart(seconds, msg); return 1; } else @@ -528,15 +593,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + private void RegionRestart(double seconds, string msg) + { + IRestartModule restartModule = World.RequestModuleInterface(); + + List times = new List(); + while (seconds > 0) + { + times.Add((int)seconds); + if (seconds > 300) + seconds -= 120; + else if (seconds > 120) + seconds -= 60; + else if (seconds > 60) + seconds -= 30; + else + seconds -= 15; + } + + if (msg == String.Empty) + restartModule.ScheduleRestart(UUID.Zero, "Region: " + World.RegionInfo.RegionName + " is about to restart.\n\nIf you stay here you will be logged out.\n\n\nTime remaining: {0}.\n", times.ToArray(), true); + + else + restartModule.ScheduleRestart(UUID.Zero, msg + "\n\nTime remaining: {0}.\n", times.ToArray(), true); + } + public void osRegionNotice(string msg) { // This implementation provides absolutely no security // It's high griefing potential makes this classification // necessary // - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice"); IDialogModule dm = World.RequestModuleInterface(); @@ -549,9 +637,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // This function has no security. It can be used to destroy // arbitrary builds the user would normally have no rights to // - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osSetRot")) return; + CheckThreatLevel(ThreatLevel.VeryHigh, "osSetRot"); - m_host.AddScriptLPS(1); if (World.Entities.ContainsKey(target)) { EntityBase entity; @@ -572,13 +659,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) { - m_host.AddScriptLPS(1); + // This may be upgraded depending on the griefing or DOS + // potential, or guarded with a delay + // + CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer); + extraParams); return createdTexture.ToString(); } else @@ -592,13 +683,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer, true, (byte) alpha); + extraParams, true, (byte) alpha); return createdTexture.ToString(); } else @@ -612,13 +704,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer, blend, disp, (byte) alpha, face); + extraParams, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } else @@ -632,7 +725,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer) { - m_host.AddScriptLPS(1); + return osSetDynamicTextureDataFace(dynamicID, contentType, data, extraParams, timer, -1); + } + + public string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, + int timer, int face) + { + CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -644,7 +744,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer); + extraParams, false, 3, 255, face); + return createdTexture.ToString(); } } @@ -659,7 +760,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -671,7 +773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, true, (byte) alpha); + extraParams, true, (byte) alpha); return createdTexture.ToString(); } } @@ -686,7 +788,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow , "osSetDynamicTextureDataBlendFace"); + if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -698,7 +801,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, blend, disp, (byte) alpha, face); + extraParams, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } } @@ -712,9 +815,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public bool osConsoleCommand(string command) { - if (!CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand")) return false; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand"); // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) @@ -728,123 +829,183 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetPrimFloatOnWater(int floatYN) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater"); m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); } + private bool checkAllowAgentTPbyLandOwner(UUID agentId, Vector3 pos) + { + UUID hostOwner = m_host.OwnerID; + + if(hostOwner == agentId) + return true; + + if (m_item.PermsGranter == agentId) + { + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) + return true; + } + + ILandObject land = World.LandChannel.GetLandObject(pos); + if(land == null) + return true; + + LandData landdata = land.LandData; + if(landdata == null) + return true; + + if(landdata.OwnerID == hostOwner) + return true; + + EstateSettings es = World.RegionInfo.EstateSettings; + if(es != null && es.IsEstateManagerOrOwner(hostOwner)) + return true; + + if(!landdata.IsGroupOwned) + return false; + + UUID landGroup = landdata.GroupID; + if(landGroup == UUID.Zero) + return false; + + if(landGroup == m_host.GroupID) + return true; + + return false; + } + // Teleport functions public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { // High because there is no security check. High griefer potential // - if (!CheckThreatLevel(ThreatLevel.High, "osTeleportAgent")) return; + CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionName, position, lookat, false); + TeleportAgent(agent, regionName, position, lookat); } private void TeleportAgent(string agent, string regionName, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - m_host.AddScriptLPS(1); - UUID agentId = new UUID(); + if(String.IsNullOrEmpty(regionName)) + regionName = World.RegionInfo.RegionName; + + UUID agentId; if (UUID.TryParse(agent, out agentId)) { ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null) + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; + + Vector3 pos = presence.AbsolutePosition; + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) { - // For osTeleportAgent, agent must be over owners land to avoid abuse - // For osTeleportOwner, this restriction isn't necessary - - // commented out because its redundant and uneeded please remove eventually. - // if (relaxRestrictions || - // m_host.OwnerID - // == World.LandChannel.GetLandObject( - // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - // { - - // We will launch the teleport on a new thread so that when the script threads are terminated - // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. - Util.FireAndForget( - o => World.RequestTeleportLocation( - presence.ControllingClient, regionName, position, - lookat, (uint)TPFlags.ViaLocation), - null, "OSSL_Api.TeleportAgentByRegionCoords"); - // } + ScriptSleep(500); + return; + } + if(regionName == World.RegionInfo.RegionName) + { + // should be faster than going to threadpool + World.RequestTeleportLocation(presence.ControllingClient, regionName, position, + lookat, (uint)TPFlags.ViaLocation); + ScriptSleep(500); + } + else + { + // We will launch the teleport on a new thread so that when the script threads are terminated + // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. + Util.FireAndForget( + o => World.RequestTeleportLocation( + presence.ControllingClient, regionName, position, + lookat, (uint)TPFlags.ViaLocation), + null, "OSSL_Api.TeleportAgentByRegionCoords"); + ScriptSleep(5000); } } } - public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + public void osTeleportAgent(string agent, int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { // High because there is no security check. High griefer potential // - if (!CheckThreatLevel(ThreatLevel.High, "osTeleportAgent")) return; + CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionX, regionY, position, lookat, false); + TeleportAgent(agent, regionGridX, regionGridY, position, lookat); } - private void TeleportAgent(string agent, int regionX, int regionY, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) + private void TeleportAgent(string agent, int regionGridX, int regionGridY, + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); - ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY); + ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); - m_host.AddScriptLPS(1); - UUID agentId = new UUID(); + UUID agentId; if (UUID.TryParse(agent, out agentId)) { ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null) - { - // For osTeleportAgent, agent must be over owners land to avoid abuse - // For osTeleportOwner, this restriction isn't necessary - - // commented out because its redundant and uneeded please remove eventually. - // if (relaxRestrictions || - // m_host.OwnerID - // == World.LandChannel.GetLandObject( - // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - // { - - // We will launch the teleport on a new thread so that when the script threads are terminated - // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. - Util.FireAndForget( - o => World.RequestTeleportLocation( - presence.ControllingClient, regionHandle, - position, lookat, (uint)TPFlags.ViaLocation), - null, "OSSL_Api.TeleportAgentByRegionName"); - // } + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; + Vector3 pos = presence.AbsolutePosition; + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) + { + ScriptSleep(500); + return; } + + Util.FireAndForget( + o => World.RequestTeleportLocation( + presence.ControllingClient, regionHandle, + position, lookat, (uint)TPFlags.ViaLocation), + null, "OSSL_Api.TeleportAgentByRegionName"); + + ScriptSleep(5000); } } public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - // High because there is no security check. High griefer potential - // - if (!CheckThreatLevel(ThreatLevel.High, "osTeleportAgent")) return; + UUID agentId; + if (UUID.TryParse(agent, out agentId)) + { + ScenePresence presence = World.GetScenePresence(agentId); + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; - osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat); + Vector3 pos = presence.AbsolutePosition; + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) + { + ScriptSleep(500); + return; + } + + World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, + lookat, (uint)TPFlags.ViaLocation); + ScriptSleep(500); + } } public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true); + // Threat level None because this is what can already be done with the World Map in the viewer + CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); + + TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); } - public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - osTeleportOwner(World.RegionInfo.RegionName, position, lookat); + CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); + + TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat); } - public void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true); + CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); + + osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); } /// @@ -856,9 +1017,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osForceOtherSit(string avatar) { - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); ForceSit(avatar, m_host.UUID); } @@ -871,9 +1030,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osForceOtherSit(string avatar, string target) { - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); UUID targetID = new UUID(target); @@ -882,7 +1039,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void ForceSit(string avatar, UUID targetID) { - UUID agentID; + UUID agentID; if (!UUID.TryParse(avatar, out agentID)) return; @@ -900,21 +1057,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.SitTargetPosition); } - // Functions that get information from the agent itself. - // - // osGetAgentIP - this is used to determine the IP address of - //the client. This is needed to help configure other in world - //resources based on the IP address of the clients connected. - //I think High is a good risk level for this, as it is an - //information leak. - // Severe is even better coz privacy is important. + // Get a list of all the avatars/agents in the region + public LSL_List osGetAgents() + { + // threat level is None as we could get this information with an + // in-world script as well, just not as efficient + CheckThreatLevel(ThreatLevel.None, "osGetAgents"); + + LSL_List result = new LSL_List(); + World.ForEachRootScenePresence(delegate(ScenePresence sp) + { + result.Add(new LSL_String(sp.Name)); + }); + return result; + } + public string osGetAgentIP(string agent) { - if (!CheckThreatLevel(ThreatLevel.Severe, "osGetAgentIP")) return ""; + CheckThreatLevel(ThreatLevel.Severe, "osGetAgentIP"); + if(!(World.Permissions.IsGod(m_host.OwnerID))) // user god always needed + return ""; UUID avatarID = (UUID)agent; - m_host.AddScriptLPS(1); if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) { ScenePresence target = (ScenePresence)World.Entities[avatarID]; @@ -925,61 +1090,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ""; } - // Get a list of all the avatars/agents in the region - public LSL_List osGetAgents() - { - m_host.AddScriptLPS(1); - - LSL_List result = new LSL_List(); - World.ForEachRootScenePresence(delegate(ScenePresence sp) - { - result.Add(new LSL_String(sp.Name)); - }); - return result; - } - // Adam's super super custom animation functions public void osAvatarPlayAnimation(string avatar, string animation) { - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation")) return; + CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation"); AvatarPlayAnimation(avatar, animation); } private void AvatarPlayAnimation(string avatar, string animation) { - UUID avatarID = (UUID)avatar; + UUID avatarID; + if(!UUID.TryParse(avatar, out avatarID)) + return; - m_host.AddScriptLPS(1); - if (World.Entities.ContainsKey((UUID)avatar) && World.Entities[avatarID] is ScenePresence) + ScenePresence target = World.GetScenePresence(avatarID); + if (target == null) + return; + + UUID animID = UUID.Zero; + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - ScenePresence target = (ScenePresence)World.Entities[avatarID]; - if (target != null) + if (inv.Value.Type == (int)AssetType.Animation) { - UUID animID=UUID.Zero; - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == animation) - { - if (inv.Value.Type == (int)AssetType.Animation) - animID = inv.Value.AssetID; - continue; - } - } - } - if (animID == UUID.Zero) - target.Animator.AddAnimation(animation, m_host.UUID); - else - target.Animator.AddAnimation(animID, m_host.UUID); + if (inv.Value.Name == animation) + { + animID = inv.Value.AssetID; + break; + } } } + m_host.TaskInventory.LockItemsForRead(false); + + if (animID == UUID.Zero) + target.Animator.AddAnimation(animation, m_host.UUID); + else + target.Animator.AddAnimation(animID, m_host.UUID); } public void osAvatarStopAnimation(string avatar, string animation) { - if (!CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation")) return; + CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation"); AvatarStopAnimation(avatar, animation); } @@ -988,8 +1140,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID avatarID = (UUID)avatar; - m_host.AddScriptLPS(1); - // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common // method (though see that doesn't do the is animation check, which is probably a bug) and have both // these functions call that common code. However, this does mean navigating the brain-dead requirement @@ -1010,6 +1160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api animID = UUID.Zero; } + if (animID == UUID.Zero) target.Animator.RemoveAnimation(animation); else @@ -1019,58 +1170,106 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } //Texture draw functions + + public string osDrawResetTransform(string drawList) + { + CheckThreatLevel(); + + drawList += "ResetTransf;"; + return drawList; + } + + public string osDrawRotationTransform(string drawList, LSL_Float x) + { + CheckThreatLevel(); + + drawList += "RotTransf " + x + ";"; + return drawList; + } + + public string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) + { + CheckThreatLevel(); + + drawList += "ScaleTransf " + x + "," + y + ";"; + return drawList; + } + + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + CheckThreatLevel(); + + drawList += "TransTransf " + x + "," + y + ";"; + return drawList; + } + public string osMovePen(string drawList, int x, int y) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "MoveTo " + x + "," + y + ";"; return drawList; } public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; return drawList; } public string osDrawLine(string drawList, int endX, int endY) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "LineTo " + endX + "," + endY + "; "; return drawList; } public string osDrawText(string drawList, string text) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osDrawText"); + drawList += "Text " + text + "; "; return drawList; } public string osDrawEllipse(string drawList, int width, int height) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "Ellipse " + width + "," + height + "; "; return drawList; } + public string osDrawFilledEllipse(string drawList, int width, int height) + { + CheckThreatLevel(); + + drawList += "FillEllipse " + width + "," + height + "; "; + return drawList; + } + public string osDrawRectangle(string drawList, int width, int height) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "Rectangle " + width + "," + height + "; "; return drawList; } public string osDrawFilledRectangle(string drawList, int width, int height) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "FillRectangle " + width + "," + height + "; "; return drawList; } public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); if (x.Length != y.Length || x.Length < 3) { @@ -1087,7 +1286,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawPolygon(string drawList, LSL_List x, LSL_List y) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); if (x.Length != y.Length || x.Length < 3) { @@ -1104,28 +1303,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetFontSize(string drawList, int fontSize) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "FontSize "+ fontSize +"; "; return drawList; } public string osSetFontName(string drawList, string fontName) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "FontName "+ fontName +"; "; return drawList; } public string osSetPenSize(string drawList, int penSize) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "PenSize " + penSize + "; "; return drawList; } public string osSetPenColor(string drawList, string color) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "PenColor " + color + "; "; return drawList; } @@ -1133,30 +1336,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Deprecated public string osSetPenColour(string drawList, string colour) { + CheckThreatLevel(); OSSLDeprecated("osSetPenColour", "osSetPenColor"); - m_host.AddScriptLPS(1); drawList += "PenColour " + colour + "; "; return drawList; } public string osSetPenCap(string drawList, string direction, string type) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList += "PenCap " + direction + "," + type + "; "; return drawList; } public string osDrawImage(string drawList, int width, int height, string imageUrl) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; return drawList; } public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); LSL_Vector vec = new LSL_Vector(0,0,0); IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -1178,17 +1383,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // It was probably added as a crutch or debugging aid, and // should be removed // - if (!CheckThreatLevel(ThreatLevel.High, "osSetStateEvents")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); m_host.SetScriptEvents(m_item.ItemID, events); } public void osSetRegionWaterHeight(double height) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); World.EventManager.TriggerRequestChangeWaterHeight((float)height); } @@ -1201,9 +1403,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); while (sunHour > 24.0) sunHour -= 24.0; @@ -1226,9 +1426,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetEstateSunSettings(bool sunFixed, double sunHour) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); while (sunHour > 24.0) sunHour -= 24.0; @@ -1250,7 +1448,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public double osGetCurrentSunHour() { - m_host.AddScriptLPS(1); + CheckThreatLevel(); // Must adjust for the fact that Region Sun Settings are still LL offset double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6; @@ -1267,19 +1465,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public double osSunGetParam(string param) { + CheckThreatLevel(ThreatLevel.None, "osSunGetParam"); OSSLDeprecated("osSunGetParam", "osGetSunParam"); return GetSunParam(param); } public double osGetSunParam(string param) { + CheckThreatLevel(); return GetSunParam(param); } private double GetSunParam(string param) { - m_host.AddScriptLPS(1); - double value = 0.0; ISunModule module = World.RequestModuleInterface(); @@ -1293,21 +1491,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSunSetParam(string param, double value) { -//// if (!CheckThreatLevel(ThreatLevel.None, "osSunSetParam")) return; + CheckThreatLevel(ThreatLevel.None, "osSunSetParam"); OSSLDeprecated("osSunSetParam", "osSetSunParam"); SetSunParam(param, value); } public void osSetSunParam(string param, double value) { -//// if (!CheckThreatLevel(ThreatLevel.None, "osSetSunParam")) return; + CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); SetSunParam(param, value); } private void SetSunParam(string param, double value) { - m_host.AddScriptLPS(1); - ISunModule module = World.RequestModuleInterface(); if (module != null) { @@ -1317,7 +1513,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osWindActiveModelPluginName() { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1330,8 +1526,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetWindParam(string plugin, string param, LSL_Float value) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osSetWindParam")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetWindParam"); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1346,7 +1541,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetWindParam(string plugin, string param) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osGetWindParam"); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1360,8 +1555,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Routines for creating and managing parcels programmatically public void osParcelJoin(LSL_Vector pos1, LSL_Vector pos2) { - if (!CheckThreatLevel(ThreatLevel.High, "osParcelJoin")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osParcelJoin"); int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x); int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y); @@ -1373,8 +1567,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osParcelSubdivide(LSL_Vector pos1, LSL_Vector pos2) { - if (!CheckThreatLevel(ThreatLevel.High, "osParcelSubdivide")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osParcelSubdivide"); int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x); int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y); @@ -1387,7 +1580,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osParcelSetDetails(LSL_Vector pos, LSL_List rules) { const string functionName = "osParcelSetDetails"; - if (!CheckThreatLevel(ThreatLevel.High, functionName)) return; + CheckThreatLevel(ThreatLevel.High, functionName); OSSLDeprecated(functionName, "osSetParcelDetails"); SetParcelDetails(pos, rules, functionName); } @@ -1395,14 +1588,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) { const string functionName = "osSetParcelDetails"; - if (!CheckThreatLevel(ThreatLevel.High, functionName)) return; + CheckThreatLevel(ThreatLevel.High, functionName); SetParcelDetails(pos, rules, functionName); } private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) { - m_host.AddScriptLPS(1); - // Get a reference to the land data and make sure the owner of the script // can modify it @@ -1413,15 +1604,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions)) + if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false)) { - OSSLShoutError("You do not have permission to modify the parcel"); + OSSLShoutError("script owner does not have permission to modify the parcel"); return; } // Create a new land data object we can modify LandData newLand = startLandObject.LandData.Copy(); UUID uuid; + EstateSettings es = World.RegionInfo.EstateSettings; + + bool changed = false; + bool changedSeeAvs = false; + bool changedoverlay = false; + bool changedneedupdate = false; // Process the rules, not sure what the impact would be of changing owner or group for (int idx = 0; idx < rules.Length;) @@ -1431,35 +1628,151 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { case ScriptBaseClass.PARCEL_DETAILS_NAME: - newLand.Name = arg; + if(newLand.Name != arg) + { + newLand.Name = arg; + changed = true; + } break; case ScriptBaseClass.PARCEL_DETAILS_DESC: - newLand.Description = arg; + if(newLand.Description != arg) + { + newLand.Description = arg; + changed = true; + } break; case ScriptBaseClass.PARCEL_DETAILS_OWNER: - if (!CheckThreatLevel(ThreatLevel.VeryHigh, functionName)) return; - if (UUID.TryParse(arg, out uuid)) - newLand.OwnerID = uuid; + if(es != null && !es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + OSSLError("script owner does not have permission to modify the parcel owner"); + } + else + { + if (UUID.TryParse(arg, out uuid)) + { + if(newLand.OwnerID != uuid) + { + changed = true; + newLand.OwnerID = uuid; + newLand.GroupID = UUID.Zero; + } + } + } break; case ScriptBaseClass.PARCEL_DETAILS_GROUP: - if (!CheckThreatLevel(ThreatLevel.VeryHigh, functionName)) return; - if (UUID.TryParse(arg, out uuid)) - newLand.GroupID = uuid; + if(m_host.OwnerID == newLand.OwnerID || es == null || es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + if (UUID.TryParse(arg, out uuid)) + { + if(newLand.GroupID != uuid) + { + if(uuid == UUID.Zero) + { + changed = true; + newLand.GroupID = uuid; + } + else + { + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface(); + GroupMembershipData member = null; + if (groupsModule != null) + member = groupsModule.GetMembershipData(uuid, newLand.OwnerID); + if (member == null) + OSSLError(string.Format("land owner is not member of the new group for parcel")); + else + { + changed = true; + newLand.GroupID = uuid; + } + } + } + } + } + else + { + OSSLError("script owner does not have permission to modify the parcel group"); + } break; case ScriptBaseClass.PARCEL_DETAILS_CLAIMDATE: - if (!CheckThreatLevel(ThreatLevel.VeryHigh, functionName)) return; - newLand.ClaimDate = Convert.ToInt32(arg); - if (newLand.ClaimDate == 0) - newLand.ClaimDate = Util.UnixTimeSinceEpoch(); + if(es != null && !es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + OSSLError("script owner does not have permission to modify the parcel CLAIM DATE"); + } + else + { + int date = Convert.ToInt32(arg); + if (date == 0) + date = Util.UnixTimeSinceEpoch(); + if(newLand.ClaimDate != date) + { + changed = true; + newLand.ClaimDate = date; + } + } + break; + + case ScriptBaseClass.PARCEL_DETAILS_SEE_AVATARS: + bool newavs = (Convert.ToInt32(arg) != 0); + if(newLand.SeeAVs != newavs) + { + changed = true; + changedSeeAvs = true; + changedoverlay = true; + changedneedupdate = true; + newLand.SeeAVs = newavs; + } + break; + + case ScriptBaseClass.PARCEL_DETAILS_ANY_AVATAR_SOUNDS: + bool newavsounds = (Convert.ToInt32(arg) != 0); + if(newLand.AnyAVSounds != newavsounds) + { + changed = true; + newLand.AnyAVSounds = newavsounds; + } + break; + + case ScriptBaseClass.PARCEL_DETAILS_GROUP_SOUNDS: + bool newgrpsounds = (Convert.ToInt32(arg) != 0); + if(newLand.GroupAVSounds != newgrpsounds) + { + changed = true; + newLand.GroupAVSounds = newgrpsounds; + } break; - } - } + } + } + if(changed) + { + World.LandChannel.UpdateLandObject(newLand.LocalID, newLand); + + if(changedneedupdate) + { + UUID parcelID= newLand.GlobalID; + World.ForEachRootScenePresence(delegate (ScenePresence avatar) + { + if (avatar == null || avatar.IsDeleted || avatar.IsInTransit) + return; + + if(changedSeeAvs && avatar.currentParcelUUID == parcelID ) + avatar.currentParcelUUID = parcelID; // force parcel flags review + + if(avatar.ControllingClient == null) + return; + + // this will be needed for some things like damage etc +// if(avatar.currentParcelUUID == parcelID) +// startLandObject.SendLandUpdateToClient(avatar.ControllingClient); - World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); + if(changedoverlay && !avatar.IsNPC) + World.LandChannel.SendParcelsOverlay(avatar.ControllingClient); + }); + } + } } public double osList2Double(LSL_Types.list src, int index) @@ -1469,7 +1782,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // is not allowed to contain any. // This really should be removed. // - m_host.AddScriptLPS(1); + CheckThreatLevel(); + if (index < 0) { index = src.Length + index; @@ -1485,9 +1799,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // What actually is the difference to the LL function? // - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); @@ -1501,9 +1813,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // What actually is the difference to the LL function? // - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelSIPAddress")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelSIPAddress"); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); @@ -1529,9 +1839,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // that trigger engine-specific failures. // Besides, public grid users aren't supposed to know. // - // On the other hand, what other script engines are there? - // - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName"); int scriptEngineNameIndex = 0; @@ -1557,7 +1865,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osCheckODE() { - m_host.AddScriptLPS(1); + CheckThreatLevel(); + LSL_Integer ret = 0; // false if (m_ScriptEngine.World.PhysicsScene != null) { @@ -1580,22 +1889,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // about the physics engine, this function returns an empty string if // the user does not have permission to see it. This as opposed to // throwing an exception. + m_host.AddScriptLPS(1); string ret = String.Empty; + if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) + { + if (m_ScriptEngine.World.PhysicsScene != null) + { + ret = m_ScriptEngine.World.PhysicsScene.EngineType; + // An old physics engine might have an uninitialized engine type + if (ret == null) + ret = "unknown"; + } + } + + return ret; + } + + public string osGetPhysicsEngineName() + { + CheckThreatLevel(); + + string ret = "NoEngine"; if (m_ScriptEngine.World.PhysicsScene != null) { - ret = m_ScriptEngine.World.PhysicsScene.EngineType; + ret = m_ScriptEngine.World.PhysicsScene.EngineName; // An old physics engine might have an uninitialized engine type if (ret == null) - ret = "unknown"; - } - + ret = "UnknownEngine"; + } return ret; } public string osGetSimulatorVersion() { - m_host.AddScriptLPS(1); + // High because it can be used to target attacks to known weaknesses + // This would allow a new class of griefer scripts that don't even + // require their user to know what they are doing (see script + // kiddie) + // + CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); return m_ScriptEngine.World.GetSimulatorVersion(); } @@ -1639,7 +1972,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Object osParseJSONNew(string JSON) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); try { @@ -1648,14 +1981,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } catch(Exception e) { - OSSLError("osParseJSONNew: Problems decoding JSON string " + JSON + " : " + e.Message); + OSSLError("osParseJSONNew: Problems decoding JSON string " + JSON + " : " + e.Message) ; return null; } } public Hashtable osParseJSON(string JSON) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osParseJSON"); Object decoded = osParseJSONNew(JSON); @@ -1686,7 +2019,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osMessageObject(LSL_Key objectUUID, string message) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead. @@ -1715,6 +2048,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api "dataserver", resobj, new DetectParams[0])); } + + /// + /// Similar to llDie but given an object UUID + /// + /// + + public void osDie(LSL_Key objectUUID) + { +// CheckThreatLevel(ThreatLevel.VeryHigh, "osDie"); + // if this is restricted to objects rezzed by this host level can be reduced + + CheckThreatLevel(ThreatLevel.Low, "osDie"); + + UUID objUUID; + if (!UUID.TryParse(objectUUID, out objUUID)) + { + OSSLShoutError("osDie() cannot delete objects with invalid UUIDs"); + return; + } + + // harakiri check + if(objUUID == UUID.Zero) + { + if (!m_host.ParentGroup.IsAttachment) + throw new SelfDeleteException(); + return; + } + + SceneObjectGroup sceneOG = World.GetSceneObjectGroup(objUUID); + + if (sceneOG == null || sceneOG.IsDeleted) + return; + + if(sceneOG.IsAttachment) + return; + + if (sceneOG.OwnerID != m_host.OwnerID) + return; + + // harakiri check + if(sceneOG.UUID == m_host.ParentGroup.UUID) + throw new SelfDeleteException(); + + // restrict to objects rezzed by host + if(sceneOG.RezzerID == m_host.ParentGroup.UUID) + World.DeleteSceneObject(sceneOG, false); + } + /// /// Write a notecard directly to the prim's inventory. /// @@ -1727,7 +2108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The contents of the notecard. public void osMakeNotecard(string notecardName, LSL_Types.list contents) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); StringBuilder notecardData = new StringBuilder(); @@ -1778,8 +2159,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taskItem.ResetIDs(m_host.UUID); taskItem.ParentID = m_host.UUID; taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); - taskItem.Name = asset.Name; - taskItem.Description = asset.Description; + taskItem.Name = name; + taskItem.Description = description; taskItem.Type = (int)AssetType.Notecard; taskItem.InvType = (int)InventoryType.Notecard; taskItem.OwnerID = m_host.OwnerID; @@ -1799,6 +2180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.Inventory.AddInventoryItemExclusive(taskItem, false); else m_host.Inventory.AddInventoryItem(taskItem, false); + m_host.ParentGroup.InvalidateDeepEffectivePerms(); return taskItem; } @@ -1843,15 +2225,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID assetID = UUID.Zero; - if (!UUID.TryParse(notecardNameOrUuid, out assetID)) + bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID); + + if (!notecardNameIsUUID) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 7 && item.Name == notecardNameOrUuid) - { - assetID = item.AssetID; - } - } + assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); } if (assetID == UUID.Zero) @@ -1862,13 +2240,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AssetBase a = World.AssetService.Get(assetID.ToString()); if (a == null) - return UUID.Zero; + { + // Whoops, it's still possible here that the notecard name was properly + // formatted like a UUID but isn't an asset UUID so lets look it up by name after all + assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); + if (assetID == UUID.Zero) + return UUID.Zero; + + if (!NotecardCache.IsCached(assetID)) + { + a = World.AssetService.Get(assetID.ToString()); + + if (a == null) + { + return UUID.Zero; + } + } + } NotecardCache.Cache(assetID, a.Data); }; return assetID; } + protected UUID SearchTaskInventoryForAssetId(string name) + { + UUID assetId = UUID.Zero; + m_host.TaskInventory.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + { + if (item.Type == 7 && item.Name == name) + { + assetId = item.AssetID; + } + } + m_host.TaskInventory.LockItemsForRead(false); + return assetId; + } /// /// Directly get an entire notecard at once. @@ -1885,7 +2293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Notecard line public string osGetNotecardLine(string name, int line) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); UUID assetID = CacheNotecard(name); @@ -1912,7 +2320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Notecard text public string osGetNotecard(string name) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); string text = LoadNotecard(name); @@ -1941,7 +2349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public int osGetNumberOfNotecardLines(string name) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); UUID assetID = CacheNotecard(name); @@ -1956,8 +2364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osAvatarName2Key(string firstname, string lastname) { - if (!CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key")) return string.Empty; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); IUserManagement userManager = World.RequestModuleInterface(); if (userManager == null) @@ -2008,7 +2415,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osKey2Name(string id) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); UUID key = new UUID(); @@ -2117,8 +2524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public string osGetGridNick() { -//// if (!CheckThreatLevel(ThreatLevel.None, "osGetGridNick")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); string nick = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2134,8 +2540,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridName() { -//// if (!CheckThreatLevel(ThreatLevel.None, "osGetGridName")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); string name = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2151,8 +2556,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridLoginURI() { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); string loginURI = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2168,11 +2572,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridHomeURI() { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); IConfigSource config = m_ScriptEngine.ConfigSource; - string HomeURI = Util.GetConfigVarFromSections(config, "HomeURI", + string HomeURI = Util.GetConfigVarFromSections(config, "HomeURI", new string[] { "Startup", "Hypergrid" }, String.Empty); if (!string.IsNullOrEmpty(HomeURI)) @@ -2190,8 +2593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridGatekeeperURI() { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); IConfigSource config = m_ScriptEngine.ConfigSource; string gatekeeperURI = Util.GetConfigVarFromSections(config, "GatekeeperURI", @@ -2209,8 +2611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridCustom(string key) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom")) return String.Empty; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); string retval = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2226,8 +2627,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetAvatarHomeURI(string uuid) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetAvatarHomeURI")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osGetAvatarHomeURI"); IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface(); string returnValue = ""; @@ -2259,14 +2659,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osFormatString(string str, LSL_List strings) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); return String.Format(str, strings.Data); } public LSL_List osMatchString(string src, string pattern, int start) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString"); LSL_List result = new LSL_List(); @@ -2307,7 +2707,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString"); // Normalize indices (if negative). // After normlaization they may still be @@ -2331,24 +2731,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osLoadedCreationDate() { - if (!CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate"); return World.RegionInfo.RegionSettings.LoadedCreationDate; } public string osLoadedCreationTime() { - if (!CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationTime")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationTime"); return World.RegionInfo.RegionSettings.LoadedCreationTime; } public string osLoadedCreationID() { - if (!CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationID")) return ""; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationID"); return World.RegionInfo.RegionSettings.LoadedCreationID; } @@ -2368,8 +2765,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { - if (!CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams")) return new LSL_List(); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); + InitLSL(); // One needs to cast m_LSL_Api because we're using functions not // on the ILSL_Api interface. @@ -2396,9 +2793,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceCreateLink(string target, int parent) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osForceCreateLink")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osForceCreateLink"); InitLSL(); ((LSL_Api)m_LSL_Api).CreateLink(target, parent); @@ -2406,9 +2801,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceBreakLink(int linknum) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakLink")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakLink"); InitLSL(); ((LSL_Api)m_LSL_Api).BreakLink(linknum); @@ -2416,9 +2809,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceBreakAllLinks() { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakAllLinks")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakAllLinks"); InitLSL(); ((LSL_Api)m_LSL_Api).BreakAllLinks(); @@ -2426,7 +2817,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osIsNpc(LSL_Key npc) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2442,31 +2833,99 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcCreate")) return new LSL_Key(ScriptBaseClass.NULL_KEY); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + + // have to get the npc module also here to set the default Not Owned + INPCModule module = World.RequestModuleInterface(); + if(module == null) + return new LSL_Key(UUID.Zero.ToString()); + + bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; - return NpcCreate(firstname, lastname, position, notecard, false, false); + return NpcCreate(firstname, lastname, position, notecard, owned, false, false); } public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcCreate")) return new LSL_Key(ScriptBaseClass.NULL_KEY); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); return NpcCreate( firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, - (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); + (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0, + (options & ScriptBaseClass.OS_NPC_OBJECT_GROUP) != 0); } private LSL_Key NpcCreate( - string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) + string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID) { + if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) + { + OSSLError("no permission to rez NPC at requested location"); + return new LSL_Key(UUID.Zero.ToString()); + } + INPCModule module = World.RequestModuleInterface(); - if (module != null) + if(module == null) + { + OSSLError("NPC module not enabled"); + return new LSL_Key(UUID.Zero.ToString()); + } + + string groupTitle = String.Empty; + UUID groupID = UUID.Zero; + + AvatarAppearance appearance = null; + + // check creation options + NPCOptionsFlags createFlags = module.NPCOptionFlags; + + if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) + { + OSSLError("Not owned NPCs disabled"); + owned = true; // we should get here... + } + + if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) { - AvatarAppearance appearance = null; + OSSLError("NPC allow sense as Avatar disabled"); + senseAsAgent = false; + } + + if(hostGroupID && m_host.GroupID != UUID.Zero) + { + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface(); + if (groupsModule != null) + { + GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID); + if (member == null) + { + OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group")); + return new LSL_Key(UUID.Zero.ToString()); + } + + groupID = m_host.GroupID; + + if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0) + { + GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID); + if(grprec != null && grprec.GroupName != "") + groupTitle = grprec.GroupName; + } + } + } + + if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) + { + if (firstname != String.Empty || lastname != String.Empty) + { + if (firstname != "Shown outfit:") + groupTitle = "- NPC -"; + } + } + if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) + { UUID id; if (UUID.TryParse(notecard, out id)) { @@ -2474,38 +2933,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (clonePresence != null) appearance = clonePresence.Appearance; } + } - if (appearance == null) - { - string appearanceSerialized = LoadNotecard(notecard); + if (appearance == null) + { + string appearanceSerialized = LoadNotecard(notecard); - if (appearanceSerialized != null) + if (appearanceSerialized != null) + { + try { OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); appearance = new AvatarAppearance(); appearance.Unpack(appearanceOsd); } - else + catch { - OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); + OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard)); + return new LSL_Key(UUID.Zero.ToString()); } } + else + { + OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); + } + } - UUID ownerID = UUID.Zero; - if (owned) - ownerID = m_host.OwnerID; - UUID x = module.CreateNPC(firstname, - lastname, - position, - ownerID, - senseAsAgent, - World, - appearance); + UUID ownerID = UUID.Zero; + if (owned) + ownerID = m_host.OwnerID; + UUID x = module.CreateNPC(firstname, + lastname, + position, + UUID.Random(), + ownerID, + groupTitle, + groupID, + senseAsAgent, + World, + appearance); - return new LSL_Key(x.ToString()); + ScenePresence sp; + if (World.TryGetScenePresence(x, out sp)) + { + sp.SendAvatarDataToAllAgents(); } - - return new LSL_Key(UUID.Zero.ToString()); + return new LSL_Key(x.ToString()); } /// @@ -2516,8 +2989,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The asset ID of the notecard saved. public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance")) return new LSL_Key(ScriptBaseClass.NULL_KEY); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); INPCModule npcModule = World.RequestModuleInterface(); @@ -2538,8 +3010,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcLoadAppearance(LSL_Key npc, string notecard) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); INPCModule npcModule = World.RequestModuleInterface(); @@ -2570,7 +3041,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcGetOwner(LSL_Key npc) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner"); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2591,7 +3062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osNpcGetPos(LSL_Key npc) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2614,8 +3085,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2633,8 +3103,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2658,7 +3127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation osNpcGetRot(LSL_Key npc) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2681,8 +3150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcSetRot")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -2703,8 +3171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopMoveToTarget(LSL_Key npc) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2718,15 +3185,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public void osNpcSay(LSL_Key npc, string message) - { - osNpcSay(npc, 0, message); - } - - public void osNpcSay(LSL_Key npc, int channel, string message) + public void osNpcSetProfileAbout(LSL_Key npc, string about) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcSay")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileAbout"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + ScenePresence sp = World.GetScenePresence(npcId); + if (sp != null) + ((INPC)(sp.ControllingClient)).profileAbout = about; + } + } + + public void osNpcSetProfileImage(LSL_Key npc, string image) + { + CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileImage"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + UUID ImageID = new UUID(); + + ImageID = ScriptUtils.GetAssetIdFromItemName(m_host, image, (int)AssetType.Texture); + + if (ImageID == null || ImageID == UUID.Zero) + { + if (!UUID.TryParse(image, out ImageID)) + return; + } + + ScenePresence sp = World.GetScenePresence(npcId); + if (sp != null) + ((INPC)(sp.ControllingClient)).profileImage = ImageID; + } + } + + public void osNpcSay(LSL_Key npc, string message) + { + osNpcSay(npc, 0, message); + } + + public void osNpcSay(LSL_Key npc, int channel, string message) + { + CheckThreatLevel(ThreatLevel.High, "osNpcSay"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2742,8 +3254,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcShout(LSL_Key npc, int channel, string message) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcShout")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcShout"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2759,8 +3270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSit(LSL_Key npc, LSL_Key target, int options) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcSit")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcSit"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2776,8 +3286,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStand(LSL_Key npc) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcStand")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcStand"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2793,25 +3302,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcRemove(LSL_Key npc) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcRemove")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); - INPCModule module = World.RequestModuleInterface(); - if (module != null) + try { - UUID npcId = new UUID(npc.m_string); + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcId = new UUID(npc.m_string); - if (!module.CheckPermissions(npcId, m_host.OwnerID)) - return; + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; - module.DeleteNPC(npcId, World); + module.DeleteNPC(npcId, World); + } } + catch { } } public void osNpcPlayAnimation(LSL_Key npc, string animation) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2825,8 +3336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopAnimation(LSL_Key npc, string animation) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2840,8 +3350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcWhisper(LSL_Key npc, int channel, string message) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcWhisper")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2857,8 +3366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num) { - if (!CheckThreatLevel(ThreatLevel.High, "osNpcTouch")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); INPCModule module = World.RequestModuleInterface(); int linkNum = link_num.value; @@ -2902,16 +3410,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The asset ID of the notecard saved. public LSL_Key osOwnerSaveAppearance(string notecard) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osOwnerSaveAppearance")) return new LSL_Key(ScriptBaseClass.NULL_KEY); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); return SaveAppearanceToNotecard(m_host.OwnerID, notecard); } public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) { - if (!CheckThreatLevel(ThreatLevel.High, "osAgentSaveAppearance")) return new LSL_Key(ScriptBaseClass.NULL_KEY); - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); return SaveAppearanceToNotecard(avatarId, notecard); } @@ -2923,7 +3429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (appearanceModule != null) { appearanceModule.SaveBakedTextures(sp.UUID); - OSDMap appearancePacked = sp.Appearance.Pack(); + EntityTransferContext ctx = new EntityTransferContext(); + OSDMap appearancePacked = sp.Appearance.Pack(ctx); TaskInventoryItem item = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); @@ -2962,7 +3469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// "male" or "female" or "unknown" public LSL_String osGetGender(LSL_Key rawAvatarId) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osGetGender"); UUID avatarId; if (!UUID.TryParse(rawAvatarId, out avatarId)) @@ -3005,7 +3512,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetMapTexture() { - m_host.AddScriptLPS(1); + CheckThreatLevel(); return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); } @@ -3017,7 +3524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetRegionMapTexture(string regionName) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); Scene scene = m_ScriptEngine.World; UUID key = UUID.Zero; @@ -3033,6 +3540,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (region != null) key = region.TerrainImage; + ScriptSleep(1000); + return key.ToString(); } @@ -3045,7 +3554,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// List of floats public LSL_List osGetRegionStats() { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats"); + LSL_List ret = new LSL_List(); float[] stats = World.StatsReporter.LastReportedSimStats; @@ -3058,32 +3568,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetRegionSize() { - m_host.AddScriptLPS(1); - - bool isMegaregion; - IRegionCombinerModule rcMod = World.RequestModuleInterface(); - if (rcMod != null) - isMegaregion = rcMod.IsRootForMegaregion(World.RegionInfo.RegionID); - else - isMegaregion = false; + CheckThreatLevel(); - if (isMegaregion) - { - Vector2 size = rcMod.GetSizeOfMegaregion(World.RegionInfo.RegionID); - return new LSL_Vector(size.X, size.Y, Constants.RegionHeight); - } - else - { - Scene scene = m_ScriptEngine.World; - GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); - return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight); - } + Scene scene = m_ScriptEngine.World; + RegionInfo reg = World.RegionInfo; +// GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); +// return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeY, (float)Constants.RegionHeight); + return new LSL_Vector((float)reg.RegionSizeX, (float)reg.RegionSizeY, 0.0f); } public int osGetSimulatorMemory() { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory")) return 0; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); + long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64; if (pws > Int32.MaxValue) @@ -3094,10 +3591,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return (int)pws; } + public int osGetSimulatorMemoryKB() + { + CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemoryKB"); + + long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64; + + if((pws & 0x3FFL) != 0) + pws += 0x400L; + pws >>= 10; + + if (pws > Int32.MaxValue) + return Int32.MaxValue; + + return (int)pws; + } + public void osSetSpeed(string UUID, LSL_Float SpeedModifier) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed"); + ScenePresence avatar = World.GetScenePresence(new UUID(UUID)); if (avatar != null) @@ -3106,8 +3619,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osKickAvatar(string FirstName, string SurName, string alert) { - if (!CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); World.ForEachRootScenePresence(delegate(ScenePresence sp) { @@ -3125,23 +3637,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetHealth(string avatar) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osGetHealth"); LSL_Float health = new LSL_Float(-1); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); - if (presence != null) health = presence.Health; + if (presence != null) + health = presence.Health; return health; } public void osCauseDamage(string avatar, double damage) { - if (!CheckThreatLevel(ThreatLevel.High, "osCauseDamage")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osCauseDamage"); UUID avatarId = new UUID(avatar); Vector3 pos = m_host.GetWorldPosition(); - ScenePresence presence = World.GetScenePresence(avatarId); + ScenePresence presence = World.GetScenePresence(avatarId); if (presence != null) { LandData land = World.GetLandData(pos); @@ -3163,13 +3675,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osCauseHealing(string avatar, double healing) { - if (!CheckThreatLevel(ThreatLevel.High, "osCauseHealing")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osCauseHealing"); UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); - if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) + if (presence != null) { float health = presence.Health; health += (float)healing; @@ -3181,31 +3692,67 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osSetHealth(string avatar, double health) + { + CheckThreatLevel(ThreatLevel.High, "osSetHealth"); + + UUID avatarId = new UUID(avatar); + ScenePresence presence = World.GetScenePresence(avatarId); + + if (presence != null) + { + if (health > 100.0) + health = 100.0; + else if (health < 1.0) + health = 1.0; + + presence.setHealthWithUpdate((float)health); + } + } + + public void osSetHealRate(string avatar, double healrate) + { + CheckThreatLevel(ThreatLevel.High, "osSetHealRate"); + + UUID avatarId = new UUID(avatar); + ScenePresence presence = World.GetScenePresence(avatarId); + + if (presence != null) + presence.HealRate = (float)healrate; + } + + public LSL_Float osGetHealRate(string avatar) + { + CheckThreatLevel(ThreatLevel.None, "osGetHealRate"); + + LSL_Float rate = new LSL_Float(0); + ScenePresence presence = World.GetScenePresence(new UUID(avatar)); + if (presence != null) + rate = presence.HealRate; + return rate; + } + public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules) { - if (!CheckThreatLevel(ThreatLevel.High, "osGetPrimitiveParams")) return new LSL_List(); - m_host.AddScriptLPS(1); - InitLSL(); + CheckThreatLevel(ThreatLevel.High, "osGetPrimitiveParams"); + InitLSL(); return m_LSL_Api.GetPrimitiveParamsEx(prim, rules); } public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams")) return; - m_host.AddScriptLPS(1); - InitLSL(); + CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams"); + InitLSL(); m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams"); } /// - /// Set parameters for light projection in host prim + /// Set parameters for light projection in host prim /// public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams")) return; - osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb); } @@ -3214,8 +3761,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams"); SceneObjectPart obj = null; if (prim == UUID.Zero.ToString()) @@ -3245,12 +3791,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Strided list of the UUID, position and name of each avatar in the region public LSL_List osGetAvatarList() { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) { - if (avatar != null && avatar.UUID != m_host.OwnerID) + if (avatar != null && !avatar.IsDeleted && avatar.UUID != m_host.OwnerID ) + { + result.Add(new LSL_String(avatar.UUID.ToString())); + result.Add(new LSL_Vector(avatar.AbsolutePosition)); + result.Add(new LSL_String(avatar.Name)); + } + }); + + return result; + } + + public LSL_List osGetNPCList() + { + CheckThreatLevel(ThreatLevel.None, "osGetNPCList"); + + LSL_List result = new LSL_List(); + World.ForEachRootScenePresence(delegate (ScenePresence avatar) + { + // npcs are not childagents but that is now. + if (avatar != null && avatar.IsNPC && !avatar.IsDeleted && !avatar.IsChildAgent && !avatar.IsInTransit) { result.Add(new LSL_String(avatar.UUID.ToString())); result.Add(new LSL_Vector(avatar.AbsolutePosition)); @@ -3268,7 +3833,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String osUnixTimeToTimestamp(long time) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp"); long baseTicks = 621355968000000000; long tickResolution = 10000000; @@ -3282,10 +3847,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Get the description from an inventory item /// /// - /// Item description + /// Item description public LSL_String osGetInventoryDesc(string item) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); lock (m_host.TaskInventory) { @@ -3308,8 +3873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Integer osInviteToGroup(LSL_Key agentId) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup")) return ScriptBaseClass.FALSE; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup"); UUID agent = new UUID(agentId); @@ -3343,8 +3907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Integer osEjectFromGroup(LSL_Key agentId) { - if (!CheckThreatLevel(ThreatLevel.VeryLow, "osEjectFromGroup")) return ScriptBaseClass.FALSE; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryLow, "osEjectFromGroup"); UUID agent = new UUID(agentId); @@ -3378,9 +3941,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetTerrainTexture(int level, LSL_Key texture) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture")) return; + CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); - m_host.AddScriptLPS(1); //Check to make sure that the script's owner is the estate manager/master //World.Permissions.GenericEstatePermission( if (World.Permissions.IsGod(m_host.OwnerID)) @@ -3408,9 +3970,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetTerrainTextureHeight(int corner, double low, double high) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight")) return; + CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); - m_host.AddScriptLPS(1); //Check to make sure that the script's owner is the estate manager/master //World.Permissions.GenericEstatePermission( if (World.Permissions.IsGod(m_host.OwnerID)) @@ -3429,9 +3990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceAttachToAvatar(int attachmentPoint) { - if (!CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); InitLSL(); ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); @@ -3439,18 +3998,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) { - if (!CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint); } public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) { - if (!CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.VeryHigh, "osForceAttachToOtherAvatarFromInventory"); UUID avatarId; @@ -3480,7 +4035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (item.InvType != (int)InventoryType.Object) { // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set - // up the api reference. + // up the api reference. if (m_LSL_Api != null) ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); @@ -3509,9 +4064,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceDetachFromAvatar() { - if (!CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar")) return; - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); InitLSL(); ((LSL_Api)m_LSL_Api).DetachFromAvatar(); @@ -3519,9 +4072,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments")) return new LSL_List(); - - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments"); UUID targetUUID; ScenePresence target; @@ -3555,15 +4106,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) { - if (!CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); UUID targetUUID; + if(!UUID.TryParse(avatar.ToString(), out targetUUID)) + return; + + if(targetUUID == UUID.Zero) + return; + ScenePresence target; + if(!World.TryGetScenePresence(targetUUID, out target)) + return; - if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) + if(target.IsDeleted || target.IsInTransit) + return; + + List aps = new List(); + if(attachmentPoints.Length != 0) { - List aps = new List(); foreach (object point in attachmentPoints.Data) { int ipoint; @@ -3572,115 +4133,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api aps.Add(ipoint); } } + // parsing failed + if(aps.Count != attachmentPoints.Length) + return; + } - List attachments = new List(); - - bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); - bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; + List attachments = new List(); - if (msgAll && invertPoints) - { - return; - } - else if (msgAll || invertPoints) - { - attachments = target.GetAttachments(); - } - else - { - foreach (int point in aps) - { - if (point > 0) - { - attachments.AddRange(target.GetAttachments((uint)point)); - } - } - } + bool msgAll; + bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; - // if we have no attachments at this point, exit now - if (attachments.Count == 0) - { + if(aps.Count == 0) + { + if(!invertPoints) return; - } + msgAll = true; + invertPoints = false; + } + else + msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); - List ignoreThese = new List(); + if (msgAll && invertPoints) + return; - if (invertPoints) + if (msgAll || invertPoints) + { + attachments = target.GetAttachments(); + } + else + { + foreach (int point in aps) { - foreach (SceneObjectGroup attachment in attachments) + if (point > 0) { - if (aps.Contains((int)attachment.AttachmentPoint)) - { - ignoreThese.Add(attachment); - } + attachments.AddRange(target.GetAttachments((uint)point)); } } + } - foreach (SceneObjectGroup attachment in ignoreThese) - { - attachments.Remove(attachment); - } - ignoreThese.Clear(); - - // if inverting removed all attachments to check, exit now - if (attachments.Count < 1) - { - return; - } + // if we have no attachments at this point, exit now + if (attachments.Count == 0) + { + return; + } - if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) - { - foreach (SceneObjectGroup attachment in attachments) - { - if (attachment.RootPart.CreatorID != m_host.CreatorID) - { - ignoreThese.Add(attachment); - } - } + bool optionObjCreator = (options & + ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0; + bool optionScriptCreator = (options & + ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0; - foreach (SceneObjectGroup attachment in ignoreThese) - { - attachments.Remove(attachment); - } - ignoreThese.Clear(); + UUID hostCreatorID = m_host.CreatorID; + UUID itemCreatorID = m_item.CreatorID; - // if filtering by same object creator removed all - // attachments to check, exit now - if (attachments.Count == 0) - { - return; - } - } + foreach (SceneObjectGroup sog in attachments) + { + if(sog.IsDeleted || sog.inTransit) + continue; - if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) - { - foreach (SceneObjectGroup attachment in attachments) - { - if (attachment.RootPart.CreatorID != m_item.CreatorID) - { - ignoreThese.Add(attachment); - } - } + if (invertPoints && aps.Contains((int)sog.AttachmentPoint)) + continue; - foreach (SceneObjectGroup attachment in ignoreThese) - { - attachments.Remove(attachment); - } - ignoreThese.Clear(); + UUID CreatorID = sog.RootPart.CreatorID; + if (optionObjCreator && CreatorID != hostCreatorID) + continue; - // if filtering by object creator must match originating - // script creator removed all attachments to check, - // exit now - if (attachments.Count == 0) - { - return; - } - } + if (optionScriptCreator && CreatorID != itemCreatorID) + continue; - foreach (SceneObjectGroup attachment in attachments) - { - MessageObject(attachment.RootPart.UUID, message); - } + SceneObjectPart[] parts = sog.Parts; + foreach(SceneObjectPart p in parts) + MessageObject(p.UUID, message); } } @@ -3693,7 +4215,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// 1 if thing is a valid UUID, 0 otherwise public LSL_Integer osIsUUID(string thing) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); UUID test; return UUID.TryParse(thing, out test) ? 1 : 0; @@ -3707,7 +4229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMin(double a, double b) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); return Math.Min(a, b); } @@ -3720,16 +4242,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMax(double a, double b) { - m_host.AddScriptLPS(1); + CheckThreatLevel(); return Math.Max(a, b); } public LSL_Key osGetRezzingObject() { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.None, "osGetRezzingObject"); - return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); + UUID rezID = m_host.ParentGroup.RezzerID; + if(rezID == UUID.Zero || m_host.ParentGroup.Scene.GetScenePresence(rezID) != null) + return new LSL_Key(UUID.Zero.ToString()); + return new LSL_Key(rezID.ToString()); } /// @@ -3738,7 +4263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetContentType(LSL_Key id, string type) { - if (!CheckThreatLevel(ThreatLevel.High, "osSetContentType")) return; + CheckThreatLevel(ThreatLevel.High, "osSetContentType"); if (m_UrlModule != null) m_UrlModule.HttpContentType(new UUID(id),type); @@ -3750,7 +4275,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// boolean indicating whether an error was shouted. protected bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix) { - m_host.AddScriptLPS(1); bool fail = false; if (m_item.PermsGranter != m_host.OwnerID) { @@ -3800,39 +4324,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osDropAttachment() { - if (!CheckThreatLevel(ThreatLevel.Low, "osDropAttachment")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment"); DropAttachment(true); } public void osForceDropAttachment() { - if (!CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment"); DropAttachment(false); } public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { - if (!CheckThreatLevel(ThreatLevel.Low, "osDropAttachmentAt")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt"); DropAttachmentAt(true, pos, rot); } public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { - if (!CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt")) return; - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt"); DropAttachmentAt(false, pos, rot); } public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osListenRegex"); + UUID keyID; UUID.TryParse(ID, out keyID); @@ -3879,7 +4400,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osRegexIsMatch(string input, string pattern) { - m_host.AddScriptLPS(1); + CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch"); + try { return Regex.IsMatch(input, pattern) ? 1 : 0; @@ -3890,5 +4412,392 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return 0; } } + + public LSL_String osRequestURL(LSL_List options) + { + CheckThreatLevel(ThreatLevel.Moderate, "osRequestSecureURL"); + + Hashtable opts = new Hashtable(); + for (int i = 0 ; i < options.Length ; i++) + { + object opt = options.Data[i]; + if (opt.ToString() == "allowXss") + opts["allowXss"] = true; + } + + if (m_UrlModule != null) + return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString(); + return UUID.Zero.ToString(); + } + + public LSL_String osRequestSecureURL(LSL_List options) + { + CheckThreatLevel(ThreatLevel.Moderate, "osRequestSecureURL"); + + Hashtable opts = new Hashtable(); + for (int i = 0 ; i < options.Length ; i++) + { + object opt = options.Data[i]; + if (opt.ToString() == "allowXss") + opts["allowXss"] = true; + } + + if (m_UrlModule != null) + return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString(); + return UUID.Zero.ToString(); + } + + public void osCollisionSound(string impact_sound, double impact_volume) + { + CheckThreatLevel(); + + if(impact_sound == "") + { + m_host.CollisionSoundVolume = (float)impact_volume; + m_host.CollisionSound = m_host.invalidCollisionSoundUUID; + if(impact_volume == 0.0) + m_host.CollisionSoundType = -1; // disable all sounds + else if(impact_volume == 1.0f) + m_host.CollisionSoundType = 0; // full return to default sounds + else + m_host.CollisionSoundType = 2; // default sounds with volume + m_host.aggregateScriptEvents(); + return; + } + // TODO: Parameter check logic required. + UUID soundId = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); + if(soundId != UUID.Zero) + { + m_host.CollisionSound = soundId; + m_host.CollisionSoundVolume = (float)impact_volume; + m_host.CollisionSoundType = 1; + } + else + m_host.CollisionSoundType = -1; + + m_host.aggregateScriptEvents(); + } + + // still not very usefull, detector is lost on rez, restarts, etc + public void osVolumeDetect(int detect) + { + CheckThreatLevel(); + + if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment) + return; + + m_host.ScriptSetVolumeDetect(detect != 0); + } + + /// + /// Get inertial data + /// + /// + /// + /// + /// a LSL list with contents: + /// LSL_Float mass, the total mass of a linkset + /// LSL_Vector CenterOfMass, center mass relative to root prim + /// LSL_Vector Inertia, elements of diagonal of inertia Ixx,Iyy,Izz divided by total mass + /// LSL_Vector aux, elements of upper triagle of inertia Ixy (= Iyx), Ixz (= Izx), Iyz(= Izy) divided by total mass + /// + public LSL_List osGetInertiaData() + { + CheckThreatLevel(); + + LSL_List result = new LSL_List(); + float TotalMass; + Vector3 CenterOfMass; + Vector3 Inertia; + Vector4 aux; + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return result; + + sog.GetInertiaData(out TotalMass, out CenterOfMass, out Inertia, out aux ); + if(TotalMass > 0) + { + float t = 1.0f/TotalMass; + Inertia.X *= t; + Inertia.Y *= t; + Inertia.Z *= t; + + aux.X *= t; + aux.Y *= t; + aux.Z *= t; + } + + result.Add(new LSL_Float(TotalMass)); + result.Add(new LSL_Vector(CenterOfMass.X, CenterOfMass.Y, CenterOfMass.Z)); + result.Add(new LSL_Vector(Inertia.X, Inertia.Y, Inertia.Z)); + result.Add(new LSL_Vector(aux.X, aux.Y, aux.Z)); + return result; + } + + /// + /// set inertial data + /// replaces the automatic calculation of mass, center of mass and inertia + /// + /// + /// total mass of linkset + /// location of center of mass relative to root prim in local coords + /// moment of inertia relative to principal axis and center of mass,Ixx, Iyy, Izz divided by mass + /// rotation of the inertia, relative to local axis + /// + /// the inertia argument is is inertia divided by mass, so corresponds only to the geometric distribution of mass and both can be changed independently. + /// + + public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return; + + if(mass < 0 || principalInertiaScaled.x < 0 || principalInertiaScaled.y < 0 || principalInertiaScaled.z < 0) + return; + + // need more checks + + Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); + Vector3 Inertia; + float m = (float)mass; + + Inertia.X = m * (float)principalInertiaScaled.x; + Inertia.Y = m * (float)principalInertiaScaled.y; + Inertia.Z = m * (float)principalInertiaScaled.z; + + Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.y, (float)lslrot.s); + rot.Normalize(); + + sog.SetInertiaData(m, CenterOfMass, Inertia, rot ); + } + + /// + /// set inertial data as a sphere + /// replaces the automatic calculation of mass, center of mass and inertia + /// + /// + /// total mass of linkset + /// size of the Box + /// location of center of mass relative to root prim in local coords + /// rotation of the box, and so inertia, relative to local axis + /// + /// + public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return; + + if(mass < 0) + return; + + // need more checks + + Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); + Vector3 Inertia; + float lx = (float)boxSize.x; + float ly = (float)boxSize.y; + float lz = (float)boxSize.z; + float m = (float)mass; + float t = m / 12.0f; + + Inertia.X = t * (ly*ly + lz*lz); + Inertia.Y = t * (lx*lx + lz*lz); + Inertia.Z = t * (lx*lx + ly*ly); + + Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s); + rot.Normalize(); + + sog.SetInertiaData(m, CenterOfMass, Inertia, rot ); + } + + /// + /// set inertial data as a sphere + /// replaces the automatic calculation of mass, center of mass and inertia + /// + /// + /// total mass of linkset + /// radius of the sphere + /// location of center of mass relative to root prim in local coords + /// + /// + public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return; + + if(mass < 0) + return; + + // need more checks + + Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); + Vector3 Inertia; + float r = (float)radius; + float m = (float)mass; + float t = 0.4f * m * r * r; + + Inertia.X = t; + Inertia.Y = t; + Inertia.Z = t; + + sog.SetInertiaData(m, CenterOfMass, Inertia, new Vector4(0f, 0f, 0f,1.0f)); + } + + /// + /// set inertial data as a cylinder + /// replaces the automatic calculation of mass, center of mass and inertia + /// + /// + /// total mass of linkset + /// radius of the cylinder + /// lenght of the cylinder + /// location of center of mass relative to root prim in local coords + /// rotation of the cylinder, and so inertia, relative to local axis + /// + /// cylinder axis aligned with Z axis. For other orientations provide the rotation. + /// + public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return; + + if(mass < 0) + return; + + // need more checks + + Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); + Vector3 Inertia; + float m = (float)mass; + float r = (float)radius; + r *= r; + Inertia.Z = 0.5f * m * r; + float t = (float)lenght; + t *= t; + t += 3.0f * r; + t *= 8.333333e-2f * m; + + Inertia.X = t; + Inertia.Y = t; + + Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s); + rot.Normalize(); + + sog.SetInertiaData(m, CenterOfMass, Inertia, rot); + } + + /// + /// removes inertial data manual override + /// default automatic calculation is used again + /// + /// + public void osClearInertia() + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return; + + sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero ); + } + + private bool checkAllowObjectTPbyLandOwner(Vector3 pos) + { + ILandObject land = World.LandChannel.GetLandObject(pos); + if(land == null) + return true; + + LandData landdata = land.LandData; + if(landdata == null) + return true; + + UUID hostOwner = m_host.OwnerID; + if(landdata.OwnerID == hostOwner) + return true; + + EstateSettings es = World.RegionInfo.EstateSettings; + if(es != null && es.IsEstateManagerOrOwner(hostOwner)) + return true; + + if(!landdata.IsGroupOwned) + return false; + + UUID landGroup = landdata.GroupID; + if(landGroup == UUID.Zero) + return false; + + if(landGroup == m_host.GroupID) + return true; + + return false; + } + + /// + /// teleports a object (full linkset) + /// + /// the id of the linkset to teleport + /// target position + /// a rotation to apply + /// several flags/param> + /// + /// only does teleport local to region + /// if object has scripts, owner must have rights to run scripts on target location + /// object owner must have rights to enter ojects on target location + /// target location parcel must have enought free prims capacity for the linkset prims + /// all avatars siting on the object must have access to target location + /// has a cool down time. retries before expire reset it + /// fail conditions are silent ignored + /// + public LSL_Integer osTeleportObject(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer flags) + { + CheckThreatLevel(ThreatLevel.Severe, "osTeleportObject"); + + UUID objUUID; + if (!UUID.TryParse(objectUUID, out objUUID)) + { + OSSLShoutError("osTeleportObject() invalid object Key"); + return -1; + } + + SceneObjectGroup sog = World.GetSceneObjectGroup(objUUID); + if(sog== null || sog.IsDeleted || sog.inTransit) + return -1; + + if(sog.OwnerID != m_host.OwnerID) + { + Vector3 pos = sog.AbsolutePosition; + if(!checkAllowObjectTPbyLandOwner(pos)) + return -1; + } + + UUID myid = m_host.ParentGroup.UUID; + + return sog.TeleportObject(myid, targetPos, rotation, flags); + // a delay here may break vehicles + } + + public LSL_Integer osGetLinkNumber(LSL_String name) + { + CheckThreatLevel(); + + SceneObjectGroup sog = m_host.ParentGroup; + if(sog== null || sog.IsDeleted) + return -1; + return sog.GetLinkNumber(name); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 64dc2e2..cc98bbb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -93,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private const int AGENT = 1; private const int AGENT_BY_USERNAME = 0x10; private const int NPC = 0x20; - private const int OS_NPC = 0x01000000; private const int ACTIVE = 2; private const int PASSIVE = 4; private const int SCRIPTED = 8; @@ -161,7 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins ts.arc = arc; ts.host = host; - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); + ts.next = DateTime.UtcNow.AddSeconds(ts.interval); AddSenseRepeater(ts); } @@ -197,14 +196,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public void CheckSenseRepeaterEvents() { // Go through all timers - foreach (SensorInfo ts in SenseRepeaters) + + List curSensors; + lock(SenseRepeatListLock) + curSensors = SenseRepeaters; + + DateTime now = DateTime.UtcNow; + foreach (SensorInfo ts in curSensors) { // Time has passed? - if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) + if (ts.next < now) { SensorSweep(ts); // set next interval - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); + ts.next = now.AddSeconds(ts.interval); } } } @@ -240,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins List sensedEntities = new List(); // Is the sensor type is AGENT and not SCRIPTED then include agents - if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) + if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } @@ -339,7 +344,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins float dy; float dz; - Quaternion q = SensePoint.GetWorldRotation(); +// Quaternion q = SensePoint.RotationOffset; + Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! if (SensePoint.ParentGroup.IsAttachment) { // In attachments, rotate the sensor cone with the @@ -351,14 +357,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // your head but the sensor will stay with your (global) // avatar rotation and position. // Position of a sensor in a child prim attached to an avatar - // will be still wrong. + // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); // Don't proceed if the avatar for this attachment has since been removed from the scene. if (avatar == null) return sensedEntities; - q = avatar.GetWorldRotation() * q; + fromRegionPos = avatar.AbsolutePosition; + q = avatar.Rotation; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); @@ -402,7 +409,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins objtype = 0; part = ((SceneObjectGroup)ent).RootPart; - if (part.ParentGroup.AttachmentPoint != 0) // Attached so ignore + if (part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.Tree && + part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.NewTree && + part.ParentGroup.AttachmentPoint != 0) // Attached so ignore continue; if (part.Inventory.ContainsScripts()) @@ -470,7 +479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins SceneObjectPart SensePoint = ts.host; Vector3 fromRegionPos = SensePoint.GetWorldPosition(); - + Quaternion q = SensePoint.GetWorldRotation(); if (SensePoint.ParentGroup.IsAttachment) { @@ -483,14 +492,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // your head but the sensor will stay with your (global) // avatar rotation and position. // Position of a sensor in a child prim attached to an avatar - // will be still wrong. + // will be still wrong. ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); // Don't proceed if the avatar for this attachment has since been removed from the scene. if (avatar == null) return sensedEntities; - - q = avatar.GetWorldRotation() * q; + fromRegionPos = avatar.AbsolutePosition; + q = avatar.Rotation; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); @@ -499,14 +508,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); Vector3 toRegionPos; double dis; - + Action senseEntity = new Action(presence => { // m_log.DebugFormat( // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", // presence.Name, presence.PresenceType, ts.name, ts.type); - if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) + if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) { INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); if (npcData == null || !npcData.SenseAsAgent) @@ -537,16 +546,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } } - if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) + if (presence.IsDeleted || presence.IsChildAgent || presence.IsViewerUIGod) return; - + // if the object the script is in is attached and the avatar is the owner // then this one is not wanted if (attached && presence.UUID == SensePoint.OwnerID) return; toRegionPos = presence.AbsolutePosition; - dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); + dis = Util.GetDistanceTo(toRegionPos, fromRegionPos); + if (presence.IsSatOnObject && presence.ParentPart != null && + presence.ParentPart.ParentGroup != null && + presence.ParentPart.ParentGroup.RootPart != null) + { + Vector3 rpos = presence.ParentPart.ParentGroup.RootPart.AbsolutePosition; + double dis2 = Util.GetDistanceTo(rpos, fromRegionPos); + if (dis > dis2) + dis = dis2; + } // Disabled for now since all osNpc* methods check for appropriate ownership permission. // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not @@ -688,7 +706,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); AddSenseRepeater(ts); - + idx += 6; } } @@ -704,6 +722,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } return retList; - } + } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index 0b14565..cae1c14 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs @@ -123,25 +123,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins if (Timers.Count == 0) return; + Dictionary tvals; lock (TimerListLock) { // Go through all timers - Dictionary.ValueCollection tvals = Timers.Values; - foreach (TimerInfo ts in tvals) + tvals = new Dictionary(Timers); + } + + foreach (TimerInfo ts in tvals.Values) + { + // Time has passed? + if (ts.next < DateTime.Now.Ticks) { - // Time has passed? - if (ts.next < DateTime.Now.Ticks) - { - //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); - // Add it to queue - m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, - new EventParams("timer", new Object[0], - new DetectParams[0])); - // set next interval - - //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - ts.next = DateTime.Now.Ticks + ts.interval; - } + //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); + // Add it to queue + m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, + new EventParams("timer", new Object[0], + new DetectParams[0])); + // set next interval + + //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); + ts.next = DateTime.Now.Ticks + ts.interval; } } } @@ -198,6 +200,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } return retList; - } + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs index 215c087..e6676b4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Api")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ab215f3 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections; +using OpenSim.Region.ScriptEngine.Interfaces; + +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; + +namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces +{ + public interface ICM_Api + { + string cmDetectedCountry(int num); + string cmGetAgentCountry(key key); + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 3d58573..17c977f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -116,6 +116,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llGetAnimation(string id); LSL_List llGetAnimationList(string id); LSL_Integer llGetAttached(); + LSL_List llGetAttachedList(string id); LSL_List llGetBoundingBox(string obj); LSL_Vector llGetCameraPos(); LSL_Rotation llGetCameraRot(); @@ -127,6 +128,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llGetEnv(LSL_String name); LSL_Vector llGetForce(); LSL_Integer llGetFreeMemory(); + LSL_Integer llGetUsedMemory(); LSL_Integer llGetFreeURLs(); LSL_Vector llGetGeometricCenter(); LSL_Float llGetGMTclock(); @@ -204,12 +206,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llGetTimestamp(); LSL_Vector llGetTorque(); LSL_Integer llGetUnixTime(); - LSL_Integer llGetUsedMemory(); LSL_Vector llGetVel(); LSL_Float llGetWallclock(); void llGiveInventory(string destination, string inventory); void llGiveInventoryList(string destination, string category, LSL_List inventory); - void llGiveMoney(string destination, int amount); + LSL_Integer llGiveMoney(string destination, int amount); LSL_String llTransferLindenDollars(string destination, int amount); void llGodLikeRezObject(string inventory, LSL_Vector pos); LSL_Float llGround(LSL_Vector offset); @@ -325,6 +326,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Integer llRound(double f); LSL_Integer llSameGroup(string agent); void llSay(int channelID, string text); + LSL_Integer llScaleByFactor(double scaling_factor); + LSL_Float llGetMaxScaleFactor(); + LSL_Float llGetMinScaleFactor(); void llScaleTexture(double u, double v, int face); LSL_Integer llScriptDanger(LSL_Vector pos); void llScriptProfiler(LSL_Integer flag); @@ -344,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSetDamage(double damage); void llSetForce(LSL_Vector force, int local); void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); - void llSetVelocity(LSL_Vector velocity, int local); + void llSetVelocity(LSL_Vector vel, int local); void llSetAngularVelocity(LSL_Vector angularVelocity, int local); void llSetHoverHeight(double height, int water, double tau); void llSetInventoryPermMask(string item, int mask, int value); @@ -362,11 +366,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSetParcelMusicURL(string url); void llSetPayPrice(int price, LSL_List quick_pay_buttons); void llSetPos(LSL_Vector pos); + LSL_Integer llSetRegionPos(LSL_Vector pos); LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); void llSetPrimitiveParams(LSL_List rules); void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); void llSetPrimURL(string url); - LSL_Integer llSetRegionPos(LSL_Vector pos); void llSetRemoteScriptAccessPin(int pin); void llSetRot(LSL_Rotation rot); void llSetScale(LSL_Vector scale); @@ -429,10 +433,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector llWind(LSL_Vector offset); LSL_String llXorBase64Strings(string str1, string str2); LSL_String llXorBase64StringsCorrect(string str1, string str2); - void print(string str); + LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); + void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density); void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); void llSetKeyframedMotion(LSL_List frames, LSL_List options); LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); + LSL_List llGetPhysicsMaterial(); + void llSetAnimationOverride(LSL_String animState, LSL_String anim); + void llResetAnimationOverride(LSL_String anim_state); + LSL_String llGetAnimationOverride(LSL_String anim_state); + LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers); + LSL_List llJson2List(LSL_String json); + LSL_String llList2Json(LSL_String type, LSL_List values); + LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value); + LSL_String llJsonValueType(LSL_String json, LSL_List specifiers); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index aa78aaa..7c518f3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector modInvokeV(string fname, params object[] parms); LSL_Rotation modInvokeR(string fname, params object[] parms); LSL_List modInvokeL(string fname, params object[] parms); - + //Module functions string modSendCommand(string modules, string command, string k); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 82fdc53..ffb7ded 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -38,6 +38,7 @@ using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; + namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces { /// @@ -50,11 +51,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// public enum ThreatLevel { - // Not documented, presumably means permanently disabled ? NoAccess = -1, /// - /// Function is no threat at all. It doesn't constitute a threat to + /// Function is no threat at all. It doesn't constitute a threat to /// either users or the system and has no known side effects. /// None = 0, @@ -66,7 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces Nuisance = 1, /// - /// Extreme levels of abuse of this function can cause impaired + /// Extreme levels of abuse of this function can cause impaired /// functioning of the region, or very gullible users can be tricked /// into experiencing harmless effects. /// @@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// Intentional abuse can cause denial of service and crashes with - /// potential of data or state loss; or trusting users can be tricked + /// potential of data or state loss; or trusting users can be tricked /// into embarrassing or uncomfortable situations. /// Moderate = 4, @@ -114,7 +114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces public interface IOSSL_Api { - bool CheckThreatLevel(ThreatLevel level, string function); + void CheckThreatLevel(ThreatLevel level, string function); //OpenSim functions string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); @@ -123,6 +123,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face); string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); + string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, int timer, int face); string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha); string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, @@ -135,6 +136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osTerrainFlush(); int osRegionRestart(double seconds); + int osRegionRestart(double seconds, string msg); void osRegionNotice(string msg); bool osConsoleCommand(string Command); void osSetParcelMediaURL(string url); @@ -142,8 +144,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetParcelSIPAddress(string SIPAddress); // Avatar Info Commands - string osGetAgentIP(string agent); LSL_List osGetAgents(); + string osGetAgentIP(string agent); // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); @@ -221,10 +223,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osDrawLine(string drawList, int endX, int endY); string osDrawText(string drawList, string text); string osDrawEllipse(string drawList, int width, int height); + string osDrawFilledEllipse(string drawList, int width, int height); string osDrawRectangle(string drawList, int width, int height); string osDrawFilledRectangle(string drawList, int width, int height); string osDrawPolygon(string drawList, LSL_List x, LSL_List y); string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y); + string osDrawResetTransform(string drawList); + string osDrawRotationTransform(string drawList, LSL_Float x); + string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y); + string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y); string osSetFontName(string drawList, string fontName); string osSetFontSize(string drawList, int fontSize); string osSetPenSize(string drawList, int penSize); @@ -261,6 +268,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osGetSimulatorVersion(); LSL_Integer osCheckODE(); string osGetPhysicsEngineType(); + string osGetPhysicsEngineName(); Object osParseJSONNew(string JSON); Hashtable osParseJSON(string JSON); @@ -315,6 +323,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osForceBreakAllLinks(); /// + /// Similar to llDie but given an object UUID + /// + /// + + void osDie(LSL_Key objectUUID); + + /// /// Check if the given key is an npc /// /// @@ -341,6 +356,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces rotation osNpcGetRot(key npc); void osNpcSetRot(LSL_Key npc, rotation rot); void osNpcStopMoveToTarget(LSL_Key npc); + void osNpcSetProfileAbout(LSL_Key npc, string about); + void osNpcSetProfileImage(LSL_Key npc, string image); void osNpcSay(key npc, string message); void osNpcSay(key npc, int channel, string message); void osNpcShout(key npc, int channel, string message); @@ -362,10 +379,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces vector osGetRegionSize(); int osGetSimulatorMemory(); + int osGetSimulatorMemoryKB(); void osKickAvatar(string FirstName,string SurName,string alert); void osSetSpeed(string UUID, LSL_Float SpeedModifier); LSL_Float osGetHealth(string avatar); void osCauseHealing(string avatar, double healing); + void osSetHealth(string avatar, double health); + void osSetHealRate(string avatar, double health); + LSL_Float osGetHealRate(string avatar); void osCauseDamage(string avatar, double damage); void osForceOtherSit(string avatar); void osForceOtherSit(string avatar, string target); @@ -375,6 +396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb); LSL_List osGetAvatarList(); + LSL_List osGetNPCList(); LSL_String osUnixTimeToTimestamp(long time); @@ -468,5 +490,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// string to use as pattern /// boolean LSL_Integer osRegexIsMatch(string input, string pattern); + + LSL_String osRequestURL(LSL_List options); + LSL_String osRequestSecureURL(LSL_List options); + void osCollisionSound(string impact_sound, double impact_volume); + + void osVolumeDetect(int detect); + + LSL_List osGetInertiaData(); + void osClearInertia(); + void osSetInertia(LSL_Float mass, vector centerOfMass, vector principalInertiaScaled, rotation rot); + void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot); + void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); + void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); + + LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags); + LSL_Integer osGetLinkNumber(LSL_String name); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..4132dfa --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Runtime.Remoting.Lifetime; +using System.Threading; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; +using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; + +namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase +{ + public partial class ScriptBaseClass : MarshalByRefObject + { + public ICM_Api m_CM_Functions; + + public void ApiTypeCM(IScriptApi api) + { + if (!(api is ICM_Api)) + return; + + m_CM_Functions = (ICM_Api)api; + } + + public string cmDetectedCountry(int num) + { + return m_CM_Functions.cmDetectedCountry(num); + } + + public string cmGetAgentCountry(key key) + { + return m_CM_Functions.cmGetAgentCountry(key); + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index ce17ed0..1cc2cfb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Reflection; using System.Runtime.Remoting.Lifetime; using OpenSim.Region.ScriptEngine.Shared; @@ -133,6 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return (eventFlags); } + [DebuggerNonUserCode] public void ExecuteEvent(string state, string FunctionName, object[] args) { // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 9aecea2..2f249a7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -29,6 +29,7 @@ using System; using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSLString = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { @@ -57,7 +58,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int ACTIVE = 2; public const int PASSIVE = 4; public const int SCRIPTED = 8; - public const int OS_NPC = 0x01000000; public const int CONTROL_FWD = 1; public const int CONTROL_BACK = 2; @@ -82,6 +82,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PERMISSION_CHANGE_PERMISSIONS = 512; public const int PERMISSION_TRACK_CAMERA = 1024; public const int PERMISSION_CONTROL_CAMERA = 2048; + public const int PERMISSION_TELEPORT = 4096; + public const int PERMISSION_OVERRIDE_ANIMATIONS = 0x8000; public const int AGENT_FLYING = 1; public const int AGENT_ATTACHMENTS = 2; @@ -96,6 +98,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int AGENT_CROUCHING = 1024; public const int AGENT_BUSY = 2048; public const int AGENT_ALWAYS_RUN = 4096; + public const int AGENT_MALE = 8192; //Particle Systems public const int PSYS_PART_INTERP_COLOR_MASK = 1; @@ -252,6 +255,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int ATTACH_HUD_BOTTOM_RIGHT = 38; public const int ATTACH_NECK = 39; public const int ATTACH_AVATAR_CENTER = 40; + public const int ATTACH_LHAND_RING1 = 41; + public const int ATTACH_RHAND_RING1 = 42; + public const int ATTACH_TAIL_BASE = 43; + public const int ATTACH_TAIL_TIP = 44; + public const int ATTACH_LWING = 45; + public const int ATTACH_RWING = 46; + public const int ATTACH_FACE_JAW = 47; + public const int ATTACH_FACE_LEAR = 48; + public const int ATTACH_FACE_REAR = 49; + public const int ATTACH_FACE_LEYE = 50; + public const int ATTACH_FACE_REYE = 51; + public const int ATTACH_FACE_TONGUE = 52; + public const int ATTACH_GROIN = 53; + public const int ATTACH_HIND_LFOOT = 54; + public const int ATTACH_HIND_RFOOT = 55; #region osMessageAttachments constants @@ -334,11 +352,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int ROTATE = 32; public const int SCALE = 64; public const int ALL_SIDES = -1; + + // LINK flags public const int LINK_SET = -1; public const int LINK_ROOT = 1; public const int LINK_ALL_OTHERS = -2; public const int LINK_ALL_CHILDREN = -3; public const int LINK_THIS = -4; + public const int CHANGED_INVENTORY = 1; public const int CHANGED_COLOR = 2; public const int CHANGED_SHAPE = 4; @@ -353,6 +374,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART public const int CHANGED_MEDIA = 2048; public const int CHANGED_ANIMATION = 16384; + public const int CHANGED_POSITION = 32768; + public const int TYPE_INVALID = 0; public const int TYPE_INTEGER = 1; public const int TYPE_FLOAT = 2; @@ -386,6 +409,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int CONTENT_TYPE_FORM = 7; //application/x-www-form-urlencoded public const int CONTENT_TYPE_RSS = 8; //application/rss+xml + //parameters comand flags public const int PRIM_MATERIAL = 2; public const int PRIM_PHYSICS = 3; public const int PRIM_TEMP_ON_REZ = 4; @@ -394,19 +418,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_SIZE = 7; public const int PRIM_ROTATION = 8; public const int PRIM_TYPE = 9; + // gap 10-16 public const int PRIM_TEXTURE = 17; public const int PRIM_COLOR = 18; public const int PRIM_BUMP_SHINY = 19; public const int PRIM_FULLBRIGHT = 20; public const int PRIM_FLEXIBLE = 21; public const int PRIM_TEXGEN = 22; - public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake public const int PRIM_POINT_LIGHT = 23; // Huh? + public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake public const int PRIM_GLOW = 25; public const int PRIM_TEXT = 26; public const int PRIM_NAME = 27; public const int PRIM_DESC = 28; public const int PRIM_ROT_LOCAL = 29; + public const int PRIM_PHYSICS_SHAPE_TYPE = 30; + public const int PRIM_PHYSICS_MATERIAL = 31; // apparently not on SL wiki public const int PRIM_OMEGA = 32; public const int PRIM_POS_LOCAL = 33; public const int PRIM_LINK_TARGET = 34; @@ -414,6 +441,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_SPECULAR = 36; public const int PRIM_NORMAL = 37; public const int PRIM_ALPHA_MODE = 38; + public const int PRIM_ALLOW_UNSIT = 39; // experiences related. unsupported + public const int PRIM_SCRIPTED_SIT_ONLY = 40; // experiences related. unsupported + public const int PRIM_SIT_TARGET = 41; + + + // parameters public const int PRIM_TEXGEN_DEFAULT = 0; public const int PRIM_TEXGEN_PLANAR = 1; @@ -470,6 +503,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_SCULPT_FLAG_INVERT = 64; public const int PRIM_SCULPT_FLAG_MIRROR = 128; + public const int PRIM_PHYSICS_SHAPE_PRIM = 0; + public const int PRIM_PHYSICS_SHAPE_NONE = 1; + public const int PRIM_PHYSICS_SHAPE_CONVEX = 2; + public const int PROFILE_NONE = 0; public const int PROFILE_SCRIPT_MEMORY = 1; @@ -600,6 +637,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OBJECT_HOVER_HEIGHT = 25; public const int OBJECT_BODY_SHAPE_TYPE = 26; public const int OBJECT_LAST_OWNER_ID = 27; + public const int OBJECT_CLICK_ACTION = 28; + public const int OBJECT_OMEGA = 29; + public const int OBJECT_PRIM_COUNT = 30; + public const int OBJECT_TOTAL_INVENTORY_COUNT = 31; + public const int OBJECT_REZZER_KEY = 32; + public const int OBJECT_GROUP_TAG = 33; + public const int OBJECT_TEMP_ATTACHED = 34; + public const int OBJECT_ATTACHED_SLOTS_AVAILABLE = 35; // Pathfinding types public const int OPT_OTHER = -1; @@ -615,6 +660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int AGENT_LIST_PARCEL = 1; public const int AGENT_LIST_PARCEL_OWNER = 2; public const int AGENT_LIST_REGION = 4; + public const int AGENT_LIST_EXCLUDENPC = 0x4000000; // our flag, not SL and it is a bit mask // Can not be public const? public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); @@ -652,7 +698,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PARCEL_DETAILS_GROUP = 3; public const int PARCEL_DETAILS_AREA = 4; public const int PARCEL_DETAILS_ID = 5; - public const int PARCEL_DETAILS_SEE_AVATARS = 6; // not implemented + public const int PARCEL_DETAILS_SEE_AVATARS = 6; + public const int PARCEL_DETAILS_ANY_AVATAR_SOUNDS = 7; + public const int PARCEL_DETAILS_GROUP_SOUNDS = 8; //osSetParcelDetails public const int PARCEL_DETAILS_CLAIMDATE = 10; @@ -698,12 +746,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_MEDIA_PERM_GROUP = 2; public const int PRIM_MEDIA_PERM_ANYONE = 4; - public const int PRIM_PHYSICS_SHAPE_TYPE = 30; - public const int PRIM_PHYSICS_SHAPE_PRIM = 0; - public const int PRIM_PHYSICS_SHAPE_CONVEX = 2; - public const int PRIM_PHYSICS_SHAPE_NONE = 1; - - public const int PRIM_PHYSICS_MATERIAL = 31; public const int DENSITY = 1; public const int FRICTION = 2; public const int RESTITUTION = 4; @@ -760,6 +802,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OS_NPC_CREATOR_OWNED = 0x1; public const int OS_NPC_NOT_OWNED = 0x2; public const int OS_NPC_SENSE_AS_AGENT = 0x4; + public const int OS_NPC_OBJECT_GROUP = 0x08; public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; @@ -795,6 +838,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int KFM_CMD_STOP = 1; public const int KFM_CMD_PAUSE = 2; + public const string JSON_INVALID = "\uFDD0"; + public const string JSON_OBJECT = "\uFDD1"; + public const string JSON_ARRAY = "\uFDD2"; + public const string JSON_NUMBER = "\uFDD3"; + public const string JSON_STRING = "\uFDD4"; + public const string JSON_NULL = "\uFDD5"; + public const string JSON_TRUE = "\uFDD6"; + public const string JSON_FALSE = "\uFDD7"; + public const string JSON_DELETE = "\uFDD8"; + public const string JSON_APPEND = "-1"; + /// /// process name parameter as regex /// @@ -804,5 +858,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase /// process message parameter as regex /// public const int OS_LISTEN_REGEX_MESSAGE = 0x2; + + // for osTeleportObject + public const int OSTPOBJ_NONE = 0x0; + public const int OSTPOBJ_STOPATTARGET = 0x1; // stops at destination + public const int OSTPOBJ_STOPONFAIL = 0x2; // stops at jump point if tp fails + public const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 35aaf01..c39248b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -26,6 +26,7 @@ */ using System; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Runtime.Remoting.Lifetime; using System.Threading; using System.Reflection; @@ -314,6 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); } + [DebuggerNonUserCode] public void llDie() { m_LSL_Functions.llDie(); @@ -424,6 +426,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetAttached(); } + public LSL_List llGetAttachedList(string id) + { + return m_LSL_Functions.llGetAttachedList(id); + } + public LSL_List llGetBoundingBox(string obj) { return m_LSL_Functions.llGetBoundingBox(obj); @@ -479,6 +486,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetFreeMemory(); } + public LSL_Integer llGetUsedMemory() + { + return m_LSL_Functions.llGetUsedMemory(); + } + public LSL_Integer llGetFreeURLs() { return m_LSL_Functions.llGetFreeURLs(); @@ -559,11 +571,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetLinkNumberOfSides(link); } - public void llSetKeyframedMotion(LSL_List frames, LSL_List options) - { - m_LSL_Functions.llSetKeyframedMotion(frames, options); - } - public LSL_Integer llGetListEntryType(LSL_List src, int index) { return m_LSL_Functions.llGetListEntryType(src, index); @@ -859,11 +866,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetUnixTime(); } - public LSL_Integer llGetUsedMemory() - { - return m_LSL_Functions.llGetUsedMemory(); - } - public LSL_Vector llGetVel() { return m_LSL_Functions.llGetVel(); @@ -884,9 +886,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llGiveInventoryList(destination, category, inventory); } - public void llGiveMoney(string destination, int amount) + public LSL_Integer llGiveMoney(string destination, int amount) { - m_LSL_Functions.llGiveMoney(destination, amount); + return m_LSL_Functions.llGiveMoney(destination, amount); } public LSL_String llTransferLindenDollars(string destination, int amount) @@ -1463,6 +1465,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSay(channelID, text); } + public LSL_Integer llScaleByFactor(double scaling_factor) + { + return m_LSL_Functions.llScaleByFactor(scaling_factor); + } + + public LSL_Float llGetMaxScaleFactor() + { + return m_LSL_Functions.llGetMaxScaleFactor(); + } + + public LSL_Float llGetMinScaleFactor() + { + return m_LSL_Functions.llGetMinScaleFactor(); + } + public void llScaleTexture(double u, double v, int face) { m_LSL_Functions.llScaleTexture(u, v, face); @@ -1563,6 +1580,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetVelocity(force, local); } + public void llSetAngularVelocity(LSL_Vector force, int local) { m_LSL_Functions.llSetAngularVelocity(force, local); @@ -1643,6 +1661,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetPos(pos); } + public LSL_Integer llSetRegionPos(LSL_Vector pos) + { + return m_LSL_Functions.llSetRegionPos(pos); + } + public void llSetPrimitiveParams(LSL_List rules) { m_LSL_Functions.llSetPrimitiveParams(rules); @@ -1658,11 +1681,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetPrimURL(url); } - public LSL_Integer llSetRegionPos(LSL_Vector pos) - { - return m_LSL_Functions.llSetRegionPos(pos); - } - public void llSetRemoteScriptAccessPin(int pin) { m_LSL_Functions.llSetRemoteScriptAccessPin(pin); @@ -1977,7 +1995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } - + public LSL_List llGetPrimMediaParams(int face, LSL_List rules) { return m_LSL_Functions.llGetPrimMediaParams(face, rules); @@ -2008,9 +2026,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llClearLinkMedia(link, face); } - public void print(string str) + public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) + { + return m_LSL_Functions.llGetLinkNumberOfSides(link); + } + + public void llSetKeyframedMotion(LSL_List frames, LSL_List options) + { + m_LSL_Functions.llSetKeyframedMotion(frames, options); + } + + public void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density) + { + m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); + } + + public LSL_List llGetPhysicsMaterial() + { + return m_LSL_Functions.llGetPhysicsMaterial(); + } + + public void llSetAnimationOverride(LSL_String animState, LSL_String anim) + { + m_LSL_Functions.llSetAnimationOverride(animState, anim); + } + + public void llResetAnimationOverride(LSL_String anim_state) + { + m_LSL_Functions.llResetAnimationOverride(anim_state); + } + + public LSL_String llGetAnimationOverride(LSL_String anim_state) + { + return m_LSL_Functions.llGetAnimationOverride(anim_state); + } + + public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers) + { + return m_LSL_Functions.llJsonGetValue(json, specifiers); + } + + public LSL_List llJson2List(LSL_String json) + { + return m_LSL_Functions.llJson2List(json); + } + + public LSL_String llList2Json(LSL_String type, LSL_List values) + { + return m_LSL_Functions.llList2Json(type, values); + } + + public LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value) + { + return m_LSL_Functions.llJsonSetValue(json, specifiers, value); + } + + public LSL_String llJsonValueType(LSL_String json, LSL_List specifiers) { - m_LSL_Functions.print(str); + return m_LSL_Functions.llJsonValueType(json, specifiers); } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs index 143b497..2e27f16 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs @@ -72,9 +72,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); } + public void lsClearWindlightScene() { m_LS_Functions.lsClearWindlightScene(); } + + public LSL_List cmGetWindlightScene(LSL_List rules) + { + return m_LS_Functions.lsGetWindlightScene(rules); + } + + public int cmSetWindlightScene(LSL_List rules) + { + return m_LS_Functions.lsSetWindlightScene(rules); + } + + public int cmSetWindlightSceneTargeted(LSL_List rules, key target) + { + return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); + } + + public void cmClearWindlightScene() + { + m_LS_Functions.lsClearWindlightScene(); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a60f381..30ff764 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -153,6 +153,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer); } + public string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, + int timer, int face) + { + return m_OSSL_Functions.osSetDynamicTextureDataFace(dynamicID, contentType, data, extraParams, timer, face); + } + public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha) { @@ -209,6 +215,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osRegionRestart(seconds); } + public int osRegionRestart(double seconds, string msg) + { + return m_OSSL_Functions.osRegionRestart(seconds, msg); + } + public void osRegionNotice(string msg) { m_OSSL_Functions.osRegionNotice(msg); @@ -266,15 +277,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportOwner(position, lookat); } - // Avatar info functions - public string osGetAgentIP(string agent) + public LSL_List osGetAgents() { - return m_OSSL_Functions.osGetAgentIP(agent); + return m_OSSL_Functions.osGetAgents(); } - public LSL_List osGetAgents() + public string osGetAgentIP(string agent) { - return m_OSSL_Functions.osGetAgents(); + return m_OSSL_Functions.osGetAgentIP(agent); } // Animation Functions @@ -350,6 +360,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawEllipse(drawList, width, height); } + public string osDrawFilledEllipse(string drawList, int width, int height) + { + return m_OSSL_Functions.osDrawFilledEllipse(drawList, width, height); + } + public string osDrawRectangle(string drawList, int width, int height) { return m_OSSL_Functions.osDrawRectangle(drawList, width, height); @@ -370,6 +385,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y); } + public string osDrawResetTransform(string drawList) + { + return m_OSSL_Functions.osDrawResetTransform(drawList); + } + + public string osDrawRotationTransform(string drawList, LSL_Float x) + { + return m_OSSL_Functions.osDrawRotationTransform(drawList, x); + } + + public string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) + { + return m_OSSL_Functions.osDrawScaleTransform(drawList, x, y); + } + + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + return m_OSSL_Functions.osDrawTranslationTransform(drawList, x, y); + } + public string osSetFontSize(string drawList, int fontSize) { return m_OSSL_Functions.osSetFontSize(drawList, fontSize); @@ -394,6 +429,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osSetPenColor(drawList, color); } + // Deprecated public string osSetPenColour(string drawList, string colour) { @@ -430,6 +466,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetPhysicsEngineType(); } + public string osGetPhysicsEngineName() + { + return m_OSSL_Functions.osGetPhysicsEngineName(); + } + public string osGetSimulatorVersion() { return m_OSSL_Functions.osGetSimulatorVersion(); @@ -439,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osParseJSON(JSON); } - + public Object osParseJSONNew(string JSON) { return m_OSSL_Functions.osParseJSONNew(JSON); @@ -529,7 +570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osReplaceString(src,pattern,replace,count,start); } - + // Information about data loaded into the region public string osLoadedCreationDate() @@ -567,6 +608,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osForceBreakAllLinks(); } + public void osDie(LSL_Key objectUUID) + { + m_OSSL_Functions.osDie(objectUUID); + } + public LSL_Integer osIsNpc(LSL_Key npc) { return m_OSSL_Functions.osIsNpc(npc); @@ -627,6 +673,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcStopMoveToTarget(npc); } + public void osNpcSetProfileAbout(LSL_Key npc, string about) + { + m_OSSL_Functions.osNpcSetProfileAbout(npc, about); + } + + public void osNpcSetProfileImage(LSL_Key npc, string image) + { + m_OSSL_Functions.osNpcSetProfileImage(npc, image); + } + public void osNpcSay(key npc, string message) { m_OSSL_Functions.osNpcSay(npc, message); @@ -744,14 +800,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase if (Position.y > ((int)Constants.RegionSize - 1)) Position.y = ((int)Constants.RegionSize - 1); */ - if (Position.z > Constants.RegionHeight) - Position.z = Constants.RegionHeight; if (Position.x < 0) Position.x = 0; if (Position.y < 0) Position.y = 0; if (Position.z < 0) Position.z = 0; + if (Position.z > Constants.RegionHeight) + Position.z = Constants.RegionHeight; prim.OSSL.llSetPos(Position); } @@ -889,7 +945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetRegionMapTexture(regionName); } - + public LSL_List osGetRegionStats() { return m_OSSL_Functions.osGetRegionStats(); @@ -902,19 +958,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase /// /// Returns the amount of memory in use by the Simulator Daemon. - /// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware) + /// Amount in bytes - if >= 2GB, returns 2GB. (LSL is not 64-bit aware) /// /// public LSL_Integer osGetSimulatorMemory() { return m_OSSL_Functions.osGetSimulatorMemory(); } - + + public LSL_Integer osGetSimulatorMemoryKB() + { + return m_OSSL_Functions.osGetSimulatorMemoryKB(); + } + public void osKickAvatar(string FirstName,string SurName,string alert) { m_OSSL_Functions.osKickAvatar(FirstName, SurName, alert); } - + public void osSetSpeed(string UUID, LSL_Float SpeedModifier) { m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier); @@ -929,12 +990,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_OSSL_Functions.osCauseDamage(avatar, damage); } - + public void osCauseHealing(string avatar, double healing) { m_OSSL_Functions.osCauseHealing(avatar, healing); } + public void osSetHealth(string avatar, double health) + { + m_OSSL_Functions.osSetHealth(avatar, health); + } + + public void osSetHealRate(string avatar, double health) + { + m_OSSL_Functions.osSetHealRate(avatar, health); + } + + public LSL_Float osGetHealRate(string avatar) + { + return m_OSSL_Functions.osGetHealRate(avatar); + } + public void osForceOtherSit(string avatar) { m_OSSL_Functions.osForceOtherSit(avatar); @@ -944,12 +1020,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_OSSL_Functions.osForceOtherSit(avatar, target); } - + public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules) { return m_OSSL_Functions.osGetPrimitiveParams(prim, rules); } - + public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) { m_OSSL_Functions.osSetPrimitiveParams(prim, rules); @@ -970,6 +1046,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetAvatarList(); } + public LSL_List osGetNPCList() + { + return m_OSSL_Functions.osGetNPCList(); + } + public LSL_String osUnixTimeToTimestamp(long time) { return m_OSSL_Functions.osUnixTimeToTimestamp(time); @@ -1054,5 +1135,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osRegexIsMatch(input, pattern); } + + public LSL_String osRequestURL(LSL_List options) + { + return m_OSSL_Functions.osRequestURL(options); + } + + public LSL_String osRequestSecureURL(LSL_List options) + { + return m_OSSL_Functions.osRequestSecureURL(options); + } + + public void osCollisionSound(string impact_sound, double impact_volume) + { + m_OSSL_Functions.osCollisionSound(impact_sound, impact_volume); + } + + public void osVolumeDetect(int detect) + { + m_OSSL_Functions.osVolumeDetect(detect); + } + + public LSL_List osGetInertiaData() + { + return m_OSSL_Functions.osGetInertiaData(); + } + + public void osSetInertia(LSL_Float mass, vector centerOfMass, vector principalInertiaScaled, rotation rot) + { + m_OSSL_Functions.osSetInertia(mass, centerOfMass, principalInertiaScaled, rot); + } + + public void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot) + { + m_OSSL_Functions.osSetInertiaAsBox(mass, boxSize, centerOfMass, rot); + } + + public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass) + { + m_OSSL_Functions.osSetInertiaAsSphere(mass, radius, centerOfMass); + } + + public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot) + { + m_OSSL_Functions.osSetInertiaAsCylinder( mass, radius, lenght, centerOfMass, lslrot); + } + + public void osClearInertia() + { + m_OSSL_Functions.osClearInertia(); + } + + public LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags) + { + return m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags); + } + + public LSL_Integer osGetLinkNumber(LSL_String name) + { + return m_OSSL_Functions.osGetLinkNumber(name); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp deleted file mode 100644 index f02d2d9..0000000 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs index b1825ac..81020f1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Api.Runtime")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,7 +25,7 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs @@ -33,6 +33,7 @@ using System.Threading; using System.Reflection; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; @@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return (int)m_Executor.GetStateEventFlags(state); } + [DebuggerNonUserCode] public void ExecuteEvent(string state, string FunctionName, object[] args) { m_Executor.ExecuteEvent(state, FunctionName, args); diff --git a/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs index 6c42e2e..e35f79f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.Shared string dirName = myDomain.FriendlyName; string ScriptEnginesPath = myDomain.SetupInformation.PrivateBinPath; - string[] pathList = new string[] {"", "caches", ScriptEnginesPath, + string[] pathList = new string[] {"", "bin", ScriptEnginesPath, Path.Combine(ScriptEnginesPath, dirName)}; string assemblyName = args.Name; diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 4e0c273..031f00a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -26,6 +26,7 @@ */ using System; +using System.Text; using System.IO; using System.Collections.Generic; using System.Reflection; @@ -39,9 +40,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static yyLSLSyntax yyLSL = new yyLSLSyntax(); private SYMBOL m_astRoot = null; private Dictionary, KeyValuePair> m_positionMap; - private int m_indentWidth = 4; // for indentation private int m_braceCount; // for indentation private int m_CSharpLine; // the current line of generated C# code private int m_CSharpCol; // the current column of generated C# code @@ -94,6 +95,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools get { return m_astRoot; } } + public void Clear() + { + m_astRoot.kids = null; + m_astRoot.yylx = null; + m_astRoot.yyps = null; + m_astRoot = null; + m_positionMap = null; + m_warnings.Clear(); + m_comms = null; + } /// /// Resets various counters and metadata. /// @@ -106,18 +117,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools m_astRoot = null; } + public string Convert(string script) + { + StringBuilder sb = new StringBuilder(4096); + Convert(script, sb); + return sb.ToString(); + } + /// /// Generate the code from the AST we have. /// /// The LSL source as a string. /// String containing the generated C# code. - public string Convert(string script) + public void Convert(string script, StringBuilder sb) { // m_log.DebugFormat("[CS CODE GENERATOR]: Converting to C#\n{0}", script); m_warnings.Clear(); ResetCounters(); - Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); + ErrorHandler errorHandler = new ErrorHandler(true); + Parser p = new LSLSyntax(yyLSL, errorHandler); LSL2CSCodeTransformer codeTransformer; try @@ -148,38 +167,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools m_astRoot = codeTransformer.Transform(); - string retstr = String.Empty; // standard preamble - //retstr = GenerateLine("using OpenSim.Region.ScriptEngine.Common;"); - //retstr += GenerateLine("using System.Collections.Generic;"); - //retstr += GenerateLine(""); - //retstr += GenerateLine("namespace SecondLife"); - //retstr += GenerateLine("{"); + + + m_braceCount++; - //retstr += GenerateIndentedLine("public class Script : OpenSim.Region.ScriptEngine.Common"); - //retstr += GenerateIndentedLine("{"); m_braceCount++; // line number - m_CSharpLine += 9; + m_CSharpLine += 10; // here's the payload - retstr += GenerateLine(); + sb.Append("\n"); foreach (SYMBOL s in m_astRoot.kids) - retstr += GenerateNode(m_astRoot, s); + GenerateNodeToSB(m_astRoot, s, sb); + + codeTransformer = null; + p.m_lexer.m_buf=null; + p.m_lexer.yytext = null; + p.m_lexer = null; + p.m_symbols = null; + p = null; + errorHandler = null; // close braces! - m_braceCount--; +// m_braceCount--; //retstr += GenerateIndentedLine("}"); - m_braceCount--; +// m_braceCount--; //retstr += GenerateLine("}"); // Removes all carriage return characters which may be generated in Windows platform. Is there // cleaner way of doing this? - retstr = retstr.Replace("\r", ""); - - return retstr; +// sb.Replace("\r", ""); } /// @@ -206,78 +226,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// The parent node. /// The current node to generate code for. /// String containing C# code for SYMBOL s. - private string GenerateNode(SYMBOL previousSymbol, SYMBOL s) + private void GenerateNodeToSB(SYMBOL previousSymbol, SYMBOL s, StringBuilder sb) { - string retstr = String.Empty; - // make sure to put type lower in the inheritance hierarchy first // ie: since IdentArgument and ExpressionArgument inherit from // Argument, put IdentArgument and ExpressionArgument before Argument if (s is GlobalFunctionDefinition) - retstr += GenerateGlobalFunctionDefinition((GlobalFunctionDefinition) s); + GenerateGlobalFunctionDefinition((GlobalFunctionDefinition) s, sb); else if (s is GlobalVariableDeclaration) - retstr += GenerateGlobalVariableDeclaration((GlobalVariableDeclaration) s); + GenerateGlobalVariableDeclaration((GlobalVariableDeclaration) s , sb); else if (s is State) - retstr += GenerateState((State) s); + GenerateState((State) s, sb); else if (s is CompoundStatement) - retstr += GenerateCompoundStatement(previousSymbol, (CompoundStatement) s); + GenerateCompoundStatement(previousSymbol, (CompoundStatement) s, sb); else if (s is Declaration) - retstr += GenerateDeclaration((Declaration) s); + GenerateDeclaration((Declaration) s, sb); else if (s is Statement) - retstr += GenerateStatement(previousSymbol, (Statement) s); + GenerateStatement(previousSymbol, (Statement) s, sb); else if (s is ReturnStatement) - retstr += GenerateReturnStatement((ReturnStatement) s); + GenerateReturnStatement((ReturnStatement) s, sb); else if (s is JumpLabel) - retstr += GenerateJumpLabel((JumpLabel) s); + GenerateJumpLabel((JumpLabel) s, sb); else if (s is JumpStatement) - retstr += GenerateJumpStatement((JumpStatement) s); + GenerateJumpStatement((JumpStatement) s, sb); else if (s is StateChange) - retstr += GenerateStateChange((StateChange) s); + GenerateStateChange((StateChange) s, sb); else if (s is IfStatement) - retstr += GenerateIfStatement((IfStatement) s); + GenerateIfStatement((IfStatement) s, sb); else if (s is WhileStatement) - retstr += GenerateWhileStatement((WhileStatement) s); + GenerateWhileStatement((WhileStatement) s, sb); else if (s is DoWhileStatement) - retstr += GenerateDoWhileStatement((DoWhileStatement) s); + GenerateDoWhileStatement((DoWhileStatement) s, sb); else if (s is ForLoop) - retstr += GenerateForLoop((ForLoop) s); + GenerateForLoop((ForLoop) s, sb); else if (s is ArgumentList) - retstr += GenerateArgumentList((ArgumentList) s); + GenerateArgumentList((ArgumentList) s, sb); else if (s is Assignment) - retstr += GenerateAssignment((Assignment) s); + GenerateAssignment((Assignment) s, sb); else if (s is BinaryExpression) - retstr += GenerateBinaryExpression((BinaryExpression) s); + GenerateBinaryExpression((BinaryExpression) s, sb); else if (s is ParenthesisExpression) - retstr += GenerateParenthesisExpression((ParenthesisExpression) s); + GenerateParenthesisExpression((ParenthesisExpression) s, sb); else if (s is UnaryExpression) - retstr += GenerateUnaryExpression((UnaryExpression) s); + GenerateUnaryExpression((UnaryExpression) s, sb); else if (s is IncrementDecrementExpression) - retstr += GenerateIncrementDecrementExpression((IncrementDecrementExpression) s); + GenerateIncrementDecrementExpression((IncrementDecrementExpression) s, sb); else if (s is TypecastExpression) - retstr += GenerateTypecastExpression((TypecastExpression) s); + GenerateTypecastExpression((TypecastExpression) s, sb); else if (s is FunctionCall) - retstr += GenerateFunctionCall((FunctionCall) s); + GenerateFunctionCall((FunctionCall) s, sb); else if (s is VectorConstant) - retstr += GenerateVectorConstant((VectorConstant) s); + GenerateVectorConstant((VectorConstant) s, sb); else if (s is RotationConstant) - retstr += GenerateRotationConstant((RotationConstant) s); + GenerateRotationConstant((RotationConstant) s, sb); else if (s is ListConstant) - retstr += GenerateListConstant((ListConstant) s); + GenerateListConstant((ListConstant) s, sb); else if (s is Constant) - retstr += GenerateConstant((Constant) s); + GenerateConstant((Constant) s, sb); else if (s is IdentDotExpression) - retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); + Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s, sb); else if (s is IdentExpression) - retstr += GenerateIdentifier(((IdentExpression) s).Name, s); + GenerateIdentifier(((IdentExpression) s).Name, s, sb); else if (s is IDENT) - retstr += Generate(CheckName(((TOKEN) s).yytext), s); + Generate(CheckName(((TOKEN) s).yytext), s, sb); else { foreach (SYMBOL kid in s.kids) - retstr += GenerateNode(s, kid); + GenerateNodeToSB(s, kid,sb); } - return retstr; + return; } /// @@ -285,10 +303,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The GlobalFunctionDefinition node. /// String containing C# code for GlobalFunctionDefinition gf. - private string GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf) + private void GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf, StringBuilder sb) { - string retstr = String.Empty; - // we need to separate the argument declaration list from other kids List argumentDeclarationListKids = new List(); List remainingKids = new List(); @@ -299,18 +315,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools else remainingKids.Add(kid); - retstr += GenerateIndented(String.Format("{0} {1}(", gf.ReturnType, CheckName(gf.Name)), gf); + GenerateIndented(String.Format("{0} {1}(", gf.ReturnType, CheckName(gf.Name)), gf, sb); // print the state arguments, if any foreach (SYMBOL kid in argumentDeclarationListKids) - retstr += GenerateArgumentDeclarationList((ArgumentDeclarationList) kid); + GenerateArgumentDeclarationList((ArgumentDeclarationList) kid, sb); - retstr += GenerateLine(")"); + GenerateLine(")", sb); foreach (SYMBOL kid in remainingKids) - retstr += GenerateNode(gf, kid); - - return retstr; + GenerateNodeToSB(gf, kid,sb); } /// @@ -318,18 +332,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The GlobalVariableDeclaration node. /// String containing C# code for GlobalVariableDeclaration gv. - private string GenerateGlobalVariableDeclaration(GlobalVariableDeclaration gv) + private void GenerateGlobalVariableDeclaration(GlobalVariableDeclaration gv, StringBuilder sb) { - string retstr = String.Empty; - foreach (SYMBOL s in gv.kids) { - retstr += Indent(); - retstr += GenerateNode(gv, s); - retstr += GenerateLine(";"); + Indent(sb); + GenerateNodeToSB(gv, s ,sb); + GenerateLine(";", sb); } - - return retstr; } /// @@ -337,15 +347,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The State node. /// String containing C# code for State s. - private string GenerateState(State s) + private void GenerateState(State s, StringBuilder sb) { - string retstr = String.Empty; - foreach (SYMBOL kid in s.kids) if (kid is StateEvent) - retstr += GenerateStateEvent((StateEvent) kid, s.Name); - - return retstr; + GenerateStateEvent((StateEvent) kid, s.Name, sb); } /// @@ -354,10 +360,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// The StateEvent node. /// The name of the parent state. /// String containing C# code for StateEvent se. - private string GenerateStateEvent(StateEvent se, string parentStateName) + private void GenerateStateEvent(StateEvent se, string parentStateName, StringBuilder sb) { - string retstr = String.Empty; - // we need to separate the argument declaration list from other kids List argumentDeclarationListKids = new List(); List remainingKids = new List(); @@ -369,18 +373,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools remainingKids.Add(kid); // "state" (function) declaration - retstr += GenerateIndented(String.Format("public void {0}_event_{1}(", parentStateName, se.Name), se); + GenerateIndented(String.Format("public void {0}_event_{1}(", parentStateName, se.Name), se , sb); // print the state arguments, if any foreach (SYMBOL kid in argumentDeclarationListKids) - retstr += GenerateArgumentDeclarationList((ArgumentDeclarationList) kid); + GenerateArgumentDeclarationList((ArgumentDeclarationList) kid, sb); - retstr += GenerateLine(")"); + GenerateLine(")", sb); foreach (SYMBOL kid in remainingKids) - retstr += GenerateNode(se, kid); - - return retstr; + GenerateNodeToSB(se, kid, sb); } /// @@ -388,20 +390,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ArgumentDeclarationList node. /// String containing C# code for ArgumentDeclarationList adl. - private string GenerateArgumentDeclarationList(ArgumentDeclarationList adl) + private void GenerateArgumentDeclarationList(ArgumentDeclarationList adl, StringBuilder sb) { - string retstr = String.Empty; - int comma = adl.kids.Count - 1; // tells us whether to print a comma foreach (Declaration d in adl.kids) { - retstr += Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); + Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d, sb); if (0 < comma--) - retstr += Generate(", "); + Generate(", ", sb); } - - return retstr; } /// @@ -409,20 +407,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ArgumentList node. /// String containing C# code for ArgumentList al. - private string GenerateArgumentList(ArgumentList al) + private void GenerateArgumentList(ArgumentList al, StringBuilder sb) { - string retstr = String.Empty; - int comma = al.kids.Count - 1; // tells us whether to print a comma foreach (SYMBOL s in al.kids) { - retstr += GenerateNode(al, s); + GenerateNodeToSB(al, s, sb); if (0 < comma--) - retstr += Generate(", "); + Generate(", ", sb); } - - return retstr; } /// @@ -430,33 +424,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The CompoundStatement node. /// String containing C# code for CompoundStatement cs. - private string GenerateCompoundStatement(SYMBOL previousSymbol, CompoundStatement cs) + private void GenerateCompoundStatement(SYMBOL previousSymbol, CompoundStatement cs, StringBuilder sb) { - string retstr = String.Empty; - // opening brace - retstr += GenerateIndentedLine("{"); + GenerateIndentedLine("{", sb); m_braceCount++; if (m_insertCoopTerminationChecks) { // We have to check in event functions as well because the user can manually call these. - if (previousSymbol is GlobalFunctionDefinition - || previousSymbol is WhileStatement - || previousSymbol is DoWhileStatement + if (previousSymbol is GlobalFunctionDefinition + || previousSymbol is WhileStatement + || previousSymbol is DoWhileStatement || previousSymbol is ForLoop || previousSymbol is StateEvent) - retstr += GenerateIndentedLine(m_coopTerminationCheck); + GenerateIndentedLine(m_coopTerminationCheck, sb); } foreach (SYMBOL kid in cs.kids) - retstr += GenerateNode(cs, kid); + GenerateNodeToSB(cs, kid, sb); // closing brace m_braceCount--; - retstr += GenerateIndentedLine("}"); - - return retstr; + GenerateIndentedLine("}", sb); } /// @@ -464,9 +454,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The Declaration node. /// String containing C# code for Declaration d. - private string GenerateDeclaration(Declaration d) + private void GenerateDeclaration(Declaration d, StringBuilder sb) { - return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); + Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d, sb); } /// @@ -474,7 +464,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The Statement node. /// String containing C# code for Statement s. - private string GenerateStatement(SYMBOL previousSymbol, Statement s) + private void GenerateStatement(SYMBOL previousSymbol, Statement s, StringBuilder sb) { string retstr = String.Empty; bool printSemicolon = true; @@ -484,20 +474,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { // A non-braced single line do while structure cannot contain multiple statements. // So to insert the termination check we change this to a braced control structure instead. - if (previousSymbol is WhileStatement - || previousSymbol is DoWhileStatement + if (previousSymbol is WhileStatement + || previousSymbol is DoWhileStatement || previousSymbol is ForLoop) { transformToBlock = true; // FIXME: This will be wrongly indented because the previous for/while/dowhile will have already indented. - retstr += GenerateIndentedLine("{"); + GenerateIndentedLine("{", sb); - retstr += GenerateIndentedLine(m_coopTerminationCheck); + GenerateIndentedLine(m_coopTerminationCheck, sb); } } - retstr += Indent(); + Indent(sb); if (0 < s.kids.Count) { @@ -508,19 +498,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // (MONO) error. if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count)) foreach (SYMBOL kid in s.kids) - retstr += GenerateNode(s, kid); + GenerateNodeToSB(s, kid, sb); } if (printSemicolon) - retstr += GenerateLine(";"); + GenerateLine(";", sb); if (transformToBlock) { // FIXME: This will be wrongly indented because the for/while/dowhile is currently handling the unindent - retstr += GenerateIndentedLine("}"); + GenerateIndentedLine("}", sb); } - - return retstr; } /// @@ -528,25 +516,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The Assignment node. /// String containing C# code for Assignment a. - private string GenerateAssignment(Assignment a) + private void GenerateAssignment(Assignment a, StringBuilder sb) { - string retstr = String.Empty; - List identifiers = new List(); checkForMultipleAssignments(identifiers, a); - retstr += GenerateNode(a, (SYMBOL) a.kids.Pop()); - retstr += Generate(String.Format(" {0} ", a.AssignmentType), a); + GenerateNodeToSB(a, (SYMBOL) a.kids.Pop(), sb); + Generate(String.Format(" {0} ", a.AssignmentType), a, sb); foreach (SYMBOL kid in a.kids) - retstr += GenerateNode(a, kid); - - return retstr; + GenerateNodeToSB(a, kid, sb); } // This code checks for LSL of the following forms, and generates a // warning if it finds them. // - // list l = [ "foo" ]; + // list l = [ "foo" ]; // l = (l=[]) + l + ["bar"]; // (produces l=["foo","bar"] in SL but l=["bar"] in OS) // @@ -604,16 +588,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ReturnStatement node. /// String containing C# code for ReturnStatement rs. - private string GenerateReturnStatement(ReturnStatement rs) + private void GenerateReturnStatement(ReturnStatement rs, StringBuilder sb) { - string retstr = String.Empty; - - retstr += Generate("return ", rs); + Generate("return ", rs, sb); foreach (SYMBOL kid in rs.kids) - retstr += GenerateNode(rs, kid); - - return retstr; + GenerateNodeToSB(rs, kid, sb); } /// @@ -621,7 +601,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The JumpLabel node. /// String containing C# code for JumpLabel jl. - private string GenerateJumpLabel(JumpLabel jl) + private void GenerateJumpLabel(JumpLabel jl, StringBuilder sb) { string labelStatement; @@ -630,7 +610,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools else labelStatement = "NoOp();"; - return GenerateLine(String.Format("{0}: {1}", CheckName(jl.LabelName), labelStatement), jl); + GenerateLine(String.Format("{0}: {1}", CheckName(jl.LabelName), labelStatement), jl, sb); } /// @@ -638,9 +618,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The JumpStatement node. /// String containing C# code for JumpStatement js. - private string GenerateJumpStatement(JumpStatement js) + private void GenerateJumpStatement(JumpStatement js, StringBuilder sb) { - return Generate(String.Format("goto {0}", CheckName(js.TargetName)), js); + Generate(String.Format("goto {0}", CheckName(js.TargetName)), js, sb); } /// @@ -648,32 +628,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The IfStatement node. /// String containing C# code for IfStatement ifs. - private string GenerateIfStatement(IfStatement ifs) + private void GenerateIfStatement(IfStatement ifs, StringBuilder sb) { - string retstr = String.Empty; - - retstr += GenerateIndented("if (", ifs); - retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); - retstr += GenerateLine(")"); + GenerateIndented("if (", ifs, sb); + GenerateNodeToSB(ifs, (SYMBOL) ifs.kids.Pop(), sb); + GenerateLine(")", sb); // CompoundStatement handles indentation itself but we need to do it // otherwise. bool indentHere = ifs.kids.Top is Statement; if (indentHere) m_braceCount++; - retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); + GenerateNodeToSB(ifs, (SYMBOL) ifs.kids.Pop(), sb); if (indentHere) m_braceCount--; if (0 < ifs.kids.Count) // do it again for an else { - retstr += GenerateIndentedLine("else", ifs); + GenerateIndentedLine("else", ifs, sb); indentHere = ifs.kids.Top is Statement; if (indentHere) m_braceCount++; - retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); + GenerateNodeToSB(ifs, (SYMBOL) ifs.kids.Pop(), sb); if (indentHere) m_braceCount--; } - - return retstr; } /// @@ -681,9 +657,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The StateChange node. /// String containing C# code for StateChange sc. - private string GenerateStateChange(StateChange sc) + private void GenerateStateChange(StateChange sc, StringBuilder sb) { - return Generate(String.Format("state(\"{0}\")", sc.NewState), sc); + Generate(String.Format("state(\"{0}\")", sc.NewState), sc, sb); } /// @@ -691,22 +667,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The WhileStatement node. /// String containing C# code for WhileStatement ws. - private string GenerateWhileStatement(WhileStatement ws) + private void GenerateWhileStatement(WhileStatement ws, StringBuilder sb) { - string retstr = String.Empty; - - retstr += GenerateIndented("while (", ws); - retstr += GenerateNode(ws, (SYMBOL) ws.kids.Pop()); - retstr += GenerateLine(")"); + GenerateIndented("while (", ws, sb); + GenerateNodeToSB(ws, (SYMBOL) ws.kids.Pop(), sb); + GenerateLine(")", sb); // CompoundStatement handles indentation itself but we need to do it // otherwise. bool indentHere = ws.kids.Top is Statement; if (indentHere) m_braceCount++; - retstr += GenerateNode(ws, (SYMBOL) ws.kids.Pop()); + GenerateNodeToSB(ws, (SYMBOL) ws.kids.Pop(), sb); if (indentHere) m_braceCount--; - - return retstr; } /// @@ -714,24 +686,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The DoWhileStatement node. /// String containing C# code for DoWhileStatement dws. - private string GenerateDoWhileStatement(DoWhileStatement dws) + private void GenerateDoWhileStatement(DoWhileStatement dws, StringBuilder sb) { - string retstr = String.Empty; - - retstr += GenerateIndentedLine("do", dws); + GenerateIndentedLine("do", dws, sb); // CompoundStatement handles indentation itself but we need to do it // otherwise. bool indentHere = dws.kids.Top is Statement; if (indentHere) m_braceCount++; - retstr += GenerateNode(dws, (SYMBOL) dws.kids.Pop()); + GenerateNodeToSB(dws, (SYMBOL) dws.kids.Pop(), sb); if (indentHere) m_braceCount--; - retstr += GenerateIndented("while (", dws); - retstr += GenerateNode(dws, (SYMBOL) dws.kids.Pop()); - retstr += GenerateLine(");"); - - return retstr; + GenerateIndented("while (", dws ,sb); + GenerateNodeToSB(dws, (SYMBOL) dws.kids.Pop(), sb); + GenerateLine(");", sb); } /// @@ -739,11 +707,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ForLoop node. /// String containing C# code for ForLoop fl. - private string GenerateForLoop(ForLoop fl) + private void GenerateForLoop(ForLoop fl, StringBuilder sb) { - string retstr = String.Empty; - - retstr += GenerateIndented("for (", fl); + GenerateIndented("for (", fl, sb); // It's possible that we don't have an assignment, in which case // the child will be null and we only print the semicolon. @@ -752,26 +718,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools ForLoopStatement s = (ForLoopStatement) fl.kids.Pop(); if (null != s) { - retstr += GenerateForLoopStatement(s); + GenerateForLoopStatement(s, sb); } - retstr += Generate("; "); + Generate("; ", sb); // for (x = 0; x < 10; x++) // ^^^^^^ - retstr += GenerateNode(fl, (SYMBOL) fl.kids.Pop()); - retstr += Generate("; "); + GenerateNodeToSB(fl, (SYMBOL) fl.kids.Pop(), sb); + Generate("; ", sb); // for (x = 0; x < 10; x++) // ^^^ - retstr += GenerateForLoopStatement((ForLoopStatement) fl.kids.Pop()); - retstr += GenerateLine(")"); + GenerateForLoopStatement((ForLoopStatement) fl.kids.Pop(), sb); + GenerateLine(")", sb); // CompoundStatement handles indentation itself but we need to do it // otherwise. bool indentHere = fl.kids.Top is Statement; if (indentHere) m_braceCount++; - retstr += GenerateNode(fl, (SYMBOL) fl.kids.Pop()); + GenerateNodeToSB(fl, (SYMBOL) fl.kids.Pop(), sb); if (indentHere) m_braceCount--; - - return retstr; } /// @@ -779,10 +743,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ForLoopStatement node. /// String containing C# code for ForLoopStatement fls. - private string GenerateForLoopStatement(ForLoopStatement fls) + private void GenerateForLoopStatement(ForLoopStatement fls, StringBuilder sb) { - string retstr = String.Empty; - int comma = fls.kids.Count - 1; // tells us whether to print a comma // It's possible that all we have is an empty Ident, for example: @@ -791,12 +753,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // // Which is illegal in C# (MONO). We'll skip it. if (fls.kids.Top is IdentExpression && 1 == fls.kids.Count) - return retstr; + return; for (int i = 0; i < fls.kids.Count; i++) { SYMBOL s = (SYMBOL)fls.kids[i]; - + // Statements surrounded by parentheses in for loops // // e.g. for ((i = 0), (j = 7); (i < 10); (++i)) @@ -812,13 +774,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // like it would be considerably more complicated to handle). while (s is ParenthesisExpression) s = (SYMBOL)s.kids.Pop(); - - retstr += GenerateNode(fls, s); + + GenerateNodeToSB(fls, s, sb); if (0 < comma--) - retstr += Generate(", "); + Generate(", ", sb); } - - return retstr; } /// @@ -826,31 +786,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The BinaryExpression node. /// String containing C# code for BinaryExpression be. - private string GenerateBinaryExpression(BinaryExpression be) + private void GenerateBinaryExpression(BinaryExpression be, StringBuilder sb) { - string retstr = String.Empty; - if (be.ExpressionSymbol.Equals("&&") || be.ExpressionSymbol.Equals("||")) { // special case handling for logical and/or, see Mantis 3174 - retstr += "((bool)("; - retstr += GenerateNode(be, (SYMBOL)be.kids.Pop()); - retstr += "))"; - retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be); - retstr += "((bool)("; + sb.Append("((bool)("); + GenerateNodeToSB(be, (SYMBOL)be.kids.Pop(), sb); + sb.Append("))"); + Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be, sb); + sb.Append("((bool)("); foreach (SYMBOL kid in be.kids) - retstr += GenerateNode(be, kid); - retstr += "))"; + GenerateNodeToSB(be, kid, sb); + sb.Append("))"); } else { - retstr += GenerateNode(be, (SYMBOL)be.kids.Pop()); - retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); + GenerateNodeToSB(be, (SYMBOL)be.kids.Pop(), sb); + Generate(String.Format(" {0} ", be.ExpressionSymbol), be, sb); foreach (SYMBOL kid in be.kids) - retstr += GenerateNode(be, kid); + GenerateNodeToSB(be, kid, sb); } - - return retstr; } /// @@ -858,14 +814,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The UnaryExpression node. /// String containing C# code for UnaryExpression ue. - private string GenerateUnaryExpression(UnaryExpression ue) + private void GenerateUnaryExpression(UnaryExpression ue, StringBuilder sb) { - string retstr = String.Empty; - - retstr += Generate(ue.UnarySymbol, ue); - retstr += GenerateNode(ue, (SYMBOL) ue.kids.Pop()); - - return retstr; + Generate(ue.UnarySymbol, ue, sb); + GenerateNodeToSB(ue, (SYMBOL) ue.kids.Pop(), sb); } /// @@ -873,16 +825,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ParenthesisExpression node. /// String containing C# code for ParenthesisExpression pe. - private string GenerateParenthesisExpression(ParenthesisExpression pe) + private void GenerateParenthesisExpression(ParenthesisExpression pe, StringBuilder sb) { string retstr = String.Empty; - retstr += Generate("("); + Generate("(", sb); foreach (SYMBOL kid in pe.kids) - retstr += GenerateNode(pe, kid); - retstr += Generate(")"); - - return retstr; + GenerateNodeToSB(pe, kid, sb); + Generate(")", sb); } /// @@ -890,19 +840,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The IncrementDecrementExpression node. /// String containing C# code for IncrementDecrementExpression ide. - private string GenerateIncrementDecrementExpression(IncrementDecrementExpression ide) + private void GenerateIncrementDecrementExpression(IncrementDecrementExpression ide, StringBuilder sb) { - string retstr = String.Empty; - if (0 < ide.kids.Count) { IdentDotExpression dot = (IdentDotExpression) ide.kids.Top; - retstr += Generate(String.Format("{0}", ide.PostOperation ? CheckName(dot.Name) + "." + dot.Member + ide.Operation : ide.Operation + CheckName(dot.Name) + "." + dot.Member), ide); + Generate(String.Format("{0}", ide.PostOperation ? CheckName(dot.Name) + "." + dot.Member + ide.Operation : ide.Operation + CheckName(dot.Name) + "." + dot.Member), ide, sb); } else - retstr += Generate(String.Format("{0}", ide.PostOperation ? CheckName(ide.Name) + ide.Operation : ide.Operation + CheckName(ide.Name)), ide); - - return retstr; + Generate(String.Format("{0}", ide.PostOperation ? CheckName(ide.Name) + ide.Operation : ide.Operation + CheckName(ide.Name)), ide, sb); } /// @@ -910,16 +856,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The TypecastExpression node. /// String containing C# code for TypecastExpression te. - private string GenerateTypecastExpression(TypecastExpression te) + private void GenerateTypecastExpression(TypecastExpression te, StringBuilder sb) { - string retstr = String.Empty; - // we wrap all typecasted statements in parentheses - retstr += Generate(String.Format("({0}) (", te.TypecastType), te); - retstr += GenerateNode(te, (SYMBOL) te.kids.Pop()); - retstr += Generate(")"); - - return retstr; + Generate(String.Format("({0}) (", te.TypecastType), te, sb); + GenerateNodeToSB(te, (SYMBOL) te.kids.Pop(), sb); + Generate(")", sb); } /// @@ -928,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// The symbol name /// The Symbol node. /// String containing C# code for identifier reference. - private string GenerateIdentifier(string id, SYMBOL s) + private void GenerateIdentifier(string id, SYMBOL s, StringBuilder sb) { if (m_comms != null) { @@ -949,12 +891,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools else if (value is OpenMetaverse.Quaternion) retval = String.Format("new LSL_Types.Quaternion(\"{0}\")",((OpenMetaverse.Quaternion)value).ToString()); else retval = id; - - return Generate(retval, s); + + Generate(retval, s, sb); + return; } } - return Generate(CheckName(id), s); + Generate(CheckName(id), s, sb); + return; } /// @@ -962,35 +906,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The FunctionCall node. /// String containing C# code for FunctionCall fc. - private string GenerateFunctionCall(FunctionCall fc) + private void GenerateFunctionCall(FunctionCall fc, StringBuilder sb) { - string retstr = String.Empty; - string modinvoke = null; if (m_comms != null) modinvoke = m_comms.LookupModInvocation(fc.Id); - + if (modinvoke != null) { if (fc.kids[0] is ArgumentList) { if ((fc.kids[0] as ArgumentList).kids.Count == 0) - retstr += Generate(String.Format("{0}(\"{1}\"",modinvoke,fc.Id), fc); + Generate(String.Format("{0}(\"{1}\"",modinvoke,fc.Id), fc, sb); else - retstr += Generate(String.Format("{0}(\"{1}\",",modinvoke,fc.Id), fc); + Generate(String.Format("{0}(\"{1}\",",modinvoke,fc.Id), fc, sb); } } else { - retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc); + Generate(String.Format("{0}(", CheckName(fc.Id)), fc, sb); } - - foreach (SYMBOL kid in fc.kids) - retstr += GenerateNode(fc, kid); - retstr += Generate(")"); + foreach (SYMBOL kid in fc.kids) + GenerateNodeToSB(fc, kid, sb); - return retstr; + Generate(")", sb); } /// @@ -998,10 +938,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The Constant node. /// String containing C# code for Constant c. - private string GenerateConstant(Constant c) + private void GenerateConstant(Constant c, StringBuilder sb) { - string retstr = String.Empty; - // Supprt LSL's weird acceptance of floats with no trailing digits // after the period. Turn float x = 10.; into float x = 10.0; if ("LSL_Types.LSLFloat" == c.Type) @@ -1020,9 +958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools c.Value = "new LSL_Types.LSLString(\""+c.Value+"\")"; } - retstr += Generate(c.Value, c); - - return retstr; + Generate(c.Value, c, sb); } /// @@ -1030,19 +966,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The VectorConstant node. /// String containing C# code for VectorConstant vc. - private string GenerateVectorConstant(VectorConstant vc) + private void GenerateVectorConstant(VectorConstant vc, StringBuilder sb) { - string retstr = String.Empty; - - retstr += Generate(String.Format("new {0}(", vc.Type), vc); - retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); - retstr += Generate(", "); - retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); - retstr += Generate(", "); - retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); - retstr += Generate(")"); - - return retstr; + Generate(String.Format("new {0}(", vc.Type), vc, sb); + GenerateNodeToSB(vc, (SYMBOL) vc.kids.Pop(), sb); + Generate(", ", sb); + GenerateNodeToSB(vc, (SYMBOL) vc.kids.Pop(), sb); + Generate(", ", sb); + GenerateNodeToSB(vc, (SYMBOL) vc.kids.Pop(), sb); + Generate(")", sb); } /// @@ -1050,21 +982,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The RotationConstant node. /// String containing C# code for RotationConstant rc. - private string GenerateRotationConstant(RotationConstant rc) + private void GenerateRotationConstant(RotationConstant rc, StringBuilder sb) { - string retstr = String.Empty; - - retstr += Generate(String.Format("new {0}(", rc.Type), rc); - retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); - retstr += Generate(", "); - retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); - retstr += Generate(", "); - retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); - retstr += Generate(", "); - retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); - retstr += Generate(")"); - - return retstr; + Generate(String.Format("new {0}(", rc.Type), rc, sb); + GenerateNodeToSB(rc, (SYMBOL) rc.kids.Pop(), sb); + Generate(", ", sb); + GenerateNodeToSB(rc, (SYMBOL) rc.kids.Pop(), sb); + Generate(", ", sb); + GenerateNodeToSB(rc, (SYMBOL) rc.kids.Pop(), sb); + Generate(", ", sb); + GenerateNodeToSB(rc, (SYMBOL) rc.kids.Pop(), sb); + Generate(")", sb); } /// @@ -1072,27 +1000,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// The ListConstant node. /// String containing C# code for ListConstant lc. - private string GenerateListConstant(ListConstant lc) + private void GenerateListConstant(ListConstant lc, StringBuilder sb) { - string retstr = String.Empty; - - retstr += Generate(String.Format("new {0}(", lc.Type), lc); + Generate(String.Format("new {0}(", lc.Type), lc, sb); foreach (SYMBOL kid in lc.kids) - retstr += GenerateNode(lc, kid); - - retstr += Generate(")"); + GenerateNodeToSB(lc, kid, sb); - return retstr; + Generate(")", sb); } /// /// Prints a newline. /// /// A newline. - private string GenerateLine() + private void GenerateLine(StringBuilder sb) { - return GenerateLine(""); + sb.Append("\n"); + m_CSharpLine++; + m_CSharpCol = 1; } /// @@ -1100,9 +1026,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// String of text to print. /// String s followed by newline. - private string GenerateLine(string s) + private void GenerateLine(string s, StringBuilder sb) { - return GenerateLine(s, null); + sb.Append(s); + sb.Append("\n"); + m_CSharpLine++; + m_CSharpCol = 1; } /// @@ -1112,14 +1041,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// Symbol being generated to extract original line /// number and column from. /// String s followed by newline. - private string GenerateLine(string s, SYMBOL sym) + private void GenerateLine(string s, SYMBOL sym, StringBuilder sb) { - string retstr = Generate(s, sym) + "\n"; + Generate(s, sym, sb); + sb.Append("\n"); m_CSharpLine++; m_CSharpCol = 1; - - return retstr; } /// @@ -1127,9 +1055,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// String of text to print. /// String s. - private string Generate(string s) + private void Generate(string s, StringBuilder sb) { - return Generate(s, null); + sb.Append(s); + m_CSharpCol += s.Length; } /// @@ -1139,14 +1068,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// Symbol being generated to extract original line /// number and column from. /// String s. - private string Generate(string s, SYMBOL sym) + private void Generate(string s, SYMBOL sym, StringBuilder sb) { + sb.Append(s); if (null != sym) m_positionMap.Add(new KeyValuePair(m_CSharpLine, m_CSharpCol), new KeyValuePair(sym.Line, sym.Position)); m_CSharpCol += s.Length; - - return s; } /// @@ -1154,9 +1082,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// String of text to print. /// Properly indented string s followed by newline. - private string GenerateIndentedLine(string s) + private void GenerateIndentedLine(string s, StringBuilder sb) { - return GenerateIndentedLine(s, null); + GenerateIndentedLine(s, null, sb); } /// @@ -1166,14 +1094,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// Symbol being generated to extract original line /// number and column from. /// Properly indented string s followed by newline. - private string GenerateIndentedLine(string s, SYMBOL sym) + private void GenerateIndentedLine(string s, SYMBOL sym, StringBuilder sb) { - string retstr = GenerateIndented(s, sym) + "\n"; - + GenerateIndented(s, sym , sb ); + sb.Append("\n"); m_CSharpLine++; m_CSharpCol = 1; - - return retstr; } /// @@ -1194,34 +1120,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// Symbol being generated to extract original line /// number and column from. /// Properly indented string s. - private string GenerateIndented(string s, SYMBOL sym) + private void GenerateIndented(string s, SYMBOL sym, StringBuilder sb) { - string retstr = Indent() + s; + Indent(sb); + sb.Append(s); if (null != sym) m_positionMap.Add(new KeyValuePair(m_CSharpLine, m_CSharpCol), new KeyValuePair(sym.Line, sym.Position)); m_CSharpCol += s.Length; - - return retstr; } /// /// Prints correct indentation. /// /// Indentation based on brace count. - private string Indent() + private void Indent(StringBuilder sb) { - string retstr = String.Empty; - for (int i = 0; i < m_braceCount; i++) - for (int j = 0; j < m_indentWidth; j++) - { - retstr += " "; - m_CSharpCol++; - } - - return retstr; + { + sb.Append(" "); + m_CSharpCol += 4; + } } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSReservedWords.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSReservedWords.cs index 7a2a4a0..19a248f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSReservedWords.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSReservedWords.cs @@ -84,7 +84,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (word.StartsWith("ll")) return false; char first = word.ToCharArray(0,1)[0]; if (first >= 'A' && first <= 'Z') return false; - + return (reservedWords.BinarySearch(word) >= 0); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index af324bf..89211a5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -79,12 +79,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools private List m_warnings = new List(); - // private object m_syncy = new object(); - - private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); - private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); - - // private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files private static UInt64 scriptCompileCounter = 0; // And a counter public IScriptEngine m_scriptEngine; @@ -119,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { in_startup = false; CheckOrCreateScriptsDirectory(); - + // First time we start? Delete old files if (DeleteScriptsOnStartup) DeleteOldFiles(); @@ -251,23 +245,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } } - ////private ICodeCompiler icc = codeProvider.CreateCompiler(); - //public string CompileFromFile(string LSOFileName) - //{ - // switch (Path.GetExtension(LSOFileName).ToLower()) - // { - // case ".txt": - // case ".lsl": - // Common.ScriptEngineBase.Shared.SendToDebug("Source code is LSL, converting to CS"); - // return CompileFromLSLText(File.ReadAllText(LSOFileName)); - // case ".cs": - // Common.ScriptEngineBase.Shared.SendToDebug("Source code is CS"); - // return CompileFromCSText(File.ReadAllText(LSOFileName)); - // default: - // throw new Exception("Unknown script type."); - // } - //} - public string GetCompilerOutput(string assetID) { return Path.Combine(ScriptEnginesPath, Path.Combine( @@ -310,9 +287,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { // m_log.DebugFormat("[Compiler]: Found existing assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name); - // If we have already read this linemap file, then it will be in our dictionary. + // If we have already read this linemap file, then it will be in our dictionary. // Don't build another copy of the dictionary (saves memory) and certainly - // don't keep reading the same file from disk multiple times. + // don't keep reading the same file from disk multiple times. if (!m_lineMaps.ContainsKey(assembly)) m_lineMaps[assembly] = ReadMapFile(assembly + ".map"); linemap = m_lineMaps[assembly]; @@ -356,14 +333,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools throw new Exception(errtext); } - string compileScript = source; + string compileScript = string.Empty; if (language == enumCompileType.lsl) { // Its LSL, convert it to C# - LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); - compileScript = LSL_Converter.Convert(source); + StringBuilder sb = new StringBuilder(16394); + + LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); + AddCSScriptHeader( + m_scriptEngine.ScriptClassName, + m_scriptEngine.ScriptBaseClassName, + m_scriptEngine.ScriptBaseClassParameters, + sb); + + LSL_Converter.Convert(source,sb); + AddCSScriptTail(sb); + compileScript = sb.ToString(); // copy converter warnings into our warnings. foreach (string warning in LSL_Converter.GetWarnings()) { @@ -371,25 +358,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } linemap = ((CSCodeGenerator)LSL_Converter).PositionMap; - // Write the linemap to a file and save it in our dictionary for next time. + // Write the linemap to a file and save it in our dictionary for next time. m_lineMaps[assembly] = linemap; WriteMapFile(assembly + ".map", linemap); + LSL_Converter.Clear(); } - - switch (language) + else { - case enumCompileType.cs: - case enumCompileType.lsl: - compileScript = CreateCSCompilerScript( - compileScript, - m_scriptEngine.ScriptClassName, - m_scriptEngine.ScriptBaseClassName, - m_scriptEngine.ScriptBaseClassParameters); - break; - case enumCompileType.vb: - compileScript = CreateVBCompilerScript( - compileScript, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName); - break; + switch (language) + { + case enumCompileType.cs: + compileScript = CreateCSCompilerScript( + source, + m_scriptEngine.ScriptClassName, + m_scriptEngine.ScriptBaseClassName, + m_scriptEngine.ScriptBaseClassParameters); + break; + case enumCompileType.vb: + compileScript = CreateVBCompilerScript( + source, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName); + break; + } } assembly = CompileFromDotNetText(compileScript, language, asset, assembly); @@ -419,29 +408,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // return compileScript; // } + public static void AddCSScriptHeader(string className, string baseClassName, ParameterInfo[] constructorParameters, StringBuilder sb) + { + sb.Append(string.Format( +@"using OpenSim.Region.ScriptEngine.Shared; +using System.Collections.Generic; + +namespace SecondLife +{{ + public class {0} : {1} + {{ + public {0}({2}) : base({3}) {{}} +", + className, + baseClassName, + constructorParameters != null + ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.ToString())) + : "", + constructorParameters != null + ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.Name)) + : "" + )); + } + + public static void AddCSScriptTail(StringBuilder sb) + { + sb.Append(string.Format(" }}\n}}\n")); + } + public static string CreateCSCompilerScript( string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) { - compileScript = string.Format( -@"using OpenSim.Region.ScriptEngine.Shared; + compileScript = string.Format( +@"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic; -namespace SecondLife -{{ - public class {0} : {1} +namespace SecondLife +{{ + public class {0} : {1} {{ public {0}({2}) : base({3}) {{}} {4} }} }}", className, - baseClassName, - constructorParameters != null - ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.ToString())) - : "", - constructorParameters != null - ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.Name)) - : "", + baseClassName, + constructorParameters != null + ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.ToString())) + : "", + constructorParameters != null + ? string.Join(", ", Array.ConvertAll(constructorParameters, pi => pi.Name)) + : "", compileScript); return compileScript; @@ -468,7 +485,7 @@ namespace SecondLife internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) { // m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script); - + string ext = "." + lang.ToString(); // Output assembly name @@ -511,8 +528,6 @@ namespace SecondLife // Do actual compile CompilerParameters parameters = new CompilerParameters(); - parameters.IncludeDebugInformation = true; - string rootPath = AppDomain.CurrentDomain.BaseDirectory; parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, @@ -524,7 +539,7 @@ namespace SecondLife if (m_scriptEngine.ScriptReferencedAssemblies != null) Array.ForEach( - m_scriptEngine.ScriptReferencedAssemblies, + m_scriptEngine.ScriptReferencedAssemblies, a => parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, a))); parameters.GenerateExecutable = false; @@ -532,62 +547,62 @@ namespace SecondLife parameters.IncludeDebugInformation = CompileWithDebugInformation; //parameters.WarningLevel = 1; // Should be 4? parameters.TreatWarningsAsErrors = false; + parameters.GenerateInMemory = false; + +// this seems to cause issues on some windows servers +// parameters.TempFiles = new TempFileCollection(Path.Combine(ScriptEnginesPath, +// m_scriptEngine.World.RegionInfo.RegionID.ToString()), CompileWithDebugInformation); CompilerResults results; + + CodeDomProvider provider; switch (lang) { case enumCompileType.vb: - results = VBcodeProvider.CompileAssemblyFromSource( - parameters, Script); + provider = CodeDomProvider.CreateProvider("VisualBasic"); break; case enumCompileType.cs: case enumCompileType.lsl: - bool complete = false; - bool retried = false; - do - { - lock (CScodeProvider) - { - results = CScodeProvider.CompileAssemblyFromSource( - parameters, Script); - } - - // Deal with an occasional segv in the compiler. - // Rarely, if ever, occurs twice in succession. - // Line # == 0 and no file name are indications that - // this is a native stack trace rather than a normal - // error log. - if (results.Errors.Count > 0) - { - if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) && - results.Errors[0].Line == 0) - { - // System.Console.WriteLine("retrying failed compilation"); - retried = true; - } - else - { - complete = true; - } - } - else - { - complete = true; - } - } while (!complete); + provider = CodeDomProvider.CreateProvider("CSharp"); break; default: throw new Exception("Compiler is not able to recongnize " + "language type \"" + lang.ToString() + "\""); } -// foreach (Type type in results.CompiledAssembly.GetTypes()) -// { -// foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) -// { -// m_log.DebugFormat("[COMPILER]: {0}.{1}", type.FullName, method.Name); -// } -// } + if(provider == null) + throw new Exception("Compiler failed to load "); + + bool complete = false; + bool retried = false; + + do + { + results = provider.CompileAssemblyFromSource( + parameters, Script); + // Deal with an occasional segv in the compiler. + // Rarely, if ever, occurs twice in succession. + // Line # == 0 and no file name are indications that + // this is a native stack trace rather than a normal + // error log. + if (results.Errors.Count > 0) + { + if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) && + results.Errors[0].Line == 0) + { + // System.Console.WriteLine("retrying failed compilation"); + retried = true; + } + else + { + complete = true; + } + } + else + { + complete = true; + } + } while (!complete); // // WARNINGS AND ERRORS @@ -628,13 +643,15 @@ namespace SecondLife } } + provider.Dispose(); + if (hadErrors) { throw new Exception(errtext); } // On today's highly asynchronous systems, the result of - // the compile may not be immediately apparent. Wait a + // the compile may not be immediately apparent. Wait a // reasonable amount of time before giving up on it. if (!File.Exists(assembly)) @@ -785,15 +802,16 @@ namespace SecondLife private static void WriteMapFile(string filename, Dictionary, KeyValuePair> linemap) { - string mapstring = String.Empty; + StringBuilder mapbuilder = new StringBuilder(1024); + foreach (KeyValuePair, KeyValuePair> kvp in linemap) { KeyValuePair k = kvp.Key; KeyValuePair v = kvp.Value; - mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); + mapbuilder.Append(String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value)); } - Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring); + Byte[] mapbytes = Encoding.ASCII.GetBytes(mapbuilder.ToString()); using (FileStream mfs = File.Create(filename)) mfs.Write(mapbytes, 0, mapbytes.Length); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs index 84e8ab2..076caad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs @@ -27,12 +27,15 @@ */ using System; +using System.Text; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { public interface ICodeConverter { string Convert(string script); + void Convert(string script, StringBuilder sb); string[] GetWarnings(); + void Clear(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs index 0fb3574..0585f8b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools Constant rca = new Constant(p, "float", "0.0"); Constant rcb = new Constant(p, "float", "0.0"); Constant rcc = new Constant(p, "float", "0.0"); - Constant rcd = new Constant(p, "float", "0.0"); + Constant rcd = new Constant(p, "float", "1.0"); ConstantExpression rcea = new ConstantExpression(p, rca); ConstantExpression rceb = new ConstantExpression(p, rcb); ConstantExpression rcec = new ConstantExpression(p, rcc); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs index 0aece99..304cd81 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.CodeTools")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index b92f3a3..a9f3283 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs @@ -1388,7 +1388,7 @@ default "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3));" + "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" + "\n LSL_Types.Vector3 w = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.5));" + - "\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" + + "\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(1.0));" + "\n LSL_Types.Quaternion u = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.8), new LSL_Types.LSLFloat(0.7), new LSL_Types.LSLFloat(0.6), llSomeFunc());" + "\n LSL_Types.LSLString k = new LSL_Types.LSLString(\"\");" + "\n LSL_Types.LSLString n = new LSL_Types.LSLString(\"ping\");" + diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index b476e32..12ba4de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -37,6 +37,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests { + /// /// Tests the LSL compiler. Among other things, test that error messages /// generated by the C# compiler can be mapped to prper lines/columns in @@ -80,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests m_resolveEventHandler = new ResolveEventHandler(AssemblyResolver.OnAssemblyResolve); System.AppDomain.CurrentDomain.AssemblyResolve += m_resolveEventHandler; - + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); @@ -111,7 +112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests CSCodeGenerator cg = new CSCodeGenerator(); string output = cg.Convert(input); - output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); // System.Console.WriteLine(output); positionMap = cg.PositionMap; @@ -132,7 +133,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests return compilerResults; } - +/* test too depedent on counting lines and columns maping code generation changes +erros position is better tested on viewers /// /// Test that line number errors are resolved as expected when preceding code contains a jump. /// @@ -152,13 +154,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests @l; i = 1; } -}", out positionMap); +}", out positionMap); Assert.AreEqual( new KeyValuePair(7, 9), positionMap[new KeyValuePair(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]); } + /// /// Test the C# compiler error message can be mapped to the correct /// line/column in the LSL source when an undeclared variable is used. @@ -183,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests new KeyValuePair(5, 21), positionMap[new KeyValuePair(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]); } - +*/ /// /// Test that a string can be cast to string and another string /// concatenated. diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs index 67ce10a..220ec72 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("changed"); - } + } [Test] public void TestCollisionEvent() @@ -159,7 +159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("collision"); - } + } [Test] public void TestCollisionStartEvent() @@ -168,7 +168,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("collision_start"); - } + } [Test] public void TestCollisionEndEvent() @@ -177,7 +177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("collision_end"); - } + } [Test] public void TestOnRezEvent() @@ -186,7 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("on_rez"); - } + } [Test] public void TestRunTimePermissionsEvent() @@ -195,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("run_time_permissions"); - } + } [Test] public void TestSensorEvent() @@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("sensor"); - } + } [Test] public void TestTouchEvent() @@ -213,7 +213,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("touch"); - } + } [Test] public void TestTouchStartEvent() @@ -222,7 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("touch_start"); - } + } [Test] public void TestTouchEndEvent() @@ -231,7 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // TestHelpers.EnableLogging(); TestIntArgEvent("touch_end"); - } + } [Test] public void TestLandCollisionEvent() @@ -351,8 +351,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } Assert.That( - gotException, - Is.EqualTo(expectException), + gotException, + Is.EqualTo(expectException), "Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a"); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs index f87f446..66210b7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs @@ -379,7 +379,7 @@ public override int yynum { get { return 96; }} public FLOAT_CONSTANT(Lexer yyl):base(yyl) {}} //%|LSLTokens public class yyLSLTokens : YyLexer { - public yyLSLTokens(ErrorHandler eh):base(eh) { arr = new int[] { + public yyLSLTokens(ErrorHandler eh):base(eh) { arr = new int[] { 101,4,6,52,0, 46,0,53,0,6, 102,4,16,117,0, @@ -19717,13 +19717,13 @@ public override TOKEN OldAction(Lexer yym,ref string yytext,int action, ref bool break; case 1063: ; break; - case 1076: ; + case 1076: ; break; case 1032: { yym.yy_begin("YYINITIAL"); ((LSLTokens)yym).yytext = ((LSLTokens)yym).str; ((LSLTokens)yym).str = String.Empty; return new STRING_CONSTANT(yym); } break; case 1067: ; break; - case 1072: ; + case 1072: ; break; case 1003: { ((LSLTokens)yym).str += "\\\""; } break; diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs index 5fef83c..e4b5891 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs @@ -886,1493 +886,1493 @@ public IncrementDecrementExpression(Parser yyp):base(yyp){}} public class LSLProgramRoot_1 : LSLProgramRoot { public LSLProgramRoot_1(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((States)(yyq.StackAt(0).m_value)) - ){}} + ((GlobalDefinitions)(yyq.StackAt(1).m_value)) + , + ((States)(yyq.StackAt(0).m_value)) + ){}} public class LSLProgramRoot_2 : LSLProgramRoot { public LSLProgramRoot_2(Parser yyq):base(yyq, - ((States)(yyq.StackAt(0).m_value)) - ){}} + ((States)(yyq.StackAt(0).m_value)) + ){}} public class GlobalDefinitions_1 : GlobalDefinitions { public GlobalDefinitions_1(Parser yyq):base(yyq, - ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class GlobalDefinitions_2 : GlobalDefinitions { public GlobalDefinitions_2(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((GlobalDefinitions)(yyq.StackAt(1).m_value)) + , + ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class GlobalDefinitions_3 : GlobalDefinitions { public GlobalDefinitions_3(Parser yyq):base(yyq, - ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) - ){}} + ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) + ){}} public class GlobalDefinitions_4 : GlobalDefinitions { public GlobalDefinitions_4(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) - ){}} + ((GlobalDefinitions)(yyq.StackAt(1).m_value)) + , + ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) + ){}} public class GlobalVariableDeclaration_1 : GlobalVariableDeclaration { public GlobalVariableDeclaration_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(1).m_value)) - ){}} + ((Declaration)(yyq.StackAt(1).m_value)) + ){}} public class GlobalVariableDeclaration_2 : GlobalVariableDeclaration { public GlobalVariableDeclaration_2(Parser yyq):base(yyq,new Assignment(((LSLSyntax -)yyq), - ((Declaration)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - , - ((EQUALS)(yyq.StackAt(2).m_value)) - .yytext)){}} +)yyq), + ((Declaration)(yyq.StackAt(3).m_value)) + , + ((Expression)(yyq.StackAt(1).m_value)) + , + ((EQUALS)(yyq.StackAt(2).m_value)) + .yytext)){}} public class GlobalFunctionDefinition_1 : GlobalFunctionDefinition { - public GlobalFunctionDefinition_1(Parser yyq):base(yyq,"void", - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + public GlobalFunctionDefinition_1(Parser yyq):base(yyq,"void", + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class GlobalFunctionDefinition_2 : GlobalFunctionDefinition { public GlobalFunctionDefinition_2(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((Typename)(yyq.StackAt(5).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class States_1 : States { public States_1(Parser yyq):base(yyq, - ((State)(yyq.StackAt(0).m_value)) - ){}} + ((State)(yyq.StackAt(0).m_value)) + ){}} public class States_2 : States { public States_2(Parser yyq):base(yyq, - ((States)(yyq.StackAt(1).m_value)) - , - ((State)(yyq.StackAt(0).m_value)) - ){}} + ((States)(yyq.StackAt(1).m_value)) + , + ((State)(yyq.StackAt(0).m_value)) + ){}} public class State_1 : State { public State_1(Parser yyq):base(yyq, - ((DEFAULT_STATE)(yyq.StackAt(3).m_value)) - .yytext, - ((StateBody)(yyq.StackAt(1).m_value)) - ){}} + ((DEFAULT_STATE)(yyq.StackAt(3).m_value)) + .yytext, + ((StateBody)(yyq.StackAt(1).m_value)) + ){}} public class State_2 : State { public State_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((StateBody)(yyq.StackAt(1).m_value)) - ){}} + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((StateBody)(yyq.StackAt(1).m_value)) + ){}} public class StateBody_1 : StateBody { public StateBody_1(Parser yyq):base(yyq, - ((StateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_2 : StateBody { public StateBody_2(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((StateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((StateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_3 : StateBody { public StateBody_3(Parser yyq):base(yyq, - ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_4 : StateBody { public StateBody_4(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_5 : StateBody { public StateBody_5(Parser yyq):base(yyq, - ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_6 : StateBody { public StateBody_6(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_7 : StateBody { public StateBody_7(Parser yyq):base(yyq, - ((IntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((IntArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_8 : StateBody { public StateBody_8(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((IntArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_9 : StateBody { public StateBody_9(Parser yyq):base(yyq, - ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_10 : StateBody { public StateBody_10(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_11 : StateBody { public StateBody_11(Parser yyq):base(yyq, - ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_12 : StateBody { public StateBody_12(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_13 : StateBody { public StateBody_13(Parser yyq):base(yyq, - ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_14 : StateBody { public StateBody_14(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_15 : StateBody { public StateBody_15(Parser yyq):base(yyq, - ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateBody_16 : StateBody { public StateBody_16(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} + ((StateBody)(yyq.StackAt(1).m_value)) + , + ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) + ){}} public class StateEvent_1 : StateEvent { public StateEvent_1(Parser yyq):base(yyq, - ((Event)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((Event)(yyq.StackAt(4).m_value)) + .yytext, + ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class VoidArgStateEvent_1 : VoidArgStateEvent { public VoidArgStateEvent_1(Parser yyq):base(yyq, - ((VoidArgEvent)(yyq.StackAt(3).m_value)) - .yytext, - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((VoidArgEvent)(yyq.StackAt(3).m_value)) + .yytext, + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class KeyArgStateEvent_1 : KeyArgStateEvent { public KeyArgStateEvent_1(Parser yyq):base(yyq, - ((KeyArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((KeyArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((KeyArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((KeyArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class IntArgStateEvent_1 : IntArgStateEvent { public IntArgStateEvent_1(Parser yyq):base(yyq, - ((IntArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((IntArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((IntArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class VectorArgStateEvent_1 : VectorArgStateEvent { public VectorArgStateEvent_1(Parser yyq):base(yyq, - ((VectorArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((VectorArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((VectorArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((VectorArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class IntRotRotArgStateEvent_1 : IntRotRotArgStateEvent { public IntRotRotArgStateEvent_1(Parser yyq):base(yyq, - ((IntRotRotArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntRotRotArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((IntRotRotArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((IntRotRotArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class IntVecVecArgStateEvent_1 : IntVecVecArgStateEvent { public IntVecVecArgStateEvent_1(Parser yyq):base(yyq, - ((IntVecVecArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntVecVecArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((IntVecVecArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((IntVecVecArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class KeyIntIntArgStateEvent_1 : KeyIntIntArgStateEvent { public KeyIntIntArgStateEvent_1(Parser yyq):base(yyq, - ((KeyIntIntArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((KeyIntIntArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((KeyIntIntArgEvent)(yyq.StackAt(4).m_value)) + .yytext, + ((KeyIntIntArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class ArgumentDeclarationList_1 : ArgumentDeclarationList { public ArgumentDeclarationList_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(0).m_value)) - ){}} + ((Declaration)(yyq.StackAt(0).m_value)) + ){}} public class ArgumentDeclarationList_2 : ArgumentDeclarationList { public ArgumentDeclarationList_2(Parser yyq):base(yyq, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((Declaration)(yyq.StackAt(0).m_value)) - ){}} + ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) + , + ((Declaration)(yyq.StackAt(0).m_value)) + ){}} public class KeyArgumentDeclarationList_1 : KeyArgumentDeclarationList { public KeyArgumentDeclarationList_1(Parser yyq):base(yyq, - ((KeyDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((KeyDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class IntArgumentDeclarationList_1 : IntArgumentDeclarationList { public IntArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((IntDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class VectorArgumentDeclarationList_1 : VectorArgumentDeclarationList { public VectorArgumentDeclarationList_1(Parser yyq):base(yyq, - ((VecDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((VecDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class IntRotRotArgumentDeclarationList_1 : IntRotRotArgumentDeclarationList { public IntRotRotArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(4).m_value)) - , - ((RotDeclaration)(yyq.StackAt(2).m_value)) - , - ((RotDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((IntDeclaration)(yyq.StackAt(4).m_value)) + , + ((RotDeclaration)(yyq.StackAt(2).m_value)) + , + ((RotDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class IntVecVecArgumentDeclarationList_1 : IntVecVecArgumentDeclarationList { public IntVecVecArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(4).m_value)) - , - ((VecDeclaration)(yyq.StackAt(2).m_value)) - , - ((VecDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((IntDeclaration)(yyq.StackAt(4).m_value)) + , + ((VecDeclaration)(yyq.StackAt(2).m_value)) + , + ((VecDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class KeyIntIntArgumentDeclarationList_1 : KeyIntIntArgumentDeclarationList { public KeyIntIntArgumentDeclarationList_1(Parser yyq):base(yyq, - ((KeyDeclaration)(yyq.StackAt(4).m_value)) - , - ((IntDeclaration)(yyq.StackAt(2).m_value)) - , - ((IntDeclaration)(yyq.StackAt(0).m_value)) - ){}} + ((KeyDeclaration)(yyq.StackAt(4).m_value)) + , + ((IntDeclaration)(yyq.StackAt(2).m_value)) + , + ((IntDeclaration)(yyq.StackAt(0).m_value)) + ){}} public class Declaration_1 : Declaration { public Declaration_1(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((Typename)(yyq.StackAt(1).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class KeyDeclaration_1 : KeyDeclaration { public KeyDeclaration_1(Parser yyq):base(yyq, - ((KEY_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((KEY_TYPE)(yyq.StackAt(1).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntDeclaration_1 : IntDeclaration { public IntDeclaration_1(Parser yyq):base(yyq, - ((INTEGER_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((INTEGER_TYPE)(yyq.StackAt(1).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VecDeclaration_1 : VecDeclaration { public VecDeclaration_1(Parser yyq):base(yyq, - ((VECTOR_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((VECTOR_TYPE)(yyq.StackAt(1).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class RotDeclaration_1 : RotDeclaration { public RotDeclaration_1(Parser yyq):base(yyq, - ((ROTATION_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((ROTATION_TYPE)(yyq.StackAt(1).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class CompoundStatement_1 : CompoundStatement { public CompoundStatement_1(Parser yyq):base(yyq){}} public class CompoundStatement_2 : CompoundStatement { public CompoundStatement_2(Parser yyq):base(yyq, - ((StatementList)(yyq.StackAt(1).m_value)) - ){}} + ((StatementList)(yyq.StackAt(1).m_value)) + ){}} public class StatementList_1 : StatementList { public StatementList_1(Parser yyq):base(yyq, - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class StatementList_2 : StatementList { public StatementList_2(Parser yyq):base(yyq, - ((StatementList)(yyq.StackAt(1).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((StatementList)(yyq.StackAt(1).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class EmptyStatement_1 : EmptyStatement { public EmptyStatement_1(Parser yyq):base(yyq){}} public class Statement_1 : Statement { public Statement_1(Parser yyq):base(yyq, - ((EmptyStatement)(yyq.StackAt(1).m_value)) - ){}} + ((EmptyStatement)(yyq.StackAt(1).m_value)) + ){}} public class Statement_2 : Statement { public Statement_2(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(1).m_value)) - ){}} + ((Declaration)(yyq.StackAt(1).m_value)) + ){}} public class Statement_3 : Statement { public Statement_3(Parser yyq):base(yyq, - ((Assignment)(yyq.StackAt(1).m_value)) - ){}} + ((Assignment)(yyq.StackAt(1).m_value)) + ){}} public class Statement_4 : Statement { public Statement_4(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} + ((Expression)(yyq.StackAt(1).m_value)) + ){}} public class Statement_5 : Statement { public Statement_5(Parser yyq):base(yyq, - ((ReturnStatement)(yyq.StackAt(1).m_value)) - ){}} + ((ReturnStatement)(yyq.StackAt(1).m_value)) + ){}} public class Statement_6 : Statement { public Statement_6(Parser yyq):base(yyq, - ((JumpLabel)(yyq.StackAt(1).m_value)) - ){}} + ((JumpLabel)(yyq.StackAt(1).m_value)) + ){}} public class Statement_7 : Statement { public Statement_7(Parser yyq):base(yyq, - ((JumpStatement)(yyq.StackAt(1).m_value)) - ){}} + ((JumpStatement)(yyq.StackAt(1).m_value)) + ){}} public class Statement_8 : Statement { public Statement_8(Parser yyq):base(yyq, - ((StateChange)(yyq.StackAt(1).m_value)) - ){}} + ((StateChange)(yyq.StackAt(1).m_value)) + ){}} public class Statement_9 : Statement { public Statement_9(Parser yyq):base(yyq, - ((IfStatement)(yyq.StackAt(0).m_value)) - ){}} + ((IfStatement)(yyq.StackAt(0).m_value)) + ){}} public class Statement_10 : Statement { public Statement_10(Parser yyq):base(yyq, - ((WhileStatement)(yyq.StackAt(0).m_value)) - ){}} + ((WhileStatement)(yyq.StackAt(0).m_value)) + ){}} public class Statement_11 : Statement { public Statement_11(Parser yyq):base(yyq, - ((DoWhileStatement)(yyq.StackAt(0).m_value)) - ){}} + ((DoWhileStatement)(yyq.StackAt(0).m_value)) + ){}} public class Statement_12 : Statement { public Statement_12(Parser yyq):base(yyq, - ((ForLoop)(yyq.StackAt(0).m_value)) - ){}} + ((ForLoop)(yyq.StackAt(0).m_value)) + ){}} public class Statement_13 : Statement { public Statement_13(Parser yyq):base(yyq, - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} + ((CompoundStatement)(yyq.StackAt(0).m_value)) + ){}} public class JumpLabel_1 : JumpLabel { public JumpLabel_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class JumpStatement_1 : JumpStatement { public JumpStatement_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class StateChange_1 : StateChange { public StateChange_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class StateChange_2 : StateChange { public StateChange_2(Parser yyq):base(yyq, - ((DEFAULT_STATE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((DEFAULT_STATE)(yyq.StackAt(0).m_value)) + .yytext){}} public class IfStatement_1 : IfStatement { public IfStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class IfStatement_2 : IfStatement { public IfStatement_2(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(4).m_value)) - , - ((Statement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(4).m_value)) + , + ((Statement)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class IfStatement_3 : IfStatement { public IfStatement_3(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class IfStatement_4 : IfStatement { public IfStatement_4(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(4).m_value)) - , - ((Statement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(4).m_value)) + , + ((Statement)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class WhileStatement_1 : WhileStatement { public WhileStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class WhileStatement_2 : WhileStatement { public WhileStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class DoWhileStatement_1 : DoWhileStatement { public DoWhileStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(5).m_value)) - ){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(5).m_value)) + ){}} public class DoWhileStatement_2 : DoWhileStatement { public DoWhileStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(5).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(5).m_value)) + ){}} public class ForLoop_1 : ForLoop { public ForLoop_1(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(6).m_value)) - , - ((Expression)(yyq.StackAt(4).m_value)) - , - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + ((ForLoopStatement)(yyq.StackAt(6).m_value)) + , + ((Expression)(yyq.StackAt(4).m_value)) + , + ((ForLoopStatement)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class ForLoop_2 : ForLoop { - public ForLoop_2(Parser yyq):base(yyq,null, - ((Expression)(yyq.StackAt(4).m_value)) - , - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} + public ForLoop_2(Parser yyq):base(yyq,null, + ((Expression)(yyq.StackAt(4).m_value)) + , + ((ForLoopStatement)(yyq.StackAt(2).m_value)) + , + ((Statement)(yyq.StackAt(0).m_value)) + ){}} public class ForLoopStatement_1 : ForLoopStatement { public ForLoopStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class ForLoopStatement_2 : ForLoopStatement { public ForLoopStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + ){}} public class ForLoopStatement_3 : ForLoopStatement { public ForLoopStatement_3(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((ForLoopStatement)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class ForLoopStatement_4 : ForLoopStatement { public ForLoopStatement_4(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} + ((ForLoopStatement)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + ){}} public class Assignment_1 : Assignment { public Assignment_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Declaration)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class Assignment_2 : Assignment { public Assignment_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + ){}} public class SimpleAssignment_1 : SimpleAssignment { public SimpleAssignment_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_2 : SimpleAssignment { public SimpleAssignment_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_3 : SimpleAssignment { public SimpleAssignment_3(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_4 : SimpleAssignment { public SimpleAssignment_4(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((STAR_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_5 : SimpleAssignment { public SimpleAssignment_5(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_6 : SimpleAssignment { public SimpleAssignment_6(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_7 : SimpleAssignment { public SimpleAssignment_7(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_8 : SimpleAssignment { public SimpleAssignment_8(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_9 : SimpleAssignment { public SimpleAssignment_9(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_10 : SimpleAssignment { public SimpleAssignment_10(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((STAR_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_11 : SimpleAssignment { public SimpleAssignment_11(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_12 : SimpleAssignment { public SimpleAssignment_12(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_13 : SimpleAssignment { public SimpleAssignment_13(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_14 : SimpleAssignment { public SimpleAssignment_14(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_15 : SimpleAssignment { public SimpleAssignment_15(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_16 : SimpleAssignment { public SimpleAssignment_16(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((STAR_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_17 : SimpleAssignment { public SimpleAssignment_17(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_18 : SimpleAssignment { public SimpleAssignment_18(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + , + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_19 : SimpleAssignment { public SimpleAssignment_19(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_20 : SimpleAssignment { public SimpleAssignment_20(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_21 : SimpleAssignment { public SimpleAssignment_21(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_22 : SimpleAssignment { public SimpleAssignment_22(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((STAR_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_23 : SimpleAssignment { public SimpleAssignment_23(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class SimpleAssignment_24 : SimpleAssignment { public SimpleAssignment_24(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} +)yyq), + ((IDENT)(yyq.StackAt(4).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext), + ((SimpleAssignment)(yyq.StackAt(0).m_value)) + , + ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class ReturnStatement_1 : ReturnStatement { public ReturnStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class ReturnStatement_2 : ReturnStatement { public ReturnStatement_2(Parser yyq):base(yyq){}} public class Constant_1 : Constant { - public Constant_1(Parser yyq):base(yyq,"integer", - ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + public Constant_1(Parser yyq):base(yyq,"integer", + ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Constant_2 : Constant { - public Constant_2(Parser yyq):base(yyq,"integer", - ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + public Constant_2(Parser yyq):base(yyq,"integer", + ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Constant_3 : Constant { - public Constant_3(Parser yyq):base(yyq,"float", - ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + public Constant_3(Parser yyq):base(yyq,"float", + ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Constant_4 : Constant { - public Constant_4(Parser yyq):base(yyq,"string", - ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + public Constant_4(Parser yyq):base(yyq,"string", + ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) + .yytext){}} public class ListConstant_1 : ListConstant { public ListConstant_1(Parser yyq):base(yyq, - ((ArgumentList)(yyq.StackAt(1).m_value)) - ){}} + ((ArgumentList)(yyq.StackAt(1).m_value)) + ){}} public class VectorConstant_1 : VectorConstant { public VectorConstant_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(5).m_value)) - , - ((Expression)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - ){}} + ((Expression)(yyq.StackAt(5).m_value)) + , + ((Expression)(yyq.StackAt(3).m_value)) + , + ((Expression)(yyq.StackAt(1).m_value)) + ){}} public class RotationConstant_1 : RotationConstant { public RotationConstant_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(7).m_value)) - , - ((Expression)(yyq.StackAt(5).m_value)) - , - ((Expression)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - ){}} + ((Expression)(yyq.StackAt(7).m_value)) + , + ((Expression)(yyq.StackAt(5).m_value)) + , + ((Expression)(yyq.StackAt(3).m_value)) + , + ((Expression)(yyq.StackAt(1).m_value)) + ){}} public class ConstantExpression_1 : ConstantExpression { public ConstantExpression_1(Parser yyq):base(yyq, - ((Constant)(yyq.StackAt(0).m_value)) - ){}} + ((Constant)(yyq.StackAt(0).m_value)) + ){}} public class IdentExpression_1 : IdentExpression { public IdentExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IdentDotExpression_1 : IdentDotExpression { public IdentDotExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IncrementDecrementExpression_1 : IncrementDecrementExpression { public IncrementDecrementExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext, + ((INCREMENT)(yyq.StackAt(0).m_value)) + .yytext, true){}} public class IncrementDecrementExpression_2 : IncrementDecrementExpression { public IncrementDecrementExpression_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext, + ((DECREMENT)(yyq.StackAt(0).m_value)) + .yytext, true){}} public class IncrementDecrementExpression_3 : IncrementDecrementExpression { public IncrementDecrementExpression_3(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} +)yyq), + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext), + ((INCREMENT)(yyq.StackAt(0).m_value)) + .yytext, true){}} public class IncrementDecrementExpression_4 : IncrementDecrementExpression { public IncrementDecrementExpression_4(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} +)yyq), + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext), + ((DECREMENT)(yyq.StackAt(0).m_value)) + .yytext, true){}} public class IncrementDecrementExpression_5 : IncrementDecrementExpression { public IncrementDecrementExpression_5(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(1).m_value)) - .yytext, false){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext, + ((INCREMENT)(yyq.StackAt(1).m_value)) + .yytext, false){}} public class IncrementDecrementExpression_6 : IncrementDecrementExpression { public IncrementDecrementExpression_6(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(1).m_value)) - .yytext, false){}} + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext, + ((DECREMENT)(yyq.StackAt(1).m_value)) + .yytext, false){}} public class IncrementDecrementExpression_7 : IncrementDecrementExpression { public IncrementDecrementExpression_7(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(3).m_value)) - .yytext, false){}} +)yyq), + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext), + ((INCREMENT)(yyq.StackAt(3).m_value)) + .yytext, false){}} public class IncrementDecrementExpression_8 : IncrementDecrementExpression { public IncrementDecrementExpression_8(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(3).m_value)) - .yytext, false){}} +)yyq), + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext), + ((DECREMENT)(yyq.StackAt(3).m_value)) + .yytext, false){}} public class FunctionCallExpression_1 : FunctionCallExpression { public FunctionCallExpression_1(Parser yyq):base(yyq, - ((FunctionCall)(yyq.StackAt(0).m_value)) - ){}} + ((FunctionCall)(yyq.StackAt(0).m_value)) + ){}} public class BinaryExpression_1 : BinaryExpression { public BinaryExpression_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PLUS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_2 : BinaryExpression { public BinaryExpression_2(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((MINUS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_3 : BinaryExpression { public BinaryExpression_3(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((STAR)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_4 : BinaryExpression { public BinaryExpression_4(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((SLASH)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_5 : BinaryExpression { public BinaryExpression_5(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((PERCENT)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_6 : BinaryExpression { public BinaryExpression_6(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((AMP)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((AMP)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_7 : BinaryExpression { public BinaryExpression_7(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STROKE)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((STROKE)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_8 : BinaryExpression { public BinaryExpression_8(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((CARET)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((CARET)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_9 : BinaryExpression { public BinaryExpression_9(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((RIGHT_ANGLE)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((RIGHT_ANGLE)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_10 : BinaryExpression { public BinaryExpression_10(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LEFT_ANGLE)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((LEFT_ANGLE)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_11 : BinaryExpression { public BinaryExpression_11(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((EQUALS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_12 : BinaryExpression { public BinaryExpression_12(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EXCLAMATION_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((EXCLAMATION_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_13 : BinaryExpression { public BinaryExpression_13(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LESS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((LESS_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_14 : BinaryExpression { public BinaryExpression_14(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((GREATER_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((GREATER_EQUALS)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_15 : BinaryExpression { public BinaryExpression_15(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((AMP_AMP)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((AMP_AMP)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_16 : BinaryExpression { public BinaryExpression_16(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STROKE_STROKE)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((STROKE_STROKE)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_17 : BinaryExpression { public BinaryExpression_17(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LEFT_SHIFT)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((LEFT_SHIFT)(yyq.StackAt(1).m_value)) + .yytext){}} public class BinaryExpression_18 : BinaryExpression { public BinaryExpression_18(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((RIGHT_SHIFT)(yyq.StackAt(1).m_value)) - .yytext){}} + ((Expression)(yyq.StackAt(2).m_value)) + , + ((Expression)(yyq.StackAt(0).m_value)) + , + ((RIGHT_SHIFT)(yyq.StackAt(1).m_value)) + .yytext){}} public class UnaryExpression_1 : UnaryExpression { public UnaryExpression_1(Parser yyq):base(yyq, - ((EXCLAMATION)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((EXCLAMATION)(yyq.StackAt(1).m_value)) + .yytext, + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class UnaryExpression_2 : UnaryExpression { public UnaryExpression_2(Parser yyq):base(yyq, - ((MINUS)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((MINUS)(yyq.StackAt(1).m_value)) + .yytext, + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class UnaryExpression_3 : UnaryExpression { public UnaryExpression_3(Parser yyq):base(yyq, - ((TILDE)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((TILDE)(yyq.StackAt(1).m_value)) + .yytext, + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class ParenthesisExpression_1 : ParenthesisExpression { public ParenthesisExpression_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} + ((Expression)(yyq.StackAt(1).m_value)) + ){}} public class ParenthesisExpression_2 : ParenthesisExpression { public ParenthesisExpression_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(1).m_value)) - ){}} + ((SimpleAssignment)(yyq.StackAt(1).m_value)) + ){}} public class TypecastExpression_1 : TypecastExpression { public TypecastExpression_1(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, - ((Constant)(yyq.StackAt(0).m_value)) - ){}} + ((Typename)(yyq.StackAt(2).m_value)) + .yytext, + ((Constant)(yyq.StackAt(0).m_value)) + ){}} public class TypecastExpression_2 : TypecastExpression { public TypecastExpression_2(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, new IdentExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext)){}} + ((Typename)(yyq.StackAt(2).m_value)) + .yytext, new IdentExpression(((LSLSyntax +)yyq), + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext)){}} public class TypecastExpression_3 : TypecastExpression { public TypecastExpression_3(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(4).m_value)) - .yytext, new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext)){}} + ((Typename)(yyq.StackAt(4).m_value)) + .yytext, new IdentDotExpression(((LSLSyntax +)yyq), + ((IDENT)(yyq.StackAt(2).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(0).m_value)) + .yytext)){}} public class TypecastExpression_4 : TypecastExpression { public TypecastExpression_4(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(3).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} + ((Typename)(yyq.StackAt(3).m_value)) + .yytext, new IncrementDecrementExpression(((LSLSyntax +)yyq), + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext, + ((INCREMENT)(yyq.StackAt(0).m_value)) + .yytext, true)){}} public class TypecastExpression_5 : TypecastExpression { public TypecastExpression_5(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax + ((Typename)(yyq.StackAt(5).m_value)) + .yytext, new IncrementDecrementExpression(((LSLSyntax )yyq), new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} +)yyq), + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext), + ((INCREMENT)(yyq.StackAt(0).m_value)) + .yytext, true)){}} public class TypecastExpression_6 : TypecastExpression { public TypecastExpression_6(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(3).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} + ((Typename)(yyq.StackAt(3).m_value)) + .yytext, new IncrementDecrementExpression(((LSLSyntax +)yyq), + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext, + ((DECREMENT)(yyq.StackAt(0).m_value)) + .yytext, true)){}} public class TypecastExpression_7 : TypecastExpression { public TypecastExpression_7(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax + ((Typename)(yyq.StackAt(5).m_value)) + .yytext, new IncrementDecrementExpression(((LSLSyntax )yyq), new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} +)yyq), + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((IDENT)(yyq.StackAt(1).m_value)) + .yytext), + ((DECREMENT)(yyq.StackAt(0).m_value)) + .yytext, true)){}} public class TypecastExpression_8 : TypecastExpression { public TypecastExpression_8(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, - ((FunctionCall)(yyq.StackAt(0).m_value)) - ){}} + ((Typename)(yyq.StackAt(2).m_value)) + .yytext, + ((FunctionCall)(yyq.StackAt(0).m_value)) + ){}} public class TypecastExpression_9 : TypecastExpression { public TypecastExpression_9(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(4).m_value)) - .yytext, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} + ((Typename)(yyq.StackAt(4).m_value)) + .yytext, + ((Expression)(yyq.StackAt(1).m_value)) + ){}} public class FunctionCall_1 : FunctionCall { public FunctionCall_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((ArgumentList)(yyq.StackAt(1).m_value)) - ){}} + ((IDENT)(yyq.StackAt(3).m_value)) + .yytext, + ((ArgumentList)(yyq.StackAt(1).m_value)) + ){}} public class ArgumentList_1 : ArgumentList { public ArgumentList_1(Parser yyq):base(yyq, - ((Argument)(yyq.StackAt(0).m_value)) - ){}} + ((Argument)(yyq.StackAt(0).m_value)) + ){}} public class ArgumentList_2 : ArgumentList { public ArgumentList_2(Parser yyq):base(yyq, - ((ArgumentList)(yyq.StackAt(2).m_value)) - , - ((Argument)(yyq.StackAt(0).m_value)) - ){}} + ((ArgumentList)(yyq.StackAt(2).m_value)) + , + ((Argument)(yyq.StackAt(0).m_value)) + ){}} public class ExpressionArgument_1 : ExpressionArgument { public ExpressionArgument_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} + ((Expression)(yyq.StackAt(0).m_value)) + ){}} public class Typename_1 : Typename { public Typename_1(Parser yyq):base(yyq, - ((INTEGER_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((INTEGER_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_2 : Typename { public Typename_2(Parser yyq):base(yyq, - ((FLOAT_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((FLOAT_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_3 : Typename { public Typename_3(Parser yyq):base(yyq, - ((STRING_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((STRING_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_4 : Typename { public Typename_4(Parser yyq):base(yyq, - ((KEY_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((KEY_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_5 : Typename { public Typename_5(Parser yyq):base(yyq, - ((VECTOR_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((VECTOR_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_6 : Typename { public Typename_6(Parser yyq):base(yyq, - ((ROTATION_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((ROTATION_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Typename_7 : Typename { public Typename_7(Parser yyq):base(yyq, - ((LIST_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LIST_TYPE)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_1 : Event { public Event_1(Parser yyq):base(yyq, - ((DATASERVER_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((DATASERVER_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_2 : Event { public Event_2(Parser yyq):base(yyq, - ((EMAIL_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((EMAIL_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_3 : Event { public Event_3(Parser yyq):base(yyq, - ((HTTP_RESPONSE_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((HTTP_RESPONSE_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_4 : Event { public Event_4(Parser yyq):base(yyq, - ((LINK_MESSAGE_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LINK_MESSAGE_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_5 : Event { public Event_5(Parser yyq):base(yyq, - ((LISTEN_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LISTEN_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_6 : Event { public Event_6(Parser yyq):base(yyq, - ((MONEY_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((MONEY_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_7 : Event { public Event_7(Parser yyq):base(yyq, - ((REMOTE_DATA_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((REMOTE_DATA_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_8 : Event { public Event_8(Parser yyq):base(yyq, - ((HTTP_REQUEST_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((HTTP_REQUEST_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class Event_9 : Event { public Event_9(Parser yyq):base(yyq, - ((TRANSACTION_RESULT_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((TRANSACTION_RESULT_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_1 : VoidArgEvent { public VoidArgEvent_1(Parser yyq):base(yyq, - ((STATE_ENTRY_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((STATE_ENTRY_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_2 : VoidArgEvent { public VoidArgEvent_2(Parser yyq):base(yyq, - ((STATE_EXIT_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((STATE_EXIT_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_3 : VoidArgEvent { public VoidArgEvent_3(Parser yyq):base(yyq, - ((MOVING_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((MOVING_END_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_4 : VoidArgEvent { public VoidArgEvent_4(Parser yyq):base(yyq, - ((MOVING_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((MOVING_START_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_5 : VoidArgEvent { public VoidArgEvent_5(Parser yyq):base(yyq, - ((NO_SENSOR_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((NO_SENSOR_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_6 : VoidArgEvent { public VoidArgEvent_6(Parser yyq):base(yyq, - ((NOT_AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((NOT_AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_7 : VoidArgEvent { public VoidArgEvent_7(Parser yyq):base(yyq, - ((NOT_AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((NOT_AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VoidArgEvent_8 : VoidArgEvent { public VoidArgEvent_8(Parser yyq):base(yyq, - ((TIMER_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((TIMER_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class KeyArgEvent_1 : KeyArgEvent { public KeyArgEvent_1(Parser yyq):base(yyq, - ((ATTACH_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((ATTACH_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class KeyArgEvent_2 : KeyArgEvent { public KeyArgEvent_2(Parser yyq):base(yyq, - ((OBJECT_REZ_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((OBJECT_REZ_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_1 : IntArgEvent { public IntArgEvent_1(Parser yyq):base(yyq, - ((CHANGED_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((CHANGED_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_2 : IntArgEvent { public IntArgEvent_2(Parser yyq):base(yyq, - ((COLLISION_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((COLLISION_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_3 : IntArgEvent { public IntArgEvent_3(Parser yyq):base(yyq, - ((COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_4 : IntArgEvent { public IntArgEvent_4(Parser yyq):base(yyq, - ((COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_5 : IntArgEvent { public IntArgEvent_5(Parser yyq):base(yyq, - ((ON_REZ_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((ON_REZ_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_6 : IntArgEvent { public IntArgEvent_6(Parser yyq):base(yyq, - ((RUN_TIME_PERMISSIONS_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((RUN_TIME_PERMISSIONS_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_7 : IntArgEvent { public IntArgEvent_7(Parser yyq):base(yyq, - ((SENSOR_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((SENSOR_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_8 : IntArgEvent { public IntArgEvent_8(Parser yyq):base(yyq, - ((TOUCH_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((TOUCH_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_9 : IntArgEvent { public IntArgEvent_9(Parser yyq):base(yyq, - ((TOUCH_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((TOUCH_END_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntArgEvent_10 : IntArgEvent { public IntArgEvent_10(Parser yyq):base(yyq, - ((TOUCH_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((TOUCH_START_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VectorArgEvent_1 : VectorArgEvent { public VectorArgEvent_1(Parser yyq):base(yyq, - ((LAND_COLLISION_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LAND_COLLISION_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VectorArgEvent_2 : VectorArgEvent { public VectorArgEvent_2(Parser yyq):base(yyq, - ((LAND_COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LAND_COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class VectorArgEvent_3 : VectorArgEvent { public VectorArgEvent_3(Parser yyq):base(yyq, - ((LAND_COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((LAND_COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntRotRotArgEvent_1 : IntRotRotArgEvent { public IntRotRotArgEvent_1(Parser yyq):base(yyq, - ((AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class IntVecVecArgEvent_1 : IntVecVecArgEvent { public IntVecVecArgEvent_1(Parser yyq):base(yyq, - ((AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class KeyIntIntArgEvent_1 : KeyIntIntArgEvent { public KeyIntIntArgEvent_1(Parser yyq):base(yyq, - ((CONTROL_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} + ((CONTROL_EVENT)(yyq.StackAt(0).m_value)) + .yytext){}} public class yyLSLSyntax : YyParser { public override object Action(Parser yyq,SYMBOL yysym, int yyact) { switch(yyact) { - case -1: break; //// keep compiler happy + case -1: break; //// keep compiler happy } return null; } public class ArgumentDeclarationList_3 : ArgumentDeclarationList { @@ -2390,7 +2390,7 @@ public class ArgumentDeclarationList_4 : ArgumentDeclarationList { public class ArgumentDeclarationList_5 : ArgumentDeclarationList { public ArgumentDeclarationList_5(Parser yyq):base(yyq){}} public yyLSLSyntax -():base() { arr = new int[] { +():base() { arr = new int[] { 101,4,6,52,0, 46,0,53,0,102, 20,103,4,28,76, diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index e02d35e..7db6b6d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -35,6 +35,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.CoreModules; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.ScriptEngine.Shared @@ -47,7 +48,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } protected EventAbortException( - SerializationInfo info, + SerializationInfo info, StreamingContext context) { } @@ -61,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } protected SelfDeleteException( - SerializationInfo info, + SerializationInfo info, StreamingContext context) { } @@ -75,14 +76,14 @@ namespace OpenSim.Region.ScriptEngine.Shared } protected ScriptDeleteException( - SerializationInfo info, + SerializationInfo info, StreamingContext context) { } } /// - /// Used to signal when the script is stopping in co-operation with the script engine + /// Used to signal when the script is stopping in co-operation with the script engine /// (instead of through Thread.Abort()). /// [Serializable] @@ -93,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } protected ScriptCoopStopException( - SerializationInfo info, + SerializationInfo info, StreamingContext context) { } @@ -198,6 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared return; Name = presence.Firstname + " " + presence.Lastname; + Owner = Key; Position = new LSL_Types.Vector3(presence.AbsolutePosition); Rotation = new LSL_Types.Quaternion( @@ -207,22 +209,9 @@ namespace OpenSim.Region.ScriptEngine.Shared presence.Rotation.W); Velocity = new LSL_Types.Vector3(presence.Velocity); - if (presence.PresenceType != PresenceType.Npc) - { - Type = AGENT; - } - else - { - Type = OS_NPC; - - INPCModule npcModule = scene.RequestModuleInterface(); - INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); - - if (npcData.SenseAsAgent) - { - Type |= AGENT; - } - } + Type = 0x01; // Avatar + if (presence.PresenceType == PresenceType.Npc) + Type = 0x20; if (presence.Velocity != Vector3.Zero) Type |= ACTIVE; @@ -260,6 +249,66 @@ namespace OpenSim.Region.ScriptEngine.Shared Velocity = new LSL_Types.Vector3(part.Velocity); } + + public void Populate(Scene scene, DetectedObject obj) + { + if(obj.keyUUID == UUID.Zero) // land + { + Position = new LSL_Types.Vector3(obj.posVector); + Rotation.s = 1.0; + return; + } + + if((obj.colliderType & 0x21) != 0) // avatar or npc + { + ScenePresence presence = scene.GetScenePresence(obj.keyUUID); + if (presence == null) + return; + + Name = obj.nameStr; + Key = obj.keyUUID; + Owner = obj.ownerUUID; + Group = obj.groupUUID; + Position = new LSL_Types.Vector3(obj.posVector); + Rotation = new LSL_Types.Quaternion(obj.rotQuat); + Velocity = new LSL_Types.Vector3(obj.velVector); + LinkNum = obj.linkNumber; + Type = obj.colliderType; + return; + } + + SceneObjectPart part = scene.GetSceneObjectPart(obj.keyUUID); + if(part == null) + return; + + Name = obj.nameStr; + Key = obj.keyUUID; + Owner = obj.ownerUUID; + Group = obj.groupUUID; + Position = new LSL_Types.Vector3(obj.posVector); + Rotation = new LSL_Types.Quaternion(obj.rotQuat); + Velocity = new LSL_Types.Vector3(obj.velVector); + LinkNum = obj.linkNumber; + if(obj.velVector == Vector3.Zero) + Type = 4; + else + Type = 2; + + part = part.ParentGroup.RootPart; + foreach (SceneObjectPart p in part.ParentGroup.Parts) + { + if (p.Inventory.ContainsScripts()) + { + // at sl a physical prim is active also if has active scripts + // assuming all scripts are in run state to save time + if((part.Flags & PrimFlags.Physics) != 0 ) + Type = 10; // script + active + else + Type |= SCRIPTED; // Scripted + break; + } + } + } } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs index b7c4bab..411d49c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Instance")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index fa6e6fc..9d72b1c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -51,7 +51,8 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Interfaces; -using System.Diagnostics; + +using System.Diagnostics; //for [DebuggerNonUserCode] namespace OpenSim.Region.ScriptEngine.Shared.Instance { @@ -87,7 +88,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // The following is for setting a minimum delay between events private double m_minEventDelay; - + private long m_eventDelayTicks; private long m_nextEventTimeTicks; private bool m_startOnInit = true; @@ -121,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { if (value > 0.001) m_minEventDelay = value; - else + else m_minEventDelay = 0.0; m_eventDelayTicks = (long)(m_minEventDelay * 10000000L); @@ -153,7 +154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { bool wasSuspended = m_Suspended; m_Suspended = value; - + if (wasSuspended && !m_Suspended) { lock (EventQueue) @@ -200,11 +201,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public long EventsQueued { - get + get { lock (EventQueue) return EventQueue.Count; - } + } } public long EventsProcessed { get; private set; } @@ -220,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private static readonly int MeasurementWindow = 30 * 1000; // show the *recent* time used by the script, to find currently active scripts private bool m_coopTermination; - + private EventWaitHandle m_coopSleepHandle; public void ClearQueue() @@ -256,8 +257,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance StartParam = startParam; m_MaxScriptQueue = maxScriptQueue; m_postOnRez = postOnRez; - m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; - m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; + m_AttachedAvatar = part.ParentGroup.AttachedAvatar; + m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; m_SaveState = StatePersistedHere; @@ -280,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// /// false if load failed, true if suceeded public bool Load( - IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, + IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, string dataPath, StateSource stateSource, bool coopTermination) { m_Script = script; @@ -323,13 +324,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return false; } - // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called. + // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called. string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); if (File.Exists(savedState)) { // m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", + // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); string xml = String.Empty; @@ -394,7 +395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // else // { // m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", + // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); // } @@ -406,16 +407,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (ShuttingDown) return; - if (m_startedFromSavedState) + if (m_startedFromSavedState) { if (m_startOnInit) Start(); - if (m_postOnRez) + if (m_postOnRez) { PostEvent(new EventParams("on_rez", new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); } - if (m_stateSource == StateSource.AttachedRez) { PostEvent(new EventParams("attach", @@ -439,13 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0])); } } - else + else { if (m_startOnInit) Start(); PostEvent(new EventParams("state_entry", new Object[0], new DetectParams[0])); - if (m_postOnRez) + if (m_postOnRez) { PostEvent(new EventParams("on_rez", new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); @@ -461,22 +461,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private void ReleaseControls() { - int permsMask; - UUID permsGranter; - lock (Part.TaskInventory) + SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); + + if (part != null) { - if (!Part.TaskInventory.ContainsKey(ItemID)) + int permsMask; + UUID permsGranter; + part.TaskInventory.LockItemsForRead(true); + if (!part.TaskInventory.ContainsKey(ItemID)) + { + part.TaskInventory.LockItemsForRead(false); return; + } + permsGranter = part.TaskInventory[ItemID].PermsGranter; + permsMask = part.TaskInventory[ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); - permsGranter = Part.TaskInventory[ItemID].PermsGranter; - permsMask = Part.TaskInventory[ItemID].PermsMask; - } - - if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) - { - ScenePresence presence = Engine.World.GetScenePresence(permsGranter); - if (presence != null) - presence.UnRegisterControlEventsToScript(LocalID, ItemID); + if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) + { + ScenePresence presence = Engine.World.GetScenePresence(permsGranter); + if (presence != null) + presence.UnRegisterControlEventsToScript(LocalID, ItemID); + } } } @@ -502,8 +508,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { m_log.Warn( string.Format( - "[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ", - savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name), + "[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ", + savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name), e); } } @@ -625,7 +631,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (!m_InSelfDelete) { m_log.DebugFormat( - "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", + "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", ScriptName, ItemID, PrimName, LocalID, timeout); workItem.Abort(); @@ -639,6 +645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return true; } + [DebuggerNonUserCode] //Prevents the debugger from farting in this function public void SetState(string state) { if (state == State) @@ -702,7 +709,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance lock (EventQueue) { // The only events that persist across state changes are timers - if (m_StateChangeInProgress && data.EventName != "timer") + if (m_StateChangeInProgress && data.EventName != "timer") return; if (EventQueue.Count >= m_MaxScriptQueue) @@ -764,6 +771,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { + EventParams data = null; // We check here as the thread stopping this instance from running may itself hold the m_Script lock. if (!Running) return 0; @@ -776,7 +784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return 0; ExecutionTimer.Restart(); - + try { return EventProcessorInt(); @@ -797,9 +805,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance lock (EventQueue) { data = (EventParams)EventQueue.Dequeue(); - if (data == null) // Shouldn't happen + if (data == null) { - if (EventQueue.Count > 0 && Running && !ShuttingDown) + // check if a null event was enqueued or if its really empty + if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) { m_CurrentWorkItem = Engine.QueueEventHandler(this); } @@ -850,7 +859,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance Part.ParentGroup.UUID, Part.AbsolutePosition, Part.ParentGroup.Scene.Name); - AsyncCommandManager.StateChange(Engine, LocalID, ItemID); // we are effectively in the new state now, so we can resume queueing @@ -861,6 +869,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else { + Exception e = null; + if (Engine.World.PipeEventsForScript(LocalID) || data.EventName == "control") // Don't freeze avies! { @@ -870,7 +880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance try { m_CurrentEvent = data.EventName; - m_EventStart = DateTime.Now; + m_EventStart = DateTime.UtcNow; m_InEvent = true; try @@ -881,6 +891,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { m_InEvent = false; m_CurrentEvent = String.Empty; + lock (EventQueue) + m_CurrentWorkItem = null; // no longer in a event that can be canceled } if (m_SaveState) @@ -893,7 +905,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_SaveState = false; } } - catch (Exception e) + catch (Exception exx) + { + e = exx; + } + + if(e != null) { // m_log.DebugFormat( // "[SCRIPT] Exception in script {0} {1}: {2}{3}", @@ -907,39 +924,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { try { - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - Part.AbsolutePosition, - Part.Name, Part.UUID, false); - - - m_log.Debug(string.Format( - "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", - ScriptName, - data.EventName, - PrimName, - Part.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name), - e); + + if(e.InnerException != null && e.InnerException is ScriptException) + { + string text = e.InnerException.Message + + "(script: " + ScriptName + + " event: " + data.EventName + + " at " + Part.AbsolutePosition + ")"; + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}", + e.InnerException.Message, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name)); + + } + else + { + + // DISPLAY ERROR INWORLD + string text = FormatException(e); + + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + + + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", + ScriptName, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name), + e); + } } catch (Exception) { } - // catch (Exception e2) // LEGIT: User Scripting - // { - // m_log.Error("[SCRIPT]: "+ - // "Error displaying error in-world: " + - // e2.ToString()); - // m_log.Error("[SCRIPT]: " + - // "Errormessage: Error compiling script:\r\n" + - // e.ToString()); - // } } else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) { @@ -978,7 +1013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance ScriptTask.ItemID, ScriptTask.AssetID, data.EventName, EventsProcessed); } - if (EventQueue.Count > 0 && Running && !ShuttingDown) + if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) { m_CurrentWorkItem = Engine.QueueEventHandler(this); } @@ -998,7 +1033,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (!m_InEvent) return 0; - return (DateTime.Now - m_EventStart).Seconds; + return (DateTime.UtcNow - m_EventStart).Seconds; } public void ResetScript(int timeout) @@ -1012,15 +1047,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance ReleaseControls(); Stop(timeout); - Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; - Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; + SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); + part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; + part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; + part.CollisionSound = UUID.Zero; AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); + + m_TimerQueued = false; + m_StateChangeInProgress = false; EventQueue.Clear(); + m_Script.ResetVars(); StartParam = 0; State = "default"; - Part.SetScriptEvents(ItemID, + + part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); if (running) Start(); @@ -1031,6 +1073,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[0], new DetectParams[0])); } + [DebuggerNonUserCode] //Stops the VS debugger from farting in this function public void ApiResetScript() { // bool running = Running; @@ -1039,17 +1082,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance ReleaseControls(); m_Script.ResetVars(); - Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; - Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; + SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); + part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; + part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; + part.CollisionSound = UUID.Zero; AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); + m_TimerQueued = false; + m_StateChangeInProgress = false; EventQueue.Clear(); m_Script.ResetVars(); string oldState = State; StartParam = 0; State = "default"; - Part.SetScriptEvents(ItemID, + part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); if (m_CurrentEvent != "state_entry" || oldState != "default") @@ -1170,7 +1217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return null; } - + public override string ToString() { return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs index bcdc7bf..cfe21fc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs @@ -207,6 +207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public static void Deserialize(string xml, ScriptInstance instance) { XmlDocument doc = new XmlDocument(); + doc.XmlResolver=null; Dictionary vars = instance.GetVars(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs index 5b9794b..8138117 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs @@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests m_xEngine.DebugLevel = 1; IniConfigSource configSource = new IniConfigSource(); - + IConfig startupConfig = configSource.AddConfig("Startup"); startupConfig.Set("DefaultScriptEngine", "XEngine"); @@ -124,9 +124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { llSay(0, ""Thin Lizzy""); @@ -143,12 +143,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { - integer i = 0; + integer i = 0; for (i = 0; i <= 1; i++) llSay(0, ""Iter "" + (string)i); } }"; @@ -162,14 +162,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - + for (i = 0; i < 2147483647; i++) llSay(0, ""Iter "" + (string)i); } }"; @@ -183,15 +183,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - - for (i = 0; i < 2147483647; i++) + + for (i = 0; i < 2147483647; i++) { llSay(0, ""Iter "" + (string)i); } @@ -207,12 +207,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { - integer i = 0; + integer i = 0; while (i < 2) llSay(0, ""Iter "" + (string)i++); } }"; @@ -226,15 +226,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - while (1 == 1) + while (1 == 1) llSay(0, ""Iter "" + (string)i++); } }"; @@ -248,15 +248,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - while (1 == 1) + while (1 == 1) { llSay(0, ""Iter "" + (string)i++); } @@ -272,9 +272,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; @@ -293,9 +293,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; @@ -315,15 +315,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - do + do { llSay(0, ""Iter "" + (string)i++); } while (1 == 1); @@ -339,15 +339,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; llSay(0, ""Thin Lizzy""); - @p1; + @p1; llSay(0, ""Iter "" + (string)i++); jump p1; } @@ -364,7 +364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @" integer i = 0; @@ -375,7 +375,7 @@ ufn1() } default -{ +{ state_entry() { integer i = 0; @@ -396,9 +396,9 @@ default TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - string script = + string script = @"default -{ +{ state_entry() { integer i = 0; @@ -417,7 +417,7 @@ default // UUID objectId = TestHelpers.ParseTail(0x100); // UUID itemId = TestHelpers.ParseTail(0x3); - SceneObjectGroup so + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, string.Format("Object for {0}", itemName), 0x100); m_scene.AddNewSceneObject(so, true); @@ -505,7 +505,7 @@ default if (++m_chatMessagesReceived >= m_chatMessagesThreshold) { - m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; + m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; m_chatEvent.Set(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 0ca5ff3..a65f71f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Globalization; +using System.Text; using System.Text.RegularExpressions; using OpenSim.Framework; @@ -38,7 +39,6 @@ using OMV_Quaternion = OpenMetaverse.Quaternion; namespace OpenSim.Region.ScriptEngine.Shared { - [Serializable] public partial class LSL_Types { // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain @@ -100,21 +100,32 @@ namespace OpenSim.Region.ScriptEngine.Shared #region Overriders + public static implicit operator Boolean(Vector3 vec) + { + if (vec.x != 0) + return true; + if (vec.y != 0) + return true; + if (vec.z != 0) + return true; + return false; + } + public override string ToString() { - string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); + string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); return s; } public static explicit operator LSLString(Vector3 vec) { - string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); + string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); return new LSLString(s); } public static explicit operator string(Vector3 vec) { - string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); + string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); return s; } @@ -328,7 +339,7 @@ namespace OpenSim.Region.ScriptEngine.Shared y = (float)Quat.y; z = (float)Quat.z; s = (float)Quat.s; - if (x == 0 && y == 0 && z == 0 && s == 0) + if (s == 0 && x == 0 && y == 0 && z == 0) s = 1; } @@ -338,7 +349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared y = Y; z = Z; s = S; - if (x == 0 && y == 0 && z == 0 && s == 0) + if (s == 0 && x == 0 && y == 0 && z == 0) s = 1; } @@ -357,7 +368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared res = res & Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y); res = res & Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z); res = res & Double.TryParse(tmps[3], NumberStyles.Float, Culture.NumberFormatInfo, out s); - if (x == 0 && y == 0 && z == 0 && s == 0) + if (s == 0 && x == 0 && y == 0 && z == 0) s = 1; } @@ -397,6 +408,18 @@ namespace OpenSim.Region.ScriptEngine.Shared #endregion #region Overriders + public static implicit operator Boolean(Quaternion q) + { + if (q.x != 0) + return true; + if (q.y != 0) + return true; + if (q.z != 0) + return true; + if (q.s != 1.0f) + return true; + return false; + } public override int GetHashCode() { @@ -414,19 +437,19 @@ namespace OpenSim.Region.ScriptEngine.Shared public override string ToString() { - string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); + string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); return st; } public static explicit operator string(Quaternion r) { - string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); + string s=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); return s; } public static explicit operator LSLString(Quaternion r) { - string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); + string s=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); return new LSLString(s); } @@ -502,7 +525,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } [Serializable] - public struct list + public class list { private object[] m_data; @@ -537,7 +560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared else if (o is LSL_Types.LSLFloat) size += 8; else if (o is LSL_Types.LSLString) - size += ((LSL_Types.LSLString)o).m_string.Length; + size += ((LSL_Types.LSLString)o).m_string == null ? 0 : ((LSL_Types.LSLString)o).m_string.Length; else if (o is LSL_Types.key) size += ((LSL_Types.key)o).value.Length; else if (o is LSL_Types.Vector3) @@ -546,6 +569,8 @@ namespace OpenSim.Region.ScriptEngine.Shared size += 64; else if (o is int) size += 4; + else if (o is uint) + size += 4; else if (o is string) size += ((string)o).Length; else if (o is float) @@ -675,16 +700,45 @@ namespace OpenSim.Region.ScriptEngine.Shared } } + // use LSL_Types.Quaternion to parse and store a vector4 for lightShare + public LSL_Types.Quaternion GetVector4Item(int itemIndex) + { + if (Data[itemIndex] is LSL_Types.Quaternion) + { + LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex]; + return q; + } + else if(Data[itemIndex] is OpenMetaverse.Quaternion) + { + LSL_Types.Quaternion q = new LSL_Types.Quaternion( + (OpenMetaverse.Quaternion)Data[itemIndex]); + q.Normalize(); + return q; + } + else + { + throw new InvalidCastException(string.Format( + "{0} expected but {1} given", + typeof(LSL_Types.Quaternion).Name, + Data[itemIndex] != null ? + Data[itemIndex].GetType().Name : "null")); + } + } + public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) { if (Data[itemIndex] is LSL_Types.Quaternion) { - return (LSL_Types.Quaternion)Data[itemIndex]; + LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex]; + q.Normalize(); + return q; } else if(Data[itemIndex] is OpenMetaverse.Quaternion) { - return new LSL_Types.Quaternion( + LSL_Types.Quaternion q = new LSL_Types.Quaternion( (OpenMetaverse.Quaternion)Data[itemIndex]); + q.Normalize(); + return q; } else { @@ -719,6 +773,11 @@ namespace OpenSim.Region.ScriptEngine.Shared Data = tmp; } + public static implicit operator Boolean(list l) + { + return l.Length != 0; + } + public static list operator +(list a, LSLString s) { a.ExtendAndAdd(s); @@ -755,7 +814,7 @@ namespace OpenSim.Region.ScriptEngine.Shared int lb = -1; try { la = a.Length; } catch (NullReferenceException) { } - try {lb = b.Length;} + try { lb = b.Length; } catch (NullReferenceException) { } return la != lb; @@ -1023,6 +1082,9 @@ namespace OpenSim.Region.ScriptEngine.Shared stride = 1; } + if ((Data.Length % stride) != 0) + return new list(ret); + // we can optimize here in the case where stride == 1 and the list // consists of homogeneous types @@ -1090,34 +1152,35 @@ namespace OpenSim.Region.ScriptEngine.Shared public string ToCSV() { - string ret = ""; - foreach (object o in this.Data) + if(m_data == null || m_data.Length == 0) + return String.Empty; + + Object o = m_data[0]; + int len = m_data.Length; + if(len == 1) + return o.ToString(); + + StringBuilder sb = new StringBuilder(1024); + sb.Append(o.ToString()); + for(int i = 1 ; i < len; i++) { - if (ret == "") - { - ret = o.ToString(); - } - else - { - ret = ret + ", " + o.ToString(); - } + sb.Append(","); + sb.Append(o.ToString()); } - return ret; + return sb.ToString(); } private string ToSoup() { - string output; - output = String.Empty; - if (Data.Length == 0) - { + if(m_data == null || m_data.Length == 0) return String.Empty; - } - foreach (object o in Data) + + StringBuilder sb = new StringBuilder(1024); + foreach (object o in m_data) { - output = output + o.ToString(); + sb.Append(o.ToString()); } - return output; + return sb.ToString(); } public static explicit operator String(list l) @@ -1307,26 +1370,33 @@ namespace OpenSim.Region.ScriptEngine.Shared public string ToPrettyString() { - string output; - if (Data.Length == 0) - { + if(m_data == null || m_data.Length == 0) return "[]"; - } - output = "["; - foreach (object o in Data) + + StringBuilder sb = new StringBuilder(1024); + int len = m_data.Length; + int last = len - 1; + object o; + + sb.Append("["); + for(int i = 0; i < len; i++ ) { + o = m_data[i]; if (o is String) { - output = output + "\"" + o + "\", "; + sb.Append("\""); + sb.Append((String)o); + sb.Append("\""); } else { - output = output + o.ToString() + ", "; + sb.Append(o.ToString()); } + if(i < last) + sb.Append(","); } - output = output.Substring(0, output.Length - 2); - output = output + "]"; - return output; + sb.Append("]"); + return sb.ToString(); } public class AlphaCompare : IComparer @@ -1433,7 +1503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared return false; } } - + public static bool operator true(key k) { return (Boolean)k; @@ -1513,7 +1583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared string s = String.Format(Culture.FormatProvider, "{0:0.000000}", f.value); m_string = s; } - + public LSLString(int i) { string s = String.Format("{0}", i); @@ -1521,7 +1591,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } public LSLString(LSLInteger i) : this(i.value) {} - + #endregion #region Operators @@ -1537,8 +1607,6 @@ namespace OpenSim.Region.ScriptEngine.Shared } } - - static public implicit operator String(LSLString s) { return s.m_string; @@ -1588,7 +1656,7 @@ namespace OpenSim.Region.ScriptEngine.Shared { return new LSLString(d); } - + static public explicit operator LSLString(int i) { return new LSLString(i); @@ -1876,7 +1944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared return false; } } - + return value == ((LSLInteger)o).value; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs index d08b0a6..a5362a4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,7 +25,7 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs index af1da7c..2af4810 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs @@ -86,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestllSetLinkPrimitiveParamsForAgent() { +/* siting avatars position changed TestHelpers.InMethod(); // TestHelpers.EnableLogging(); @@ -153,6 +154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.Update(1); Assert.That(entityUpdates, Is.EqualTo(4)); } +*/ } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs index 9a5ebce..241a24d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs @@ -87,17 +87,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests uint port = 9999; MainServer.RemoveHttpServer(port); + m_engine = new MockScriptEngine(); + m_urlModule = new UrlModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Network"); + config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1"); + m_scene = new SceneHelpers().SetupScene(); + BaseHttpServer server = new BaseHttpServer(port, false, 0, ""); MainServer.AddHttpServer(server); MainServer.Instance = server; server.Start(); - m_engine = new MockScriptEngine(); - m_urlModule = new UrlModule(); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule); + SceneHelpers.SetupSceneModules(m_scene, config, m_engine, m_urlModule); SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); @@ -112,7 +116,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests public void TearDown() { MainServer.Instance.Stop(); - } + } [Test] public void TestLlReleaseUrl() @@ -155,8 +159,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } catch (WebException e) { - using (HttpWebResponse response = (HttpWebResponse)e.Response) - gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; +// using (HttpWebResponse response = (HttpWebResponse)e.Response) +// gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; + gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); @@ -203,8 +208,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check that request to URL works. string testResponse = "Hello World"; - m_engine.ClearPostedEvents(); - m_engine.PostEventHook + m_engine.ClearPostedEvents(); + m_engine.PostEventHook += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse); // Console.WriteLine("Trying {0}", returnedUri); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index 9b7cab2..16b87b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs @@ -39,6 +39,7 @@ using OpenSim.Framework; using OpenSim.Region.CoreModules.Avatar.AvatarFactory; using OpenSim.Region.OptionalModules.World.NPC; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.CoreModules.World.Permissions; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api; using OpenSim.Region.ScriptEngine.Shared.Instance; @@ -63,12 +64,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests base.SetUp(); IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); + IConfig config = initConfigSource.AddConfig("Startup"); + config.Set("serverside_object_permissions", true); + config =initConfigSource.AddConfig("Permissions"); + config.Set("permissionmodules", "DefaultPermissionsModule"); + config.Set("serverside_object_permissions", true); + config.Set("propagate_permissions", true); + + config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource); - + SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new object[] { new DefaultPermissionsModule() }); m_engine = new XEngine.XEngine(); m_engine.Initialise(initConfigSource); m_engine.AddRegion(m_scene); @@ -160,7 +167,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Item has copy permissions so original should stay intact. List originalItems = so1.RootPart.Inventory.GetInventoryItems(); Assert.That(originalItems.Count, Is.EqualTo(1)); - + // Should now have copied. List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); Assert.That(copiedItems.Count, Is.EqualTo(1)); @@ -194,7 +201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests api.llGiveInventory(user2Id.ToString(), inventoryItemName); - InventoryItemBase receivedItem + InventoryItemBase receivedItem = UserInventoryHelpers.GetInventoryItem( m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); @@ -222,7 +229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryItem tii + TaskInventoryItem tii = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); tii.NextPermissions &= ~((uint)PermissionMask.Modify); @@ -230,7 +237,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests api.llGiveInventory(user2Id.ToString(), inventoryItemName); - InventoryItemBase receivedItem + InventoryItemBase receivedItem = UserInventoryHelpers.GetInventoryItem( m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index 14b1890..435a95f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs @@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); - + grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; LSL_Api apiGrp1 = new LSL_Api(); @@ -156,7 +156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); - + grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; LSL_Api apiGrp1 = new LSL_Api(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs index 34a29e6..f978138 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs @@ -37,7 +37,7 @@ using OpenSim.Region.ScriptEngine.Shared.Api; using OpenSim.Region.ScriptEngine.Shared.Instance; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenMetaverse; - + using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; @@ -69,7 +69,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_lslApi = new LSL_Api(); m_lslApi.Initialize(engine, part, null); } - + [Test] public void TestllListFindList() { diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs index 9ab3115..a341311 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests string[] ncLines = { "One", "Twoè", "Three" }; - TaskInventoryItem ncItem + TaskInventoryItem ncItem = TaskInventoryHelpers.AddNotecard(m_scene.AssetService, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines)); AssertValidNotecardLine(ncItem.Name, 0, ncLines[0]); @@ -111,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests { string key = m_lslApi.llGetNotecardLine(ncName, lineNumber); Assert.That(key, Is.Not.EqualTo(UUID.Zero.ToString())); - + Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(1)); Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); @@ -223,8 +223,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // // Check that request to URL works. // string testResponse = "Hello World"; // -// m_engine.ClearPostedEvents(); -// m_engine.PostEventHook +// m_engine.ClearPostedEvents(); +// m_engine.PostEventHook // += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse); // //// Console.WriteLine("Trying {0}", returnedUri); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs index d957bf2..b994901 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check simple 1 prim case { - LSL_List resList + LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(1)); @@ -101,11 +101,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check 2 prim case { - LSL_List resList + LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( - 1, + 1, new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(2), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); @@ -115,7 +115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check invalid parameters are ignored { - LSL_List resList + LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(0)); @@ -123,11 +123,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check all parameters are ignored if an initial bad link is given { - LSL_List resList + LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( - 3, + 3, new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(1), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); @@ -137,11 +137,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Check only subsequent parameters are ignored when we hit the first bad link number { - LSL_List resList + LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( - 1, + 1, new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), + new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(3), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); @@ -197,7 +197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.90f, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.90f); // Prim hollow check @@ -211,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.99f, // Prim hollow new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.99f); // Prim hollow check @@ -252,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist // Expression for y selected to test precision problems during sbyte // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper + new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.70f); // Prim hollow check diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index d929da8..98800d0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -88,19 +88,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests CheckllAngleBetween(new Vector3(1, 1, 1), 0, 1, 1); CheckllAngleBetween(new Vector3(1, 1, 1), 90, 1, 1); CheckllAngleBetween(new Vector3(1, 1, 1), 180, 1, 1); - + CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1.6f, 1.8f); CheckllAngleBetween(new Vector3(1, 0, 0), 90, 0.3f, 3.9f); CheckllAngleBetween(new Vector3(1, 0, 0), 180, 8.8f, 7.4f); - + CheckllAngleBetween(new Vector3(0, 1, 0), 0, 9.8f, -9.4f); CheckllAngleBetween(new Vector3(0, 1, 0), 90, 8.4f, -8.2f); CheckllAngleBetween(new Vector3(0, 1, 0), 180, 0.4f, -5.8f); - + CheckllAngleBetween(new Vector3(0, 0, 1), 0, -6.8f, 3.4f); CheckllAngleBetween(new Vector3(0, 0, 1), 90, -3.6f, 5.6f); CheckllAngleBetween(new Vector3(0, 0, 1), 180, -3.8f, 1.1f); - + CheckllAngleBetween(new Vector3(1, 1, 1), 0, -7.7f, -2.0f); CheckllAngleBetween(new Vector3(1, 1, 1), 90, -3.0f, -9.1f); CheckllAngleBetween(new Vector3(1, 1, 1), 180, -7.9f, -8.0f); @@ -246,7 +246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests LSL_Types.Quaternion newRot = m_lslApi.llEuler2Rot(eulerCalc); // Multiple original quaternion by conjugate of quaternion calculated with angles. LSL_Types.Quaternion check = rot * new LSL_Types.Quaternion(-newRot.x, -newRot.y, -newRot.z, newRot.s); - + Assert.AreEqual(0.0, check.x, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler X bounds check fail"); Assert.AreEqual(0.0, check.y, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Y bounds check fail"); Assert.AreEqual(0.0, check.z, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Z bounds check fail"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs index c8c7f82..b2396fa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_stringDoubleSet.Add("1ef", 1.0); m_stringDoubleSet.Add("e10", 0.0); m_stringDoubleSet.Add("1.e0.0", 1.0); - + m_doubleStringSet = new Dictionary(); m_doubleStringSet.Add(2.0, "2.000000"); m_doubleStringSet.Add(-2.0, "-2.000000"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs index c664108..2bd684f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs @@ -131,7 +131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests public void TestImplicitCastBooleanToLSLInteger() { TestHelpers.InMethod(); - + LSL_Types.LSLInteger testInteger; testInteger = (1 == 0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs index 8550f2d..0159b9e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests public void TestImplicitCastBooleanToLSLFloat() { TestHelpers.InMethod(); - + LSL_Types.LSLString testString; testString = (LSL_Types.LSLString) (1 == 0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs index 71b88bc..fe2113b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs @@ -270,6 +270,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests TestHelpers.InMethod(); LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); + // make that nonsense a quaternion + testValue.Normalize(); LSL_Types.list testList = new LSL_Types.list(testValue); Assert.AreEqual(testValue, testList.GetQuaternionItem(0)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 99bff83..6936191 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs @@ -296,7 +296,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests string npcRaw = osslApi.osNpcCreate( "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_CREATOR_OWNED); - + otherOsslApi.osNpcRemove(npcRaw); // Should still be around @@ -340,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests string npcRaw = osslApi.osNpcCreate( "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); - + osslApi.osNpcRemove(npcRaw); UUID npcId = new UUID(npcRaw); -- cgit v1.1 From 295e91b8f44a356ab742dedd27c1b7edfe7b1157 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:15:41 +1000 Subject: Move cache, config, logs out of tree, and various related clean ups. --- OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs index e35f79f..6c42e2e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/AssemblyResolver.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.Shared string dirName = myDomain.FriendlyName; string ScriptEnginesPath = myDomain.SetupInformation.PrivateBinPath; - string[] pathList = new string[] {"", "bin", ScriptEnginesPath, + string[] pathList = new string[] {"", "caches", ScriptEnginesPath, Path.Combine(ScriptEnginesPath, dirName)}; string assemblyName = args.Name; -- cgit v1.1 From 7874a0b578acd49ecb981e1f1bdcbd33a67d16c6 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:39:27 +1000 Subject: Less Oh Silly Threat detection. Scripts run a little faster if they don't stop to be overly paranoid all the time. --- .../Shared/Api/Implementation/OSSL_Api.cs | 238 +++------------------ 1 file changed, 24 insertions(+), 214 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6e28fe0..5c03191 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -516,13 +516,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetTerrainHeight(int x, int y) { - CheckThreatLevel(); return GetTerrainHeight(x, y); } public LSL_Float osTerrainGetHeight(int x, int y) { - CheckThreatLevel(); OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); return GetTerrainHeight(x, y); } @@ -659,11 +657,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) { - // This may be upgraded depending on the griefing or DOS - // potential, or guarded with a delay - // - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -683,8 +676,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -704,8 +695,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -731,8 +720,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, int timer, int face) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -760,8 +747,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -788,8 +773,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - CheckThreatLevel(ThreatLevel.VeryLow , "osSetDynamicTextureDataBlendFace"); - if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -989,22 +972,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { // Threat level None because this is what can already be done with the World Map in the viewer - CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); } public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat); } public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); } @@ -1062,8 +1039,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // threat level is None as we could get this information with an // in-world script as well, just not as efficient - CheckThreatLevel(ThreatLevel.None, "osGetAgents"); - LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate(ScenePresence sp) { @@ -1173,104 +1148,78 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawResetTransform(string drawList) { - CheckThreatLevel(); - drawList += "ResetTransf;"; return drawList; } public string osDrawRotationTransform(string drawList, LSL_Float x) { - CheckThreatLevel(); - drawList += "RotTransf " + x + ";"; return drawList; } public string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) { - CheckThreatLevel(); - drawList += "ScaleTransf " + x + "," + y + ";"; return drawList; } public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) { - CheckThreatLevel(); - drawList += "TransTransf " + x + "," + y + ";"; return drawList; } public string osMovePen(string drawList, int x, int y) { - CheckThreatLevel(); - drawList += "MoveTo " + x + "," + y + ";"; return drawList; } public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) { - CheckThreatLevel(); - drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; return drawList; } public string osDrawLine(string drawList, int endX, int endY) { - CheckThreatLevel(); - drawList += "LineTo " + endX + "," + endY + "; "; return drawList; } public string osDrawText(string drawList, string text) { - CheckThreatLevel(ThreatLevel.None, "osDrawText"); - drawList += "Text " + text + "; "; return drawList; } public string osDrawEllipse(string drawList, int width, int height) { - CheckThreatLevel(); - drawList += "Ellipse " + width + "," + height + "; "; return drawList; } public string osDrawFilledEllipse(string drawList, int width, int height) { - CheckThreatLevel(); - drawList += "FillEllipse " + width + "," + height + "; "; return drawList; } public string osDrawRectangle(string drawList, int width, int height) { - CheckThreatLevel(); - drawList += "Rectangle " + width + "," + height + "; "; return drawList; } public string osDrawFilledRectangle(string drawList, int width, int height) { - CheckThreatLevel(); - drawList += "FillRectangle " + width + "," + height + "; "; return drawList; } public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) { - CheckThreatLevel(); - if (x.Length != y.Length || x.Length < 3) { return ""; @@ -1286,8 +1235,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawPolygon(string drawList, LSL_List x, LSL_List y) { - CheckThreatLevel(); - if (x.Length != y.Length || x.Length < 3) { return ""; @@ -1303,32 +1250,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetFontSize(string drawList, int fontSize) { - CheckThreatLevel(); - drawList += "FontSize "+ fontSize +"; "; return drawList; } public string osSetFontName(string drawList, string fontName) { - CheckThreatLevel(); - drawList += "FontName "+ fontName +"; "; return drawList; } public string osSetPenSize(string drawList, int penSize) { - CheckThreatLevel(); - drawList += "PenSize " + penSize + "; "; return drawList; } public string osSetPenColor(string drawList, string color) { - CheckThreatLevel(); - drawList += "PenColor " + color + "; "; return drawList; } @@ -1336,7 +1275,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Deprecated public string osSetPenColour(string drawList, string colour) { - CheckThreatLevel(); OSSLDeprecated("osSetPenColour", "osSetPenColor"); drawList += "PenColour " + colour + "; "; @@ -1345,24 +1283,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetPenCap(string drawList, string direction, string type) { - CheckThreatLevel(); - drawList += "PenCap " + direction + "," + type + "; "; return drawList; } public string osDrawImage(string drawList, int width, int height, string imageUrl) { - CheckThreatLevel(); - drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; return drawList; } public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) { - CheckThreatLevel(); - LSL_Vector vec = new LSL_Vector(0,0,0); IDynamicTextureManager textureManager = World.RequestModuleInterface(); if (textureManager != null) @@ -1403,7 +1335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) { - CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); + CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); while (sunHour > 24.0) sunHour -= 24.0; @@ -1426,7 +1358,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise public void osSetEstateSunSettings(bool sunFixed, double sunHour) { - CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); + CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); while (sunHour > 24.0) sunHour -= 24.0; @@ -1448,8 +1380,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public double osGetCurrentSunHour() { - CheckThreatLevel(); - // Must adjust for the fact that Region Sun Settings are still LL offset double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6; @@ -1465,14 +1395,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public double osSunGetParam(string param) { - CheckThreatLevel(ThreatLevel.None, "osSunGetParam"); OSSLDeprecated("osSunGetParam", "osGetSunParam"); return GetSunParam(param); } public double osGetSunParam(string param) { - CheckThreatLevel(); return GetSunParam(param); } @@ -1491,14 +1419,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSunSetParam(string param, double value) { - CheckThreatLevel(ThreatLevel.None, "osSunSetParam"); + CheckThreatLevel(ThreatLevel.Nuisance, "osSunSetParam"); OSSLDeprecated("osSunSetParam", "osSetSunParam"); SetSunParam(param, value); } public void osSetSunParam(string param, double value) { - CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); + CheckThreatLevel(ThreatLevel.Nuisance, "osSetSunParam"); SetSunParam(param, value); } @@ -1513,8 +1441,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osWindActiveModelPluginName() { - CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); - IWindModule module = World.RequestModuleInterface(); if (module != null) { @@ -1526,7 +1452,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetWindParam(string plugin, string param, LSL_Float value) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetWindParam"); + CheckThreatLevel(ThreatLevel.Nuisance, "osSetWindParam"); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1541,8 +1467,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetWindParam(string plugin, string param) { - CheckThreatLevel(ThreatLevel.VeryLow, "osGetWindParam"); - IWindModule module = World.RequestModuleInterface(); if (module != null) { @@ -1782,8 +1706,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // is not allowed to contain any. // This really should be removed. // - CheckThreatLevel(); - if (index < 0) { index = src.Length + index; @@ -1839,7 +1761,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // that trigger engine-specific failures. // Besides, public grid users aren't supposed to know. // - CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName"); + // And yet, they get to choose the engine in their scripts. Pfffft +// CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName"); int scriptEngineNameIndex = 0; @@ -1865,8 +1788,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osCheckODE() { - CheckThreatLevel(); - LSL_Integer ret = 0; // false if (m_ScriptEngine.World.PhysicsScene != null) { @@ -1892,7 +1813,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); string ret = String.Empty; - if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) +// if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) { if (m_ScriptEngine.World.PhysicsScene != null) { @@ -1928,7 +1849,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // require their user to know what they are doing (see script // kiddie) // - CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); + // Or they could check in the About window. Pfffft +// CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); return m_ScriptEngine.World.GetSimulatorVersion(); } @@ -1972,8 +1894,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Object osParseJSONNew(string JSON) { - CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); - try { OSD decoded = OSDParser.DeserializeJson(JSON); @@ -1988,8 +1908,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public Hashtable osParseJSON(string JSON) { - CheckThreatLevel(ThreatLevel.None, "osParseJSON"); - Object decoded = osParseJSONNew(JSON); if ( decoded is Hashtable ) { @@ -2019,8 +1937,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osMessageObject(LSL_Key objectUUID, string message) { - CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); - UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead. { @@ -2059,7 +1975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryHigh, "osDie"); // if this is restricted to objects rezzed by this host level can be reduced - CheckThreatLevel(ThreatLevel.Low, "osDie"); +// CheckThreatLevel(ThreatLevel.Low, "osDie"); UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) @@ -2108,7 +2024,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The contents of the notecard. public void osMakeNotecard(string notecardName, LSL_Types.list contents) { - CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); +// CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); StringBuilder notecardData = new StringBuilder(); @@ -2293,7 +2209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Notecard line public string osGetNotecardLine(string name, int line) { - CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); +// CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); UUID assetID = CacheNotecard(name); @@ -2320,7 +2236,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Notecard text public string osGetNotecard(string name) { - CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); +// CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); string text = LoadNotecard(name); @@ -2349,7 +2265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public int osGetNumberOfNotecardLines(string name) { - CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); +// CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); UUID assetID = CacheNotecard(name); @@ -2415,8 +2331,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osKey2Name(string id) { - CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); - UUID key = new UUID(); if (UUID.TryParse(id, out key)) @@ -2524,7 +2438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public string osGetGridNick() { - CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); +// CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); string nick = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2540,7 +2454,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridName() { - CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); +// CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); string name = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2556,7 +2470,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridLoginURI() { - CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); +// CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); string loginURI = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2572,7 +2486,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridHomeURI() { - CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); +// CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); IConfigSource config = m_ScriptEngine.ConfigSource; string HomeURI = Util.GetConfigVarFromSections(config, "HomeURI", @@ -2611,7 +2525,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridCustom(string key) { - CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); +// CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); string retval = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2627,7 +2541,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetAvatarHomeURI(string uuid) { - CheckThreatLevel(ThreatLevel.Low, "osGetAvatarHomeURI"); +// CheckThreatLevel(ThreatLevel.Low, "osGetAvatarHomeURI"); IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface(); string returnValue = ""; @@ -2659,15 +2573,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osFormatString(string str, LSL_List strings) { - CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); - return String.Format(str, strings.Data); } public LSL_List osMatchString(string src, string pattern, int start) { - CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString"); - LSL_List result = new LSL_List(); // Normalize indices (if negative). @@ -2707,8 +2617,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) { - CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString"); - // Normalize indices (if negative). // After normlaization they may still be // negative, but that is now relative to @@ -2731,22 +2639,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osLoadedCreationDate() { - CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate"); - return World.RegionInfo.RegionSettings.LoadedCreationDate; } public string osLoadedCreationTime() { - CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationTime"); - return World.RegionInfo.RegionSettings.LoadedCreationTime; } public string osLoadedCreationID() { - CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationID"); - return World.RegionInfo.RegionSettings.LoadedCreationID; } @@ -2765,7 +2667,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { - CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); + CheckThreatLevel(ThreatLevel.VeryLow, "osGetLinkPrimitiveParams"); InitLSL(); // One needs to cast m_LSL_Api because we're using functions not @@ -2817,8 +2719,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osIsNpc(LSL_Key npc) { - CheckThreatLevel(); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -2989,8 +2889,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The asset ID of the notecard saved. public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) { - CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3010,8 +2908,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcLoadAppearance(LSL_Key npc, string notecard) { - CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3041,8 +2937,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcGetOwner(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) { @@ -3062,8 +2956,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osNpcGetPos(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) { @@ -3085,8 +2977,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) { - CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3103,8 +2993,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { - CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3127,8 +3015,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation osNpcGetRot(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) { @@ -3150,8 +3036,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) { - CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); - INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) { @@ -3171,8 +3055,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopMoveToTarget(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3187,8 +3069,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetProfileAbout(LSL_Key npc, string about) { - CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileAbout"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3205,8 +3085,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetProfileImage(LSL_Key npc, string image) { - CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileImage"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3238,8 +3116,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSay(LSL_Key npc, int channel, string message) { - CheckThreatLevel(ThreatLevel.High, "osNpcSay"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3254,8 +3130,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcShout(LSL_Key npc, int channel, string message) { - CheckThreatLevel(ThreatLevel.High, "osNpcShout"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3270,8 +3144,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSit(LSL_Key npc, LSL_Key target, int options) { - CheckThreatLevel(ThreatLevel.High, "osNpcSit"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3286,8 +3158,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStand(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.High, "osNpcStand"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3302,8 +3172,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcRemove(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); - try { INPCModule module = World.RequestModuleInterface(); @@ -3322,8 +3190,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcPlayAnimation(LSL_Key npc, string animation) { - CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3336,8 +3202,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopAnimation(LSL_Key npc, string animation) { - CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3350,8 +3214,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcWhisper(LSL_Key npc, int channel, string message) { - CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); - INPCModule module = World.RequestModuleInterface(); if (module != null) { @@ -3366,8 +3228,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num) { - CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); - INPCModule module = World.RequestModuleInterface(); int linkNum = link_num.value; if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS)) @@ -3410,8 +3270,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The asset ID of the notecard saved. public LSL_Key osOwnerSaveAppearance(string notecard) { - CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); - return SaveAppearanceToNotecard(m_host.OwnerID, notecard); } @@ -3469,8 +3327,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// "male" or "female" or "unknown" public LSL_String osGetGender(LSL_Key rawAvatarId) { - CheckThreatLevel(ThreatLevel.None, "osGetGender"); - UUID avatarId; if (!UUID.TryParse(rawAvatarId, out avatarId)) return new LSL_String("unknown"); @@ -3512,8 +3368,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetMapTexture() { - CheckThreatLevel(); - return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); } @@ -3524,8 +3378,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetRegionMapTexture(string regionName) { - CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); - Scene scene = m_ScriptEngine.World; UUID key = UUID.Zero; GridRegion region; @@ -3568,8 +3420,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetRegionSize() { - CheckThreatLevel(); - Scene scene = m_ScriptEngine.World; RegionInfo reg = World.RegionInfo; // GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); @@ -3637,8 +3487,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetHealth(string avatar) { - CheckThreatLevel(ThreatLevel.None, "osGetHealth"); - LSL_Float health = new LSL_Float(-1); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); if (presence != null) @@ -3723,8 +3571,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetHealRate(string avatar) { - CheckThreatLevel(ThreatLevel.None, "osGetHealRate"); - LSL_Float rate = new LSL_Float(0); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); if (presence != null) @@ -3742,7 +3588,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) { - CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams"); + CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimitiveParams"); InitLSL(); m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams"); @@ -3791,8 +3637,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Strided list of the UUID, position and name of each avatar in the region public LSL_List osGetAvatarList() { - CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); - LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) { @@ -3809,8 +3653,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetNPCList() { - CheckThreatLevel(ThreatLevel.None, "osGetNPCList"); - LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) { @@ -3833,8 +3675,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String osUnixTimeToTimestamp(long time) { - CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp"); - long baseTicks = 621355968000000000; long tickResolution = 10000000; long epochTicks = (time * tickResolution) + baseTicks; @@ -3850,8 +3690,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Item description public LSL_String osGetInventoryDesc(string item) { - CheckThreatLevel(); - lock (m_host.TaskInventory) { foreach (KeyValuePair inv in m_host.TaskInventory) @@ -4064,7 +3902,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceDetachFromAvatar() { - CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); + CheckThreatLevel(ThreatLevel.VeryHigh, "osForceDetachFromAvatar"); InitLSL(); ((LSL_Api)m_LSL_Api).DetachFromAvatar(); @@ -4215,8 +4053,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// 1 if thing is a valid UUID, 0 otherwise public LSL_Integer osIsUUID(string thing) { - CheckThreatLevel(); - UUID test; return UUID.TryParse(thing, out test) ? 1 : 0; } @@ -4229,8 +4065,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMin(double a, double b) { - CheckThreatLevel(); - return Math.Min(a, b); } @@ -4242,15 +4076,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMax(double a, double b) { - CheckThreatLevel(); - return Math.Max(a, b); } public LSL_Key osGetRezzingObject() { - CheckThreatLevel(ThreatLevel.None, "osGetRezzingObject"); - UUID rezID = m_host.ParentGroup.RezzerID; if(rezID == UUID.Zero || m_host.ParentGroup.Scene.GetScenePresence(rezID) != null) return new LSL_Key(UUID.Zero.ToString()); @@ -4352,8 +4182,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) { - CheckThreatLevel(ThreatLevel.Low, "osListenRegex"); - UUID keyID; UUID.TryParse(ID, out keyID); @@ -4400,8 +4228,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osRegexIsMatch(string input, string pattern) { - CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch"); - try { return Regex.IsMatch(input, pattern) ? 1 : 0; @@ -4449,8 +4275,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osCollisionSound(string impact_sound, double impact_volume) { - CheckThreatLevel(); - if(impact_sound == "") { m_host.CollisionSoundVolume = (float)impact_volume; @@ -4503,8 +4327,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List osGetInertiaData() { - CheckThreatLevel(); - LSL_List result = new LSL_List(); float TotalMass; Vector3 CenterOfMass; @@ -4550,8 +4372,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return; @@ -4588,8 +4408,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return; @@ -4629,8 +4447,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return; @@ -4668,8 +4484,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return; @@ -4706,8 +4520,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osClearInertia() { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return; @@ -4792,8 +4604,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osGetLinkNumber(LSL_String name) { - CheckThreatLevel(); - SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) return -1; -- cgit v1.1 From afb347fbc0ae726ed352cc0b3cb10a483729639b Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:52:49 +1000 Subject: More script speed ups. Don't waste time collecting bogus statistics. At least I think they are bogus. --- .../Shared/Api/Implementation/CM_Api.cs | 1 - .../Shared/Api/Implementation/LSL_Api.cs | 533 --------------------- .../Shared/Api/Implementation/LS_Api.cs | 3 - .../Shared/Api/Implementation/OSSL_Api.cs | 3 - 4 files changed, 540 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index 3509968..c848555 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs @@ -93,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string cmDetectedCountry(int number) { - m_host.AddScriptLPS(1); if(!m_CMFunctionsEnabled) return String.Empty; if(World.UserAccountService == null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bac1468..3a3703c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -446,7 +446,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Sleep(delay); } - protected virtual void Sleep(int delay) { if (m_item == null) // Some unit tests don't set this @@ -481,8 +480,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api [DebuggerNonUserCode] public void llResetScript() { - m_host.AddScriptLPS(1); - // We need to tell the URL module, if we hav one, to release // the allocated URLs if (m_UrlModule != null) @@ -497,7 +494,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((item = GetScriptByName(name)) == UUID.Zero) { - m_host.AddScriptLPS(1); Error("llResetOtherScript", "Can't find script '" + name + "'"); return; } @@ -505,7 +501,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api llResetScript(); else { - m_host.AddScriptLPS(1); m_ScriptEngine.ResetScript(item); } } @@ -514,8 +509,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID item; - m_host.AddScriptLPS(1); - if ((item = GetScriptByName(name)) != UUID.Zero) { return m_ScriptEngine.GetScriptState(item) ?1:0; @@ -533,8 +526,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID item; - m_host.AddScriptLPS(1); - // These functions are supposed to be robust, // so get the state one step at a time. @@ -773,44 +764,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //These are the implementations of the various ll-functions used by the LSL scripts. public LSL_Float llSin(double f) { - m_host.AddScriptLPS(1); return (double)Math.Sin(f); } public LSL_Float llCos(double f) { - m_host.AddScriptLPS(1); return (double)Math.Cos(f); } public LSL_Float llTan(double f) { - m_host.AddScriptLPS(1); return (double)Math.Tan(f); } public LSL_Float llAtan2(double x, double y) { - m_host.AddScriptLPS(1); return (double)Math.Atan2(x, y); } public LSL_Float llSqrt(double f) { - m_host.AddScriptLPS(1); return (double)Math.Sqrt(f); } public LSL_Float llPow(double fbase, double fexponent) { - m_host.AddScriptLPS(1); return (double)Math.Pow(fbase, fexponent); } public LSL_Integer llAbs(int i) { // changed to replicate LSL behaviour whereby minimum int value is returned untouched. - m_host.AddScriptLPS(1); if (i == Int32.MinValue) return i; else @@ -819,13 +803,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llFabs(double f) { - m_host.AddScriptLPS(1); return (double)Math.Abs(f); } public LSL_Float llFrand(double mag) { - m_host.AddScriptLPS(1); lock (Util.RandomClass) { return Util.RandomClass.NextDouble() * mag; @@ -834,33 +816,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llFloor(double f) { - m_host.AddScriptLPS(1); return (int)Math.Floor(f); } public LSL_Integer llCeil(double f) { - m_host.AddScriptLPS(1); return (int)Math.Ceiling(f); } // Xantor 01/May/2008 fixed midpointrounding (2.5 becomes 3.0 instead of 2.0, default = ToEven) public LSL_Integer llRound(double f) { - m_host.AddScriptLPS(1); return (int)Math.Round(f, MidpointRounding.AwayFromZero); } //This next group are vector operations involving squaring and square root. ckrinke public LSL_Float llVecMag(LSL_Vector v) { - m_host.AddScriptLPS(1); return LSL_Vector.Mag(v); } public LSL_Vector llVecNorm(LSL_Vector v) { - m_host.AddScriptLPS(1); return LSL_Vector.Norm(v); } @@ -874,7 +851,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b) { - m_host.AddScriptLPS(1); return VecDist(a, b); } @@ -884,7 +860,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llRot2Euler(LSL_Rotation q1) { - m_host.AddScriptLPS(1); LSL_Vector eul = new LSL_Vector(); double sqw = q1.s*q1.s; @@ -958,8 +933,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llEuler2Rot(LSL_Vector v) { - m_host.AddScriptLPS(1); - double x,y,z,s; v.x *= 0.5; v.y *= 0.5; @@ -985,7 +958,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llAxes2Rot(LSL_Vector fwd, LSL_Vector left, LSL_Vector up) { - m_host.AddScriptLPS(1); double s; double tr = fwd.x + left.y + up.z + 1.0; @@ -1040,8 +1012,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llRot2Fwd(LSL_Rotation r) { - m_host.AddScriptLPS(1); - double x, y, z, m; m = r.x * r.x + r.y * r.y + r.z * r.z + r.s * r.s; @@ -1065,8 +1035,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llRot2Left(LSL_Rotation r) { - m_host.AddScriptLPS(1); - double x, y, z, m; m = r.x * r.x + r.y * r.y + r.z * r.z + r.s * r.s; @@ -1090,7 +1058,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llRot2Up(LSL_Rotation r) { - m_host.AddScriptLPS(1); double x, y, z, m; m = r.x * r.x + r.y * r.y + r.z * r.z + r.s * r.s; @@ -1115,7 +1082,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llRotBetween(LSL_Vector a, LSL_Vector b) { //A and B should both be normalized - m_host.AddScriptLPS(1); /* This method is more accurate than the SL one, and thus causes problems for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. @@ -1188,8 +1154,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llWhisper(int channelID, string text) { - m_host.AddScriptLPS(1); - if (text.Length > 1023) text = text.Substring(0, 1023); @@ -1215,8 +1179,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSay(int channelID, string text) { - m_host.AddScriptLPS(1); - if (channelID == 0) // m_SayShoutCount++; CheckSayShoutTime(); @@ -1244,8 +1206,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llShout(int channelID, string text) { - m_host.AddScriptLPS(1); - if (channelID == 0) // m_SayShoutCount++; CheckSayShoutTime(); @@ -1275,8 +1235,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (text.Length > 1023) text = text.Substring(0, 1023); - m_host.AddScriptLPS(1); - // debug channel is also sent to avatars if (channelID == ScriptBaseClass.DEBUG_CHANNEL) { @@ -1295,8 +1253,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (msg.Length > 1023) msg = msg.Substring(0, 1023); - m_host.AddScriptLPS(1); - if (channel == ScriptBaseClass.DEBUG_CHANNEL) return; @@ -1310,7 +1266,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llListen(int channelID, string name, string ID, string msg) { - m_host.AddScriptLPS(1); UUID keyID; UUID.TryParse(ID, out keyID); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); @@ -1322,7 +1277,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llListenControl(int number, int active) { - m_host.AddScriptLPS(1); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) wComm.ListenControl(m_item.ItemID, number, active); @@ -1330,7 +1284,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llListenRemove(int number) { - m_host.AddScriptLPS(1); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) wComm.ListenRemove(m_item.ItemID, number); @@ -1338,7 +1291,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSensor(string name, string id, int type, double range, double arc) { - m_host.AddScriptLPS(1); UUID keyID = UUID.Zero; UUID.TryParse(id, out keyID); @@ -1347,7 +1299,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { - m_host.AddScriptLPS(1); UUID keyID = UUID.Zero; UUID.TryParse(id, out keyID); @@ -1356,7 +1307,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSensorRemove() { - m_host.AddScriptLPS(1); AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID); } @@ -1397,7 +1347,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llDetectedName(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return String.Empty; @@ -1406,7 +1355,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llDetectedKey(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return String.Empty; @@ -1415,7 +1363,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llDetectedOwner(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return String.Empty; @@ -1424,7 +1371,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llDetectedType(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return 0; @@ -1433,7 +1379,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llDetectedPos(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return new LSL_Vector(); @@ -1442,7 +1387,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llDetectedVel(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return new LSL_Vector(); @@ -1451,7 +1395,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llDetectedGrab(int number) { - m_host.AddScriptLPS(1); DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (parms == null) return new LSL_Vector(0, 0, 0); @@ -1461,7 +1404,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llDetectedRot(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return new LSL_Rotation(); @@ -1470,7 +1412,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llDetectedGroup(int number) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return new LSL_Integer(0); @@ -1481,7 +1422,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llDetectedLinkNumber(int number) { - m_host.AddScriptLPS(1); DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (parms == null) return new LSL_Integer(0); @@ -1494,7 +1434,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llDetectedTouchBinormal(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Vector(); @@ -1506,7 +1445,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Integer llDetectedTouchFace(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Integer(-1); @@ -1518,7 +1456,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llDetectedTouchNormal(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Vector(); @@ -1530,7 +1467,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llDetectedTouchPos(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Vector(); @@ -1542,7 +1478,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llDetectedTouchST(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Vector(-1.0, -1.0, 0.0); @@ -1554,7 +1489,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llDetectedTouchUV(int index) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index); if (detectedParams == null) return new LSL_Vector(-1.0, -1.0, 0.0); @@ -1564,13 +1498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api [DebuggerNonUserCode] public virtual void llDie() { - m_host.AddScriptLPS(1); if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); } public LSL_Float llGround(LSL_Vector offset) { - m_host.AddScriptLPS(1); Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset; //Get the slope normal. This gives us the equation of the plane tangent to the slope. @@ -1600,7 +1532,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llCloud(LSL_Vector offset) { - m_host.AddScriptLPS(1); float cloudCover = 0f; ICloudModule module = World.RequestModuleInterface(); if (module != null) @@ -1617,7 +1548,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llWind(LSL_Vector offset) { - m_host.AddScriptLPS(1); LSL_Vector wind = new LSL_Vector(0, 0, 0); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1638,7 +1568,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) return; - m_host.AddScriptLPS(1); int statusrotationaxis = 0; @@ -1755,7 +1684,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetStatus(int status) { - m_host.AddScriptLPS(1); // m_log.Debug(m_host.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString()); switch (status) { @@ -1824,7 +1752,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llScaleByFactor(double scaling_factor) { - m_host.AddScriptLPS(1); SceneObjectGroup group = m_host.ParentGroup; if(scaling_factor < 1e-6) @@ -1849,7 +1776,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetMaxScaleFactor() { - m_host.AddScriptLPS(1); SceneObjectGroup group = m_host.ParentGroup; if (group == null || group.IsDeleted || group.inTransit) @@ -1860,7 +1786,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetMinScaleFactor() { - m_host.AddScriptLPS(1); SceneObjectGroup group = m_host.ParentGroup; if (group == null || group.IsDeleted || group.inTransit) @@ -1871,7 +1796,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetScale(LSL_Vector scale) { - m_host.AddScriptLPS(1); SetScale(m_host, scale); } @@ -1907,13 +1831,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetScale() { - m_host.AddScriptLPS(1); return new LSL_Vector(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); } public void llSetClickAction(int action) { - m_host.AddScriptLPS(1); m_host.ClickAction = (byte)action; m_host.ParentGroup.HasGroupChanged = true; m_host.ScheduleFullUpdate(); @@ -1922,8 +1844,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetColor(LSL_Vector color, int face) { - m_host.AddScriptLPS(1); - SetColor(m_host, color, face); } @@ -1976,8 +1896,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetContentType(LSL_Key id, LSL_Integer type) { - m_host.AddScriptLPS(1); - if (m_UrlModule == null) return; @@ -2204,8 +2122,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetAlpha(int face) { - m_host.AddScriptLPS(1); - return GetAlpha(m_host, face); } @@ -2230,15 +2146,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetAlpha(double alpha, int face) { - m_host.AddScriptLPS(1); - SetAlpha(m_host, alpha, face); } public void llSetLinkAlpha(int linknumber, double alpha, int face) { - m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); if (parts.Count > 0) { @@ -2375,7 +2287,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetColor(int face) { - m_host.AddScriptLPS(1); return GetColor(m_host, face); } @@ -2422,15 +2333,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetTexture(string texture, int face) { - m_host.AddScriptLPS(1); SetTexture(m_host, texture, face); ScriptSleep(m_sleepMsOnSetTexture); } public void llSetLinkTexture(int linknumber, string texture, int face) { - m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); if (parts.Count > 0) { @@ -2487,8 +2395,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llScaleTexture(double u, double v, int face) { - m_host.AddScriptLPS(1); - ScaleTexture(m_host, u, v, face); ScriptSleep(m_sleepMsOnScaleTexture); } @@ -2529,7 +2435,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llOffsetTexture(double u, double v, int face) { - m_host.AddScriptLPS(1); OffsetTexture(m_host, u, v, face); ScriptSleep(m_sleepMsOnOffsetTexture); } @@ -2570,7 +2475,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRotateTexture(double rotation, int face) { - m_host.AddScriptLPS(1); RotateTexture(m_host, rotation, face); ScriptSleep(m_sleepMsOnRotateTexture); } @@ -2608,7 +2512,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetTexture(int face) { - m_host.AddScriptLPS(1); return GetTexture(m_host, face); } @@ -2650,8 +2553,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPos(LSL_Vector pos) { - m_host.AddScriptLPS(1); - SetPos(m_host, pos, true); ScriptSleep(m_sleepMsOnSetPos); @@ -2666,8 +2567,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// 1 if successful, 0 otherwise. public LSL_Integer llSetRegionPos(LSL_Vector pos) { - m_host.AddScriptLPS(1); - // BEGIN WORKAROUND // IF YOU GET REGION CROSSINGS WORKING WITH THIS FUNCTION, REPLACE THE WORKAROUND. // @@ -2782,20 +2681,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetPos() { - m_host.AddScriptLPS(1); return m_host.GetWorldPosition(); } public LSL_Vector llGetLocalPos() { - m_host.AddScriptLPS(1); return GetPartLocalPos(m_host); } protected LSL_Vector GetPartLocalPos(SceneObjectPart part) { - m_host.AddScriptLPS(1); - Vector3 pos; if (!part.IsRoot) @@ -2817,8 +2712,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetRot(LSL_Rotation rot) { - m_host.AddScriptLPS(1); - // try to let this work as in SL... if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart)) { @@ -2840,7 +2733,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLocalRot(LSL_Rotation rot) { - m_host.AddScriptLPS(1); SetRot(m_host, rot); ScriptSleep(m_sleepMsOnSetLocalRot); } @@ -2902,7 +2794,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return llGetRootRotation(); } - m_host.AddScriptLPS(1); Quaternion q = m_host.GetWorldRotation(); if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0) @@ -2967,15 +2858,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private LSL_Rotation GetPartLocalRot(SceneObjectPart part) { - m_host.AddScriptLPS(1); Quaternion rot = part.RotationOffset; return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); } public void llSetForce(LSL_Vector force, int local) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { if (local != 0) @@ -2989,8 +2877,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { LSL_Vector force = new LSL_Vector(0.0, 0.0, 0.0); - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { force = m_host.ParentGroup.RootPart.GetForce(); @@ -3001,55 +2887,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVelocity(LSL_Vector vel, int local) { - m_host.AddScriptLPS(1); m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); } public void llSetAngularVelocity(LSL_Vector avel, int local) { - m_host.AddScriptLPS(1); m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); } public LSL_Integer llTarget(LSL_Vector position, double range) { - m_host.AddScriptLPS(1); return m_host.ParentGroup.registerTargetWaypoint(position, (float)range); } public void llTargetRemove(int number) { - m_host.AddScriptLPS(1); m_host.ParentGroup.unregisterTargetWaypoint(number); } public LSL_Integer llRotTarget(LSL_Rotation rot, double error) { - m_host.AddScriptLPS(1); return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error); } public void llRotTargetRemove(int number) { - m_host.AddScriptLPS(1); m_host.ParentGroup.unregisterRotTargetWaypoint(number); } public void llMoveToTarget(LSL_Vector target, double tau) { - m_host.AddScriptLPS(1); m_host.MoveToTarget(target, (float)tau); } public void llStopMoveToTarget() { - m_host.AddScriptLPS(1); m_host.StopMoveToTarget(); } public void llApplyImpulse(LSL_Vector force, int local) { - m_host.AddScriptLPS(1); //No energy force yet Vector3 v = force; if (v.Length() > 20000.0f) @@ -3063,26 +2940,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llApplyRotationalImpulse(LSL_Vector force, int local) { - m_host.AddScriptLPS(1); m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); } public void llSetTorque(LSL_Vector torque, int local) { - m_host.AddScriptLPS(1); m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); } public LSL_Vector llGetTorque() { - m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.ParentGroup.GetTorque()); } public void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local) { - m_host.AddScriptLPS(1); llSetForce(force, local); llSetTorque(torque, local); } @@ -3090,8 +2962,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetVel() { - m_host.AddScriptLPS(1); - Vector3 vel = Vector3.Zero; if (m_host.ParentGroup.IsAttachment) @@ -3110,46 +2980,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetAccel() { - m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.Acceleration); } public LSL_Vector llGetOmega() { - m_host.AddScriptLPS(1); Vector3 avel = m_host.AngularVelocity; return new LSL_Vector(avel.X, avel.Y, avel.Z); } public LSL_Float llGetTimeOfDay() { - m_host.AddScriptLPS(1); return (double)((DateTime.Now.TimeOfDay.TotalMilliseconds / 1000) % (3600 * 4)); } public LSL_Float llGetWallclock() { - m_host.AddScriptLPS(1); return DateTime.Now.TimeOfDay.TotalSeconds; } public LSL_Float llGetTime() { - m_host.AddScriptLPS(1); double ScriptTime = Util.GetTimeStampMS() - m_timer; return (float)Math.Round((ScriptTime / 1000.0), 3); } public void llResetTime() { - m_host.AddScriptLPS(1); m_timer = Util.GetTimeStampMS(); } public LSL_Float llGetAndResetTime() { - m_host.AddScriptLPS(1); double now = Util.GetTimeStampMS(); double ScriptTime = now - m_timer; m_timer = now; @@ -3158,7 +3020,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSound(string sound, double volume, int queue, int loop) { - m_host.AddScriptLPS(1); Deprecated("llSound", "Use llPlaySound instead"); } @@ -3166,8 +3027,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // 20080530 Updated to remove code duplication public void llPlaySound(string sound, double volume) { - m_host.AddScriptLPS(1); - // send the sound, once, to all clients in range if (m_SoundModule != null) { @@ -3181,7 +3040,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoopSound(string sound, double volume) { - m_host.AddScriptLPS(1); if (m_SoundModule != null) { m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), @@ -3191,7 +3049,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoopSoundMaster(string sound, double volume) { - m_host.AddScriptLPS(1); if (m_SoundModule != null) { m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), @@ -3201,7 +3058,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoopSoundSlave(string sound, double volume) { - m_host.AddScriptLPS(1); if (m_SoundModule != null) { m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), @@ -3211,8 +3067,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llPlaySoundSlave(string sound, double volume) { - m_host.AddScriptLPS(1); - // send the sound, once, to all clients in range if (m_SoundModule != null) { @@ -3224,7 +3078,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTriggerSound(string sound, double volume) { - m_host.AddScriptLPS(1); // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. if (m_SoundModule != null) { @@ -3236,15 +3089,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopSound() { - m_host.AddScriptLPS(1); - if (m_SoundModule != null) m_SoundModule.StopSound(m_host.UUID); } public void llPreloadSound(string sound) { - m_host.AddScriptLPS(1); if (m_SoundModule != null) m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0); ScriptSleep(m_sleepMsOnPreloadSound); @@ -3258,8 +3108,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String llGetSubString(string src, int start, int end) { - m_host.AddScriptLPS(1); - // Normalize indices (if negative). // After normlaization they may still be // negative, but that is now relative to @@ -3352,8 +3200,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String llDeleteSubString(string src, int start, int end) { - m_host.AddScriptLPS(1); - // Normalize indices (if negative). // After normlaization they may still be // negative, but that is now relative to @@ -3433,8 +3279,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String llInsertString(string dest, int index, string src) { - m_host.AddScriptLPS(1); - // Normalize indices (if negative). // After normlaization they may still be // negative, but that is now relative to @@ -3470,13 +3314,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llToUpper(string src) { - m_host.AddScriptLPS(1); return src.ToUpper(); } public LSL_String llToLower(string src) { - m_host.AddScriptLPS(1); return src.ToLower(); } @@ -3484,8 +3326,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { Util.FireAndForget(x => { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter == UUID.Zero) return; @@ -3522,28 +3362,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { - m_host.AddScriptLPS(1); Deprecated("llMakeExplosion", "Use llParticleSystem instead"); ScriptSleep(m_sleepMsOnMakeExplosion); } public void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset) { - m_host.AddScriptLPS(1); Deprecated("llMakeFountain", "Use llParticleSystem instead"); ScriptSleep(m_sleepMsOnMakeFountain); } public void llMakeSmoke(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { - m_host.AddScriptLPS(1); Deprecated("llMakeSmoke", "Use llParticleSystem instead"); ScriptSleep(m_sleepMsOnMakeSmoke); } public void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { - m_host.AddScriptLPS(1); Deprecated("llMakeFire", "Use llParticleSystem instead"); ScriptSleep(m_sleepMsOnMakeFire); } @@ -3555,7 +3391,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void doObjectRez(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param, bool atRoot) { - m_host.AddScriptLPS(1); if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) return; @@ -3634,8 +3469,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLookAt(LSL_Vector target, double strength, double damping) { - m_host.AddScriptLPS(1); - // Get the normalized vector to the target LSL_Vector from = llGetPos(); @@ -3682,7 +3515,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopLookAt() { - m_host.AddScriptLPS(1); m_host.StopLookAt(); } @@ -3690,7 +3522,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (sec != 0.0 && sec < m_MinTimerInterval) sec = m_MinTimerInterval; - m_host.AddScriptLPS(1); // Setting timer repeat AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec); } @@ -3698,15 +3529,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public virtual void llSleep(double sec) { // m_log.Info("llSleep snoozing " + sec + "s."); - m_host.AddScriptLPS(1); - Sleep((int)(sec * 1000)); } public LSL_Float llGetMass() { - m_host.AddScriptLPS(1); - if (m_host.ParentGroup.IsAttachment) { ScenePresence attachedAvatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); @@ -3741,7 +3568,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCollisionFilter(string name, string id, int accept) { - m_host.AddScriptLPS(1); m_host.CollisionFilter.Clear(); UUID objectID; @@ -3768,14 +3594,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - - m_host.AddScriptLPS(1); } public void llReleaseControls() { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter != UUID.Zero) { ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); @@ -3795,7 +3617,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llReleaseURL(string url) { - m_host.AddScriptLPS(1); if (m_UrlModule != null) m_UrlModule.ReleaseURL(url); } @@ -3843,8 +3664,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAttachToAvatar(int attachmentPoint) { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter != m_host.OwnerID) return; @@ -3854,8 +3673,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llDetachFromAvatar() { - m_host.AddScriptLPS(1); - if (m_host.ParentGroup.AttachmentPoint == 0) return; @@ -3868,26 +3685,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTakeCamera(string avatar) { - m_host.AddScriptLPS(1); Deprecated("llTakeCamera", "Use llSetCameraParams instead"); } public void llReleaseCamera(string avatar) { - m_host.AddScriptLPS(1); Deprecated("llReleaseCamera", "Use llClearCameraParams instead"); } public LSL_String llGetOwner() { - m_host.AddScriptLPS(1); - return m_host.OwnerID.ToString(); } public void llInstantMessage(string user, string message) { - m_host.AddScriptLPS(1); UUID result; if (!UUID.TryParse(user, out result) || result == UUID.Zero) { @@ -3946,7 +3758,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llEmail(string address, string subject, string message) { - m_host.AddScriptLPS(1); IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface(); if (emailModule == null) { @@ -3984,7 +3795,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGetNextEmail(string address, string subject) { - m_host.AddScriptLPS(1); IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface(); if (emailModule == null) { @@ -4012,20 +3822,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetKey() { - m_host.AddScriptLPS(1); return m_host.UUID.ToString(); } public LSL_Key llGenerateKey() { - m_host.AddScriptLPS(1); return UUID.Random().ToString(); } public void llSetBuoyancy(double buoyancy) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); @@ -4040,8 +3846,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Number of seconds over which to reach target public void llSetHoverHeight(double height, int water, double tau) { - m_host.AddScriptLPS(1); - PIDHoverType hoverType = PIDHoverType.Ground; if (water != 0) { @@ -4052,13 +3856,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopHover() { - m_host.AddScriptLPS(1); m_host.SetHoverHeight(0f, PIDHoverType.Ground, 0f); } public void llMinEventDelay(double delay) { - m_host.AddScriptLPS(1); try { m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay); @@ -4072,14 +3874,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSoundPreload(string sound) { - m_host.AddScriptLPS(1); Deprecated("llSoundPreload", "Use llPreloadSound instead"); } public void llRotLookAt(LSL_Rotation target, double strength, double damping) { - m_host.AddScriptLPS(1); - // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior SceneObjectGroup sog = m_host.ParentGroup; @@ -4098,7 +3897,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llStringLength(string str) { - m_host.AddScriptLPS(1); if (str.Length > 0) { return str.Length; @@ -4111,8 +3909,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStartAnimation(string anim) { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter == UUID.Zero) return; @@ -4134,8 +3930,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopAnimation(string anim) { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter == UUID.Zero) return; @@ -4157,17 +3951,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llPointAt(LSL_Vector pos) { - m_host.AddScriptLPS(1); } public void llStopPointAt() { - m_host.AddScriptLPS(1); } public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) { - m_host.AddScriptLPS(1); TargetOmega(m_host, axis, spinrate, gain); } @@ -4181,7 +3972,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetStartParameter() { - m_host.AddScriptLPS(1); return m_ScriptEngine.GetStartParameter(m_item.ItemID); } @@ -4210,8 +4000,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); - m_host.AddScriptLPS(1); - int implicitPerms = 0; if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) @@ -4338,15 +4126,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetPermissionsKey() { - m_host.AddScriptLPS(1); - return m_item.PermsGranter.ToString(); } public LSL_Integer llGetPermissions() { - m_host.AddScriptLPS(1); - int perms = m_item.PermsMask; if (m_automaticLinkPermission) @@ -4357,8 +4141,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetLinkNumber() { - m_host.AddScriptLPS(1); - if (m_host.ParentGroup.PrimCount > 1) { return m_host.LinkNum; @@ -4385,8 +4167,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(string target, int parent) { - m_host.AddScriptLPS(1); - UUID targetID; if (!UUID.TryParse(target, out targetID)) @@ -4449,14 +4229,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (client != null) parentPrim.SendPropertiesToClient(client); - - ScriptSleep(m_sleepMsOnCreateLink); } public void llBreakLink(int linknum) { - m_host.AddScriptLPS(1); - if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { @@ -4556,8 +4332,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llBreakAllLinks() { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_item; if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 @@ -4589,7 +4363,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLinkKey(int linknum) { - m_host.AddScriptLPS(1); SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); if (part != null) { @@ -4655,8 +4428,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String llGetLinkName(int linknum) { - m_host.AddScriptLPS(1); - ISceneEntity entity = GetLinkEntity(m_host, linknum); if (entity != null) @@ -4667,7 +4438,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetInventoryNumber(int type) { - m_host.AddScriptLPS(1); int count = 0; m_host.TaskInventory.LockItemsForRead(true); @@ -4685,7 +4455,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetInventoryName(int type, int number) { - m_host.AddScriptLPS(1); ArrayList keys = new ArrayList(); m_host.TaskInventory.LockItemsForRead(true); @@ -4712,15 +4481,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetEnergy() { - m_host.AddScriptLPS(1); // TODO: figure out real energy value return 1.0f; } public void llGiveInventory(string destination, string inventory) { - m_host.AddScriptLPS(1); - UUID destId = UUID.Zero; if (!UUID.TryParse(destination, out destId)) @@ -4811,8 +4577,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api [DebuggerNonUserCode] public void llRemoveInventory(string name) { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); if (item == null) @@ -4826,7 +4590,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetText(string text, LSL_Vector color, double alpha) { - m_host.AddScriptLPS(1); Vector3 av3 = Util.Clip(color, 0.0f, 1.0f); byte[] data; data = Util.StringToBytes256(text); @@ -4836,13 +4599,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llWater(LSL_Vector offset) { - m_host.AddScriptLPS(1); return World.RegionInfo.RegionSettings.WaterHeight; } public void llPassTouches(int pass) { - m_host.AddScriptLPS(1); if (pass != 0) m_host.PassTouches = true; else @@ -4851,8 +4612,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llRequestAgentData(string id, int data) { - m_host.AddScriptLPS(1); - UUID uuid; if (UUID.TryParse(id, out uuid)) { @@ -4957,7 +4716,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands. DataserverPlugin.DataserverReply(rq.ToString(), reply); - ScriptSleep(m_sleepMsOnRequestAgentData); return tid.ToString(); } else @@ -4969,8 +4727,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llRequestInventoryData(string name) { - m_host.AddScriptLPS(1); - foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) { if (item.Type == 3 && item.Name == name) @@ -5007,13 +4763,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetDamage(double damage) { - m_host.AddScriptLPS(1); m_host.ParentGroup.Damage = (float)damage; } public void llTeleportAgentHome(string agent) { - m_host.AddScriptLPS(1); UUID agentId = new UUID(); if (UUID.TryParse(agent, out agentId)) { @@ -5046,7 +4800,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt) { - m_host.AddScriptLPS(1); UUID agentId = new UUID(); if (UUID.TryParse(agent, out agentId)) @@ -5089,7 +4842,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt) { - m_host.AddScriptLPS(1); UUID agentId = new UUID(); ulong regionHandle = Util.RegionWorldLocToHandle((uint)global_coords.x, (uint)global_coords.y); @@ -5154,7 +4906,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dm == null) return; - m_host.AddScriptLPS(1); UUID av = new UUID(); if (!UUID.TryParse(agent,out av)) { @@ -5179,7 +4930,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llModifyLand(int action, int brush) { - m_host.AddScriptLPS(1); ITerrainModule tm = m_ScriptEngine.World.RequestModuleInterface(); if (tm != null) { @@ -5189,8 +4939,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCollisionSound(string impact_sound, double impact_volume) { - m_host.AddScriptLPS(1); - if(impact_sound == "") { m_host.CollisionSoundVolume = (float)impact_volume; @@ -5217,7 +4965,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetAnimation(string id) { // This should only return a value if the avatar is in the same region - m_host.AddScriptLPS(1); UUID avatar = (UUID)id; ScenePresence presence = World.GetScenePresence(avatar); if (presence == null) @@ -5245,8 +4992,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llMessageLinked(int linknumber, int num, string msg, string id) { - m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); UUID partItemID; @@ -5276,7 +5021,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local) { - m_host.AddScriptLPS(1); bool pushrestricted = World.RegionInfo.RegionSettings.RestrictPushing; bool pushAllowed = false; @@ -5443,7 +5187,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llPassCollisions(int pass) { - m_host.AddScriptLPS(1); if (pass == 0) { m_host.PassCollisions = false; @@ -5456,15 +5199,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetScriptName() { - m_host.AddScriptLPS(1); - return m_item.Name != null ? m_item.Name : String.Empty; } public LSL_Integer llGetLinkNumberOfSides(int link) { - m_host.AddScriptLPS(1); - SceneObjectPart linkedPart; if (link == ScriptBaseClass.LINK_ROOT) @@ -5479,8 +5218,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetNumberOfSides() { - m_host.AddScriptLPS(1); - return m_host.GetNumberOfSides(); } @@ -5518,8 +5255,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) public LSL_Rotation llAxisAngle2Rot(LSL_Vector axis, double angle) { - m_host.AddScriptLPS(1); - double x, y, z, s, t; s = Math.Cos(angle * 0.5); @@ -5539,8 +5274,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llRot2Axis(LSL_Rotation rot) { - m_host.AddScriptLPS(1); - rot.Normalize(); double s = Math.Sqrt(1 - rot.s * rot.s); @@ -5557,8 +5290,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Returns the angle of a quaternion (see llRot2Axis for the axis) public LSL_Float llRot2Angle(LSL_Rotation rot) { - m_host.AddScriptLPS(1); - rot.Normalize(); double angle = 2 * Math.Acos(rot.s); @@ -5570,21 +5301,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llAcos(double val) { - m_host.AddScriptLPS(1); return (double)Math.Acos(val); } public LSL_Float llAsin(double val) { - m_host.AddScriptLPS(1); return (double)Math.Asin(val); } // jcochran 5/jan/2012 public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b) { - m_host.AddScriptLPS(1); - double aa = (a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s); double bb = (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s); double aa_bb = aa * bb; @@ -5597,8 +5324,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetInventoryKey(string name) { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); if (item == null) @@ -5616,8 +5341,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAllowInventoryDrop(int add) { - m_host.AddScriptLPS(1); - if (add != 0) m_host.ParentGroup.RootPart.AllowedDrop = true; else @@ -5629,8 +5352,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetSunDirection() { - m_host.AddScriptLPS(1); - LSL_Vector SunDoubleVector3; Vector3 SunFloatVector3; @@ -5646,7 +5367,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetTextureOffset(int face) { - m_host.AddScriptLPS(1); return GetTextureOffset(m_host, face); } @@ -5673,7 +5393,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetTextureScale(int side) { - m_host.AddScriptLPS(1); Primitive.TextureEntry tex = m_host.Shape.Textures; LSL_Vector scale; if (side == -1) @@ -5688,7 +5407,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetTextureRot(int face) { - m_host.AddScriptLPS(1); return GetTextureRot(m_host, face); } @@ -5711,13 +5429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llSubStringIndex(string source, string pattern) { - m_host.AddScriptLPS(1); return source.IndexOf(pattern); } public LSL_String llGetOwnerKey(string id) { - m_host.AddScriptLPS(1); UUID key = new UUID(); if (UUID.TryParse(id, out key)) { @@ -5742,15 +5458,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetCenterOfMass() { - m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.GetCenterOfMass()); } public LSL_List llListSort(LSL_List src, int stride, int ascending) { - m_host.AddScriptLPS(1); - if (stride <= 0) { stride = 1; @@ -5760,14 +5472,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetListLength(LSL_List src) { - m_host.AddScriptLPS(1); - return src.Length; } public LSL_Integer llList2Integer(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5797,7 +5506,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llList2Float(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5852,7 +5560,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llList2String(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5864,7 +5571,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key llList2Key(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5892,7 +5598,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llList2Vector(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5921,7 +5626,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llList2Rot(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) index = src.Length + index; @@ -5948,7 +5652,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llList2List(LSL_List src, int start, int end) { - m_host.AddScriptLPS(1); return src.GetSublist(start, end); } @@ -5959,7 +5662,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetListEntryType(LSL_List src, int index) { - m_host.AddScriptLPS(1); if (index < 0) { index = src.Length + index; @@ -6003,8 +5705,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_String llList2CSV(LSL_List src) { - m_host.AddScriptLPS(1); - return string.Join(", ", (new List(src.Data)).ConvertAll(o => { @@ -6028,8 +5728,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int start = 0; int length = 0; - m_host.AddScriptLPS(1); - for (int i = 0; i < src.Length; i++) { switch (src[i]) @@ -6085,8 +5783,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int chunkk; int[] chunks; - m_host.AddScriptLPS(1); - if (stride <= 0) { stride = 1; @@ -6157,8 +5853,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int[] ei = new int[2]; bool twopass = false; - m_host.AddScriptLPS(1); - // First step is always to deal with negative indices if (start < 0) @@ -6238,8 +5932,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetRegionAgentCount() { - m_host.AddScriptLPS(1); - int count = 0; World.ForEachRootScenePresence(delegate(ScenePresence sp) { count++; @@ -6250,13 +5942,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetRegionCorner() { - m_host.AddScriptLPS(1); return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); } public LSL_String llGetEnv(LSL_String name) { - m_host.AddScriptLPS(1); if (name == "agent_limit") { return World.RegionInfo.RegionSettings.AgentLimit.ToString(); @@ -6340,8 +6030,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List pref; LSL_List suff; - m_host.AddScriptLPS(1); - if (index < 0) { index = index+dest.Length; @@ -6394,8 +6082,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int index = -1; int length = src.Length - test.Length + 1; - m_host.AddScriptLPS(1); - // If either list is empty, do not match if (src.Length != 0 && test.Length != 0) { @@ -6435,19 +6121,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetObjectName() { - m_host.AddScriptLPS(1); return m_host.Name !=null ? m_host.Name : String.Empty; } public void llSetObjectName(string name) { - m_host.AddScriptLPS(1); m_host.Name = name != null ? name : String.Empty; } public LSL_String llGetDate() { - m_host.AddScriptLPS(1); DateTime date = DateTime.Now.ToUniversalTime(); string result = date.ToString("yyyy-MM-dd"); return result; @@ -6455,8 +6138,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llEdgeOfWorld(LSL_Vector pos, LSL_Vector dir) { - m_host.AddScriptLPS(1); - if(dir.x == 0 && dir.y == 0) return 1; // SL wiki @@ -6522,8 +6203,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Integer llGetAgentInfo(string id) { - m_host.AddScriptLPS(1); - UUID key = new UUID(); if (!UUID.TryParse(id, out key)) { @@ -6630,7 +6309,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetAgentLanguage(string id) { // This should only return a value if the avatar is in the same region, but eh. idc. - m_host.AddScriptLPS(1); if (World.AgentPreferencesService == null) { Error("llGetAgentLanguage", "No AgentPreferencesService present"); @@ -6657,8 +6335,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options) { - m_host.AddScriptLPS(1); - // do our bit masks part bool noNPC = (scope & ScriptBaseClass.AGENT_LIST_EXCLUDENPC) !=0; @@ -6740,20 +6416,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAdjustSoundVolume(double volume) { - m_host.AddScriptLPS(1); m_host.AdjustSoundGain(volume); ScriptSleep(m_sleepMsOnAdjustSoundVolume); } public void llSetSoundRadius(double radius) { - m_host.AddScriptLPS(1); m_host.SoundRadius = radius; } public LSL_String llKey2Name(string id) { - m_host.AddScriptLPS(1); UUID key = new UUID(); if (UUID.TryParse(id,out key)) { @@ -6777,15 +6450,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { - m_host.AddScriptLPS(1); - SetTextureAnim(m_host, mode, face, sizex, sizey, start, length, rate); } public void llSetLinkTextureAnim(int linknumber, int mode, int face, int sizex, int sizey, double start, double length, double rate) { - m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); try @@ -6825,7 +6494,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTriggerSoundLimited(string sound, double volume, LSL_Vector top_north_east, LSL_Vector bottom_south_west) { - m_host.AddScriptLPS(1); if (m_SoundModule != null) { m_SoundModule.TriggerSoundLimited(m_host.UUID, @@ -6836,7 +6504,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llEjectFromLand(string pest) { - m_host.AddScriptLPS(1); UUID agentID = new UUID(); if (UUID.TryParse(pest, out agentID)) { @@ -6866,7 +6533,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llOverMyLand(string id) { - m_host.AddScriptLPS(1); UUID key = new UUID(); if (UUID.TryParse(id, out key)) { @@ -6893,7 +6559,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLandOwnerAt(LSL_Vector pos) { - m_host.AddScriptLPS(1); ILandObject land = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); if (land == null) return UUID.Zero.ToString(); @@ -6907,7 +6572,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Vector llGetAgentSize(string id) { - m_host.AddScriptLPS(1); ScenePresence avatar = World.GetScenePresence((UUID)id); LSL_Vector agentSize; if (avatar == null || avatar.IsChildAgent) // Fail if not in the same region @@ -6925,7 +6589,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llSameGroup(string id) { - m_host.AddScriptLPS(1); UUID uuid = new UUID(); if (!UUID.TryParse(id, out uuid)) return new LSL_Integer(0); @@ -6973,8 +6636,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llUnSit(string id) { - m_host.AddScriptLPS(1); - UUID key = new UUID(); if (UUID.TryParse(id, out key)) { @@ -7014,8 +6675,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGroundSlope(LSL_Vector offset) { - m_host.AddScriptLPS(1); - //Get the slope normal. This gives us the equation of the plane tangent to the slope. LSL_Vector vsn = llGroundNormal(offset); @@ -7035,7 +6694,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGroundNormal(LSL_Vector offset) { - m_host.AddScriptLPS(1); Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset; // Clamp to valid position if (pos.X < 0) @@ -7085,21 +6743,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGroundContour(LSL_Vector offset) { - m_host.AddScriptLPS(1); LSL_Vector x = llGroundSlope(offset); return new LSL_Vector(-x.y, x.x, 0.0); } public LSL_Integer llGetAttached() { - m_host.AddScriptLPS(1); return m_host.ParentGroup.AttachmentPoint; } public LSL_List llGetAttachedList(string id) { - m_host.AddScriptLPS(1); - ScenePresence av = World.GetScenePresence((UUID)id); if (av == null || av.IsDeleted) @@ -7125,14 +6779,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public virtual LSL_Integer llGetFreeMemory() { - m_host.AddScriptLPS(1); // Make scripts designed for Mono happy return 65536; } public LSL_Integer llGetFreeURLs() { - m_host.AddScriptLPS(1); if (m_UrlModule != null) return new LSL_Integer(m_UrlModule.GetFreeUrls()); return new LSL_Integer(0); @@ -7141,13 +6793,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetRegionName() { - m_host.AddScriptLPS(1); return World.RegionInfo.RegionName; } public LSL_Float llGetRegionTimeDilation() { - m_host.AddScriptLPS(1); return (double)World.TimeDilation; } @@ -7156,7 +6806,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float llGetRegionFPS() { - m_host.AddScriptLPS(1); return World.StatsReporter.LastReportedSimFPS; } @@ -7234,8 +6883,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLinkParticleSystem(int linknumber, LSL_List rules) { - m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); foreach (SceneObjectPart part in parts) @@ -7246,7 +6893,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llParticleSystem(LSL_List rules) { - m_host.AddScriptLPS(1); SetParticleSystem(m_host, rules, "llParticleSystem"); } @@ -7663,7 +7309,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGroundRepel(double height, int water, double tau) { - m_host.AddScriptLPS(1); if (m_host.PhysActor != null) { float ground = (float)llGround(new LSL_Types.Vector3(0, 0, 0)); @@ -7688,8 +7333,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGiveInventoryList(string destination, string category, LSL_List inventory) { - m_host.AddScriptLPS(1); - UUID destID; if (!UUID.TryParse(destination, out destID)) return; @@ -7743,8 +7386,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVehicleType(int type) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleType(type); @@ -7755,8 +7396,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //CFK 9/28: so these are not complete yet. public void llSetVehicleFloatParam(int param, LSL_Float value) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleFloatParam(param, (float)value); @@ -7767,8 +7406,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //CFK 9/28: so these are not complete yet. public void llSetVehicleVectorParam(int param, LSL_Vector vec) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec); @@ -7779,8 +7416,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //CFK 9/28: so these are not complete yet. public void llSetVehicleRotationParam(int param, LSL_Rotation rot) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot); @@ -7789,8 +7424,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVehicleFlags(int flags) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false); @@ -7799,8 +7432,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoveVehicleFlags(int flags) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) { m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true); @@ -7820,13 +7451,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) { - m_host.AddScriptLPS(1); SitTarget(m_host, offset, rot); } public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot) { - m_host.AddScriptLPS(1); if (link == ScriptBaseClass.LINK_ROOT) SitTarget(m_host.ParentGroup.RootPart, offset, rot); else if (link == ScriptBaseClass.LINK_THIS) @@ -7843,14 +7472,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llAvatarOnSitTarget() { - m_host.AddScriptLPS(1); return m_host.SitTargetAvatar.ToString(); } // http://wiki.secondlife.com/wiki/LlAvatarOnLinkSitTarget public LSL_String llAvatarOnLinkSitTarget(int linknum) { - m_host.AddScriptLPS(1); if(linknum == ScriptBaseClass.LINK_SET || linknum == ScriptBaseClass.LINK_ALL_CHILDREN || linknum == ScriptBaseClass.LINK_ALL_OTHERS || @@ -7866,7 +7493,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAddToLandPassList(string avatar, double hours) { - m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); @@ -7903,24 +7529,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } - ScriptSleep(m_sleepMsOnAddToLandPassList); } public void llSetTouchText(string text) { - m_host.AddScriptLPS(1); m_host.TouchName = text; } public void llSetSitText(string text) { - m_host.AddScriptLPS(1); m_host.SitName = text; } public void llSetCameraEyeOffset(LSL_Vector offset) { - m_host.AddScriptLPS(1); m_host.SetCameraEyeOffset(offset); if (m_host.ParentGroup.RootPart.GetCameraEyeOffset() == Vector3.Zero) @@ -7929,7 +7551,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetCameraAtOffset(LSL_Vector offset) { - m_host.AddScriptLPS(1); m_host.SetCameraAtOffset(offset); if (m_host.ParentGroup.RootPart.GetCameraAtOffset() == Vector3.Zero) @@ -7938,8 +7559,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) { - m_host.AddScriptLPS(1); - if (link == ScriptBaseClass.LINK_SET || link == ScriptBaseClass.LINK_ALL_CHILDREN || link == ScriptBaseClass.LINK_ALL_OTHERS) return; @@ -7968,7 +7587,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llDumpList2String(LSL_List src, string seperator) { - m_host.AddScriptLPS(1); if (src.Length == 0) { return String.Empty; @@ -7984,7 +7602,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llScriptDanger(LSL_Vector pos) { - m_host.AddScriptLPS(1); bool result = World.LSLScriptDanger(m_host, pos); if (result) { @@ -8003,7 +7620,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dm == null) return; - m_host.AddScriptLPS(1); UUID av = new UUID(); if (!UUID.TryParse(avatar,out av)) { @@ -8059,29 +7675,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llVolumeDetect(int detect) { - m_host.AddScriptLPS(1); - if (!m_host.ParentGroup.IsDeleted) m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0); } public void llRemoteLoadScript(string target, string name, int running, int start_param) { - m_host.AddScriptLPS(1); Deprecated("llRemoteLoadScript", "Use llRemoteLoadScriptPin instead"); ScriptSleep(m_sleepMsOnRemoteLoadScript); } public void llSetRemoteScriptAccessPin(int pin) { - m_host.AddScriptLPS(1); m_host.ScriptAccessPin = pin; } public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { - m_host.AddScriptLPS(1); - UUID destId = UUID.Zero; if (!UUID.TryParse(target, out destId)) @@ -8124,7 +7734,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llOpenRemoteDataChannel() { - m_host.AddScriptLPS(1); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null && xmlrpcMod.IsEnabled()) { @@ -8155,7 +7764,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llSendRemoteData(string channel, string dest, int idata, string sdata) { - m_host.AddScriptLPS(1); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); ScriptSleep(m_sleepMsOnSendRemoteData); if (xmlrpcMod == null) @@ -8165,7 +7773,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { - m_host.AddScriptLPS(1); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null) xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata); @@ -8174,8 +7781,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCloseRemoteDataChannel(string channel) { - m_host.AddScriptLPS(1); - IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface(); if (xmlRpcRouter != null) { @@ -8190,13 +7795,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llMD5String(string src, int nonce) { - m_host.AddScriptLPS(1); return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); } public LSL_String llSHA1String(string src) { - m_host.AddScriptLPS(1); return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); } @@ -8588,8 +8191,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimitiveParams(LSL_List rules) { - m_host.AddScriptLPS(1); - SetLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams"); ScriptSleep(m_sleepMsOnSetPrimitiveParams); @@ -8597,8 +8198,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) { - m_host.AddScriptLPS(1); - SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); ScriptSleep(m_sleepMsOnSetLinkPrimitiveParams); @@ -8606,8 +8205,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) { - m_host.AddScriptLPS(1); - SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); } @@ -10359,7 +9956,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llStringToBase64(string str) { - m_host.AddScriptLPS(1); try { byte[] encData_byte; @@ -10376,7 +9972,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llBase64ToString(string str) { - m_host.AddScriptLPS(1); try { byte[] b = Convert.FromBase64String(str); @@ -10396,8 +9991,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; ScriptSleep(300); - m_host.AddScriptLPS(1); - if (str1 == String.Empty) return String.Empty; if (str2 == String.Empty) @@ -10493,26 +10086,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoteDataSetRegion() { - m_host.AddScriptLPS(1); Deprecated("llRemoteDataSetRegion", "Use llOpenRemoteDataChannel instead"); } public LSL_Float llLog10(double val) { - m_host.AddScriptLPS(1); return (double)Math.Log10(val); } public LSL_Float llLog(double val) { - m_host.AddScriptLPS(1); return (double)Math.Log(val); } public LSL_List llGetAnimationList(string id) { - m_host.AddScriptLPS(1); - LSL_List l = new LSL_List(); ScenePresence av = World.GetScenePresence((UUID)id); if (av == null || av.IsChildAgent) // only if in the region @@ -10526,8 +10114,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetParcelMusicURL(string url) { - m_host.AddScriptLPS(1); - ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (land.LandData.OwnerID != m_host.OwnerID) @@ -10540,8 +10126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetParcelMusicURL() { - m_host.AddScriptLPS(1); - ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (land.LandData.OwnerID != m_host.OwnerID) @@ -10552,8 +10136,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetRootPosition() { - m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.ParentGroup.AbsolutePosition); } @@ -10568,7 +10150,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Rotation llGetRootRotation() { - m_host.AddScriptLPS(1); Quaternion q; if (m_host.ParentGroup.AttachmentPoint != 0) { @@ -10594,26 +10175,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetObjectDesc(string desc) { - m_host.AddScriptLPS(1); m_host.Description = desc!=null?desc:String.Empty; } public LSL_String llGetCreator() { - m_host.AddScriptLPS(1); return m_host.CreatorID.ToString(); } public LSL_String llGetTimestamp() { - m_host.AddScriptLPS(1); return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } public LSL_Integer llGetNumberOfPrims() { - m_host.AddScriptLPS(1); - return m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount(); } @@ -10630,7 +10206,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List llGetBoundingBox(string obj) { - m_host.AddScriptLPS(1); UUID objID = UUID.Zero; LSL_List result = new LSL_List(); @@ -10796,8 +10371,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetPrimitiveParams(LSL_List rules) { - m_host.AddScriptLPS(1); - LSL_List result = new LSL_List(); LSL_List remaining = GetPrimParams(m_host, rules, ref result); @@ -10817,8 +10390,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) { - m_host.AddScriptLPS(1); - // acording to SL wiki this must indicate a single link number or link_root or link_this. // keep other options as before @@ -11468,14 +11039,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetPrimMediaParams(int face, LSL_List rules) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnGetPrimMediaParams); return GetPrimMediaParams(m_host, face, rules); } public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnGetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); @@ -11595,14 +11164,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnSetPrimMediaParams); return SetPrimMediaParams(m_host, face, rules); } public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnSetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); @@ -11721,14 +11288,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llClearPrimMedia(LSL_Integer face) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnClearPrimMedia); return ClearPrimMedia(m_host, face); } public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face) { - m_host.AddScriptLPS(1); ScriptSleep(m_sleepMsOnClearLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return ClearPrimMedia(m_host.ParentGroup.RootPart, face); @@ -11894,8 +11459,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api char[] imdt = new char[8]; - m_host.AddScriptLPS(1); - // Manually unroll the loop imdt[7] = '='; @@ -11956,8 +11519,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int number = 0; int digit; - m_host.AddScriptLPS(1); - // Require a well-fromed base64 string if (str.Length > 8) @@ -12013,14 +11574,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetGMTclock() { - m_host.AddScriptLPS(1); return DateTime.UtcNow.TimeOfDay.TotalSeconds; } public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) { - m_host.AddScriptLPS(1); - if (m_UrlModule != null) return m_UrlModule.GetHttpHeader(new UUID(request_id), header); return String.Empty; @@ -12029,7 +11587,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetSimulatorHostname() { - m_host.AddScriptLPS(1); IUrlModule UrlModule = World.RequestModuleInterface(); return UrlModule.ExternalHostNameForLSL; } @@ -12103,8 +11660,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int i, j; string d; - m_host.AddScriptLPS(1); - /* * Convert separator and spacer lists to C# strings. * Also filter out null strings so we don't hang. @@ -12200,8 +11755,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetObjectPermMask(int mask) { - m_host.AddScriptLPS(1); - int permmask = 0; if (mask == ScriptBaseClass.MASK_BASE)//0 @@ -12234,8 +11787,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetObjectPermMask(int mask, int value) { - m_host.AddScriptLPS(1); - if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) { if (World.Permissions.IsAdministrator(m_host.OwnerID)) @@ -12270,8 +11821,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetInventoryPermMask(string itemName, int mask) { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); if (item == null) @@ -12296,8 +11845,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetInventoryPermMask(string itemName, int mask, int value) { - m_host.AddScriptLPS(1); - if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) { if (World.Permissions.IsAdministrator(m_host.OwnerID)) @@ -12331,8 +11878,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetInventoryCreator(string itemName) { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); if (item == null) @@ -12347,8 +11892,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llOwnerSay(string msg) { - m_host.AddScriptLPS(1); - World.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); // IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); @@ -12357,7 +11900,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llRequestSecureURL() { - m_host.AddScriptLPS(1); if (m_UrlModule != null) return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, null).ToString(); return UUID.Zero.ToString(); @@ -12369,8 +11911,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { - m_host.AddScriptLPS(1); - string reply = String.Empty; GridRegion info; @@ -12474,8 +12014,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llRequestURL() { - m_host.AddScriptLPS(1); - if (m_UrlModule != null) return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, null).ToString(); return UUID.Zero.ToString(); @@ -12483,13 +12021,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llForceMouselook(int mouselook) { - m_host.AddScriptLPS(1); m_host.SetForceMouselook(mouselook != 0); } public LSL_Float llGetObjectMass(string id) { - m_host.AddScriptLPS(1); UUID key = new UUID(); if (UUID.TryParse(id, out key)) { @@ -12533,8 +12069,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { LSL_List pref; - m_host.AddScriptLPS(1); - // Note that although we have normalized, both // indices could still be negative. if (start < 0) @@ -12604,8 +12138,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoadURL(string avatar_id, string message, string url) { - m_host.AddScriptLPS(1); - IDialogModule dm = World.RequestModuleInterface(); if (null != dm) dm.SendUrlToUser( @@ -12619,8 +12151,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // TODO: Not implemented yet (missing in libomv?): // PARCEL_MEDIA_COMMAND_LOOP_SET float loop Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later) - m_host.AddScriptLPS(1); - // according to the docs, this command only works if script owner and land owner are the same // lets add estate owners and gods, too, and use the generic permission check. ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition); @@ -12857,7 +12387,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llParcelMediaQuery(LSL_List aList) { - m_host.AddScriptLPS(1); LSL_List list = new LSL_List(); //TO DO: make the implementation for the missing commands //PARCEL_MEDIA_COMMAND_LOOP_SET float loop Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later) @@ -12898,7 +12427,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llModPow(int a, int b, int c) { - m_host.AddScriptLPS(1); Int64 tmp = 0; Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); ScriptSleep(m_sleepMsOnModPow); @@ -12907,8 +12435,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetInventoryType(string name) { - m_host.AddScriptLPS(1); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); if (item == null) @@ -12919,8 +12445,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPayPrice(int price, LSL_List quick_pay_buttons) { - m_host.AddScriptLPS(1); - if (quick_pay_buttons.Data.Length < 4) { int x; @@ -12941,8 +12465,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetCameraPos() { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter == UUID.Zero) return Vector3.Zero; @@ -12965,8 +12487,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetCameraRot() { - m_host.AddScriptLPS(1); - if (m_item.PermsGranter == UUID.Zero) return Quaternion.Identity; @@ -12988,21 +12508,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimURL(string url) { - m_host.AddScriptLPS(1); Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead"); ScriptSleep(m_sleepMsOnSetPrimURL); } public void llRefreshPrimURL() { - m_host.AddScriptLPS(1); Deprecated("llRefreshPrimURL"); ScriptSleep(m_sleepMsOnRefreshPrimURL); } public LSL_String llEscapeURL(string url) { - m_host.AddScriptLPS(1); try { return Uri.EscapeDataString(url); @@ -13015,7 +12532,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llUnescapeURL(string url) { - m_host.AddScriptLPS(1); try { return Uri.UnescapeDataString(url); @@ -13028,7 +12544,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) { - m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); if (detectedParams == null) { @@ -13054,7 +12569,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAddToLandBanList(string avatar, double hours) { - m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) @@ -13095,7 +12609,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoveFromLandPassList(string avatar) { - m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManagePasses, false)) @@ -13122,7 +12635,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoveFromLandBanList(string avatar) { - m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) @@ -13149,8 +12661,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetCameraParams(LSL_List rules) { - m_host.AddScriptLPS(1); - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) @@ -13276,8 +12786,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llClearCameraParams() { - m_host.AddScriptLPS(1); - // the object we are in UUID objectID = m_host.ParentUUID; if (objectID == UUID.Zero) @@ -13303,7 +12811,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llListStatistics(int operation, LSL_List src) { - m_host.AddScriptLPS(1); switch (operation) { case ScriptBaseClass.LIST_STAT_RANGE: @@ -13335,19 +12842,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetUnixTime() { - m_host.AddScriptLPS(1); return Util.UnixTimeSinceEpoch(); } public LSL_Integer llGetParcelFlags(LSL_Vector pos) { - m_host.AddScriptLPS(1); return (int)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).LandData.Flags; } public LSL_Integer llGetRegionFlags() { - m_host.AddScriptLPS(1); IEstateModule estate = World.RequestModuleInterface(); if (estate == null) return 67108864; @@ -13356,8 +12860,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llXorBase64StringsCorrect(string str1, string str2) { - m_host.AddScriptLPS(1); - if (str1 == String.Empty) return String.Empty; if (str2 == String.Empty) @@ -13425,7 +12927,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // parameter flags support are implemented in ScriptsHttpRequests.cs // in StartHttpRequest - m_host.AddScriptLPS(1); IHttpRequestModule httpScriptMod = m_ScriptEngine.World.RequestModuleInterface(); List param = new List(); @@ -13616,15 +13117,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Partial implementation: support for parameter flags needed // see http://wiki.secondlife.com/wiki/llHTTPResponse - m_host.AddScriptLPS(1); - if (m_UrlModule != null) m_UrlModule.HttpResponse(new UUID(id), status,body); } public void llResetLandBanList() { - m_host.AddScriptLPS(1); LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData; if (land.OwnerID == m_host.OwnerID) { @@ -13641,7 +13139,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llResetLandPassList() { - m_host.AddScriptLPS(1); LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData; if (land.OwnerID == m_host.OwnerID) { @@ -13658,8 +13155,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) { - m_host.AddScriptLPS(1); - ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); if (lo == null) @@ -13700,7 +13195,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetParcelPrimOwners(LSL_Vector pos) { - m_host.AddScriptLPS(1); LandObject land = (LandObject)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); LSL_List ret = new LSL_List(); if (land != null) @@ -13717,7 +13211,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetObjectPrimCount(string object_id) { - m_host.AddScriptLPS(1); SceneObjectPart part = World.GetSceneObjectPart(new UUID(object_id)); if (part == null) { @@ -13731,8 +13224,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide) { - m_host.AddScriptLPS(1); - ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); if (lo == null) @@ -13746,7 +13237,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param) { - m_host.AddScriptLPS(1); LandData land = World.GetLandData(pos); if (land == null) { @@ -13785,7 +13275,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llStringTrim(string src, int type) { - m_host.AddScriptLPS(1); if (type == (int)ScriptBaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); } if (type == (int)ScriptBaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); } if (type == (int)ScriptBaseClass.STRING_TRIM) { return src.Trim(); } @@ -13794,8 +13283,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetObjectDetails(string id, LSL_List args) { - m_host.AddScriptLPS(1); - LSL_List ret = new LSL_List(); UUID key = new UUID(); @@ -14276,8 +13763,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetNumberOfNotecardLines(string name) { - m_host.AddScriptLPS(1); - UUID assetID = UUID.Zero; if (!UUID.TryParse(name, out assetID)) @@ -14327,8 +13812,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetNotecardLine(string name, int line) { - m_host.AddScriptLPS(1); - UUID assetID = UUID.Zero; if (!UUID.TryParse(name, out assetID)) @@ -14801,8 +14284,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List list = new LSL_List(); - m_host.AddScriptLPS(1); - Vector3 rayStart = start; Vector3 rayEnd = end; Vector3 dir = rayEnd - rayStart; @@ -15022,7 +14503,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_List llCastRayV3(LSL_Vector start, LSL_Vector end, LSL_List options) { - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); // Prepare throttle data @@ -15874,7 +15354,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llManageEstateAccess(int action, string avatar) { - m_host.AddScriptLPS(1); EstateSettings estate = World.RegionInfo.EstateSettings; bool isAccount = false; bool isGroup = false; @@ -15943,35 +15422,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetMemoryLimit() { - m_host.AddScriptLPS(1); // The value returned for Mono scripts in SL return 65536; } public LSL_Integer llSetMemoryLimit(LSL_Integer limit) { - m_host.AddScriptLPS(1); // Treat as an LSO script return ScriptBaseClass.FALSE; } public LSL_Integer llGetSPMaxMemory() { - m_host.AddScriptLPS(1); // The value returned for Mono scripts in SL return 65536; } public virtual LSL_Integer llGetUsedMemory() { - m_host.AddScriptLPS(1); // The value returned for Mono scripts in SL return 65536; } public void llScriptProfiler(LSL_Integer flags) { - m_host.AddScriptLPS(1); // This does nothing for LSO scripts in SL } @@ -15983,23 +15457,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetSoundQueueing(int queue) { - m_host.AddScriptLPS(1); - if (m_SoundModule != null) m_SoundModule.SetSoundQueueing(m_host.UUID, queue == ScriptBaseClass.TRUE.value); } public void llCollisionSprite(string impact_sprite) { - m_host.AddScriptLPS(1); // Viewer 2.0 broke this and it's likely LL has no intention // of fixing it. Therefore, letting this be a NOP seems appropriate. } public void llGodLikeRezObject(string inventory, LSL_Vector pos) { - m_host.AddScriptLPS(1); - if (!World.Permissions.IsGod(m_host.OwnerID)) NotImplemented("llGodLikeRezObject"); @@ -16080,8 +15549,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - m_host.AddScriptLPS(1); - if (item.PermsGranter == UUID.Zero) { replydata = "MISSING_PERMISSION_DEBIT"; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 238fefb..e50b7fd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -120,7 +120,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSShoutError("LightShare functions are not enabled."); return new LSL_List(); } - m_host.AddScriptLPS(1); RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; LSL_List values = new LSL_List(); @@ -729,7 +728,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } int success = 0; - m_host.AddScriptLPS(1); if (LightShareModule.EnableWindlight) { @@ -807,7 +805,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } int success = 0; - m_host.AddScriptLPS(1); if (LightShareModule.EnableWindlight) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5c03191..2c025c1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -264,7 +264,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // for safe funtions always active public void CheckThreatLevel() { - m_host.AddScriptLPS(1); if (!m_OSFunctionsEnabled) OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws } @@ -272,7 +271,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Returns if the function is allowed. Throws a script exception if not allowed. public void CheckThreatLevel(ThreatLevel level, string function) { - m_host.AddScriptLPS(1); if (!m_OSFunctionsEnabled) OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws @@ -1811,7 +1809,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // the user does not have permission to see it. This as opposed to // throwing an exception. - m_host.AddScriptLPS(1); string ret = String.Empty; // if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) { -- cgit v1.1 From c568d4c16b75615dd10b253cad5cd2fd710e2fb9 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:54:18 +1000 Subject: One last big source of script slowness removed. No need to artificially slow stuff down. lol --- .../Shared/Api/Implementation/LSL_Api.cs | 158 +-------------------- .../Shared/Api/Implementation/OSSL_Api.cs | 37 +---- 2 files changed, 14 insertions(+), 181 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3a3703c..ecaa672 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -109,7 +109,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected bool throwErrorOnNotImplemented = false; protected AsyncCommandManager AsyncCommands = null; - protected float m_ScriptDelayFactor = 1.0f; protected float m_ScriptDistanceFactor = 1.0f; protected float m_MinTimerInterval = 0.5f; protected float m_recoilScaleFactor = 0.0f; @@ -126,64 +125,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. - protected int m_sleepMsOnSetTexture = 200; - protected int m_sleepMsOnSetLinkTexture = 200; - protected int m_sleepMsOnScaleTexture = 200; - protected int m_sleepMsOnOffsetTexture = 200; - protected int m_sleepMsOnRotateTexture = 200; - protected int m_sleepMsOnSetPos = 200; - protected int m_sleepMsOnSetRot = 200; - protected int m_sleepMsOnSetLocalRot = 200; - protected int m_sleepMsOnPreloadSound = 1000; - protected int m_sleepMsOnMakeExplosion = 100; - protected int m_sleepMsOnMakeFountain = 100; - protected int m_sleepMsOnMakeSmoke = 100; - protected int m_sleepMsOnMakeFire = 100; - protected int m_sleepMsOnRezAtRoot = 100; - protected int m_sleepMsOnInstantMessage = 2000; - protected int m_sleepMsOnEmail = 20000; - protected int m_sleepMsOnCreateLink = 1000; - protected int m_sleepMsOnGiveInventory = 3000; - protected int m_sleepMsOnRequestAgentData = 100; - protected int m_sleepMsOnRequestInventoryData = 1000; - protected int m_sleepMsOnSetDamage = 5000; - protected int m_sleepMsOnTextBox = 1000; - protected int m_sleepMsOnAdjustSoundVolume = 100; - protected int m_sleepMsOnEjectFromLand = 5000; - protected int m_sleepMsOnAddToLandPassList = 100; - protected int m_sleepMsOnDialog = 1000; - protected int m_sleepMsOnRemoteLoadScript = 3000; - protected int m_sleepMsOnRemoteLoadScriptPin = 3000; - protected int m_sleepMsOnOpenRemoteDataChannel = 1000; - protected int m_sleepMsOnSendRemoteData = 3000; - protected int m_sleepMsOnRemoteDataReply = 3000; - protected int m_sleepMsOnCloseRemoteDataChannel = 1000; - protected int m_sleepMsOnSetPrimitiveParams = 200; - protected int m_sleepMsOnSetLinkPrimitiveParams = 200; - protected int m_sleepMsOnXorBase64Strings = 300; - protected int m_sleepMsOnSetParcelMusicURL = 2000; - protected int m_sleepMsOnGetPrimMediaParams = 1000; - protected int m_sleepMsOnGetLinkMedia = 1000; - protected int m_sleepMsOnSetPrimMediaParams = 1000; - protected int m_sleepMsOnSetLinkMedia = 1000; - protected int m_sleepMsOnClearPrimMedia = 1000; - protected int m_sleepMsOnClearLinkMedia = 1000; - protected int m_sleepMsOnRequestSimulatorData = 1000; - protected int m_sleepMsOnLoadURL = 10000; - protected int m_sleepMsOnParcelMediaCommandList = 2000; - protected int m_sleepMsOnParcelMediaQuery = 2000; - protected int m_sleepMsOnModPow = 1000; - protected int m_sleepMsOnSetPrimURL = 2000; - protected int m_sleepMsOnRefreshPrimURL = 20000; - protected int m_sleepMsOnMapDestination = 1000; - protected int m_sleepMsOnAddToLandBanList = 100; - protected int m_sleepMsOnRemoveFromLandPassList = 100; - protected int m_sleepMsOnRemoveFromLandBanList = 100; - protected int m_sleepMsOnResetLandBanList = 100; - protected int m_sleepMsOnResetLandPassList = 100; - protected int m_sleepMsOnGetParcelPrimOwners = 2000; - protected int m_sleepMsOnGetNumberOfNotecardLines = 100; - protected int m_sleepMsOnGetNotecardLine = 100; protected string m_internalObjectHost = "lsl.opensim.local"; protected bool m_restrictEmail = false; protected ISoundModule m_SoundModule = null; @@ -321,10 +262,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (seConfig != null) { - m_ScriptDelayFactor = - seConfig.GetFloat("ScriptDelayFactor", m_ScriptDelayFactor); - m_ScriptDistanceFactor = - seConfig.GetFloat("ScriptDistanceLimitFactor", m_ScriptDistanceFactor); m_MinTimerInterval = seConfig.GetFloat("MinTimerInterval", m_MinTimerInterval); m_automaticLinkPermission = @@ -409,7 +346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_internalObjectHost = smtpConfig.GetString("internal_object_host", m_internalObjectHost); } } - m_sleepMsOnEmail = EMAIL_PAUSE_TIME * 1000; +//// m_sleepMsOnEmail = EMAIL_PAUSE_TIME * 1000; } public override Object InitializeLifetimeService() @@ -438,14 +375,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return p; } - protected virtual void ScriptSleep(int delay) - { - delay = (int)((float)delay * m_ScriptDelayFactor); - if (delay == 0) - return; - - Sleep(delay); - } protected virtual void Sleep(int delay) { if (m_item == null) // Some unit tests don't set this @@ -1183,8 +1112,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // m_SayShoutCount++; CheckSayShoutTime(); - if (m_SayShoutCount >= 11) - ScriptSleep(2000); +//// if (m_SayShoutCount >= 11) +//// ScriptSleep(2000); if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) { @@ -1210,8 +1139,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // m_SayShoutCount++; CheckSayShoutTime(); - if (m_SayShoutCount >= 11) - ScriptSleep(2000); +//// if (m_SayShoutCount >= 11) +//// ScriptSleep(2000); if (text.Length > 1023) text = text.Substring(0, 1023); @@ -2334,7 +2263,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetTexture(string texture, int face) { SetTexture(m_host, texture, face); - ScriptSleep(m_sleepMsOnSetTexture); } public void llSetLinkTexture(int linknumber, string texture, int face) @@ -2349,7 +2277,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { } } - ScriptSleep(m_sleepMsOnSetLinkTexture); } protected void SetTexture(SceneObjectPart part, string texture, int face) @@ -2396,7 +2323,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llScaleTexture(double u, double v, int face) { ScaleTexture(m_host, u, v, face); - ScriptSleep(m_sleepMsOnScaleTexture); } protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) @@ -2436,7 +2362,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llOffsetTexture(double u, double v, int face) { OffsetTexture(m_host, u, v, face); - ScriptSleep(m_sleepMsOnOffsetTexture); } protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) @@ -2476,7 +2401,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRotateTexture(double rotation, int face) { RotateTexture(m_host, rotation, face); - ScriptSleep(m_sleepMsOnRotateTexture); } protected void RotateTexture(SceneObjectPart part, double rotation, int face) @@ -2554,8 +2478,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPos(LSL_Vector pos) { SetPos(m_host, pos, true); - - ScriptSleep(m_sleepMsOnSetPos); } /// @@ -2727,14 +2649,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); } } - - ScriptSleep(m_sleepMsOnSetRot); } public void llSetLocalRot(LSL_Rotation rot) { SetRot(m_host, rot); - ScriptSleep(m_sleepMsOnSetLocalRot); } protected void SetRot(SceneObjectPart part, Quaternion rot) @@ -3097,7 +3016,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (m_SoundModule != null) m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0); - ScriptSleep(m_sleepMsOnPreloadSound); } /// @@ -3363,25 +3281,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { Deprecated("llMakeExplosion", "Use llParticleSystem instead"); - ScriptSleep(m_sleepMsOnMakeExplosion); } public void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset) { Deprecated("llMakeFountain", "Use llParticleSystem instead"); - ScriptSleep(m_sleepMsOnMakeFountain); } public void llMakeSmoke(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { Deprecated("llMakeSmoke", "Use llParticleSystem instead"); - ScriptSleep(m_sleepMsOnMakeSmoke); } public void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) { Deprecated("llMakeFire", "Use llParticleSystem instead"); - ScriptSleep(m_sleepMsOnMakeFire); } public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) @@ -3458,8 +3372,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } }, null, "LSL_Api.doObjectRez"); - //ScriptSleep((int)((groupmass * velmag) / 10)); - ScriptSleep(m_sleepMsOnRezAtRoot); } public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) @@ -3704,7 +3616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(user, out result) || result == UUID.Zero) { Error("llInstantMessage","An invalid key was passed to llInstantMessage"); - ScriptSleep(2000); +//// ScriptSleep(2000); return; } @@ -3752,8 +3664,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); } - - ScriptSleep(m_sleepMsOnInstantMessage); } public void llEmail(string address, string subject, string message) @@ -3790,7 +3700,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } emailModule.SendEmail(m_host.UUID, address, subject, message); - ScriptSleep(m_sleepMsOnEmail); +//// ScriptSleep(m_sleepMsOnEmail); } public void llGetNextEmail(string address, string subject) @@ -4568,9 +4478,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_TransferModule != null) m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); } - - //This delay should only occur when giving inventory to avatars. - ScriptSleep(m_sleepMsOnGiveInventory); } } @@ -4752,12 +4659,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api reply); }); - ScriptSleep(m_sleepMsOnRequestInventoryData); return tid.ToString(); } } - ScriptSleep(m_sleepMsOnRequestInventoryData); return String.Empty; } @@ -4794,8 +4699,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - - ScriptSleep(m_sleepMsOnSetDamage); } public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt) @@ -4924,7 +4827,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { dm.SendTextBoxToUser(av, message, chatChannel, m_host.Name, m_host.UUID, m_host.OwnerID); - ScriptSleep(m_sleepMsOnTextBox); } } @@ -6417,7 +6319,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llAdjustSoundVolume(double volume) { m_host.AdjustSoundGain(volume); - ScriptSleep(m_sleepMsOnAdjustSoundVolume); } public void llSetSoundRadius(double radius) @@ -6523,7 +6424,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - ScriptSleep(m_sleepMsOnEjectFromLand); } public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) @@ -7669,8 +7569,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api dm.SendDialogToUser( av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts); - - ScriptSleep(m_sleepMsOnDialog); } public void llVolumeDetect(int detect) @@ -7682,7 +7580,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRemoteLoadScript(string target, string name, int running, int start_param) { Deprecated("llRemoteLoadScript", "Use llRemoteLoadScriptPin instead"); - ScriptSleep(m_sleepMsOnRemoteLoadScript); } public void llSetRemoteScriptAccessPin(int pin) @@ -7728,8 +7625,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.Inventory.RemoveInventoryItem(item.ItemID); } } - // this will cause the delay even if the script pin or permissions were wrong - seems ok - ScriptSleep(m_sleepMsOnRemoteLoadScriptPin); } public void llOpenRemoteDataChannel() @@ -7759,13 +7654,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj, new DetectParams[0])); } - ScriptSleep(m_sleepMsOnOpenRemoteDataChannel); } public LSL_String llSendRemoteData(string channel, string dest, int idata, string sdata) { IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); - ScriptSleep(m_sleepMsOnSendRemoteData); if (xmlrpcMod == null) return ""; return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString(); @@ -7776,7 +7669,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null) xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata); - ScriptSleep(m_sleepMsOnRemoteDataReply); } public void llCloseRemoteDataChannel(string channel) @@ -7790,7 +7682,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod != null) xmlrpcMod.CloseXMLRPCChannel((UUID)channel); - ScriptSleep(m_sleepMsOnCloseRemoteDataChannel); } public LSL_String llMD5String(string src, int nonce) @@ -8192,15 +8083,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimitiveParams(LSL_List rules) { SetLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams"); - - ScriptSleep(m_sleepMsOnSetPrimitiveParams); } public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) { SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); - - ScriptSleep(m_sleepMsOnSetLinkPrimitiveParams); } public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) @@ -9990,7 +9877,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - ScriptSleep(300); if (str1 == String.Empty) return String.Empty; if (str2 == String.Empty) @@ -10120,8 +10006,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; land.SetMusicUrl(url); - - ScriptSleep(m_sleepMsOnSetParcelMusicURL); } public LSL_String llGetParcelMusicURL() @@ -11039,13 +10923,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetPrimMediaParams(int face, LSL_List rules) { - ScriptSleep(m_sleepMsOnGetPrimMediaParams); return GetPrimMediaParams(m_host, face, rules); } public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { - ScriptSleep(m_sleepMsOnGetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); else if (link == ScriptBaseClass.LINK_THIS) @@ -11164,13 +11046,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules) { - ScriptSleep(m_sleepMsOnSetPrimMediaParams); return SetPrimMediaParams(m_host, face, rules); } public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules) { - ScriptSleep(m_sleepMsOnSetLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules); else if (link == ScriptBaseClass.LINK_THIS) @@ -11288,13 +11168,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llClearPrimMedia(LSL_Integer face) { - ScriptSleep(m_sleepMsOnClearPrimMedia); return ClearPrimMedia(m_host, face); } public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face) { - ScriptSleep(m_sleepMsOnClearLinkMedia); if (link == ScriptBaseClass.LINK_ROOT) return ClearPrimMedia(m_host.ParentGroup.RootPart, face); else if (link == ScriptBaseClass.LINK_THIS) @@ -11925,7 +11803,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.DATA_SIM_POS: if (info == null) { - ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); } @@ -11972,7 +11849,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.DATA_SIM_RATING: if (info == null) { - ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); } int access = info.Maturity; @@ -11991,7 +11867,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api reply = "OpenSim"; break; default: - ScriptSleep(m_sleepMsOnRequestSimulatorData); return UUID.Zero.ToString(); // Raise no event } UUID rq = UUID.Random(); @@ -12002,7 +11877,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands. DataserverPlugin.DataserverReply(rq.ToString(), reply); - ScriptSleep(m_sleepMsOnRequestSimulatorData); return tid.ToString(); } catch(Exception) @@ -12142,8 +12016,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (null != dm) dm.SendUrlToUser( new UUID(avatar_id), m_host.Name, m_host.UUID, m_host.OwnerID, false, message, url); - - ScriptSleep(m_sleepMsOnLoadURL); } public void llParcelMediaCommandList(LSL_List commandList) @@ -12382,7 +12254,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api (ParcelMediaCommandEnum)commandToSend, time); } } - ScriptSleep(m_sleepMsOnParcelMediaCommandList); } public LSL_List llParcelMediaQuery(LSL_List aList) @@ -12421,7 +12292,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - ScriptSleep(m_sleepMsOnParcelMediaQuery); return list; } @@ -12429,7 +12299,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { Int64 tmp = 0; Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp); - ScriptSleep(m_sleepMsOnModPow); return Convert.ToInt32(tmp); } @@ -12509,13 +12378,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimURL(string url) { Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead"); - ScriptSleep(m_sleepMsOnSetPrimURL); } public void llRefreshPrimURL() { Deprecated("llRefreshPrimURL"); - ScriptSleep(m_sleepMsOnRefreshPrimURL); } public LSL_String llEscapeURL(string url) @@ -12564,7 +12431,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, pos, lookAt); } - ScriptSleep(m_sleepMsOnMapDestination); } public void llAddToLandBanList(string avatar, double hours) @@ -12604,7 +12470,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } - ScriptSleep(m_sleepMsOnAddToLandBanList); } public void llRemoveFromLandPassList(string avatar) @@ -12630,7 +12495,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - ScriptSleep(m_sleepMsOnRemoveFromLandPassList); } public void llRemoveFromLandBanList(string avatar) @@ -12656,7 +12520,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - ScriptSleep(m_sleepMsOnRemoveFromLandBanList); } public void llSetCameraParams(LSL_List rules) @@ -13134,7 +12997,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - ScriptSleep(m_sleepMsOnResetLandBanList); } public void llResetLandPassList() @@ -13150,7 +13012,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - ScriptSleep(m_sleepMsOnResetLandPassList); } public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) @@ -13205,7 +13066,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_Integer(detectedParams.Value)); } } - ScriptSleep(m_sleepMsOnGetParcelPrimOwners); return ret; } @@ -13790,7 +13650,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(assetID).ToString()); - ScriptSleep(m_sleepMsOnGetNumberOfNotecardLines); return tid.ToString(); } @@ -13806,7 +13665,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(id).ToString()); }); - ScriptSleep(m_sleepMsOnGetNumberOfNotecardLines); return tid.ToString(); } @@ -13840,7 +13698,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands.DataserverPlugin.DataserverReply( reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); - ScriptSleep(m_sleepMsOnGetNotecardLine); return tid.ToString(); } @@ -13859,7 +13716,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); }); - ScriptSleep(m_sleepMsOnGetNotecardLine); return tid.ToString(); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2c025c1..d897098 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -139,8 +139,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal TaskInventoryItem m_item; internal bool m_OSFunctionsEnabled = false; internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; - internal float m_ScriptDelayFactor = 1.0f; - internal float m_ScriptDistanceFactor = 1.0f; internal bool m_debuggerSafe = false; internal Dictionary m_FunctionPerms = new Dictionary(); protected IUrlModule m_UrlModule = null; @@ -161,11 +159,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED"); } - m_ScriptDelayFactor = - m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); - m_ScriptDistanceFactor = - m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f); - string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow"); switch (risk) { @@ -473,13 +466,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLShoutError(string.Format("Use of function {0} is deprecated. Use {1} instead.", function, replacement)); } - protected void ScriptSleep(int delay) - { - delay = (int)((float)delay * m_ScriptDelayFactor); - if (delay == 0) - return; - System.Threading.Thread.Sleep(delay); - } +//// protected void ScriptSleep(int delay) +//// { +//// delay = (int)((float)delay * m_ScriptDelayFactor); +//// if (delay == 0) +//// return; +//// System.Threading.Thread.Sleep(delay); +//// } public LSL_Integer osSetTerrainHeight(int x, int y, double val) { @@ -881,17 +874,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = presence.AbsolutePosition; if(!checkAllowAgentTPbyLandOwner(agentId, pos)) - { - ScriptSleep(500); return; - } if(regionName == World.RegionInfo.RegionName) { // should be faster than going to threadpool World.RequestTeleportLocation(presence.ControllingClient, regionName, position, lookat, (uint)TPFlags.ViaLocation); - ScriptSleep(500); } else { @@ -902,7 +891,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api presence.ControllingClient, regionName, position, lookat, (uint)TPFlags.ViaLocation), null, "OSSL_Api.TeleportAgentByRegionCoords"); - ScriptSleep(5000); } } } @@ -930,18 +918,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = presence.AbsolutePosition; if(!checkAllowAgentTPbyLandOwner(agentId, pos)) - { - ScriptSleep(500); return; - } Util.FireAndForget( o => World.RequestTeleportLocation( presence.ControllingClient, regionHandle, position, lookat, (uint)TPFlags.ViaLocation), null, "OSSL_Api.TeleportAgentByRegionName"); - - ScriptSleep(5000); } } @@ -956,14 +939,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = presence.AbsolutePosition; if(!checkAllowAgentTPbyLandOwner(agentId, pos)) - { - ScriptSleep(500); return; - } World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, lookat, (uint)TPFlags.ViaLocation); - ScriptSleep(500); } } @@ -3389,8 +3368,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (region != null) key = region.TerrainImage; - ScriptSleep(1000); - return key.ToString(); } -- cgit v1.1 From 5aba03bbf48ccf01e10d7fd44a5a2fb83558d9af Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:54:49 +1000 Subject: Remove some script distance limits. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ecaa672..229ad1d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2506,8 +2506,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. pos.x > (World.RegionInfo.RegionSizeX + 10) || // return FALSE if more than 10 meters into a east-adjacent region. pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. - pos.y > (World.RegionInfo.RegionSizeY + 10) || // return FALSE if more than 10 meters into a north-adjacent region. - pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m + pos.y > (World.RegionInfo.RegionSizeY + 10) // return FALSE if more than 10 meters into a north-adjacent region. ) ) { @@ -3310,9 +3309,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api float dist = (float)llVecDist(llGetPos(), pos); - if (dist > m_ScriptDistanceFactor * 10.0f) - return; - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); if (item == null) -- cgit v1.1 From cdb1851f438349a8721c0d9cef54837d0b302189 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 4 Jun 2019 00:50:59 +1000 Subject: Warnings-- --- OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs index 66210b7..9dc8d05 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs @@ -19720,7 +19720,7 @@ public override TOKEN OldAction(Lexer yym,ref string yytext,int action, ref bool case 1076: ; break; case 1032: { yym.yy_begin("YYINITIAL"); ((LSLTokens)yym).yytext = ((LSLTokens)yym).str; ((LSLTokens)yym).str = String.Empty; return new STRING_CONSTANT(yym); } - break; +// break; case 1067: ; break; case 1072: ; diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 9d72b1c..5342c28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -771,7 +771,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { - EventParams data = null; +// EventParams data = null; // We check here as the thread stopping this instance from running may itself hold the m_Script lock. if (!Running) return 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs index 241a24d..8ceb4cc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs @@ -157,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) {} } - catch (WebException e) + catch (WebException) { // using (HttpWebResponse response = (HttpWebResponse)e.Response) // gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; -- cgit v1.1 From bdd2d59d6d97e555ad572d1ec5649697233903ab Mon Sep 17 00:00:00 2001 From: onefang Date: Sat, 20 Jul 2019 20:24:25 +1000 Subject: Allow menu items longer than 24 characters once more. I've never seen any problems with allowing this, my NPC tool does that. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 229ad1d..8141c17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7549,16 +7549,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (buttons.Data[i].ToString() == String.Empty) { - Error("llDialog", "Button label cannot be blank"); + Error("llDialog", "Button label cannot be blank."); return; } -/* if (buttons.Data[i].ToString().Length > 24) { - Error("llDialog", "Button label cannot be longer than 24 characters"); - return; + Error("llDialog", "Button label should not be longer than 24 characters."); } -*/ buts[i] = buttons.Data[i].ToString(); } -- cgit v1.1 From 5b752dd4b7fd2600157ec90da5051623afe1dc4d Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 21 Jul 2019 21:25:11 +1000 Subject: TPs from scripts avoid all that silly raycasting nonsense, just go where we ask. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++---- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8141c17..84e4546 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4689,7 +4689,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { World.RequestTeleportLocation( presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, - (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); + (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome | Constants.TeleportFlags.ViaScript)); } } } @@ -4768,7 +4768,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) { - World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); } } } @@ -4782,7 +4782,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Use it as a sim name if (assetID == UUID.Zero) { - World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); return; } @@ -4795,7 +4795,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AssetLandmark lm = new AssetLandmark(lma); - World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)(Constants.TeleportFlags.ViaLocation | Constants.TeleportFlags.ViaScript)); } public void llTextBox(string agent, string message, int chatChannel) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index d897098..2be5200 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -880,7 +880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // should be faster than going to threadpool World.RequestTeleportLocation(presence.ControllingClient, regionName, position, - lookat, (uint)TPFlags.ViaLocation); + lookat, (uint)(TPFlags.ViaLocation | TPFlags.ViaScript)); } else { @@ -889,7 +889,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Util.FireAndForget( o => World.RequestTeleportLocation( presence.ControllingClient, regionName, position, - lookat, (uint)TPFlags.ViaLocation), + lookat, (uint)(TPFlags.ViaLocation | TPFlags.ViaScript)), null, "OSSL_Api.TeleportAgentByRegionCoords"); } } @@ -923,7 +923,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Util.FireAndForget( o => World.RequestTeleportLocation( presence.ControllingClient, regionHandle, - position, lookat, (uint)TPFlags.ViaLocation), + position, lookat, (uint)(TPFlags.ViaLocation | TPFlags.ViaScript)), null, "OSSL_Api.TeleportAgentByRegionName"); } } @@ -942,7 +942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, - lookat, (uint)TPFlags.ViaLocation); + lookat, (uint)(TPFlags.ViaLocation | TPFlags.ViaScript)); } } -- cgit v1.1 From d1a1338d1a63c2992868d1b66ea5e5741e8a3971 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 24 Jul 2019 01:07:48 +1000 Subject: Revert list content type check. https://sledjhamr.org/mantisbt/view.php?id=19 --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 84e4546..ce2bfaf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5985,23 +5985,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { for (int i = 0; i < length; i++) { - int needle = llGetListEntryType(test, 0).value; - int haystack = llGetListEntryType(src, i).value; +//// int needle = llGetListEntryType(test, 0).value; +//// int haystack = llGetListEntryType(src, i).value; // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code // and so the comparison fails even if the LSL_Integer conceptually has the same value. // Therefore, here we test Equals on both the source and destination objects. // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). - if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))) + + // The commented out bit of insanity was to check the LSL types are the same as well, which we don't really want. + if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) +//// if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))) { int j; for (j = 1; j < test.Length; j++) + if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) { - needle = llGetListEntryType(test, j).value; - haystack = llGetListEntryType(src, i+j).value; +//// needle = llGetListEntryType(test, j).value; +//// haystack = llGetListEntryType(src, i+j).value; - if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))) +//// if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))) break; } -- cgit v1.1 From 77737c81234c98d72bffaa6ddca374504f971b12 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 25 Jul 2019 20:19:51 +1000 Subject: Gatekeeper -> GatekeeperURI Coz it says all over the source code - // Legacy. Remove soon! And has since later OpenSim 0.7s. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2be5200..64da67e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2493,8 +2493,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return gatekeeperURI; // Legacy. Remove soon! - if (config.Configs["GridService"] != null) - gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); +//// if (config.Configs["GridService"] != null) +//// gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); return gatekeeperURI; } -- cgit v1.1 From 5ab0f0190d93759368d2f6e4553a8da2644bc638 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 22 Aug 2019 10:54:20 +1000 Subject: OhSillyThreatLevels should throw an exception when not allowed. --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 64da67e..544dce4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -212,9 +212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal void OSSLError(string msg) { if (m_debuggerSafe) - { OSSLShoutError(msg); - } else { throw new ScriptException("OSSL Runtime Error: " + msg); @@ -258,20 +256,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void CheckThreatLevel() { if (!m_OSFunctionsEnabled) - OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws + throw new ScriptException(String.Format("{0} permission denied. All OS functions are disabled.")); } // Returns if the function is allowed. Throws a script exception if not allowed. public void CheckThreatLevel(ThreatLevel level, string function) { if (!m_OSFunctionsEnabled) - OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws + throw new ScriptException(String.Format("{0} permission denied. All OS functions are disabled.", function)); string reasonWhyNot = CheckThreatLevelTest(level, function); if (!String.IsNullOrEmpty(reasonWhyNot)) - { - OSSLError(reasonWhyNot); - } + throw new ScriptException(reasonWhyNot); } // Check to see if function is allowed. Returns an empty string if function permitted -- cgit v1.1 From 4e1a8967847b93442ec3e4e0d254c5d6c1edffb7 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 25 Aug 2019 07:56:14 +1000 Subject: Gods can do anything they want, including bypassing OhSilly threat levels. --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 544dce4..a8c1a8f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -274,6 +274,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // or a string explaining why this function can't be used. private string CheckThreatLevelTest(ThreatLevel level, string function) { + // Grid gods can do anything they damn well please. + if (World.Permissions.IsGridGod(m_item.OwnerID)) + return String.Empty; + else + { + // So can active gods. + ScenePresence sp = World.GetScenePresence(m_item.OwnerID); + if (sp != null && !sp.IsDeleted && sp.IsGod) + return String.Empty; + } + if (!m_FunctionPerms.ContainsKey(function)) { FunctionPerms perms = new FunctionPerms(); -- cgit v1.1