public void AddNewScript(ScriptData ID)
        {
            if (ID.Part == null)
            {
                return;
            }

            lock (ScriptsItems)
            {
                if (ID.Part != null)
                {
                    ScriptsItems[ID.ItemID] = ID.Part.UUID;
                }
            }
            lock (Scripts)
            {
                Dictionary <UUID, ScriptData> Instances = new Dictionary <UUID, ScriptData>();
                if (!Scripts.TryGetValue(ID.Part.UUID, out Instances))
                {
                    Instances = new Dictionary <UUID, ScriptData>();
                }

                Instances[ID.ItemID]  = ID;
                Scripts[ID.Part.UUID] = Instances;
            }
        }
        public void DeleteFrom(ScriptData script)
        {
            bool changed = false;

            lock (StateSaveLock)
            {
                //if we did remove something, resave it
                if (script.Part.StateSaves.Remove(script.ItemID))
                {
                    changed = true;
                }
                if (script.Part.StateSaves.Remove(script.InventoryItem.OldItemID))
                {
                    changed = true;
                }
                if (script.Part.StateSaves.Remove(script.InventoryItem.ItemID))
                {
                    changed = true;
                }
            }
            if (changed)
            {
                script.Part.ParentEntity.HasGroupChanged = true;
            }
        }
Beispiel #3
0
        public void AddEventSchQueue(ScriptData ID, string FunctionName, DetectParams[] qParams, EventPriority priority,
                                     params object[] param)
        {
            QueueItemStruct QIS = new QueueItemStruct
            {
                EventsProcData = new ScriptEventsProcData(),
                ID             = ID,
                functionName   = FunctionName,
                llDetectParams = qParams,
                param          = param,
                VersionID      = Interlocked.Read(ref ID.VersionID),
                State          = ID.State,
                CurrentlyAt    = null
            };

            if (ID.Script == null || ID.IgnoreNew)
            {
                return;
            }

            if (!ID.SetEventParams(QIS)) // check events delay rules
            {
                return;
            }

            ScriptEvents.Enqueue(QIS);

            long threadCount = Interlocked.Read(ref scriptThreadpool.nthreads);

            if (threadCount == 0 || threadCount < (ScriptEvents.Count + (SleepingScriptEventCount / 2)) * EventPerformance)
            {
                scriptThreadpool.QueueEvent(eventLoop, 2);
            }
        }
 /// <summary>
 ///     Fires the action associated with the limitation
 /// </summary>
 /// <param name="d"></param>
 /// <param name="m_host"></param>
 /// <param name="itemID"></param>
 /// <returns>Whether the event should be dropped</returns>
 bool TriggerAction(LimitDef d, ISceneChildEntity m_host, UUID itemID)
 {
     if (d.Action == LimitAction.None)
     {
         return(true);
     }
     if (d.Action == LimitAction.Drop)
     {
         return(false); //Drop it
     }
     if (d.Action == LimitAction.TerminateEvent)
     {
         throw new Exception("");  //Blank messages kill events, but don't show anything on the console/inworld
     }
     if (d.Action == LimitAction.TerminateScript)
     {
         ScriptData script = GetScript(itemID);
         if (script != null)
         {
             script.IgnoreNew = true; //Blocks all new events, can be reversed by resetting or resaving the script
         }
         throw new Exception("");     //Blank messages kill events, but don't show anything on the console/inworld
     }
     if (d.Action == LimitAction.Delay)
     {
         MainConsole.Instance.Warn("Function delaying is not implemented");
     }
     return(true);
 }
        public void control(ISceneChildEntity part, UUID itemID, UUID agentID, uint held, uint change)
        {
            if (part == null)
            {
                return;
            }
            ScriptData ID = ScriptEngine.ScriptProtection.GetScript(part.UUID, itemID);

            if (ID == null)
            {
                return;
            }

            string functionName = "control";

            object[] param =
            {
                new LSL_Types.LSLString(agentID.ToString()),
                new LSL_Types.LSLInteger(held),
                new LSL_Types.LSLInteger(change)
            };

            m_scriptEngine.AddToScriptQueue(ID, functionName, new DetectParams[0],
                                            EventPriority.FirstStart, param);
        }
Beispiel #6
0
 public void SetEventSchSetIgnoreNew(ScriptData ID, bool yes)
 {
     if (ID == null)
     {
         return;
     }
     ID.IgnoreNew = yes;
 }
Beispiel #7
0
        public void RemoveFromEventSchQueue(ScriptData ID, bool abortcur)
        {
            if (ID == null)
            {
                return;
            }

            //Ignore any events to be added after this
            ID.IgnoreNew = true;
            //Clear out the old events
            Interlocked.Increment(ref ID.VersionID);
        }
        public void SaveStateTo(ScriptData script, bool forced, bool saveBackup)
        {
            if (!forced)
            {
                if (script.Script == null)
                    return; //If it didn't compile correctly, this happens
                if (!script.Script.NeedsStateSaved)
                    return; //If it doesn't need a state save, don't save one
            }
            if (script.Script != null)
                script.Script.NeedsStateSaved = false;
            StateSave stateSave = new StateSave
                                      {
                                          State = script.State,
                                          ItemID = script.ItemID,
                                          Running = script.Running,
                                          MinEventDelay = script.EventDelayTicks,
                                          Disabled = script.Disabled,
                                          UserInventoryID = script.UserInventoryItemID,
                                          AssemblyName = script.AssemblyName,
                                          Compiled = script.Compiled,
                                          Source = script.Source == null ? "" : script.Source
                                      };
            //Allow for the full path to be put down, not just the assembly name itself
            if (script.InventoryItem != null)
            {
                stateSave.PermsGranter = script.InventoryItem.PermsGranter;
                stateSave.PermsMask = script.InventoryItem.PermsMask;
            }
            else
            {
                stateSave.PermsGranter = UUID.Zero;
                stateSave.PermsMask = 0;
            }
            stateSave.TargetOmegaWasSet = script.TargetOmegaWasSet;

            //Vars
            Dictionary<string, object> vars = new Dictionary<string, object>();
            if (script.Script != null)
                vars = script.Script.GetStoreVars();
            stateSave.Variables = XMLUtils.BuildXmlResponse(vars);

            //Plugins
            stateSave.Plugins =
                OSDParser.SerializeJsonString(m_module.GetSerializationData(script.ItemID, script.Part.UUID));

            lock (StateSaveLock)
                script.Part.StateSaves[script.ItemID] = stateSave;
            if (saveBackup)
                script.Part.ParentEntity.HasGroupChanged = true;
        }
        public void AddPreviouslyCompiled(string source, ScriptData ID)
        {
            //string key = source.Length.ToString() + source.GetHashCode().ToString();
            string key = Util.Md5Hash(source);

            lock (PreviouslyCompiled)
            {
                if (!PreviouslyCompiled.ContainsKey(key))
                {
                    //PreviouslyCompiled.Add (source, ID.AssemblyName);
                    PreviouslyCompiled.Add(key, ID.AssemblyName);
                }
            }
        }
        public ScriptData GetScript(UUID primID, UUID itemID)
        {
            Dictionary <UUID, ScriptData> Instances;

            lock (Scripts)
            {
                if (Scripts.TryGetValue(primID, out Instances))
                {
                    ScriptData ID = null;
                    Instances.TryGetValue(itemID, out ID);
                    return(ID);
                }
            }
            return(null);
        }
 public void DeleteFrom(ScriptData script)
 {
     bool changed = false;
     lock (StateSaveLock)
     {
         //if we did remove something, resave it
         if (script.Part.StateSaves.Remove(script.ItemID))
             changed = true;
         if (script.Part.StateSaves.Remove(script.InventoryItem.OldItemID))
             changed = true;
         if (script.Part.StateSaves.Remove(script.InventoryItem.ItemID))
             changed = true;
     }
     if (changed)
         script.Part.ParentEntity.HasGroupChanged = true;
 }
 public StateSave FindScriptStateSave(ScriptData script)
 {
     lock (StateSaveLock)
     {
         StateSave save;
         if (!script.Part.StateSaves.TryGetValue(script.ItemID, out save))
         {
             if (!script.Part.StateSaves.TryGetValue(script.InventoryItem.OldItemID, out save))
             {
                 if (!script.Part.StateSaves.TryGetValue(script.InventoryItem.ItemID, out save))
                 {
                     return(null);
                 }
             }
         }
         return(save);
     }
 }
Beispiel #13
0
 /// <summary>
 ///     Makes sure that all the threads that need to be running are running and starts them if they need to be running
 /// </summary>
 public void PokeThreads(UUID itemID)
 {
     if (itemID != UUID.Zero)
     {
         ScriptData script = ScriptEngine.ScriptProtection.GetScript(itemID);
         if (script != null && script.Script != null)
         {
             script.Script.NeedsStateSaved = true;
         }
     }
     if (LUQueue.Count() > 0 && !ScriptChangeIsRunning)
     {
         StartThread("Change");
     }
     if (Interlocked.Read(ref CmdHandlerQueueIsRunning) == 0)
     {
         StartThread("CmdHandlerQueue");
     }
 }
 public void RemoveScript(ScriptData Data)
 {
     lock (ScriptsItems)
     {
         ScriptsItems.Remove(Data.ItemID);
     }
     lock (Scripts)
     {
         Dictionary <UUID, ScriptData> Instances = new Dictionary <UUID, ScriptData>();
         if (Scripts.TryGetValue(Data.Part.UUID, out Instances))
         {
             Instances.Remove(Data.ItemID);
             if (Instances.Count > 0)
             {
                 Scripts[Data.Part.UUID] = Instances;
             }
             else
             {
                 Scripts.Remove(Data.Part.UUID);
             }
         }
     }
 }
        public void Deserialize(ScriptData instance, StateSave save)
        {
            instance.State               = save.State;
            instance.Running             = save.Running;
            instance.EventDelayTicks     = (long)save.MinEventDelay;
            instance.AssemblyName        = save.AssemblyName;
            instance.Disabled            = save.Disabled;
            instance.UserInventoryItemID = save.UserInventoryID;
            if (save.Plugins != "")
            {
                instance.PluginData = (OSDMap)OSDParser.DeserializeJson(save.Plugins);
            }
            m_module.CreateFromData(instance.Part.UUID, instance.ItemID, instance.Part.UUID,
                                    instance.PluginData);
            instance.Source = save.Source;
            instance.InventoryItem.PermsGranter = save.PermsGranter;
            instance.InventoryItem.PermsMask    = save.PermsMask;
            instance.TargetOmegaWasSet          = save.TargetOmegaWasSet;

            if (save.Variables != null && instance.Script != null)
            {
                instance.Script.SetStoreVars(XMLUtils.ParseXmlResponse(save.Variables));
            }
        }
 public StateSave FindScriptStateSave(ScriptData script)
 {
     lock (StateSaveLock)
     {
         StateSave save;
         if (!script.Part.StateSaves.TryGetValue(script.ItemID, out save))
         {
             if (!script.Part.StateSaves.TryGetValue(script.InventoryItem.OldItemID, out save))
             {
                 if (!script.Part.StateSaves.TryGetValue(script.InventoryItem.ItemID, out save))
                 {
                     return null;
                 }
             }
         }
         return save;
     }
 }
 public void RemoveScript(ScriptData Data)
 {
     lock (ScriptsItems)
     {
         ScriptsItems.Remove(Data.ItemID);
     }
     lock (Scripts)
     {
         Dictionary<UUID, ScriptData> Instances = new Dictionary<UUID, ScriptData>();
         if (Scripts.TryGetValue(Data.Part.UUID, out Instances))
         {
             Instances.Remove(Data.ItemID);
             if (Instances.Count > 0)
                 Scripts[Data.Part.UUID] = Instances;
             else
                 Scripts.Remove(Data.Part.UUID);
         }
     }
 }
 public void AddPreviouslyCompiled(string source, ScriptData ID)
 {
     //string key = source.Length.ToString() + source.GetHashCode().ToString();
     string key = Util.Md5Hash(source);
     lock (PreviouslyCompiled)
     {
         if (!PreviouslyCompiled.ContainsKey(key))
         {
             //PreviouslyCompiled.Add (source, ID.AssemblyName);
             PreviouslyCompiled.Add(key, ID.AssemblyName);
         }
     }
 }
        public void AddNewScript(ScriptData ID)
        {
            lock (ScriptsItems)
            {
                if (ID.Part != null)
                    ScriptsItems[ID.ItemID] = ID.Part.UUID;
            }
            lock (Scripts)
            {
                Dictionary<UUID, ScriptData> Instances = new Dictionary<UUID, ScriptData>();
                if (!Scripts.TryGetValue(ID.Part.UUID, out Instances))
                    Instances = new Dictionary<UUID, ScriptData>();

                Instances[ID.ItemID] = ID;
                Scripts[ID.Part.UUID] = Instances;
            }
        }
 public void SetEventSchSetIgnoreNew(ScriptData ID, bool yes)
 {
     if (ID == null)
         return;
     ID.IgnoreNew = yes;
 }
 public void RemoveState(ScriptData ID)
 {
     m_ScriptEngine.StateSave.DeleteFrom(ID);
 }
        /// <summary>
        ///     This checks the minimum amount of time between script firings as well as control events, making sure that events do NOT fire after scripts reset, close or restart, etc
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="FunctionName"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool CheckIfEventShouldFire(ScriptData ID, string FunctionName, object[] param)
        {
            lock (ID.ScriptEventLock)
            {
                if (ID.Loading)
                {
                    //If the script is loading, enqueue all events
                    return true;
                }
                //This will happen if the script doesn't compile correctly
                if (ID.Script == null)
                {
                    MainConsole.Instance.Info("[Virtual Script Engine]: Could not load script from item '" +
                                              ID.InventoryItem.Name +
                                              "' to fire event " + FunctionName);
                    return false;
                }
                scriptEvents eventType = (scriptEvents) Enum.Parse(typeof (scriptEvents), FunctionName);

                // this must be done even if there is no event method

                if (eventType == scriptEvents.touch_start)
                    ID.RemoveTouchEvents = false;
                else if (eventType == scriptEvents.collision_start)
                    ID.RemoveCollisionEvents = false;
                else if (eventType == scriptEvents.land_collision_start)
                    ID.RemoveLandCollisionEvents = false;

                if (eventType == scriptEvents.state_entry)
                    ID.ResetEvents();

                if ((ID.Script.GetStateEventFlags(ID.State) & (long) eventType) == 0)
                    return false; //If the script doesn't contain the state, don't even bother queueing it

                //Make sure we can execute events at position
                if (!m_scriptEngine.PipeEventsForScript(ID.Part))
                    return false;

                switch (eventType)
                {
                    case scriptEvents.timer:
                        if (ID.TimerInQueue)
                            return false;
                        ID.TimerInQueue = true;
                        break;
                    case scriptEvents.sensor:
                        if (ID.SensorInQueue)
                            return false;
                        ID.SensorInQueue = true;
                        break;
                    case scriptEvents.no_sensor:
                        if (ID.NoSensorInQueue)
                            return false;
                        ID.NoSensorInQueue = true;
                        break;
                    case scriptEvents.at_target:
                        if (ID.AtTargetInQueue)
                            return false;
                        ID.AtTargetInQueue = true;
                        break;
                    case scriptEvents.not_at_target:
                        if (ID.NotAtTargetInQueue)
                            return false;
                        ID.NotAtTargetInQueue = true;
                        break;
                    case scriptEvents.at_rot_target:
                        if (ID.AtRotTargetInQueue)
                            return false;
                        ID.AtRotTargetInQueue = true;
                        break;
                    case scriptEvents.not_at_rot_target:
                        if (ID.NotAtRotTargetInQueue)
                            return false;
                        ID.NotAtRotTargetInQueue = true;
                        break;
                    case scriptEvents.control:
                        int held = ((LSL_Types.LSLInteger) param[1]).value;
                        // int changed = ((LSL_Types.LSLInteger)data.Params[2]).value;

                        // If the last message was a 0 (nothing held)
                        // and this one is also nothing held, drop it
                        //
                        if (ID.LastControlLevel == held && held == 0)
                            return true;

                        // If there is one or more queued, then queue
                        // only changed ones, else queue unconditionally
                        //
                        if (ID.ControlEventsInQueue > 0)
                        {
                            if (ID.LastControlLevel == held)
                                return false;
                        }
                        break;
                    case scriptEvents.collision:
                        if (ID.CollisionInQueue || ID.RemoveCollisionEvents)
                            return false;
                        ID.CollisionInQueue = true;
                        break;
                    case scriptEvents.moving_start:
                        if (ID.MovingInQueue) //Block all other moving_starts until moving_end is called
                            return false;
                        ID.MovingInQueue = true;
                        break;
                    case scriptEvents.moving_end:
                        if (!ID.MovingInQueue) //If we get a moving_end after we have sent one event, don't fire another
                            return false;
                        break;
                    case scriptEvents.collision_end:
                        if (ID.RemoveCollisionEvents)
                            return false;
                        break;
                    case scriptEvents.touch:
                        if (ID.TouchInQueue || ID.RemoveTouchEvents)
                            return false;
                        ID.TouchInQueue = true;
                        break;
                    case scriptEvents.touch_end:
                        if (ID.RemoveTouchEvents)
                            return false;
                        break;
                    case scriptEvents.land_collision:
                        if (ID.LandCollisionInQueue || ID.RemoveLandCollisionEvents)
                            return false;
                        ID.LandCollisionInQueue = true;
                        break;
                    case scriptEvents.land_collision_end:
                        if (ID.RemoveLandCollisionEvents)
                            return false;
                        break;
                    case scriptEvents.changed:
                    Changed scptChanged;
                        if (param[0] is Changed)
                            scptChanged = (Changed) param[0];
                        else
                            scptChanged = (Changed) (((LSL_Types.LSLInteger) param[0]).value);
                        if (ID.ChangedInQueue.Contains(scptChanged))
                            return false;
                        ID.ChangedInQueue.Add(scptChanged);
                        break;
                }
            }
            return true;
        }
        public void AddEventSchQueue(ScriptData ID, string FunctionName, DetectParams[] qParams, EventPriority priority,
                                     params object[] param)
        {
            QueueItemStruct QIS = new QueueItemStruct
            {
                EventsProcData = new ScriptEventsProcData(),
                ID = ID,
                functionName = FunctionName,
                llDetectParams = qParams,
                param = param,
                VersionID = Interlocked.Read(ref ID.VersionID),
                State = ID.State,
                CurrentlyAt = null
            };

            if (ID == null || ID.Script == null || ID.IgnoreNew)
                return;

            if (!ID.SetEventParams(QIS)) // check events delay rules
                return;

            ScriptEvents.Enqueue(QIS);

            long threadCount = Interlocked.Read(ref scriptThreadpool.nthreads);
            if (threadCount == 0 || threadCount < (ScriptEvents.Count + (SleepingScriptEventCount/2))*EventPerformance)
            {
                scriptThreadpool.QueueEvent(eventLoop, 2);
            }
        }
        public void SaveStateTo(ScriptData script, bool forced, bool saveBackup)
        {
            if (!forced)
            {
                if (script.Script == null)
                {
                    return; //If it didn't compile correctly, this happens
                }
                if (!script.Script.NeedsStateSaved)
                {
                    return; //If it doesn't need a state save, don't save one
                }
            }
            if (script.Script != null)
            {
                script.Script.NeedsStateSaved = false;
            }
            StateSave stateSave = new StateSave
            {
                State           = script.State,
                ItemID          = script.ItemID,
                Running         = script.Running,
                MinEventDelay   = script.EventDelayTicks,
                Disabled        = script.Disabled,
                UserInventoryID = script.UserInventoryItemID,
                AssemblyName    = script.AssemblyName,
                Compiled        = script.Compiled,
                Source          = script.Source == null ? "" : script.Source
            };

            //Allow for the full path to be put down, not just the assembly name itself
            if (script.InventoryItem != null)
            {
                stateSave.PermsGranter = script.InventoryItem.PermsGranter;
                stateSave.PermsMask    = script.InventoryItem.PermsMask;
            }
            else
            {
                stateSave.PermsGranter = UUID.Zero;
                stateSave.PermsMask    = 0;
            }
            stateSave.TargetOmegaWasSet = script.TargetOmegaWasSet;

            //Vars
            Dictionary <string, object> vars = new Dictionary <string, object>();

            if (script.Script != null)
            {
                vars = script.Script.GetStoreVars();
            }
            stateSave.Variables = XMLUtils.BuildXmlResponse(vars);

            //Plugins
            stateSave.Plugins =
                OSDParser.SerializeJsonString(m_module.GetSerializationData(script.ItemID, script.Part.UUID));

            lock (StateSaveLock)
                script.Part.StateSaves[script.ItemID] = stateSave;
            if (saveBackup)
            {
                script.Part.ParentEntity.HasGroupChanged = true;
            }
        }
 public void SaveStateTo(ScriptData script, bool forced)
 {
     SaveStateTo(script, forced, true);
 }
 public void SaveStateTo(ScriptData script)
 {
     SaveStateTo(script, false);
 }
Beispiel #27
0
 public void RemoveState(ScriptData ID)
 {
     m_ScriptEngine.StateSave.DeleteFrom(ID);
 }
 public void SaveStateTo(ScriptData script)
 {
     SaveStateTo(script, false);
 }
 public void SaveStateTo(ScriptData script, bool forced)
 {
     SaveStateTo(script, forced, true);
 }
        public void RemoveFromEventSchQueue(ScriptData ID, bool abortcur)
        {
            if (ID == null)
                return;

            //Ignore any events to be added after this
            ID.IgnoreNew = true;
            //Clear out the old events
            Interlocked.Increment(ref ID.VersionID);
        }
        public void Deserialize(ScriptData instance, StateSave save)
        {
            instance.State = save.State;
            instance.Running = save.Running;
            instance.EventDelayTicks = (long) save.MinEventDelay;
            instance.AssemblyName = save.AssemblyName;
            instance.Disabled = save.Disabled;
            instance.UserInventoryItemID = save.UserInventoryID;
            if (save.Plugins != "")
                instance.PluginData = (OSDMap) OSDParser.DeserializeJson(save.Plugins);
            m_module.CreateFromData(instance.Part.UUID, instance.ItemID, instance.Part.UUID,
                                    instance.PluginData);
            instance.Source = save.Source;
            instance.InventoryItem.PermsGranter = save.PermsGranter;
            instance.InventoryItem.PermsMask = save.PermsMask;
            instance.TargetOmegaWasSet = save.TargetOmegaWasSet;

            if (save.Variables != null && instance.Script != null)
                instance.Script.SetStoreVars(XMLUtils.ParseXmlResponse(save.Variables));
        }
Beispiel #32
0
        /// <summary>
        ///     This checks the minimum amount of time between script firings as well as control events, making sure that events do NOT fire after scripts reset, close or restart, etc
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="FunctionName"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool CheckIfEventShouldFire(ScriptData ID, string FunctionName, object[] param)
        {
            lock (ID.ScriptEventLock)
            {
                if (ID.Loading)
                {
                    //If the script is loading, enqueue all events
                    return(true);
                }
                //This will happen if the script doesn't compile correctly
                if (ID.Script == null)
                {
                    MainConsole.Instance.Info("[VirtualScript]: Could not load script from item '" +
                                              ID.InventoryItem.Name +
                                              "' to fire event " + FunctionName);
                    return(false);
                }
                scriptEvents eventType = (scriptEvents)Enum.Parse(typeof(scriptEvents), FunctionName);

                // this must be done even if there is no event method

                if (eventType == scriptEvents.touch_start)
                {
                    ID.RemoveTouchEvents = false;
                }
                else if (eventType == scriptEvents.collision_start)
                {
                    ID.RemoveCollisionEvents = false;
                }
                else if (eventType == scriptEvents.land_collision_start)
                {
                    ID.RemoveLandCollisionEvents = false;
                }

                if (eventType == scriptEvents.state_entry)
                {
                    ID.ResetEvents();
                }

                if ((ID.Script.GetStateEventFlags(ID.State) & (long)eventType) == 0)
                {
                    return(false); //If the script doesn't contain the state, don't even bother queueing it
                }
                //Make sure we can execute events at position
                if (!m_scriptEngine.PipeEventsForScript(ID.Part))
                {
                    return(false);
                }

                switch (eventType)
                {
                case scriptEvents.timer:
                    if (ID.TimerInQueue)
                    {
                        return(false);
                    }
                    ID.TimerInQueue = true;
                    break;

                case scriptEvents.sensor:
                    if (ID.SensorInQueue)
                    {
                        return(false);
                    }
                    ID.SensorInQueue = true;
                    break;

                case scriptEvents.no_sensor:
                    if (ID.NoSensorInQueue)
                    {
                        return(false);
                    }
                    ID.NoSensorInQueue = true;
                    break;

                case scriptEvents.at_target:
                    if (ID.AtTargetInQueue)
                    {
                        return(false);
                    }
                    ID.AtTargetInQueue = true;
                    break;

                case scriptEvents.not_at_target:
                    if (ID.NotAtTargetInQueue)
                    {
                        return(false);
                    }
                    ID.NotAtTargetInQueue = true;
                    break;

                case scriptEvents.at_rot_target:
                    if (ID.AtRotTargetInQueue)
                    {
                        return(false);
                    }
                    ID.AtRotTargetInQueue = true;
                    break;

                case scriptEvents.not_at_rot_target:
                    if (ID.NotAtRotTargetInQueue)
                    {
                        return(false);
                    }
                    ID.NotAtRotTargetInQueue = true;
                    break;

                case scriptEvents.control:
                    int held = ((LSL_Types.LSLInteger)param[1]).value;
                    // int changed = ((LSL_Types.LSLInteger)data.Params[2]).value;

                    // If the last message was a 0 (nothing held)
                    // and this one is also nothing held, drop it
                    //
                    if (ID.LastControlLevel == held && held == 0)
                    {
                        return(true);
                    }

                    // If there is one or more queued, then queue
                    // only changed ones, else queue unconditionally
                    //
                    if (ID.ControlEventsInQueue > 0)
                    {
                        if (ID.LastControlLevel == held)
                        {
                            return(false);
                        }
                    }
                    break;

                case scriptEvents.collision:
                    if (ID.CollisionInQueue || ID.RemoveCollisionEvents)
                    {
                        return(false);
                    }
                    ID.CollisionInQueue = true;
                    break;

                case scriptEvents.moving_start:
                    if (ID.MovingInQueue)     //Block all other moving_starts until moving_end is called
                    {
                        return(false);
                    }
                    ID.MovingInQueue = true;
                    break;

                case scriptEvents.moving_end:
                    if (!ID.MovingInQueue)     //If we get a moving_end after we have sent one event, don't fire another
                    {
                        return(false);
                    }
                    break;

                case scriptEvents.collision_end:
                    if (ID.RemoveCollisionEvents)
                    {
                        return(false);
                    }
                    break;

                case scriptEvents.touch:
                    if (ID.TouchInQueue || ID.RemoveTouchEvents)
                    {
                        return(false);
                    }
                    ID.TouchInQueue = true;
                    break;

                case scriptEvents.touch_end:
                    if (ID.RemoveTouchEvents)
                    {
                        return(false);
                    }
                    break;

                case scriptEvents.land_collision:
                    if (ID.LandCollisionInQueue || ID.RemoveLandCollisionEvents)
                    {
                        return(false);
                    }
                    ID.LandCollisionInQueue = true;
                    break;

                case scriptEvents.land_collision_end:
                    if (ID.RemoveLandCollisionEvents)
                    {
                        return(false);
                    }
                    break;

                case scriptEvents.changed:
                    Changed changed;
                    if (param[0] is Changed)
                    {
                        changed = (Changed)param[0];
                    }
                    else
                    {
                        changed = (Changed)(((LSL_Types.LSLInteger)param[0]).value);
                    }
                    if (ID.ChangedInQueue.Contains(changed))
                    {
                        return(false);
                    }
                    ID.ChangedInQueue.Add(changed);
                    break;
                }
            }
            return(true);
        }