Ejemplo n.º 1
0
        /// <summary>
        ///     Stop a script which is in this prim's inventory.
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="sceneObjectBeingDeleted">
        ///     Should be true if this script is being removed because the scene
        ///     object is being deleted.  This will prevent spurious updates to the client.
        /// </param>
        public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted)
        {
            bool scriptPresent = false;

            lock (m_itemsLock)
            {
                if (m_items.ContainsKey(itemId))
                {
                    scriptPresent = true;
                }
            }

            if (scriptPresent)
            {
                if (!sceneObjectBeingDeleted)
                {
                    m_part.RemoveScriptEvents(itemId);
                }

                m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId);
            }
            else
            {
                MainConsole.Instance.ErrorFormat(
                    "[PRIM INVENTORY]: " +
                    "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
                    itemId, m_part.Name, m_part.UUID,
                    m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Stop all the scripts in this prim.
 /// </summary>
 public void RemoveScriptInstances()
 {
     lock (Items)
     {
         foreach (TaskInventoryItem item in Items.Values)
         {
             if ((int)InventoryType.LSL == item.InvType)
             {
                 RemoveScriptInstance(item.ItemID);
                 m_part.RemoveScriptEvents(item.ItemID);
             }
         }
     }
 }
Ejemplo n.º 3
0
        private Hashtable changePrimPermissions(Hashtable requestData)
        {
            Hashtable rparms = new Hashtable();

            try
            {
                UUID            primUUID = UUID.Parse((string)requestData["primUUID"]);
                SceneObjectPart part     = SceneHandler.Instance.FindPrim(primUUID);
                if (part == null)
                {
                    throw new Exception("Could not find the requested prim");
                }

                string inventoryItemsString = (string)requestData["inventoryItems"];
                Dictionary <string, string> inventoryItems = JsonMapper.ToObject <Dictionary <string, string> >(inventoryItemsString);
                foreach (KeyValuePair <string, string> inventoryItem in inventoryItems)
                {
                    if (inventoryItem.Value == "0")
                    {
                        part.RemoveScriptEvents(UUID.Parse(inventoryItem.Key));
                    }
                    else
                    {
                        part.SetScriptEvents(UUID.Parse(inventoryItem.Key), Convert.ToInt32(inventoryItem.Value));
                    }
                }

                rparms["success"] = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[OMECONOMY]: changePrimPermissions() Exception: {1} - {2}", Name, e.Message, e.StackTrace);
                rparms["success"] = false;
            }
            return(rparms);
        }
Ejemplo n.º 4
0
        public void OnRemoveScript(uint localID, UUID itemID)
        {
            lock (m_Scripts)
            {
                // Do we even have it?
                if (!m_Scripts.ContainsKey(itemID))
                {
                    return;
                }

                IScriptInstance instance = m_Scripts[itemID];
                m_Scripts.Remove(itemID);

                instance.ClearQueue();
                instance.Stop(0);

                SceneObjectPart part =
                    m_Scene.GetSceneObjectPart(localID);

                if (part != null)
                {
                    part.RemoveScriptEvents(itemID);
                }

//                bool objectRemoved = false;

                lock (m_PrimObjects)
                {
                    // Remove the script from it's prim
                    if (m_PrimObjects.ContainsKey(localID))
                    {
                        // Remove inventory item record
                        if (m_PrimObjects[localID].Contains(itemID))
                        {
                            m_PrimObjects[localID].Remove(itemID);
                        }

                        // If there are no more scripts, remove prim
                        if (m_PrimObjects[localID].Count == 0)
                        {
                            m_PrimObjects.Remove(localID);
//                            objectRemoved = true;
                        }
                    }
                }

                m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
                if (m_DomainScripts[instance.AppDomain].Count == 0)
                {
                    m_DomainScripts.Remove(instance.AppDomain);
                    UnloadAppDomain(instance.AppDomain);
                }

                instance.RemoveState();
                instance.DestroyScriptInstance();

                instance = null;

                ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
                if (handlerObjectRemoved != null)
                {
                    handlerObjectRemoved(part.UUID);
                }

                CleanAssemblies();
            }

            ScriptRemoved handlerScriptRemoved = OnScriptRemoved;

            if (handlerScriptRemoved != null)
            {
                handlerScriptRemoved(itemID);
            }
        }