Convergence is almost complete. This brings the diff between the API to < 10k
and makes it use a common set of types in both engine. Fixes the issues with running both engines and HTTP requests / listens / timers etc.. Also fixes a couple of minor Scene issues and a CTB by nullref.0.6.0-stable
							parent
							
								
									5edaddce6d
								
							
						
					
					
						commit
						f3c8963c86
					
				| 
						 | 
				
			
			@ -502,7 +502,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
 | 
			
		|||
            // horribly tangly.  Hopefully it should be possible to greatly simplify it.
 | 
			
		||||
            if (shutdownCircuit)
 | 
			
		||||
            {
 | 
			
		||||
                OnConnectionClosed(this);
 | 
			
		||||
                if (OnConnectionClosed != null)
 | 
			
		||||
                    OnConnectionClosed(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,38 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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 OpenSim.Framework;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.Environment.Interfaces
 | 
			
		||||
{
 | 
			
		||||
    public interface IScriptModule : IRegionModule
 | 
			
		||||
    {
 | 
			
		||||
        bool GetScriptRunning(UUID objectID, UUID itemID);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -192,6 +192,8 @@ namespace OpenSim.Region.Environment.Scenes
 | 
			
		|||
        public event ScriptTimerEvent OnScriptTimerEvent;
 | 
			
		||||
 | 
			
		||||
        public delegate void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
 | 
			
		||||
        public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
 | 
			
		||||
 | 
			
		||||
        public event EstateToolsTimeUpdate OnEstateToolsTimeUpdate;
 | 
			
		||||
 | 
			
		||||
        public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
 | 
			
		||||
| 
						 | 
				
			
			@ -211,6 +213,7 @@ namespace OpenSim.Region.Environment.Scenes
 | 
			
		|||
 | 
			
		||||
        public delegate void ParcelPrimCountTainted();
 | 
			
		||||
        public event ParcelPrimCountTainted OnParcelPrimCountTainted;
 | 
			
		||||
        public event GetScriptRunning OnGetScriptRunning;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// RegisterCapsEvent is called by Scene after the Caps object
 | 
			
		||||
| 
						 | 
				
			
			@ -368,9 +371,17 @@ namespace OpenSim.Region.Environment.Scenes
 | 
			
		|||
        private ScriptColliding handlerCollidingStart = null;
 | 
			
		||||
        private ScriptColliding handlerColliding = null;
 | 
			
		||||
        private ScriptColliding handlerCollidingEnd = null;
 | 
			
		||||
        private GetScriptRunning handlerGetScriptRunning = null;
 | 
			
		||||
 | 
			
		||||
        private SunLindenHour handlerSunGetLindenHour = null;
 | 
			
		||||
 | 
			
		||||
        public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            handlerGetScriptRunning = OnGetScriptRunning;
 | 
			
		||||
            if (handlerGetScriptRunning != null)
 | 
			
		||||
                handlerGetScriptRunning(controllingClient, objectID, itemID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void TriggerOnScriptChangedEvent(uint localID, uint change)
 | 
			
		||||
        {
 | 
			
		||||
            handlerScriptChangedEvent = OnScriptChangedEvent;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -445,7 +445,6 @@ namespace OpenSim.Region.Environment.Scenes
 | 
			
		|||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                            Console.WriteLine("Non-Prim item ==>");
 | 
			
		||||
                                itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -896,6 +895,9 @@ namespace OpenSim.Region.Environment.Scenes
 | 
			
		|||
            if (group != null)
 | 
			
		||||
            {
 | 
			
		||||
                TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
 | 
			
		||||
                if (item == null)
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                if (item.Type == 10)
 | 
			
		||||
                {
 | 
			
		||||
                    EventManager.TriggerRemoveScript(localID, itemID);
 | 
			
		||||
| 
						 | 
				
			
			@ -2311,16 +2313,6 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
 | 
			
		|||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            IScriptModule scriptModule = RequestModuleInterface<IScriptModule>();
 | 
			
		||||
            if (scriptModule == null)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            controllingClient.SendScriptRunningReply(objectID, itemID,
 | 
			
		||||
                    scriptModule.GetScriptRunning(objectID, itemID));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
 | 
			
		||||
        {
 | 
			
		||||
            SceneObjectPart part = GetSceneObjectPart(objectID);
 | 
			
		||||
| 
						 | 
				
			
			@ -2388,5 +2380,10 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T
 | 
			
		|||
            }
 | 
			
		||||
            m_innerScene.DetachSingleAttachmentToInv(itemID, remoteClient);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +37,5 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
        ExecutorBase Exec { get; }
 | 
			
		||||
        string Source { get; set; }
 | 
			
		||||
        void Start(BuilIn_Commands BuiltIn_Commands);
 | 
			
		||||
        EventQueueManager.Queue_llDetectParams_Struct llDetectParams { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,6 +45,7 @@ using OpenSim.Region.Environment.Scenes;
 | 
			
		|||
using OpenSim.Region.Physics.Manager;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared.Api;
 | 
			
		||||
 | 
			
		||||
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
 | 
			
		||||
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +80,8 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
            m_localID = localID;
 | 
			
		||||
            m_itemID = itemID;
 | 
			
		||||
 | 
			
		||||
            AsyncCommands = m_ScriptEngine.m_ASYNCLSLCommandManager;
 | 
			
		||||
            AsyncCommands = new AsyncCommandManager(m_ScriptEngine);
 | 
			
		||||
 | 
			
		||||
            //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -759,256 +761,95 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
        public LSL_String llDetectedName(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
 | 
			
		||||
            if (SenseList != null)
 | 
			
		||||
            {
 | 
			
		||||
                if ((number >= 0) && (number < SenseList.Length))
 | 
			
		||||
                {
 | 
			
		||||
                    UUID SensedUUID = (UUID)SenseList.Data[number];
 | 
			
		||||
                    return resolveName(SensedUUID);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                ScriptManager sm;
 | 
			
		||||
                IScript script = null;
 | 
			
		||||
 | 
			
		||||
                if ((sm = m_ScriptEngine.m_ScriptManager) != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (sm.Scripts.ContainsKey(m_localID))
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((script = sm.GetScript(m_localID, m_itemID)) != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
 | 
			
		||||
                            if (script.llDetectParams._string != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (script.llDetectParams._string.Length > number)
 | 
			
		||||
                                {
 | 
			
		||||
                                    if (script.llDetectParams._string[number] != null)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        return script.llDetectParams._string[number];
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
            return String.Empty;
 | 
			
		||||
       }
 | 
			
		||||
 | 
			
		||||
        public UUID uuidDetectedKey(int number)
 | 
			
		||||
        {
 | 
			
		||||
            LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
 | 
			
		||||
            if (SenseList != null)
 | 
			
		||||
            {
 | 
			
		||||
                if ((number >= 0) && (number < SenseList.Length))
 | 
			
		||||
                {
 | 
			
		||||
                    UUID SensedUUID = (UUID)SenseList.Data[number];
 | 
			
		||||
                    return SensedUUID;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                ScriptManager sm;
 | 
			
		||||
                IScript script = null;
 | 
			
		||||
 | 
			
		||||
                if ((sm = m_ScriptEngine.m_ScriptManager) != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (sm.Scripts.ContainsKey(m_localID))
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((script = sm.GetScript(m_localID, m_itemID)) != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
 | 
			
		||||
                            if (script.llDetectParams._key.Length > number)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (script.llDetectParams._key[number])
 | 
			
		||||
                                {
 | 
			
		||||
                                    return new UUID(script.llDetectParams._key[number]);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return UUID.Zero;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public EntityBase entityDetectedKey(int number)
 | 
			
		||||
        {
 | 
			
		||||
            LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
 | 
			
		||||
            if (SenseList != null)
 | 
			
		||||
            {
 | 
			
		||||
                if ((number >= 0) && (number < SenseList.Length))
 | 
			
		||||
                {
 | 
			
		||||
                    UUID SensedUUID = (UUID)SenseList.Data[number];
 | 
			
		||||
                    EntityBase SensedObject = null;
 | 
			
		||||
                    lock (World.Entities)
 | 
			
		||||
                    {
 | 
			
		||||
                        World.Entities.TryGetValue(SensedUUID, out SensedObject);
 | 
			
		||||
                    }
 | 
			
		||||
                    return SensedObject;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                ScriptManager sm;
 | 
			
		||||
                IScript script = null;
 | 
			
		||||
 | 
			
		||||
                if ((sm = m_ScriptEngine.m_ScriptManager) != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (sm.Scripts.ContainsKey(m_localID))
 | 
			
		||||
                    {
 | 
			
		||||
                        if ((script = sm.GetScript(m_localID, m_itemID)) != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            //System.Console.WriteLine(number + " - " + script.llDetectParams._key.Length);
 | 
			
		||||
                            if (script.llDetectParams._key.Length > number)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (script.llDetectParams._key[number])
 | 
			
		||||
                                {
 | 
			
		||||
                                    UUID SensedUUID = new UUID(script.llDetectParams._key[number]);
 | 
			
		||||
                                    EntityBase SensedObject = null;
 | 
			
		||||
                                    lock (World.Entities)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        World.Entities.TryGetValue(SensedUUID, out SensedObject);
 | 
			
		||||
                                    }
 | 
			
		||||
                                    return SensedObject;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return null;
 | 
			
		||||
            return d.Name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_String llDetectedKey(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            UUID SensedUUID = uuidDetectedKey(number);
 | 
			
		||||
            if (SensedUUID == UUID.Zero)
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return String.Empty;
 | 
			
		||||
            return SensedUUID.ToString();
 | 
			
		||||
            return d.Key.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_String llDetectedOwner(int number)
 | 
			
		||||
        {
 | 
			
		||||
            // returns UUID of owner of object detected
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject ==null)
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return String.Empty;
 | 
			
		||||
            UUID SensedUUID = uuidDetectedKey(number);
 | 
			
		||||
            if (World.GetScenePresence(SensedUUID) == null)
 | 
			
		||||
            {
 | 
			
		||||
                // sensed object is not an avatar
 | 
			
		||||
                // so get the owner of the sensed object
 | 
			
		||||
                SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID);
 | 
			
		||||
                if (SOP != null) { return SOP.ObjectOwner.ToString(); }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // sensed object is an avatar, and so must be its own owner
 | 
			
		||||
                return SensedUUID.ToString();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            return String.Empty;
 | 
			
		||||
 | 
			
		||||
            return d.Owner.ToString();
 | 
			
		||||
       }
 | 
			
		||||
 | 
			
		||||
        public LSL_Integer llDetectedType(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return 0;
 | 
			
		||||
            int mask = 0;
 | 
			
		||||
 | 
			
		||||
            UUID SensedUUID = uuidDetectedKey(number);
 | 
			
		||||
            LSL_Vector ZeroVector = new LSL_Vector(0, 0, 0);
 | 
			
		||||
 | 
			
		||||
            if (World.GetScenePresence(SensedUUID) != null) mask |= 0x01; // actor
 | 
			
		||||
            if (SensedObject.Velocity.Equals(ZeroVector))
 | 
			
		||||
                mask |= 0x04; // passive non-moving
 | 
			
		||||
            else
 | 
			
		||||
                mask |= 0x02; // active moving
 | 
			
		||||
            if (SensedObject is IScript) mask |= 0x08; // Scripted. It COULD have one hidden ...
 | 
			
		||||
            return mask;
 | 
			
		||||
            return new LSL_Integer(d.Type);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Vector llDetectedPos(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
                return new LSL_Vector(0, 0, 0);
 | 
			
		||||
            return new LSL_Vector(
 | 
			
		||||
                SensedObject.AbsolutePosition.X,
 | 
			
		||||
                SensedObject.AbsolutePosition.Y,
 | 
			
		||||
                SensedObject.AbsolutePosition.Z);
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return new LSL_Vector();
 | 
			
		||||
            return d.Position;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Vector llDetectedVel(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
                return new LSL_Vector(0, 0, 0);
 | 
			
		||||
            return new LSL_Vector(
 | 
			
		||||
                SensedObject.Velocity.X,
 | 
			
		||||
                SensedObject.Velocity.Y,
 | 
			
		||||
                SensedObject.Velocity.Z);
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return new LSL_Vector();
 | 
			
		||||
            return d.Velocity;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Vector llDetectedGrab(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
            DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (parms == null)
 | 
			
		||||
                return new LSL_Vector(0, 0, 0);
 | 
			
		||||
 | 
			
		||||
            return new LSL_Vector(
 | 
			
		||||
                SensedObject.AbsolutePosition.X,
 | 
			
		||||
                SensedObject.AbsolutePosition.Y,
 | 
			
		||||
                SensedObject.AbsolutePosition.Z);
 | 
			
		||||
            return parms.OffsetPos;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Rotation llDetectedRot(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return new LSL_Rotation();
 | 
			
		||||
            return new LSL_Rotation(
 | 
			
		||||
                SensedObject.Rotation.X,
 | 
			
		||||
                SensedObject.Rotation.Y,
 | 
			
		||||
                SensedObject.Rotation.Z,
 | 
			
		||||
                SensedObject.Rotation.W);
 | 
			
		||||
            return d.Rotation;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Integer llDetectedGroup(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            UUID SensedUUID = uuidDetectedKey(number);
 | 
			
		||||
            if (SensedUUID == UUID.Zero)
 | 
			
		||||
            DetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (d == null)
 | 
			
		||||
                return new LSL_Integer(0);
 | 
			
		||||
            ScenePresence presence = World.GetScenePresence(SensedUUID);
 | 
			
		||||
            IClientAPI client = presence.ControllingClient;
 | 
			
		||||
            if (m_host.GroupID == client.ActiveGroupId)
 | 
			
		||||
            if (m_host.GroupID == d.Group)
 | 
			
		||||
                return new LSL_Integer(1);
 | 
			
		||||
            else
 | 
			
		||||
                return new LSL_Integer(0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Integer llDetectedLinkNumber(int number)
 | 
			
		||||
        {
 | 
			
		||||
            m_host.AddScriptLPS(1);
 | 
			
		||||
            EntityBase SensedObject = entityDetectedKey(number);
 | 
			
		||||
            if (SensedObject == null)
 | 
			
		||||
                return 0;
 | 
			
		||||
            return m_host.LinkNum;
 | 
			
		||||
            DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
 | 
			
		||||
            if (parms == null)
 | 
			
		||||
                return new LSL_Integer(0);
 | 
			
		||||
 | 
			
		||||
            return new LSL_Integer(parms.LinkNum);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Vector llDetectedTouchBinormal(int index)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -577,7 +577,7 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
            {
 | 
			
		||||
                UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, new UUID(channel));
 | 
			
		||||
                object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(UUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
 | 
			
		||||
                m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj);
 | 
			
		||||
                m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", new DetectParams[0], resobj);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,7 @@ using System.Runtime.Remoting.Lifetime;
 | 
			
		|||
using System.Threading;
 | 
			
		||||
using OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
 | 
			
		||||
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
 | 
			
		||||
| 
						 | 
				
			
			@ -68,13 +69,6 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
            return lease;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public EventQueueManager.Queue_llDetectParams_Struct _llDetectParams;
 | 
			
		||||
        EventQueueManager.Queue_llDetectParams_Struct IScript.llDetectParams
 | 
			
		||||
        {
 | 
			
		||||
            get { return _llDetectParams; }
 | 
			
		||||
            set { _llDetectParams = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Executor m_Exec;
 | 
			
		||||
 | 
			
		||||
        ExecutorBase IScript.Exec
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,234 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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 System.Threading;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
using OpenSim.Framework;
 | 
			
		||||
using OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins;
 | 
			
		||||
using Timer=OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins.Timer;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class AsyncCommandManager : iScriptEngineFunctionModule
 | 
			
		||||
    {
 | 
			
		||||
        private static Thread cmdHandlerThread;
 | 
			
		||||
        private static int cmdHandlerThreadCycleSleepms;
 | 
			
		||||
 | 
			
		||||
        public ScriptEngine m_ScriptEngine;
 | 
			
		||||
 | 
			
		||||
        private Timer m_Timer;
 | 
			
		||||
        private HttpRequest m_HttpRequest;
 | 
			
		||||
        private Listener m_Listener;
 | 
			
		||||
        private SensorRepeat m_SensorRepeat;
 | 
			
		||||
        private XmlRequest m_XmlRequest;
 | 
			
		||||
        private Dataserver m_Dataserver;
 | 
			
		||||
 | 
			
		||||
        public Dataserver DataserverPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Dataserver; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Timer TimerPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Timer; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public HttpRequest HttpRequestPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_HttpRequest; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Listener ListenerPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Listener; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SensorRepeat SensorRepeatPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_SensorRepeat; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public XmlRequest XmlRequestPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_XmlRequest; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AsyncCommandManager(ScriptEngine _ScriptEngine)
 | 
			
		||||
        {
 | 
			
		||||
            m_ScriptEngine = _ScriptEngine;
 | 
			
		||||
            ReadConfig();
 | 
			
		||||
 | 
			
		||||
            // Create instances of all plugins
 | 
			
		||||
            m_Timer = new Timer(this);
 | 
			
		||||
            m_HttpRequest = new HttpRequest(this);
 | 
			
		||||
            m_Listener = new Listener(this);
 | 
			
		||||
            m_SensorRepeat = new SensorRepeat(this);
 | 
			
		||||
            m_XmlRequest = new XmlRequest(this);
 | 
			
		||||
            m_Dataserver = new Dataserver(this);
 | 
			
		||||
 | 
			
		||||
            StartThread();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static void StartThread()
 | 
			
		||||
        {
 | 
			
		||||
            if (cmdHandlerThread == null)
 | 
			
		||||
            {
 | 
			
		||||
                // Start the thread that will be doing the work
 | 
			
		||||
                cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
 | 
			
		||||
                cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
 | 
			
		||||
                cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
 | 
			
		||||
                cmdHandlerThread.IsBackground = true;
 | 
			
		||||
                cmdHandlerThread.Start();
 | 
			
		||||
                ThreadTracker.Add(cmdHandlerThread);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ReadConfig()
 | 
			
		||||
        {
 | 
			
		||||
            cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ~AsyncCommandManager()
 | 
			
		||||
        {
 | 
			
		||||
            // Shut down thread
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                if (cmdHandlerThread != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (cmdHandlerThread.IsAlive == true)
 | 
			
		||||
                    {
 | 
			
		||||
                        cmdHandlerThread.Abort();
 | 
			
		||||
                        //cmdHandlerThread.Join();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static void CmdHandlerThreadLoop()
 | 
			
		||||
        {
 | 
			
		||||
            while (true)
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    while (true)
 | 
			
		||||
                    {
 | 
			
		||||
                        Thread.Sleep(cmdHandlerThreadCycleSleepms);
 | 
			
		||||
                        //lock (ScriptEngine.ScriptEngines)
 | 
			
		||||
                        //{
 | 
			
		||||
                            foreach (ScriptEngine se in new ArrayList(ScriptEngine.ScriptEngines))
 | 
			
		||||
                            {
 | 
			
		||||
                                se.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
 | 
			
		||||
                            }
 | 
			
		||||
                        //}
 | 
			
		||||
                        // Sleep before next cycle
 | 
			
		||||
                        //Thread.Sleep(cmdHandlerThreadCycleSleepms);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                catch
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal void DoOneCmdHandlerPass()
 | 
			
		||||
        {
 | 
			
		||||
            // Check timers
 | 
			
		||||
            m_Timer.CheckTimerEvents();
 | 
			
		||||
            // Check HttpRequests
 | 
			
		||||
            m_HttpRequest.CheckHttpRequests();
 | 
			
		||||
            // Check XMLRPCRequests
 | 
			
		||||
            m_XmlRequest.CheckXMLRPCRequests();
 | 
			
		||||
            // Check Listeners
 | 
			
		||||
            m_Listener.CheckListeners();
 | 
			
		||||
            // Check Sensors
 | 
			
		||||
            m_SensorRepeat.CheckSenseRepeaterEvents();
 | 
			
		||||
            // Check dataserver
 | 
			
		||||
            m_Dataserver.ExpireRequests();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Remove a specific script (and all its pending commands)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="localID"></param>
 | 
			
		||||
        /// <param name="itemID"></param>
 | 
			
		||||
        public void RemoveScript(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            // Remove a specific script
 | 
			
		||||
 | 
			
		||||
            // Remove from: Timers
 | 
			
		||||
            m_Timer.UnSetTimerEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove from: HttpRequest
 | 
			
		||||
            IHttpRequests iHttpReq =
 | 
			
		||||
                m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
 | 
			
		||||
            iHttpReq.StopHttpRequest(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
 | 
			
		||||
            comms.DeleteListener(itemID);
 | 
			
		||||
 | 
			
		||||
            IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
 | 
			
		||||
            xmlrpc.DeleteChannels(itemID);
 | 
			
		||||
            xmlrpc.CancelSRDRequests(itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove Sensors
 | 
			
		||||
            m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove queries
 | 
			
		||||
            m_Dataserver.RemoveEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #region Check llRemoteData channels
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Check llListeners
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// If set to true then threads and stuff should try to make a graceful exit
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public bool PleaseShutdown
 | 
			
		||||
        {
 | 
			
		||||
            get { return _PleaseShutdown; }
 | 
			
		||||
            set { _PleaseShutdown = value; }
 | 
			
		||||
        }
 | 
			
		||||
        private bool _PleaseShutdown = false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,127 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    public class Dataserver
 | 
			
		||||
    {
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        private Dictionary<string, DataserverRequest> DataserverRequests =
 | 
			
		||||
                new Dictionary<string, DataserverRequest>();
 | 
			
		||||
 | 
			
		||||
        public Dataserver(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private class DataserverRequest
 | 
			
		||||
        {
 | 
			
		||||
            public uint localID;
 | 
			
		||||
            public UUID itemID;
 | 
			
		||||
 | 
			
		||||
            public UUID ID;
 | 
			
		||||
            public string handle;
 | 
			
		||||
 | 
			
		||||
            public DateTime startTime;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public UUID RegisterRequest(uint localID, UUID itemID,
 | 
			
		||||
                string identifier)
 | 
			
		||||
        {
 | 
			
		||||
            lock (DataserverRequests)
 | 
			
		||||
            {
 | 
			
		||||
                if (DataserverRequests.ContainsKey(identifier))
 | 
			
		||||
                    return UUID.Zero;
 | 
			
		||||
 | 
			
		||||
                DataserverRequest ds = new DataserverRequest();
 | 
			
		||||
 | 
			
		||||
                ds.localID = localID;
 | 
			
		||||
                ds.itemID = itemID;
 | 
			
		||||
 | 
			
		||||
                ds.ID = UUID.Random();
 | 
			
		||||
                ds.handle = identifier;
 | 
			
		||||
 | 
			
		||||
                ds.startTime = DateTime.Now;
 | 
			
		||||
 | 
			
		||||
                DataserverRequests[identifier]=ds;
 | 
			
		||||
 | 
			
		||||
                return ds.ID;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void DataserverReply(string identifier, string reply)
 | 
			
		||||
        {
 | 
			
		||||
            DataserverRequest ds;
 | 
			
		||||
 | 
			
		||||
            lock (DataserverRequests)
 | 
			
		||||
            {
 | 
			
		||||
                if (!DataserverRequests.ContainsKey(identifier))
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                ds=DataserverRequests[identifier];
 | 
			
		||||
                DataserverRequests.Remove(identifier);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToObjectQueue(
 | 
			
		||||
                    ds.localID, "dataserver", EventQueueManager.llDetectNull,
 | 
			
		||||
                    new Object[] { new LSL_Types.LSLString(ds.ID.ToString()),
 | 
			
		||||
                    new LSL_Types.LSLString(reply)});
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemoveEvents(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            lock (DataserverRequests)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
 | 
			
		||||
                {
 | 
			
		||||
                    if (ds.itemID == itemID)
 | 
			
		||||
                        DataserverRequests.Remove(ds.handle);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ExpireRequests()
 | 
			
		||||
        {
 | 
			
		||||
            lock (DataserverRequests)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
 | 
			
		||||
                {
 | 
			
		||||
                    if (ds.startTime > DateTime.Now.AddSeconds(30))
 | 
			
		||||
                        DataserverRequests.Remove(ds.handle);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,98 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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 OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.Environment.Modules.Scripting.HttpRequest;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
{
 | 
			
		||||
    public class HttpRequest
 | 
			
		||||
    {
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        public HttpRequest(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CheckHttpRequests()
 | 
			
		||||
        {
 | 
			
		||||
            if (m_CmdManager.m_ScriptEngine.World == null)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            IHttpRequests iHttpReq =
 | 
			
		||||
                m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
 | 
			
		||||
 | 
			
		||||
            HttpRequestClass httpInfo = null;
 | 
			
		||||
 | 
			
		||||
            if (iHttpReq != null)
 | 
			
		||||
                httpInfo = iHttpReq.GetNextCompletedRequest();
 | 
			
		||||
 | 
			
		||||
            while (httpInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
 | 
			
		||||
 | 
			
		||||
                // Deliver data to prim's remote_data handler
 | 
			
		||||
                //
 | 
			
		||||
                // TODO: Returning null for metadata, since the lsl function
 | 
			
		||||
                // only returns the byte for HTTP_BODY_TRUNCATED, which is not
 | 
			
		||||
                // implemented here yet anyway.  Should be fixed if/when maxsize
 | 
			
		||||
                // is supported
 | 
			
		||||
 | 
			
		||||
                bool handled = false;
 | 
			
		||||
                iHttpReq.RemoveCompletedRequest(httpInfo.reqID);
 | 
			
		||||
                foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
 | 
			
		||||
                {
 | 
			
		||||
                    if (sman.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        object[] resobj = new object[]
 | 
			
		||||
                        {
 | 
			
		||||
                            new LSL_Types.LSLString(httpInfo.reqID.ToString()), new LSL_Types.LSLInteger(httpInfo.status), null, new LSL_Types.LSLString(httpInfo.response_body)
 | 
			
		||||
                        };
 | 
			
		||||
 | 
			
		||||
                        sman.m_EventQueueManager.AddToScriptQueue(
 | 
			
		||||
                            httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj
 | 
			
		||||
                        );
 | 
			
		||||
 | 
			
		||||
                        handled = true;
 | 
			
		||||
                        break;
 | 
			
		||||
                        //Thread.Sleep(2500);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (!handled)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine("Unhandled http_response: " + httpInfo.reqID);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                httpInfo = iHttpReq.GetNextCompletedRequest();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,76 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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 OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
{
 | 
			
		||||
    public class Listener
 | 
			
		||||
    {
 | 
			
		||||
        // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
			
		||||
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        public Listener(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CheckListeners()
 | 
			
		||||
        {
 | 
			
		||||
            if (m_CmdManager.m_ScriptEngine.World == null)
 | 
			
		||||
                return;
 | 
			
		||||
            IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
 | 
			
		||||
 | 
			
		||||
            if (comms != null)
 | 
			
		||||
            {
 | 
			
		||||
                while (comms.HasMessages())
 | 
			
		||||
                {
 | 
			
		||||
                    ListenerInfo lInfo = comms.GetNextMessage();
 | 
			
		||||
                    if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(
 | 
			
		||||
                        lInfo.GetLocalID(), lInfo.GetItemID()) != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        //Deliver data to prim's listen handler
 | 
			
		||||
                        object[] resobj = new object[]
 | 
			
		||||
                        {
 | 
			
		||||
                        //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
 | 
			
		||||
                            new LSL_Types.LSLInteger(lInfo.GetChannel()), new LSL_Types.LSLString(lInfo.GetName()), new LSL_Types.LSLString(lInfo.GetID().ToString()), new LSL_Types.LSLString(lInfo.GetMessage())
 | 
			
		||||
                        };
 | 
			
		||||
 | 
			
		||||
                        m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
 | 
			
		||||
                            lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj
 | 
			
		||||
                        );
 | 
			
		||||
                    }
 | 
			
		||||
                    // else
 | 
			
		||||
                    //     m_log.Info("[ScriptEngineBase.AsyncCommandPlugins: received a listen event for a (no longer) existing script ("+lInfo.GetLocalID().AsString()+")");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,334 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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.
 | 
			
		||||
 */
 | 
			
		||||
//#define SPAM
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
using OpenSim.Framework;
 | 
			
		||||
using OpenSim.Region.Environment.Scenes;
 | 
			
		||||
using OpenSim.Framework.Communications.Cache;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
{
 | 
			
		||||
    public class SensorRepeat
 | 
			
		||||
    {
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        public SensorRepeat(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Dictionary<uint, Dictionary<UUID, LSL_Types.list>> SenseEvents =
 | 
			
		||||
            new Dictionary<uint, Dictionary<UUID, LSL_Types.list>>();
 | 
			
		||||
        private Object SenseLock = new Object();
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        // SenseRepeater and Sensors
 | 
			
		||||
        //
 | 
			
		||||
        private class SenseRepeatClass
 | 
			
		||||
        {
 | 
			
		||||
            public uint localID;
 | 
			
		||||
            public UUID itemID;
 | 
			
		||||
            public double interval;
 | 
			
		||||
            public DateTime next;
 | 
			
		||||
 | 
			
		||||
            public string name;
 | 
			
		||||
            public UUID keyID;
 | 
			
		||||
            public int type;
 | 
			
		||||
            public double range;
 | 
			
		||||
            public double arc;
 | 
			
		||||
            public SceneObjectPart host;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
 | 
			
		||||
        private object SenseRepeatListLock = new object();
 | 
			
		||||
 | 
			
		||||
        public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID,
 | 
			
		||||
            string name, UUID keyID, int type, double range, double arc, double sec, SceneObjectPart host)
 | 
			
		||||
        {
 | 
			
		||||
            #if SPAM
 | 
			
		||||
            Console.WriteLine("SetSensorEvent");
 | 
			
		||||
            #endif
 | 
			
		||||
            // Always remove first, in case this is a re-set
 | 
			
		||||
            UnSetSenseRepeaterEvents(m_localID, m_itemID);
 | 
			
		||||
            if (sec == 0) // Disabling timer
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            // Add to timer
 | 
			
		||||
            SenseRepeatClass ts = new SenseRepeatClass();
 | 
			
		||||
            ts.localID = m_localID;
 | 
			
		||||
            ts.itemID = m_itemID;
 | 
			
		||||
            ts.interval = sec;
 | 
			
		||||
            ts.name = name;
 | 
			
		||||
            ts.keyID = keyID;
 | 
			
		||||
            ts.type = type;
 | 
			
		||||
            ts.range = range;
 | 
			
		||||
            ts.arc = arc;
 | 
			
		||||
            ts.host = host;
 | 
			
		||||
 | 
			
		||||
            ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
 | 
			
		||||
            lock (SenseRepeatListLock)
 | 
			
		||||
            {
 | 
			
		||||
                SenseRepeaters.Add(ts);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UnSetSenseRepeaterEvents(uint m_localID, UUID m_itemID)
 | 
			
		||||
        {
 | 
			
		||||
            // Remove from timer
 | 
			
		||||
            lock (SenseRepeatListLock)
 | 
			
		||||
            {
 | 
			
		||||
                List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
 | 
			
		||||
                foreach (SenseRepeatClass ts in SenseRepeaters)
 | 
			
		||||
                {
 | 
			
		||||
                    if (ts.localID != m_localID && ts.itemID != m_itemID)
 | 
			
		||||
                    {
 | 
			
		||||
                        NewSensors.Add(ts);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                SenseRepeaters.Clear();
 | 
			
		||||
                SenseRepeaters = NewSensors;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CheckSenseRepeaterEvents()
 | 
			
		||||
        {
 | 
			
		||||
            // Nothing to do here?
 | 
			
		||||
            if (SenseRepeaters.Count == 0)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            lock (SenseRepeatListLock)
 | 
			
		||||
            {
 | 
			
		||||
                // Go through all timers
 | 
			
		||||
                foreach (SenseRepeatClass ts in SenseRepeaters)
 | 
			
		||||
                {
 | 
			
		||||
                    // Time has passed?
 | 
			
		||||
                    if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
 | 
			
		||||
                    {
 | 
			
		||||
                        SensorSweep(ts);
 | 
			
		||||
                        // set next interval
 | 
			
		||||
                        ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } // lock
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SenseOnce(uint m_localID, UUID m_itemID,
 | 
			
		||||
                              string name, UUID keyID, int type,
 | 
			
		||||
                              double range, double arc, SceneObjectPart host)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to timer
 | 
			
		||||
            SenseRepeatClass ts = new SenseRepeatClass();
 | 
			
		||||
            ts.localID = m_localID;
 | 
			
		||||
            ts.itemID = m_itemID;
 | 
			
		||||
            ts.interval = 0;
 | 
			
		||||
            ts.name = name;
 | 
			
		||||
            ts.keyID = keyID;
 | 
			
		||||
            ts.type = type;
 | 
			
		||||
            ts.range = range;
 | 
			
		||||
            ts.arc = arc;
 | 
			
		||||
            ts.host = host;
 | 
			
		||||
            SensorSweep(ts);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID)
 | 
			
		||||
        {
 | 
			
		||||
            lock (SenseLock)
 | 
			
		||||
            {
 | 
			
		||||
                Dictionary<UUID, LSL_Types.list> Obj = null;
 | 
			
		||||
                if (!SenseEvents.TryGetValue(m_localID, out Obj))
 | 
			
		||||
                {
 | 
			
		||||
                    #if SPAM
 | 
			
		||||
                    m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
 | 
			
		||||
                    #endif
 | 
			
		||||
                    return null;
 | 
			
		||||
                }
 | 
			
		||||
                lock (Obj)
 | 
			
		||||
                {
 | 
			
		||||
                    // Get script
 | 
			
		||||
                    LSL_Types.list SenseList = null;
 | 
			
		||||
                    if (!Obj.TryGetValue(m_itemID, out SenseList))
 | 
			
		||||
                    {
 | 
			
		||||
                        #if SPAM
 | 
			
		||||
                        m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
 | 
			
		||||
                        #endif
 | 
			
		||||
                        return null;
 | 
			
		||||
                    }
 | 
			
		||||
                    return SenseList;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void SensorSweep(SenseRepeatClass ts)
 | 
			
		||||
        {
 | 
			
		||||
            //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
 | 
			
		||||
            SceneObjectPart SensePoint = ts.host;
 | 
			
		||||
 | 
			
		||||
            if (SensePoint == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                #if SPAM
 | 
			
		||||
                //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
 | 
			
		||||
                #endif
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
 | 
			
		||||
 | 
			
		||||
            Vector3 sensorPos = SensePoint.AbsolutePosition;
 | 
			
		||||
            Vector3 regionPos = new Vector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
 | 
			
		||||
            Vector3 fromRegionPos = sensorPos + regionPos;
 | 
			
		||||
 | 
			
		||||
            Quaternion q = SensePoint.RotationOffset;
 | 
			
		||||
            LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
 | 
			
		||||
            LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
 | 
			
		||||
            double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
 | 
			
		||||
 | 
			
		||||
            // Here we should do some smart culling ...
 | 
			
		||||
            // math seems quicker than strings so try that first
 | 
			
		||||
            LSL_Types.list SensedObjects = new LSL_Types.list();
 | 
			
		||||
            LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
 | 
			
		||||
 | 
			
		||||
            foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values)
 | 
			
		||||
            {
 | 
			
		||||
                Vector3 toRegionPos = ent.AbsolutePosition + regionPos;
 | 
			
		||||
                double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos));
 | 
			
		||||
                if (dis <= ts.range)
 | 
			
		||||
                {
 | 
			
		||||
                    // In Range, is it the right Type ?
 | 
			
		||||
                    int objtype = 0;
 | 
			
		||||
 | 
			
		||||
                    if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor
 | 
			
		||||
                    if (ent.Velocity.Equals(ZeroVector))
 | 
			
		||||
                        objtype |= 0x04; // passive non-moving
 | 
			
		||||
                    else
 | 
			
		||||
                        objtype |= 0x02; // active moving
 | 
			
		||||
                    if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ...
 | 
			
		||||
 | 
			
		||||
                    if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type))
 | 
			
		||||
                    {
 | 
			
		||||
                        // docs claim AGENT|ACTIVE should find agent objects OR active objects
 | 
			
		||||
                        // so the bitwise AND with object type should be non-zero
 | 
			
		||||
 | 
			
		||||
                        // Right type too, what about the other params , key and name ?
 | 
			
		||||
                        bool keep = true;
 | 
			
		||||
                        if (ts.arc < Math.PI)
 | 
			
		||||
                        {
 | 
			
		||||
                            // not omni-directional. Can you see it ?
 | 
			
		||||
                            // vec forward_dir = llRot2Fwd(llGetRot())
 | 
			
		||||
                            // vec obj_dir = toRegionPos-fromRegionPos
 | 
			
		||||
                            // dot=dot(forward_dir,obj_dir)
 | 
			
		||||
                            // mag_fwd = mag(forward_dir)
 | 
			
		||||
                            // mag_obj = mag(obj_dir)
 | 
			
		||||
                            // ang = acos(dot /(mag_fwd*mag_obj))
 | 
			
		||||
                            double ang_obj = 0;
 | 
			
		||||
                            try
 | 
			
		||||
                            {
 | 
			
		||||
                                Vector3 diff = toRegionPos - fromRegionPos;
 | 
			
		||||
                                LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
 | 
			
		||||
                                double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
 | 
			
		||||
                                double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
 | 
			
		||||
                                ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
 | 
			
		||||
                            }
 | 
			
		||||
                            catch
 | 
			
		||||
                            {
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            if (ang_obj > ts.arc) keep = false;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (keep && (ts.keyID != UUID.Zero) && (ts.keyID != ent.UUID))
 | 
			
		||||
                        {
 | 
			
		||||
                            keep = false;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (keep && (ts.name.Length > 0))
 | 
			
		||||
                        {
 | 
			
		||||
                            string avatarname=null;
 | 
			
		||||
                            string objectname=null;
 | 
			
		||||
                            string entname =ent.Name;
 | 
			
		||||
 | 
			
		||||
                            // try avatar username surname
 | 
			
		||||
                            CachedUserInfo profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserProfileCacheService.GetUserDetails(ent.UUID);
 | 
			
		||||
                            if (profile != null && profile.UserProfile != null)
 | 
			
		||||
                            {
 | 
			
		||||
                               avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName;
 | 
			
		||||
                            }
 | 
			
		||||
                            // try an scene object
 | 
			
		||||
                            SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
 | 
			
		||||
                            if (SOP != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                objectname = SOP.Name;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname))
 | 
			
		||||
                            {
 | 
			
		||||
                               keep = false;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if (keep == true) SensedObjects.Add(ent.UUID);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            #if SPAM
 | 
			
		||||
            //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
 | 
			
		||||
            #endif
 | 
			
		||||
            lock (SenseLock)
 | 
			
		||||
            {
 | 
			
		||||
                // Create object if it doesn't exist
 | 
			
		||||
                if (SenseEvents.ContainsKey(ts.localID) == false)
 | 
			
		||||
                {
 | 
			
		||||
                    SenseEvents.Add(ts.localID, new Dictionary<UUID, LSL_Types.list>());
 | 
			
		||||
                }
 | 
			
		||||
                // clear if previous traces exist
 | 
			
		||||
                Dictionary<UUID, LSL_Types.list> Obj;
 | 
			
		||||
                SenseEvents.TryGetValue(ts.localID, out Obj);
 | 
			
		||||
                if (Obj.ContainsKey(ts.itemID) == true)
 | 
			
		||||
                    Obj.Remove(ts.itemID);
 | 
			
		||||
 | 
			
		||||
                // note list may be zero length
 | 
			
		||||
                Obj.Add(ts.itemID, SensedObjects);
 | 
			
		||||
 | 
			
		||||
                if (SensedObjects.Length == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    // send a "no_sensor"
 | 
			
		||||
                    // Add it to queue
 | 
			
		||||
                    m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull,
 | 
			
		||||
                                                                        new object[] { });
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull,
 | 
			
		||||
                                                                        new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) });
 | 
			
		||||
                }
 | 
			
		||||
                m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ts.interval);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,139 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
{
 | 
			
		||||
    public class Timer
 | 
			
		||||
    {
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        public Timer(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        // TIMER
 | 
			
		||||
        //
 | 
			
		||||
        private class TimerClass
 | 
			
		||||
        {
 | 
			
		||||
            public uint localID;
 | 
			
		||||
            public UUID itemID;
 | 
			
		||||
            //public double interval;
 | 
			
		||||
            public long interval;
 | 
			
		||||
            //public DateTime next;
 | 
			
		||||
            public long next;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private List<TimerClass> Timers = new List<TimerClass>();
 | 
			
		||||
        private object TimerListLock = new object();
 | 
			
		||||
 | 
			
		||||
        public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec)
 | 
			
		||||
        {
 | 
			
		||||
            // Console.WriteLine("SetTimerEvent");
 | 
			
		||||
 | 
			
		||||
            // Always remove first, in case this is a re-set
 | 
			
		||||
            UnSetTimerEvents(m_localID, m_itemID);
 | 
			
		||||
            if (sec == 0) // Disabling timer
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            // Add to timer
 | 
			
		||||
            TimerClass ts = new TimerClass();
 | 
			
		||||
            ts.localID = m_localID;
 | 
			
		||||
            ts.itemID = m_itemID;
 | 
			
		||||
            ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
 | 
			
		||||
            //       2193386136332921 ticks
 | 
			
		||||
            //       219338613 seconds
 | 
			
		||||
 | 
			
		||||
            //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
 | 
			
		||||
            ts.next = DateTime.Now.Ticks + ts.interval;
 | 
			
		||||
            lock (TimerListLock)
 | 
			
		||||
            {
 | 
			
		||||
                Timers.Add(ts);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void UnSetTimerEvents(uint m_localID, UUID m_itemID)
 | 
			
		||||
        {
 | 
			
		||||
            // Remove from timer
 | 
			
		||||
            lock (TimerListLock)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (TimerClass ts in new ArrayList(Timers))
 | 
			
		||||
                {
 | 
			
		||||
                    if (ts.localID == m_localID && ts.itemID == m_itemID)
 | 
			
		||||
                        Timers.Remove(ts);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Old method: Create new list
 | 
			
		||||
            //List<TimerClass> NewTimers = new List<TimerClass>();
 | 
			
		||||
            //foreach (TimerClass ts in Timers)
 | 
			
		||||
            //{
 | 
			
		||||
            //    if (ts.localID != m_localID && ts.itemID != m_itemID)
 | 
			
		||||
            //    {
 | 
			
		||||
            //        NewTimers.Add(ts);
 | 
			
		||||
            //    }
 | 
			
		||||
            //}
 | 
			
		||||
            //Timers.Clear();
 | 
			
		||||
            //Timers = NewTimers;
 | 
			
		||||
            //}
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CheckTimerEvents()
 | 
			
		||||
        {
 | 
			
		||||
            // Nothing to do here?
 | 
			
		||||
            if (Timers.Count == 0)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            lock (TimerListLock)
 | 
			
		||||
            {
 | 
			
		||||
                // Go through all timers
 | 
			
		||||
                foreach (TimerClass ts in Timers)
 | 
			
		||||
                {
 | 
			
		||||
                    // Time has passed?
 | 
			
		||||
                    if (ts.next < DateTime.Now.Ticks)
 | 
			
		||||
                    {
 | 
			
		||||
                        //                        Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
 | 
			
		||||
                        // Add it to queue
 | 
			
		||||
                        m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull,
 | 
			
		||||
                                                                            null);
 | 
			
		||||
                        m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ((double)ts.interval / 10000000));
 | 
			
		||||
                        // set next interval
 | 
			
		||||
 | 
			
		||||
                        //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
 | 
			
		||||
                        ts.next = DateTime.Now.Ticks + ts.interval;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,130 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 OpenSim 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 OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.Environment.Modules.Scripting.XMLRPC;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
 | 
			
		||||
{
 | 
			
		||||
    public class XmlRequest
 | 
			
		||||
    {
 | 
			
		||||
        public AsyncCommandManager m_CmdManager;
 | 
			
		||||
 | 
			
		||||
        public XmlRequest(AsyncCommandManager CmdManager)
 | 
			
		||||
        {
 | 
			
		||||
            m_CmdManager = CmdManager;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CheckXMLRPCRequests()
 | 
			
		||||
        {
 | 
			
		||||
            if (m_CmdManager.m_ScriptEngine.World == null)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
 | 
			
		||||
            if (null == xmlrpc)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            // Process the completed request queue
 | 
			
		||||
            RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest();
 | 
			
		||||
 | 
			
		||||
            while (rInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                bool handled = false;
 | 
			
		||||
 | 
			
		||||
                // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
 | 
			
		||||
                xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID());
 | 
			
		||||
 | 
			
		||||
                // And since the xmlrpc request queue is actually shared among all regions on the simulator, we need
 | 
			
		||||
                // to look in each one for the appropriate handler
 | 
			
		||||
                foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) {
 | 
			
		||||
                    if (sman.m_ScriptManager.GetScript(rInfo.GetLocalID(),rInfo.GetItemID()) != null) {
 | 
			
		||||
 | 
			
		||||
                        //Deliver data to prim's remote_data handler
 | 
			
		||||
                        object[] resobj = new object[]
 | 
			
		||||
                        {
 | 
			
		||||
                            new LSL_Types.LSLInteger(2), new LSL_Types.LSLString(rInfo.GetChannelKey().ToString()), new LSL_Types.LSLString(rInfo.GetMessageID().ToString()), new LSL_Types.LSLString(String.Empty),
 | 
			
		||||
                            new LSL_Types.LSLInteger(rInfo.GetIntValue()),
 | 
			
		||||
                            new LSL_Types.LSLString(rInfo.GetStrVal())
 | 
			
		||||
                        };
 | 
			
		||||
                        sman.m_EventQueueManager.AddToScriptQueue(
 | 
			
		||||
                            rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj
 | 
			
		||||
                        );
 | 
			
		||||
 | 
			
		||||
                        handled = true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (! handled)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine("Unhandled xml_request: " + rInfo.GetItemID());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                rInfo = xmlrpc.GetNextCompletedRequest();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Process the send queue
 | 
			
		||||
            SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest();
 | 
			
		||||
 | 
			
		||||
            while (srdInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                bool handled = false;
 | 
			
		||||
 | 
			
		||||
                // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
 | 
			
		||||
                xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID());
 | 
			
		||||
 | 
			
		||||
                // And this is another shared queue... so we check each of the script engines for a handler
 | 
			
		||||
                foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
 | 
			
		||||
                {
 | 
			
		||||
                    if (sman.m_ScriptManager.GetScript(srdInfo.m_localID,srdInfo.m_itemID) != null) {
 | 
			
		||||
 | 
			
		||||
                        //Deliver data to prim's remote_data handler
 | 
			
		||||
                        object[] resobj = new object[]
 | 
			
		||||
                        {
 | 
			
		||||
                            new LSL_Types.LSLInteger(3), new LSL_Types.LSLString(srdInfo.channel.ToString()), new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), new LSL_Types.LSLString(String.Empty),
 | 
			
		||||
                            new LSL_Types.LSLInteger(srdInfo.idata),
 | 
			
		||||
                            new LSL_Types.LSLString(srdInfo.sdata)
 | 
			
		||||
                        };
 | 
			
		||||
                        sman.m_EventQueueManager.AddToScriptQueue(
 | 
			
		||||
                            srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj
 | 
			
		||||
                        );
 | 
			
		||||
 | 
			
		||||
                        handled = true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (! handled)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine("Unhandled xml_srdrequest: " + srdInfo.GetReqID());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                srdInfo = xmlrpc.GetNextCompletedSRDRequest();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -114,83 +114,103 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        public void changed(uint localID, uint change)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in localID, Object pass change.
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "changed", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(change) });
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "changed",new object[] { new LSL_Types.LSLInteger(change) },
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void state_entry(uint localID)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_entry", EventQueueManager.llDetectNull, new object[] { });
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "state_entry",new object[] { },
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient)
 | 
			
		||||
        public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
 | 
			
		||||
                IClientAPI remoteClient)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
 | 
			
		||||
            detstruct._key = new LSL_Types.key[1];
 | 
			
		||||
            detstruct._key2 = new LSL_Types.key[1];
 | 
			
		||||
            detstruct._string = new string[1];
 | 
			
		||||
            detstruct._Vector3 = new LSL_Types.Vector3[1];
 | 
			
		||||
            detstruct._Vector32 = new LSL_Types.Vector3[1];
 | 
			
		||||
            detstruct._Quaternion = new LSL_Types.Quaternion[1];
 | 
			
		||||
            detstruct._int = new int[1];
 | 
			
		||||
            ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId);
 | 
			
		||||
            if (av != null)
 | 
			
		||||
            DetectParams[] det = new DetectParams[1];
 | 
			
		||||
            det[0] = new DetectParams();
 | 
			
		||||
            det[0].Key = remoteClient.AgentId;
 | 
			
		||||
            det[0].Populate(myScriptEngine.World);
 | 
			
		||||
 | 
			
		||||
            if (originalID == 0)
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._string[0] = remoteClient.Name;
 | 
			
		||||
                detstruct._int[0] = 0;
 | 
			
		||||
                detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X,av.Rotation.Y,av.Rotation.Z,av.Rotation.W);
 | 
			
		||||
                detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X,av.AbsolutePosition.Y,av.AbsolutePosition.Z);
 | 
			
		||||
                detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z);
 | 
			
		||||
                SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
 | 
			
		||||
                if (part == null)
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                det[0].LinkNum = part.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._string[0] = remoteClient.Name;
 | 
			
		||||
                detstruct._int[0] = 0;
 | 
			
		||||
                detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1);
 | 
			
		||||
                detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0);
 | 
			
		||||
                detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0);
 | 
			
		||||
                SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
 | 
			
		||||
                det[0].LinkNum = originalPart.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
 | 
			
		||||
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
 | 
			
		||||
                    det));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void touch(uint localID, uint originalID, Vector3 offsetPos,
 | 
			
		||||
                IClientAPI remoteClient)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            DetectParams[] det = new DetectParams[1];
 | 
			
		||||
            det[0] = new DetectParams();
 | 
			
		||||
            det[0].Key = remoteClient.AgentId;
 | 
			
		||||
            det[0].Populate(myScriptEngine.World);
 | 
			
		||||
            det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
 | 
			
		||||
                                                     offsetPos.Y,
 | 
			
		||||
                                                     offsetPos.Z);
 | 
			
		||||
 | 
			
		||||
            if (originalID == 0)
 | 
			
		||||
            {
 | 
			
		||||
                SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
 | 
			
		||||
                if (part == null)
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                det[0].LinkNum = part.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
 | 
			
		||||
                det[0].LinkNum = originalPart.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "touch", new Object[] { new LSL_Types.LSLInteger(1) },
 | 
			
		||||
                    det));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void touch_end(uint localID, uint originalID, IClientAPI remoteClient)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
 | 
			
		||||
            detstruct._key = new LSL_Types.key[1];
 | 
			
		||||
            detstruct._key2 = new LSL_Types.key[1];
 | 
			
		||||
            detstruct._string = new string[1];
 | 
			
		||||
            detstruct._Vector3 = new LSL_Types.Vector3[1];
 | 
			
		||||
            detstruct._Vector32 = new LSL_Types.Vector3[1];
 | 
			
		||||
            detstruct._Quaternion = new LSL_Types.Quaternion[1];
 | 
			
		||||
            detstruct._int = new int[1];
 | 
			
		||||
            ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId);
 | 
			
		||||
            if (av != null)
 | 
			
		||||
            DetectParams[] det = new DetectParams[1];
 | 
			
		||||
            det[0] = new DetectParams();
 | 
			
		||||
            det[0].Key = remoteClient.AgentId;
 | 
			
		||||
            det[0].Populate(myScriptEngine.World);
 | 
			
		||||
 | 
			
		||||
            if (originalID == 0)
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._string[0] = remoteClient.Name;
 | 
			
		||||
                detstruct._int[0] = 0;
 | 
			
		||||
                detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W);
 | 
			
		||||
                detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X, av.AbsolutePosition.Y, av.AbsolutePosition.Z);
 | 
			
		||||
                detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X, av.Velocity.Y, av.Velocity.Z);
 | 
			
		||||
                SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
 | 
			
		||||
                if (part == null)
 | 
			
		||||
                    return;
 | 
			
		||||
 | 
			
		||||
                det[0].LinkNum = part.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
 | 
			
		||||
                detstruct._string[0] = remoteClient.Name;
 | 
			
		||||
                detstruct._int[0] = 0;
 | 
			
		||||
                detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1);
 | 
			
		||||
                detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0);
 | 
			
		||||
                detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0);
 | 
			
		||||
                SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
 | 
			
		||||
                det[0].LinkNum = originalPart.LinkNum;
 | 
			
		||||
            }
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
 | 
			
		||||
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
 | 
			
		||||
                    det));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +248,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
 | 
			
		||||
        public void money(uint localID, UUID agentID, int amount)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(amount) });
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "money", new object[] {
 | 
			
		||||
                    new LSL_Types.LSLString(agentID.ToString()),
 | 
			
		||||
                    new LSL_Types.LSLInteger(amount) },
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO: Replace placeholders below
 | 
			
		||||
| 
						 | 
				
			
			@ -239,225 +263,196 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
 | 
			
		||||
        public void state_exit(uint localID)
 | 
			
		||||
        {
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_exit", EventQueueManager.llDetectNull, new object[] { });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void touch(uint localID, uint originalID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void touch_end(uint localID, uint originalID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "state_exit", new object[] { },
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void collision_start(uint localID, ColliderArgs col)
 | 
			
		||||
        {
 | 
			
		||||
            EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
 | 
			
		||||
            detstruct._string = new string[col.Colliders.Count];
 | 
			
		||||
            detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count];
 | 
			
		||||
            detstruct._int = new int[col.Colliders.Count];
 | 
			
		||||
            detstruct._key = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._bool = new bool[col.Colliders.Count];
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            List<DetectParams> det = new List<DetectParams>();
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            foreach (DetectedObject detobj in col.Colliders)
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString());
 | 
			
		||||
                detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString());
 | 
			
		||||
                detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W);
 | 
			
		||||
                detstruct._string[i] = detobj.nameStr;
 | 
			
		||||
                detstruct._int[i] = detobj.colliderType;
 | 
			
		||||
                detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
 | 
			
		||||
                detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
 | 
			
		||||
                detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry...
 | 
			
		||||
                i++;
 | 
			
		||||
                DetectParams d = new DetectParams();
 | 
			
		||||
                d.Key =detobj.keyUUID;
 | 
			
		||||
                d.Populate(myScriptEngine.World);
 | 
			
		||||
                det.Add(d);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_start", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) });
 | 
			
		||||
            if (det.Count > 0)
 | 
			
		||||
                myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                        "collision_start",
 | 
			
		||||
                        new Object[] { new LSL_Types.LSLInteger(det.Count) },
 | 
			
		||||
                        det.ToArray()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void collision(uint localID, ColliderArgs col)
 | 
			
		||||
        {
 | 
			
		||||
            EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
 | 
			
		||||
            detstruct._string = new string[col.Colliders.Count];
 | 
			
		||||
            detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count];
 | 
			
		||||
            detstruct._int = new int[col.Colliders.Count];
 | 
			
		||||
            detstruct._key = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._bool = new bool[col.Colliders.Count];
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            List<DetectParams> det = new List<DetectParams>();
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            foreach (DetectedObject detobj in col.Colliders)
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString());
 | 
			
		||||
                detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString());
 | 
			
		||||
                detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W);
 | 
			
		||||
                detstruct._string[i] = detobj.nameStr;
 | 
			
		||||
                detstruct._int[i] = detobj.colliderType;
 | 
			
		||||
                detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
 | 
			
		||||
                detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
 | 
			
		||||
                detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry...                    i++;
 | 
			
		||||
                DetectParams d = new DetectParams();
 | 
			
		||||
                d.Key =detobj.keyUUID;
 | 
			
		||||
                d.Populate(myScriptEngine.World);
 | 
			
		||||
                det.Add(d);
 | 
			
		||||
            }
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) });
 | 
			
		||||
 | 
			
		||||
            if (det.Count > 0)
 | 
			
		||||
                myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                        "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
 | 
			
		||||
                        det.ToArray()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void collision_end(uint localID, ColliderArgs col)
 | 
			
		||||
        {
 | 
			
		||||
            EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
 | 
			
		||||
            detstruct._string = new string[col.Colliders.Count];
 | 
			
		||||
            detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count];
 | 
			
		||||
            detstruct._int = new int[col.Colliders.Count];
 | 
			
		||||
            detstruct._key = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._key2 = new LSL_Types.key[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count];
 | 
			
		||||
            detstruct._bool = new bool[col.Colliders.Count];
 | 
			
		||||
            // Add to queue for all scripts in ObjectID object
 | 
			
		||||
            List<DetectParams> det = new List<DetectParams>();
 | 
			
		||||
 | 
			
		||||
            int i = 0;
 | 
			
		||||
            foreach (DetectedObject detobj in col.Colliders)
 | 
			
		||||
            {
 | 
			
		||||
                detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString());
 | 
			
		||||
                detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString());
 | 
			
		||||
                detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W);
 | 
			
		||||
                detstruct._string[i] = detobj.nameStr;
 | 
			
		||||
                detstruct._int[i] = detobj.colliderType;
 | 
			
		||||
                detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z);
 | 
			
		||||
                detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z);
 | 
			
		||||
                detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry...
 | 
			
		||||
                i++;
 | 
			
		||||
                DetectParams d = new DetectParams();
 | 
			
		||||
                d.Key =detobj.keyUUID;
 | 
			
		||||
                d.Populate(myScriptEngine.World);
 | 
			
		||||
                det.Add(d);
 | 
			
		||||
            }
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) });
 | 
			
		||||
 | 
			
		||||
            if (det.Count > 0)
 | 
			
		||||
                myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                        "collision_end",
 | 
			
		||||
                        new Object[] { new LSL_Types.LSLInteger(det.Count) },
 | 
			
		||||
                        det.ToArray()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void land_collision_start(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "land_collision_start",
 | 
			
		||||
                    new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void land_collision(uint localID, ColliderArgs col)
 | 
			
		||||
        public void land_collision(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "land_collision", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "land_collision",
 | 
			
		||||
                    new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void land_collision_end(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "land_collision_end",
 | 
			
		||||
                    new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Handled by long commands
 | 
			
		||||
        public void timer(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, String.Empty);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void listen(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void on_rez(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void sensor(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void no_sensor(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change)
 | 
			
		||||
        {
 | 
			
		||||
            if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return;
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(held), new LSL_Types.LSLInteger(change)});
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "control",new object[] {
 | 
			
		||||
                    new LSL_Types.LSLString(agentID.ToString()),
 | 
			
		||||
                    new LSL_Types.LSLInteger(held),
 | 
			
		||||
                    new LSL_Types.LSLInteger(change)},
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void email(uint localID, UUID itemID)
 | 
			
		||||
        public void email(uint localID, UUID itemID, string timeSent,
 | 
			
		||||
                string address, string subject, string message, int numLeft)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "email",new object[] {
 | 
			
		||||
                    new LSL_Types.LSLString(timeSent),
 | 
			
		||||
                    new LSL_Types.LSLString(address),
 | 
			
		||||
                    new LSL_Types.LSLString(subject),
 | 
			
		||||
                    new LSL_Types.LSLString(message),
 | 
			
		||||
                    new LSL_Types.LSLInteger(numLeft)},
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos)
 | 
			
		||||
        public void at_target(uint localID, uint handle, Vector3 targetpos,
 | 
			
		||||
                Vector3 atpos)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "at_target", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(handle), new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) });
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "at_target", new object[] {
 | 
			
		||||
                    new LSL_Types.LSLInteger(handle),
 | 
			
		||||
                    new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
 | 
			
		||||
                    new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void not_at_target(uint localID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "not_at_target", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "not_at_target",new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void at_rot_target(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "at_rot_target",new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void not_at_rot_target(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void run_time_permissions(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void changed(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "not_at_rot_target",new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void attach(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void dataserver(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void link_message(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void moving_start(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "moving_start",new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void moving_end(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end", EventQueueManager.llDetectNull);
 | 
			
		||||
            myScriptEngine.PostObjectEvent(localID, new EventParams(
 | 
			
		||||
                    "moving_end",new object[0],
 | 
			
		||||
                    new DetectParams[0]));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void object_rez(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void remote_data(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Handled by long commands
 | 
			
		||||
        public void http_response(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            //    myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response", EventQueueManager.llDetectNull);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,32 +137,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
            public uint localID;
 | 
			
		||||
            public UUID itemID;
 | 
			
		||||
            public string functionName;
 | 
			
		||||
            public Queue_llDetectParams_Struct llDetectParams;
 | 
			
		||||
            public DetectParams[] llDetectParams;
 | 
			
		||||
            public object[] param;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shared empty llDetectNull
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public readonly static Queue_llDetectParams_Struct llDetectNull = new Queue_llDetectParams_Struct();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Structure to hold data for llDetect* commands
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Serializable]
 | 
			
		||||
        public struct Queue_llDetectParams_Struct
 | 
			
		||||
        {
 | 
			
		||||
            // More or less just a placeholder for the actual moving of additional data
 | 
			
		||||
            // should be fixed to something better :)
 | 
			
		||||
            public LSL_Types.key[] _key; // detected key
 | 
			
		||||
            public LSL_Types.key[] _key2;  // ownerkey
 | 
			
		||||
            public LSL_Types.Quaternion[] _Quaternion;
 | 
			
		||||
            public LSL_Types.Vector3[] _Vector3; // Pos
 | 
			
		||||
            public LSL_Types.Vector3[] _Vector32; // Vel
 | 
			
		||||
            public bool[] _bool;
 | 
			
		||||
            public int[] _int;
 | 
			
		||||
            public string[] _string;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region " Initialization / Startup "
 | 
			
		||||
| 
						 | 
				
			
			@ -322,7 +300,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        /// <param name="localID">Region object ID</param>
 | 
			
		||||
        /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
 | 
			
		||||
        /// <param name="param">Array of parameters to match event mask</param>
 | 
			
		||||
        public bool AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
 | 
			
		||||
        public bool AddToObjectQueue(uint localID, string FunctionName, DetectParams[] qParams, params object[] param)
 | 
			
		||||
        {
 | 
			
		||||
            // Determine all scripts in Object and add to their queue
 | 
			
		||||
            //myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
 | 
			
		||||
| 
						 | 
				
			
			@ -353,7 +331,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        /// <param name="itemID">Region script ID</param>
 | 
			
		||||
        /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
 | 
			
		||||
        /// <param name="param">Array of parameters to match event mask</param>
 | 
			
		||||
        public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
 | 
			
		||||
        public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, params object[] param)
 | 
			
		||||
        {
 | 
			
		||||
            List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,7 +57,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        public EventQueueManager m_EventQueueManager;               // Executes events, handles script threads
 | 
			
		||||
        public ScriptManager m_ScriptManager;                       // Load, unload and execute scripts
 | 
			
		||||
        public AppDomainManager m_AppDomainManager;                 // Handles loading/unloading of scripts into AppDomains
 | 
			
		||||
        public AsyncCommandManager m_ASYNCLSLCommandManager;     // Asyncronous LSL commands (commands that returns with an event)
 | 
			
		||||
        public static MaintenanceThread m_MaintenanceThread;        // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long
 | 
			
		||||
 | 
			
		||||
        public IConfigSource ConfigSource;
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +120,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
            // We need to start it
 | 
			
		||||
            m_ScriptManager = newScriptManager;
 | 
			
		||||
            m_AppDomainManager = new AppDomainManager(this);
 | 
			
		||||
            m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
 | 
			
		||||
            if (m_MaintenanceThread == null)
 | 
			
		||||
                m_MaintenanceThread = new MaintenanceThread();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +170,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
            if (m_EventManager != null) m_EventManager.ReadConfig();
 | 
			
		||||
            if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
 | 
			
		||||
            if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig();
 | 
			
		||||
            if (m_ASYNCLSLCommandManager != null) m_ASYNCLSLCommandManager.ReadConfig();
 | 
			
		||||
            if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -196,15 +193,33 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
 | 
			
		||||
        public bool PostObjectEvent(uint localID, EventParams p)
 | 
			
		||||
        {
 | 
			
		||||
            return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, EventQueueManager.llDetectNull, p.Params);
 | 
			
		||||
            return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, p.DetectParams, p.Params);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool PostScriptEvent(UUID itemID, EventParams p)
 | 
			
		||||
        {
 | 
			
		||||
            uint localID = m_ScriptManager.GetLocalID(itemID);
 | 
			
		||||
            return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params);
 | 
			
		||||
            return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, p.DetectParams, p.Params);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public DetectParams GetDetectParams(UUID itemID, int number)
 | 
			
		||||
        {
 | 
			
		||||
            uint localID = m_ScriptManager.GetLocalID(itemID);
 | 
			
		||||
            if (localID == 0)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            IScript Script = m_ScriptManager.GetScript(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            if (Script == null)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            DetectParams[] det = m_ScriptManager.GetDetectParams(Script);
 | 
			
		||||
 | 
			
		||||
            if (number < 0 || number >= det.Length)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            return det[number];
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,7 @@ using System.Runtime.Serialization.Formatters.Binary;
 | 
			
		|||
using System.Threading;
 | 
			
		||||
using OpenMetaverse;
 | 
			
		||||
using OpenSim.Region.Environment.Scenes;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -65,6 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        private int LoadUnloadMaxQueueSize;
 | 
			
		||||
        private Object scriptLock = new Object();
 | 
			
		||||
        private bool m_started = false;
 | 
			
		||||
        private Dictionary<IScript, DetectParams[]> detparms = new Dictionary<IScript, DetectParams[]>();
 | 
			
		||||
 | 
			
		||||
        // Load/Unload structure
 | 
			
		||||
        private struct LUStruct
 | 
			
		||||
| 
						 | 
				
			
			@ -228,6 +230,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
                    if (item.Action == LUType.Unload)
 | 
			
		||||
                    {
 | 
			
		||||
                        _StopScript(item.localID, item.itemID);
 | 
			
		||||
                        RemoveScript(item.localID, item.itemID);
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (item.Action == LUType.Load)
 | 
			
		||||
                    {
 | 
			
		||||
| 
						 | 
				
			
			@ -318,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        /// <param name="itemID">Script ID</param>
 | 
			
		||||
        /// <param name="FunctionName">Name of function</param>
 | 
			
		||||
        /// <param name="args">Arguments to pass to function</param>
 | 
			
		||||
        internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args)
 | 
			
		||||
        internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined
 | 
			
		||||
            ///#if DEBUG
 | 
			
		||||
| 
						 | 
				
			
			@ -337,8 +340,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
            ///            Console.WriteLine("ScriptEngine: Executing event: " + FunctionName);
 | 
			
		||||
            ///#endif
 | 
			
		||||
            // Must be done in correct AppDomain, so leaving it up to the script itself
 | 
			
		||||
            Script.llDetectParams = qParams;
 | 
			
		||||
            detparms[Script] = qParams;
 | 
			
		||||
            Script.Exec.ExecuteEvent(FunctionName, args);
 | 
			
		||||
            detparms.Remove(Script);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public uint GetLocalID(UUID itemID)
 | 
			
		||||
| 
						 | 
				
			
			@ -430,6 +434,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
 | 
			
		||||
        public void RemoveScript(uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            if (localID == 0)
 | 
			
		||||
                localID = GetLocalID(itemID);
 | 
			
		||||
 | 
			
		||||
            // Don't have that object?
 | 
			
		||||
            if (Scripts.ContainsKey(localID) == false)
 | 
			
		||||
                return;
 | 
			
		||||
| 
						 | 
				
			
			@ -486,5 +493,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
 | 
			
		|||
        //    set { _PleaseShutdown = value; }
 | 
			
		||||
        //}
 | 
			
		||||
        //private bool _PleaseShutdown = false;
 | 
			
		||||
        
 | 
			
		||||
        public DetectParams[] GetDetectParams(IScript script)
 | 
			
		||||
        {
 | 
			
		||||
            if (detparms.ContainsKey(script))
 | 
			
		||||
                return detparms[script];
 | 
			
		||||
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,7 @@ using Nini.Config;
 | 
			
		|||
using OpenSim.Framework;
 | 
			
		||||
using OpenSim.Region.Environment.Scenes;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		||||
| 
						 | 
				
			
			@ -42,28 +43,29 @@ namespace OpenSim.Region.ScriptEngine.Common
 | 
			
		|||
            void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
 | 
			
		||||
            void OnRemoveScript(uint localID, UUID itemID);
 | 
			
		||||
            void state_exit(uint localID);
 | 
			
		||||
            void touch(uint localID, uint originalID, UUID itemID);
 | 
			
		||||
            void touch_end(uint localID, uint originalID, UUID itemID);
 | 
			
		||||
            void touch(uint localID, uint originalID, Vector3 offsetPos,
 | 
			
		||||
                            IClientAPI remoteClient);
 | 
			
		||||
            void touch_end(uint localID, uint originalID, IClientAPI remoteClient);
 | 
			
		||||
            void collision_start(uint localID, ColliderArgs col);
 | 
			
		||||
            void collision(uint localID, ColliderArgs col);
 | 
			
		||||
            void collision_end(uint localID, ColliderArgs col);
 | 
			
		||||
            void land_collision_start(uint localID, UUID itemID);
 | 
			
		||||
            void land_collision(uint localID, ColliderArgs col);
 | 
			
		||||
            void land_collision_end(uint localID, UUID itemID);
 | 
			
		||||
//            void land_collision_start(uint localID, UUID itemID);
 | 
			
		||||
//            void land_collision(uint localID, ColliderArgs col);
 | 
			
		||||
//            void land_collision_end(uint localID, UUID itemID);
 | 
			
		||||
            void timer(uint localID, UUID itemID);
 | 
			
		||||
            void listen(uint localID, UUID itemID);
 | 
			
		||||
            void on_rez(uint localID, UUID itemID);
 | 
			
		||||
            void sensor(uint localID, UUID itemID);
 | 
			
		||||
            void no_sensor(uint localID, UUID itemID);
 | 
			
		||||
//            void on_rez(uint localID, UUID itemID);
 | 
			
		||||
//            void sensor(uint localID, UUID itemID);
 | 
			
		||||
//            void no_sensor(uint localID, UUID itemID);
 | 
			
		||||
            void control(uint localID, UUID itemID, UUID agentID, uint held, uint change);
 | 
			
		||||
            void money(uint LocalID, UUID agentID, int amount);
 | 
			
		||||
            void email(uint localID, UUID itemID);
 | 
			
		||||
//            void email(uint localID, UUID itemID);
 | 
			
		||||
            void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
 | 
			
		||||
            void not_at_target(uint localID);
 | 
			
		||||
            void at_rot_target(uint localID, UUID itemID);
 | 
			
		||||
            void not_at_rot_target(uint localID, UUID itemID);
 | 
			
		||||
            void run_time_permissions(uint localID, UUID itemID);
 | 
			
		||||
            void changed(uint localID, UUID itemID);
 | 
			
		||||
//            void run_time_permissions(uint localID, UUID itemID);
 | 
			
		||||
//            void changed(uint localID, UUID itemID);
 | 
			
		||||
            void attach(uint localID, UUID itemID);
 | 
			
		||||
            void dataserver(uint localID, UUID itemID);
 | 
			
		||||
            void link_message(uint localID, UUID itemID);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,7 @@ using OpenSim.Framework;
 | 
			
		|||
using OpenSim.Region.Environment.Scenes;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared.Api;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
 | 
			
		||||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
 | 
			
		||||
| 
						 | 
				
			
			@ -139,10 +140,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
 | 
			
		|||
                // Fire the first start-event
 | 
			
		||||
                int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID);
 | 
			
		||||
                m_host.SetScriptEvents(itemID, eventFlags);
 | 
			
		||||
                m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { });
 | 
			
		||||
                m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new DetectParams[0], new object[] { });
 | 
			
		||||
                if (postOnRez)
 | 
			
		||||
                {
 | 
			
		||||
                    m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(startParam) });
 | 
			
		||||
                    m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", new DetectParams[0], new object[] { new LSL_Types.LSLInteger(startParam) });
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) // LEGIT: User Scripting
 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +175,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
 | 
			
		|||
//#endif
 | 
			
		||||
 | 
			
		||||
            // Stop long command on script
 | 
			
		||||
            m_scriptEngine.m_ASYNCLSLCommandManager.RemoveScript(localID, itemID);
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
 | 
			
		||||
 | 
			
		||||
            IScript LSLBC = GetScript(localID, itemID);
 | 
			
		||||
            if (LSLBC == null)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,47 +54,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
        public IEventReceiver m_ScriptEngine;
 | 
			
		||||
        private IScene m_Scene;
 | 
			
		||||
 | 
			
		||||
        private static Dictionary<IScene, Dataserver> m_Dataserver =
 | 
			
		||||
                new Dictionary<IScene, Dataserver>();
 | 
			
		||||
        private static Dictionary<IScene, Timer> m_Timer =
 | 
			
		||||
                new Dictionary<IScene, Timer>();
 | 
			
		||||
        private static Dictionary<IScene, Listener> m_Listener =
 | 
			
		||||
                new Dictionary<IScene, Listener>();
 | 
			
		||||
        private static Dictionary<IScene, HttpRequest> m_HttpRequest =
 | 
			
		||||
                new Dictionary<IScene, HttpRequest>();
 | 
			
		||||
        private static Dictionary<IScene, SensorRepeat> m_SensorRepeat =
 | 
			
		||||
                new Dictionary<IScene, SensorRepeat>();
 | 
			
		||||
        private static Dictionary<IScene, XmlRequest> m_XmlRequest =
 | 
			
		||||
                new Dictionary<IScene, XmlRequest>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, Dataserver> m_Dataserver =
 | 
			
		||||
                new Dictionary<IEventReceiver, Dataserver>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, Timer> m_Timer =
 | 
			
		||||
                new Dictionary<IEventReceiver, Timer>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, Listener> m_Listener =
 | 
			
		||||
                new Dictionary<IEventReceiver, Listener>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, HttpRequest> m_HttpRequest =
 | 
			
		||||
                new Dictionary<IEventReceiver, HttpRequest>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, SensorRepeat> m_SensorRepeat =
 | 
			
		||||
                new Dictionary<IEventReceiver, SensorRepeat>();
 | 
			
		||||
        private static Dictionary<IEventReceiver, XmlRequest> m_XmlRequest =
 | 
			
		||||
                new Dictionary<IEventReceiver, XmlRequest>();
 | 
			
		||||
 | 
			
		||||
        public Dataserver DataserverPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Dataserver[m_Scene]; }
 | 
			
		||||
            get { return m_Dataserver[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Timer TimerPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Timer[m_Scene]; }
 | 
			
		||||
            get { return m_Timer[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public HttpRequest HttpRequestPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_HttpRequest[m_Scene]; }
 | 
			
		||||
            get { return m_HttpRequest[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Listener ListenerPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_Listener[m_Scene]; }
 | 
			
		||||
            get { return m_Listener[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SensorRepeat SensorRepeatPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_SensorRepeat[m_Scene]; }
 | 
			
		||||
            get { return m_SensorRepeat[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public XmlRequest XmlRequestPlugin
 | 
			
		||||
        {
 | 
			
		||||
            get { return m_XmlRequest[m_Scene]; }
 | 
			
		||||
            get { return m_XmlRequest[m_ScriptEngine]; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IEventReceiver[] ScriptEngines
 | 
			
		||||
| 
						 | 
				
			
			@ -107,26 +107,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
            m_ScriptEngine = _ScriptEngine;
 | 
			
		||||
            m_Scene = m_ScriptEngine.World;
 | 
			
		||||
 | 
			
		||||
            if (m_Scenes.Count == 0)
 | 
			
		||||
                ReadConfig();
 | 
			
		||||
 | 
			
		||||
            if (!m_Scenes.Contains(m_Scene))
 | 
			
		||||
                m_Scenes.Add(m_Scene);
 | 
			
		||||
            if (!m_ScriptEngines.Contains(m_ScriptEngine))
 | 
			
		||||
                m_ScriptEngines.Add(m_ScriptEngine);
 | 
			
		||||
 | 
			
		||||
            ReadConfig();
 | 
			
		||||
 | 
			
		||||
            // Create instances of all plugins
 | 
			
		||||
            if (!m_Dataserver.ContainsKey(m_Scene))
 | 
			
		||||
                m_Dataserver[m_Scene] = new Dataserver(this);
 | 
			
		||||
            if (!m_Timer.ContainsKey(m_Scene))
 | 
			
		||||
                m_Timer[m_Scene] = new Timer(this);
 | 
			
		||||
            if (!m_HttpRequest.ContainsKey(m_Scene))
 | 
			
		||||
                m_HttpRequest[m_Scene] = new HttpRequest(this);
 | 
			
		||||
            if (!m_Listener.ContainsKey(m_Scene))
 | 
			
		||||
                m_Listener[m_Scene] = new Listener(this);
 | 
			
		||||
            if (!m_SensorRepeat.ContainsKey(m_Scene))
 | 
			
		||||
                m_SensorRepeat[m_Scene] = new SensorRepeat(this);
 | 
			
		||||
            if (!m_XmlRequest.ContainsKey(m_Scene))
 | 
			
		||||
                m_XmlRequest[m_Scene] = new XmlRequest(this);
 | 
			
		||||
            if (!m_Dataserver.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_Dataserver[m_ScriptEngine] = new Dataserver(this);
 | 
			
		||||
            if (!m_Timer.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_Timer[m_ScriptEngine] = new Timer(this);
 | 
			
		||||
            if (!m_HttpRequest.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_HttpRequest[m_ScriptEngine] = new HttpRequest(this);
 | 
			
		||||
            if (!m_Listener.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_Listener[m_ScriptEngine] = new Listener(this);
 | 
			
		||||
            if (!m_SensorRepeat.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_SensorRepeat[m_ScriptEngine] = new SensorRepeat(this);
 | 
			
		||||
            if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
 | 
			
		||||
                m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
 | 
			
		||||
 | 
			
		||||
            StartThread();
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ReadConfig()
 | 
			
		||||
        private void ReadConfig()
 | 
			
		||||
        {
 | 
			
		||||
//            cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100);
 | 
			
		||||
            // TODO: Make this sane again
 | 
			
		||||
| 
						 | 
				
			
			@ -195,18 +196,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
 | 
			
		||||
        private static void DoOneCmdHandlerPass()
 | 
			
		||||
        {
 | 
			
		||||
            foreach (IScene s in m_Scenes)
 | 
			
		||||
            // Check Listeners
 | 
			
		||||
            m_Listener[m_ScriptEngines[0]].CheckListeners();
 | 
			
		||||
 | 
			
		||||
            // Check HttpRequests
 | 
			
		||||
            m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests();
 | 
			
		||||
 | 
			
		||||
            // Check XMLRPCRequests
 | 
			
		||||
            m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests();
 | 
			
		||||
 | 
			
		||||
            foreach (IEventReceiver s in m_ScriptEngines)
 | 
			
		||||
            {
 | 
			
		||||
                // Check timers
 | 
			
		||||
                m_Timer[s].CheckTimerEvents();
 | 
			
		||||
                // Check HttpRequests
 | 
			
		||||
                m_HttpRequest[s].CheckHttpRequests();
 | 
			
		||||
                // Check XMLRPCRequests
 | 
			
		||||
                m_XmlRequest[s].CheckXMLRPCRequests();
 | 
			
		||||
                // Check Listeners
 | 
			
		||||
                m_Listener[s].CheckListeners();
 | 
			
		||||
 | 
			
		||||
                // Check Sensors
 | 
			
		||||
                m_SensorRepeat[s].CheckSenseRepeaterEvents();
 | 
			
		||||
 | 
			
		||||
                // Check dataserver
 | 
			
		||||
                m_Dataserver[s].ExpireRequests();
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -217,38 +223,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="localID"></param>
 | 
			
		||||
        /// <param name="itemID"></param>
 | 
			
		||||
        public static void RemoveScript(IScene scene, uint localID, UUID itemID)
 | 
			
		||||
        public static void RemoveScript(IEventReceiver engine, uint localID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            // Remove a specific script
 | 
			
		||||
 | 
			
		||||
            // Remove dataserver events
 | 
			
		||||
            m_Dataserver[scene].RemoveEvents(localID, itemID);
 | 
			
		||||
            m_Dataserver[engine].RemoveEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove from: Timers
 | 
			
		||||
            m_Timer[scene].UnSetTimerEvents(localID, itemID);
 | 
			
		||||
            m_Timer[engine].UnSetTimerEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove from: HttpRequest
 | 
			
		||||
            IHttpRequests iHttpReq =
 | 
			
		||||
                scene.RequestModuleInterface<IHttpRequests>();
 | 
			
		||||
                engine.World.RequestModuleInterface<IHttpRequests>();
 | 
			
		||||
            iHttpReq.StopHttpRequest(localID, itemID);
 | 
			
		||||
 | 
			
		||||
            IWorldComm comms = scene.RequestModuleInterface<IWorldComm>();
 | 
			
		||||
            IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
 | 
			
		||||
            comms.DeleteListener(itemID);
 | 
			
		||||
 | 
			
		||||
            IXMLRPC xmlrpc = scene.RequestModuleInterface<IXMLRPC>();
 | 
			
		||||
            IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
 | 
			
		||||
            xmlrpc.DeleteChannels(itemID);
 | 
			
		||||
            xmlrpc.CancelSRDRequests(itemID);
 | 
			
		||||
 | 
			
		||||
            // Remove Sensors
 | 
			
		||||
            m_SensorRepeat[scene].UnSetSenseRepeaterEvents(localID, itemID);
 | 
			
		||||
            m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static Object[] GetSerializationData(IScene scene, UUID itemID)
 | 
			
		||||
        public static Object[] GetSerializationData(IEventReceiver engine, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            List<Object> data = new List<Object>();
 | 
			
		||||
 | 
			
		||||
            Object[] listeners=m_Listener[scene].GetSerializationData(itemID);
 | 
			
		||||
            Object[] listeners=m_Listener[engine].GetSerializationData(itemID);
 | 
			
		||||
            if (listeners.Length > 0)
 | 
			
		||||
            {
 | 
			
		||||
                data.Add("listener");
 | 
			
		||||
| 
						 | 
				
			
			@ -256,7 +262,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
                data.AddRange(listeners);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Object[] timers=m_Timer[scene].GetSerializationData(itemID);
 | 
			
		||||
            Object[] timers=m_Timer[engine].GetSerializationData(itemID);
 | 
			
		||||
            if (timers.Length > 0)
 | 
			
		||||
            {
 | 
			
		||||
                data.Add("timer");
 | 
			
		||||
| 
						 | 
				
			
			@ -264,7 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
                data.AddRange(timers);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Object[] sensors=m_SensorRepeat[scene].GetSerializationData(itemID);
 | 
			
		||||
            Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID);
 | 
			
		||||
            if (sensors.Length > 0)
 | 
			
		||||
            {
 | 
			
		||||
                data.Add("sensor");
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
            return data.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void CreateFromData(IScene scene, uint localID,
 | 
			
		||||
        public static void CreateFromData(IEventReceiver engine, uint localID,
 | 
			
		||||
                UUID itemID, UUID hostID, Object[] data)
 | 
			
		||||
        {
 | 
			
		||||
            int idx = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -297,15 +303,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 | 
			
		|||
                    switch (type)
 | 
			
		||||
                    {
 | 
			
		||||
                    case "listener":
 | 
			
		||||
                        m_Listener[scene].CreateFromData(localID, itemID,
 | 
			
		||||
                        m_Listener[engine].CreateFromData(localID, itemID,
 | 
			
		||||
                                                    hostID, item);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case "timer":
 | 
			
		||||
                        m_Timer[scene].CreateFromData(localID, itemID,
 | 
			
		||||
                        m_Timer[engine].CreateFromData(localID, itemID,
 | 
			
		||||
                                                    hostID, item);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case "sensor":
 | 
			
		||||
                        m_SensorRepeat[scene].CreateFromData(localID,
 | 
			
		||||
                        m_SensorRepeat[engine].CreateFromData(localID,
 | 
			
		||||
                                                    itemID, hostID, item);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
 | 
			
		||||
            while (httpInfo != null)
 | 
			
		||||
            {
 | 
			
		||||
                //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
 | 
			
		||||
                //System.Console.WriteLine("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
 | 
			
		||||
 | 
			
		||||
                // Deliver data to prim's remote_data handler
 | 
			
		||||
                //
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
                    new LSL_Types.LSLString(httpInfo.response_body)
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                {
 | 
			
		||||
                    if (e.PostObjectEvent(httpInfo.localID,
 | 
			
		||||
                            new EventParams("http_response",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ using System;
 | 
			
		|||
using OpenMetaverse;
 | 
			
		||||
using OpenSim.Region.Environment.Interfaces;
 | 
			
		||||
using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Interfaces;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared;
 | 
			
		||||
using OpenSim.Region.ScriptEngine.Shared.Api;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,10 +67,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
                        new LSL_Types.LSLString(lInfo.GetMessage())
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    m_CmdManager.m_ScriptEngine.PostScriptEvent(
 | 
			
		||||
                            lInfo.GetItemID(), new EventParams(
 | 
			
		||||
                            "listen", resobj,
 | 
			
		||||
                            new DetectParams[0]));
 | 
			
		||||
                    foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                    {
 | 
			
		||||
                        e.PostScriptEvent(
 | 
			
		||||
                                lInfo.GetItemID(), new EventParams(
 | 
			
		||||
                                "listen", resobj,
 | 
			
		||||
                                new DetectParams[0]));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,28 +156,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
            SensorSweep(ts);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID)
 | 
			
		||||
        {
 | 
			
		||||
            lock (SenseLock)
 | 
			
		||||
            {
 | 
			
		||||
                Dictionary<UUID, LSL_Types.list> Obj = null;
 | 
			
		||||
                if (!SenseEvents.TryGetValue(m_localID, out Obj))
 | 
			
		||||
                {
 | 
			
		||||
                    return null;
 | 
			
		||||
                }
 | 
			
		||||
                lock (Obj)
 | 
			
		||||
                {
 | 
			
		||||
                    // Get script
 | 
			
		||||
                    LSL_Types.list SenseList = null;
 | 
			
		||||
                    if (!Obj.TryGetValue(m_itemID, out SenseList))
 | 
			
		||||
                    {
 | 
			
		||||
                        return null;
 | 
			
		||||
                    }
 | 
			
		||||
                    return SenseList;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void SensorSweep(SenseRepeatClass ts)
 | 
			
		||||
        {
 | 
			
		||||
            SceneObjectPart SensePoint = ts.host;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
                    // Time has passed?
 | 
			
		||||
                    if (ts.next < DateTime.Now.Ticks)
 | 
			
		||||
                    {
 | 
			
		||||
                        //                        Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
 | 
			
		||||
                        //Console.WriteLine("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],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
                        new LSL_Types.LSLString(rInfo.GetStrVal())
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                    foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (e.PostScriptEvent(
 | 
			
		||||
                                rInfo.GetItemID(), new EventParams(
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
 | 
			
		|||
                        new LSL_Types.LSLString(srdInfo.sdata)
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                    foreach (IEventReceiver e in m_CmdManager.ScriptEngines)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (e.PostScriptEvent(
 | 
			
		||||
                                srdInfo.m_itemID, new EventParams(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -246,7 +246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
 | 
			
		||||
                            ScriptSerializer.Deserialize(xml, this);
 | 
			
		||||
 | 
			
		||||
                            AsyncCommandManager.CreateFromData(m_Engine.World,
 | 
			
		||||
                            AsyncCommandManager.CreateFromData(m_Engine,
 | 
			
		||||
                                m_LocalID, m_ItemID, m_ObjectID,
 | 
			
		||||
                                PluginData);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -336,7 +336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
        public void DestroyScriptInstance()
 | 
			
		||||
        {
 | 
			
		||||
            ReleaseControls();
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID);
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemoveState()
 | 
			
		||||
| 
						 | 
				
			
			@ -554,7 +554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
    //                m_Engine.Log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
 | 
			
		||||
    //                        m_PrimName, m_ScriptName, data.Params[0].ToString());
 | 
			
		||||
                    m_State=data.Params[0].ToString();
 | 
			
		||||
                    AsyncCommandManager.RemoveScript(m_Engine.World,
 | 
			
		||||
                    AsyncCommandManager.RemoveScript(m_Engine,
 | 
			
		||||
                        m_LocalID, m_ItemID);
 | 
			
		||||
 | 
			
		||||
                    SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
 | 
			
		||||
| 
						 | 
				
			
			@ -690,7 +690,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
            SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
 | 
			
		||||
            part.GetInventoryItem(m_ItemID).PermsMask = 0;
 | 
			
		||||
            part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID);
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
 | 
			
		||||
            m_EventQueue.Clear();
 | 
			
		||||
            m_Script.ResetVars();
 | 
			
		||||
            m_State = "default";
 | 
			
		||||
| 
						 | 
				
			
			@ -715,7 +715,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
            SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
 | 
			
		||||
            part.GetInventoryItem(m_ItemID).PermsMask = 0;
 | 
			
		||||
            part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID);
 | 
			
		||||
            AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
 | 
			
		||||
 | 
			
		||||
            m_EventQueue.Clear();
 | 
			
		||||
            m_Script.ResetVars();
 | 
			
		||||
| 
						 | 
				
			
			@ -772,7 +772,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
 | 
			
		|||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PluginData = AsyncCommandManager.GetSerializationData(m_Engine.World, m_ItemID);
 | 
			
		||||
            PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID);
 | 
			
		||||
 | 
			
		||||
            string xml = ScriptSerializer.Serialize(this);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ using OpenSim.Region.ScriptEngine.Interfaces;
 | 
			
		|||
 | 
			
		||||
namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		||||
{
 | 
			
		||||
    public class XEngine : IScriptModule, IScriptEngine
 | 
			
		||||
    public class XEngine : IRegionModule, IScriptEngine
 | 
			
		||||
    {
 | 
			
		||||
        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
#pragma warning restore 414
 | 
			
		||||
        private int m_EventLimit;
 | 
			
		||||
        private bool m_KillTimedOutScripts;
 | 
			
		||||
        bool m_firstStart = true;
 | 
			
		||||
//        bool m_firstStart = true;
 | 
			
		||||
 | 
			
		||||
        private static List<XEngine> m_ScriptEngines =
 | 
			
		||||
                new List<XEngine>();
 | 
			
		||||
| 
						 | 
				
			
			@ -205,8 +205,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
                m_ScriptEngines.Add(this);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            scene.RegisterModuleInterface<IScriptModule>(this);
 | 
			
		||||
 | 
			
		||||
            // Needs to be here so we can queue the scripts that need starting
 | 
			
		||||
            //
 | 
			
		||||
            m_Scene.EventManager.OnRezScript += OnRezScript;
 | 
			
		||||
| 
						 | 
				
			
			@ -230,6 +228,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
            m_Scene.EventManager.OnScriptReset += OnScriptReset;
 | 
			
		||||
            m_Scene.EventManager.OnStartScript += OnStartScript;
 | 
			
		||||
            m_Scene.EventManager.OnStopScript += OnStopScript;
 | 
			
		||||
            m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
 | 
			
		||||
            m_Scene.EventManager.OnShutdown += OnShutdown;
 | 
			
		||||
 | 
			
		||||
            if (m_SleepTime > 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -357,14 +356,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
 | 
			
		||||
                if (m_CurrentCompile == null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (m_firstStart)
 | 
			
		||||
                    {
 | 
			
		||||
                        m_firstStart = false;
 | 
			
		||||
                        m_CurrentCompile = m_ThreadPool.QueueWorkItem(
 | 
			
		||||
                            new WorkItemCallback(this.DoScriptWait),
 | 
			
		||||
                            new Object[0]);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
//                    if (m_firstStart)
 | 
			
		||||
//                    {
 | 
			
		||||
//                        m_firstStart = false;
 | 
			
		||||
//                        m_CurrentCompile = m_ThreadPool.QueueWorkItem(
 | 
			
		||||
//                            new WorkItemCallback(this.DoScriptWait),
 | 
			
		||||
//                            new Object[0]);
 | 
			
		||||
//                        return;
 | 
			
		||||
//                    }
 | 
			
		||||
 | 
			
		||||
                    m_CurrentCompile = m_ThreadPool.QueueWorkItem(
 | 
			
		||||
                            new WorkItemCallback(this.DoOnRezScriptQueue),
 | 
			
		||||
| 
						 | 
				
			
			@ -375,7 +374,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
 | 
			
		||||
        public Object DoScriptWait(Object dummy)
 | 
			
		||||
        {
 | 
			
		||||
            Thread.Sleep(30000);
 | 
			
		||||
            Thread.Sleep(10000);
 | 
			
		||||
 | 
			
		||||
            lock (m_CompileQueue)
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -884,11 +883,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
            return instance.StartParam;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool GetScriptRunning(UUID objectID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            return GetScriptState(itemID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnShutdown()
 | 
			
		||||
        {
 | 
			
		||||
            List<IScriptInstance> instances = new List<IScriptInstance>();
 | 
			
		||||
| 
						 | 
				
			
			@ -922,5 +916,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
 | 
			
		|||
                return null;
 | 
			
		||||
            return instance.GetApi(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
 | 
			
		||||
        {
 | 
			
		||||
            IScriptInstance instance = GetInstance(itemID);
 | 
			
		||||
            if (instance == null)
 | 
			
		||||
                return;
 | 
			
		||||
            controllingClient.SendScriptRunningReply(objectID, itemID,
 | 
			
		||||
                    GetScriptState(itemID));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1952,6 +1952,7 @@
 | 
			
		|||
      <Reference name="OpenSim.Region.Physics.Manager" />
 | 
			
		||||
      <Reference name="OpenSim.Framework.Console"/>
 | 
			
		||||
      <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
 | 
			
		||||
      <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
 | 
			
		||||
      <Reference name="Nini.dll" />
 | 
			
		||||
      <Reference name="RAIL.dll"/>
 | 
			
		||||
      <Reference name="OpenSim.Framework.Console"/>
 | 
			
		||||
| 
						 | 
				
			
			@ -1990,6 +1991,7 @@
 | 
			
		|||
      <Reference name="OpenSim.Region.Environment" />
 | 
			
		||||
      <Reference name="OpenSim.Region.ScriptEngine.Common"/>
 | 
			
		||||
      <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
 | 
			
		||||
      <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
 | 
			
		||||
      <Reference name="Microsoft.JScript"/>
 | 
			
		||||
      <Reference name="Nini.dll" />
 | 
			
		||||
      <Reference name="log4net.dll"/>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue