public void DeleteFrom(ScriptData script)
        {
            OSDMap component = m_manager.GetComponentState(script.Part, m_componentName) as OSDMap;

            //Attempt to find the state saves we have
            if (component != null)
            {
                bool changed = false;
                //if we did remove something, resave it
                if (component.Remove(script.ItemID.ToString()))
                {
                    changed = true;
                }
                if (component.Remove(script.InventoryItem.OldItemID.ToString()))
                {
                    changed = true;
                }
                if (component.Remove(script.InventoryItem.ItemID.ToString()))
                {
                    changed = true;
                }
                if (changed)
                {
                    if (component.Count == 0)
                    {
                        m_manager.RemoveComponentState(script.Part.UUID, m_componentName);
                    }
                    else
                    {
                        m_manager.SetComponentState(script.Part, m_componentName, component);
                    }
                    script.Part.ParentEntity.HasGroupChanged = true;
                }
            }
        }
Exemple #2
0
        public bool Remove(string key)
        {
            bool ret = SettingsData.Remove(key);

            FireEvent(key, null);
            Save();
            return(ret);
        }
Exemple #3
0
        public bool RemoveStore(string ns, string storeName)
        {
            OSD namespaceOsd;

            lock (this)
            {
                if (m_map.TryGetValue(ns, out namespaceOsd))
                {
                    namespaceOsd = null;
                }
            }

            if (null != namespaceOsd)
            {
                OSDMap namespaceOsdMap = (OSDMap)namespaceOsd;
                namespaceOsdMap.Remove(storeName);

                // Don't keep empty namespaces around
                if (namespaceOsdMap.Count <= 0)
                {
                    m_map.Remove(ns);
                }
            }

            return(false);
        }
 public void RemoveGeneric(string key)
 {
     if (m_Generic.ContainsKey(key))
     {
         m_Generic.Remove(key);
     }
 }
Exemple #5
0
 public void RemoveGenericData(string Key)
 {
     if (m_GenericMap.ContainsKey(Key))
     {
         m_GenericMap.Remove(Key);
     }
 }
Exemple #6
0
        /// <summary>
        /// Sanitise the map to remove any namespaces or stores that are not OSDMap.
        /// </summary>
        /// <param name='map'>
        /// </param>
        public static void SanitiseMap(DAMap daMap)
        {
            List <string> keysToRemove = null;

            OSDMap namespacesMap = daMap.m_map;

            foreach (string key in namespacesMap.Keys)
            {
//                Console.WriteLine("Processing ns {0}", key);
                if (!(namespacesMap[key] is OSDMap))
                {
                    if (keysToRemove == null)
                    {
                        keysToRemove = new List <string>();
                    }

                    keysToRemove.Add(key);
                }
            }

            if (keysToRemove != null)
            {
                foreach (string key in keysToRemove)
                {
//                    Console.WriteLine ("Removing bad ns {0}", key);
                    namespacesMap.Remove(key);
                }
            }

            foreach (OSD nsOsd in namespacesMap.Values)
            {
                OSDMap nsOsdMap = (OSDMap)nsOsd;
                keysToRemove = null;

                foreach (string key in nsOsdMap.Keys)
                {
                    if (!(nsOsdMap[key] is OSDMap))
                    {
                        if (keysToRemove == null)
                        {
                            keysToRemove = new List <string>();
                        }

                        keysToRemove.Add(key);
                    }
                }

                if (keysToRemove != null)
                {
                    foreach (string key in keysToRemove)
                    {
                        nsOsdMap.Remove(key);
                    }
                }
            }
        }
        public bool RemoveFeature(string name)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }

            lock (m_features)
                return(m_features.Remove(name));
        }
 public bool RemoveFeature(string name)
 {
     m_featuresRwLock.AcquireWriterLock(-1);
     try
     {
         return(m_features.Remove(name));
     }
     finally
     {
         m_featuresRwLock.ReleaseWriterLock();
     }
 }
Exemple #9
0
        public void DeleteFrom(ScriptData script)
        {
            OSDMap component = (OSDMap)m_manager.GetComponentState(script.Part, m_componentName);

            //Attempt to find the state saves we have
            if (component != null)
            {
                //if we did remove something, resave it
                if (component.Remove(script.ItemID.ToString()))
                {
                    m_manager.SetComponentState(script.Part, m_componentName, component);
                }
            }
        }
Exemple #10
0
        public void DeleteFrom(ISceneChildEntity Part, UUID ItemID)
        {
            OSDMap component = m_manager.GetComponentState(Part, m_componentName) as OSDMap;

            //Attempt to find the state saves we have
            if (component != null)
            {
                //if we did remove something, resave it
                if (component.Remove(ItemID.ToString()))
                {
                    if (component.Count == 0)
                    {
                        m_manager.RemoveComponentState(Part.UUID, m_componentName);
                    }
                    else
                    {
                        m_manager.SetComponentState(Part, m_componentName, component);
                    }
                    Part.ParentEntity.HasGroupChanged = true;
                }
            }
        }
Exemple #11
0
        private byte[] DispatchWindLightSettings(string path, Stream request,
                                                 OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID agentID)
        {
            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(new byte[0]); //They don't exist
            }
            MainConsole.Instance.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            RegionLightShareData lsd = new RegionLightShareData();

            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;

            if (rm.ContainsKey("remove"))
            {
                remove = rm["remove"].AsBoolean();
            }

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(new byte[0]); // No permissions
                    }
#if (!ISWIN)
                    bool found = false;
                    foreach (RegionLightShareData regionLsd in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLsd.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLsd.maxEffectiveAltitude)
                        {
                            found = true;
                            break;
                        }
                    }
#else
                    bool found = m_WindlightSettings.Values.Any(regionLSD => lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude);
#endif

                    //Set to default
                    if (found)
                    {
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                    }
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X,
                                                                          (int)SP.AbsolutePosition.Y);
                        if (SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(new byte[0]); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(new byte[0]);
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                        {
                            innerMap.Remove(lsd.minEffectiveAltitude.ToString());
                        }

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, false);
                    }
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(new byte[0]); // No permissions
                    }
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return(new byte[0]);
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X,
                                                                          (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(new byte[0]); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(new byte[0]);
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        foreach (KeyValuePair <string, OSD> kvp in innerMap)
                        {
                            OSDMap lsdMap = (OSDMap)kvp.Value;
                            RegionLightShareData parcelLSD = new RegionLightShareData();
                            parcelLSD.FromOSD(lsdMap);

                            string message = "";
                            if (checkAltitude(lsd, parcelLSD, out message))
                            {
                                SP.ControllingClient.SendAlertMessage(message);
                                return(new byte[0]);
                            }
                        }

                        innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, lsd);
                    }
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return(new byte[0]);
        }
        private OSDMap GetEstate(OSDMap map)
        {
            OSDMap resp = new OSDMap(1);
            resp["Failed"] = true;

            IEstateConnector estates = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector>();
            if (estates != null && map.ContainsKey("Estate"))
            {
                int EstateID;
                EstateSettings es = null;
                if (int.TryParse(map["Estate"], out EstateID))
                {
                    es = estates.GetEstateSettings(map["Estate"].AsInteger());
                }
                else
                {
                    es = estates.GetEstateSettings(map["Estate"].AsString());
                }
                if (es != null)
                {
                    resp.Remove("Failed");
                    resp["Estate"] = EstateSettings2WebOSD(es);
                }
            }

            return resp;
        }
Exemple #13
0
 public bool RemoveFeature(string name)
 {
     lock (m_features)
         return(m_features.Remove(name));
 }
Exemple #14
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        protected bool SetValueFromExpression(string expr, OSD ovalue)
        {
            Stack <string> path = ParsePathExpression(expr);

            if (path.Count == 0)
            {
                m_ValueStore = ovalue;
                return(true);
            }

            string pkey  = path.Pop();
            string pexpr = PathExpressionToKey(path);

            if (pexpr != "")
            {
                pexpr += ".";
            }

            OSD result = ProcessPathExpression(m_ValueStore, path);

            if (result == null)
            {
                return(false);
            }

            Regex           aPattern = new Regex("\\[([0-9]+|\\+)\\]");
            MatchCollection amatches = aPattern.Matches(pkey, 0);

            if (amatches.Count > 0)
            {
                if (result.Type != OSDType.Array)
                {
                    return(false);
                }

                OSDArray amap = result as OSDArray;

                Match           match  = amatches[0];
                GroupCollection groups = match.Groups;
                string          akey   = groups[1].Value;

                if (akey == "+")
                {
                    string npkey = String.Format("[{0}]", amap.Count);

                    amap.Add(ovalue);
                    InvokeNextCallback(pexpr + npkey);
                    return(true);
                }

                int aval = Convert.ToInt32(akey);
                if (0 <= aval && aval < amap.Count)
                {
                    if (ovalue == null)
                    {
                        amap.RemoveAt(aval);
                    }
                    else
                    {
                        amap[aval] = ovalue;
                        InvokeNextCallback(pexpr + pkey);
                    }
                    return(true);
                }

                return(false);
            }

            Regex           hPattern = new Regex("{([^}]+)}");
            MatchCollection hmatches = hPattern.Matches(pkey, 0);

            if (hmatches.Count > 0)
            {
                Match           match  = hmatches[0];
                GroupCollection groups = match.Groups;
                string          hkey   = groups[1].Value;

                if (result is OSDMap)
                {
                    OSDMap hmap = result as OSDMap;
                    if (ovalue != null)
                    {
                        hmap[hkey] = ovalue;
                        InvokeNextCallback(pexpr + pkey);
                    }
                    else if (hmap.ContainsKey(hkey))
                    {
                        hmap.Remove(hkey);
                    }

                    return(true);
                }

                return(false);
            }

            // Shouldn't get here if the path was checked correctly
            m_log.WarnFormat("[JsonStore] invalid path expression");
            return(false);
        }
Exemple #15
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        protected bool SetValueFromExpression(string expr, OSD ovalue)
        {
            Stack <string> path;

            if (!ParsePathExpression(expr, out path))
            {
                return(false);
            }

            if (path.Count == 0)
            {
                ValueStore  = ovalue;
                StringSpace = 0;
                return(true);
            }

            // pkey will be the final element in the path, we pull it out here to make sure
            // that the assignment works correctly
            string pkey  = path.Pop();
            string pexpr = PathExpressionToKey(path);

            if (pexpr != "")
            {
                pexpr += ".";
            }

            OSD result = ProcessPathExpression(ValueStore, path);

            if (result == null)
            {
                return(false);
            }

            // Check pkey, the last element in the path, for and extract array references
            MatchCollection amatches = m_ArrayPattern.Matches(pkey, 0);

            if (amatches.Count > 0)
            {
                if (result.Type != OSDType.Array)
                {
                    return(false);
                }

                OSDArray amap = result as OSDArray;

                Match           match  = amatches[0];
                GroupCollection groups = match.Groups;
                string          akey   = groups[1].Value;

                if (akey == "+")
                {
                    string npkey = String.Format("[{0}]", amap.Count);

                    if (ovalue != null)
                    {
                        StringSpace += ComputeSizeOf(ovalue);

                        amap.Add(ovalue);
                        InvokeNextCallback(pexpr + npkey);
                    }
                    return(true);
                }

                int aval = Convert.ToInt32(akey);
                if (0 <= aval && aval < amap.Count)
                {
                    if (ovalue == null)
                    {
                        StringSpace -= ComputeSizeOf(amap[aval]);
                        amap.RemoveAt(aval);
                    }
                    else
                    {
                        StringSpace -= ComputeSizeOf(amap[aval]);
                        StringSpace += ComputeSizeOf(ovalue);
                        amap[aval]   = ovalue;
                        InvokeNextCallback(pexpr + pkey);
                    }
                    return(true);
                }

                return(false);
            }

            // Check for and extract hash references
            MatchCollection hmatches = m_HashPattern.Matches(pkey, 0);

            if (hmatches.Count > 0)
            {
                Match           match  = hmatches[0];
                GroupCollection groups = match.Groups;
                string          hkey   = groups[1].Value;

                if (result is OSDMap)
                {
                    // this is the assignment case
                    OSDMap hmap = result as OSDMap;
                    if (ovalue != null)
                    {
                        StringSpace -= ComputeSizeOf(hmap[hkey]);
                        StringSpace += ComputeSizeOf(ovalue);

                        hmap[hkey] = ovalue;
                        InvokeNextCallback(pexpr + pkey);
                        return(true);
                    }

                    // this is the remove case
                    if (hmap.ContainsKey(hkey))
                    {
                        StringSpace -= ComputeSizeOf(hmap[hkey]);
                        hmap.Remove(hkey);
                        return(true);
                    }

                    return(false);
                }

                return(false);
            }

            // Shouldn't get here if the path was checked correctly
            m_log.WarnFormat("[JsonStore] invalid path expression");
            return(false);
        }
Exemple #16
0
        private Hashtable DispatchWindLightSettings(Hashtable m_dhttpMethod, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"]   = 200; //501; //410; //404;
            responsedata["content_type"]        = "text/plain";
            responsedata["keepalive"]           = false;
            responsedata["str_response_string"] = "";

            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(responsedata); //They don't exist
            }
            m_log.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);

            RegionLightShareData lsd = new RegionLightShareData();

            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;

            if (rm.ContainsKey("remove"))
            {
                remove = rm["remove"].AsBoolean();
            }

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(responsedata); // No permissions
                    }
                    bool found = false;
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude &&
                            lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude)
                        {
                            //it exists
                            found = true;
                            break;
                        }
                    }

                    //Set to default
                    if (found)
                    {
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                    }
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement = SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(responsedata); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(responsedata);
                        }

                        OSDMap map = land.LandData.GenericDataMap;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                        {
                            innerMap.Remove(lsd.minEffectiveAltitude.ToString());
                        }

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP);
                    }
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                    {
                        return(responsedata); // No permissions
                    }
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return(responsedata);
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement = SP.Scene.RequestModuleInterface <IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        {
                            return(responsedata); // No permissions
                        }
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return(responsedata);
                        }

                        OSDMap map = land.LandData.GenericDataMap;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        {
                            innerMap = (OSDMap)map["WindLight"];
                        }

                        string removeThisMap = "";

                        foreach (KeyValuePair <string, OSD> kvp in innerMap)
                        {
                            OSDMap lsdMap = (OSDMap)kvp.Value;
                            RegionLightShareData parcelLSD = new RegionLightShareData();
                            parcelLSD.FromOSD(lsdMap);

                            string message = "";
                            if (checkAltitude(lsd, parcelLSD, out message))
                            {
                                SP.ControllingClient.SendAlertMessage(message);
                                return(responsedata);
                            }
                        }

                        if (removeThisMap != "")
                        {
                            innerMap.Remove(removeThisMap);
                        }

                        innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, lsd);
                    }
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return(responsedata);
        }
Exemple #17
0
 protected void RemoveCaps(string method)
 {
     registeredCAPS.Remove(method);
 }
        private byte[] DispatchWindLightSettings(string path, Stream request,
                                  OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID agentID)
        {
            IScenePresence SP = m_scene.GetScenePresence(agentID);
            if (SP == null)
                return new byte[0]; //They don't exist

            MainConsole.Instance.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap) OSDParser.DeserializeLLSDXml(request);

            RegionLightShareData lsd = new RegionLightShareData();
            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;
            if (rm.ContainsKey("remove"))
                remove = rm["remove"].AsBoolean();

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                        return new byte[0]; // No permissions
#if (!ISWIN)
                    bool found = false;
                    foreach (RegionLightShareData regionLsd in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLsd.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLsd.maxEffectiveAltitude)
                        {
                            found = true;
                            break;
                        }
                    }
#else
                    bool found = m_WindlightSettings.Values.Any(regionLSD => lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude && lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude);
#endif

                    //Set to default
                    if (found)
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface<IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int) SP.AbsolutePosition.X,
                                                                          (int) SP.AbsolutePosition.Y);
                        if (SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong) GroupPowers.LandOptions))
                            return new byte[0]; // No permissions
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface<IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return new byte[0];
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                            innerMap = (OSDMap) map["WindLight"];

                        if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                            innerMap.Remove(lsd.minEffectiveAltitude.ToString());

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, false);
                    }
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                        return new byte[0]; // No permissions

                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return new byte[0];
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    IParcelManagementModule parcelManagement =
                        SP.Scene.RequestModuleInterface<IParcelManagementModule>();
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject((int) SP.AbsolutePosition.X,
                                                                          (int) SP.AbsolutePosition.Y);
                        if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong) GroupPowers.LandOptions))
                            return new byte[0]; // No permissions
                        IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface<IOpenRegionSettingsModule>();
                        if (ORSM == null || !ORSM.AllowParcelWindLight)
                        {
                            SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                            return new byte[0];
                        }

                        OSDMap map = land.LandData.GenericData;

                        OSDMap innerMap = new OSDMap();
                        if (land.LandData.GenericData.ContainsKey("WindLight"))
                            innerMap = (OSDMap) map["WindLight"];

                        foreach (KeyValuePair<string, OSD> kvp in innerMap)
                        {
                            OSDMap lsdMap = (OSDMap) kvp.Value;
                            RegionLightShareData parcelLSD = new RegionLightShareData();
                            parcelLSD.FromOSD(lsdMap);

                            string message = "";
                            if (checkAltitude(lsd, parcelLSD, out message))
                            {
                                SP.ControllingClient.SendAlertMessage(message);
                                return new byte[0];
                            }
                        }

                        innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                        land.LandData.AddGenericData("WindLight", innerMap);
                        //Update the client
                        SendProfileToClient(SP, lsd);
                    }
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return new byte[0];
        }
        private Hashtable DispatchWindLightSettings(Hashtable m_dhttpMethod, UUID capuuid, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();
            responsedata["int_response_code"] = 200; //501; //410; //404;
            responsedata["content_type"] = "text/plain";
            responsedata["keepalive"] = false;
            responsedata["str_response_string"] = "";

            ScenePresence SP = m_scene.GetScenePresence(agentID);
            if(SP == null)
                return responsedata; //They don't exist

            m_log.Info("[WindLightSettings]: Got a request to update WindLight from " + SP.Name);

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);

            RegionLightShareData lsd = new RegionLightShareData();
            lsd.FromOSD(rm);
            lsd.regionID = SP.Scene.RegionInfo.RegionID;
            bool remove = false;
            if (rm.ContainsKey("remove"))
                remove = rm["remove"].AsBoolean();

            if (remove)
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                        return responsedata; // No permissions
                    bool found = false;
                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        if (lsd.minEffectiveAltitude == regionLSD.minEffectiveAltitude &&
                            lsd.maxEffectiveAltitude == regionLSD.maxEffectiveAltitude)
                        {
                            //it exists
                            found = true;
                            break;
                        }
                    }

                    //Set to default
                    if(found)
                        SaveWindLightSettings(lsd.minEffectiveAltitude, new RegionLightShareData());
                }
                else if (lsd.type == 1) //Parcel
                {
                    ILandObject land = SP.Scene.LandChannel.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                    if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        return responsedata; // No permissions
                    IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface<IOpenRegionSettingsModule>();
                    if (ORSM == null || !ORSM.AllowParcelWindLight)
                    {
                        SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                        return responsedata;
                    }

                    OSDMap map = land.LandData.GenericDataMap;

                    OSDMap innerMap = new OSDMap();
                    if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        innerMap = (OSDMap)map["WindLight"];

                    if (innerMap.ContainsKey(lsd.minEffectiveAltitude.ToString()))
                    {
                        innerMap.Remove(lsd.minEffectiveAltitude.ToString());
                    }

                    land.LandData.AddGenericData("WindLight", innerMap);
                    //Update the client
                    SendProfileToClient(SP);
                }
            }
            else
            {
                if (lsd.type == 0) //Region
                {
                    if (!SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
                        return responsedata; // No permissions

                    foreach (RegionLightShareData regionLSD in m_WindlightSettings.Values)
                    {
                        string message = "";
                        if (checkAltitude(lsd, regionLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return responsedata;
                        }
                    }
                    SaveWindLightSettings(lsd.minEffectiveAltitude, lsd);
                }
                else if (lsd.type == 1) //Parcel
                {
                    ILandObject land = SP.Scene.LandChannel.GetLandObject((int)SP.AbsolutePosition.X, (int)SP.AbsolutePosition.Y);
                    if (!SP.Scene.Permissions.GenericParcelPermission(SP.UUID, land, (ulong)GroupPowers.LandOptions))
                        return responsedata; // No permissions
                    IOpenRegionSettingsModule ORSM = SP.Scene.RequestModuleInterface<IOpenRegionSettingsModule>();
                    if (ORSM == null || !ORSM.AllowParcelWindLight)
                    {
                        SP.ControllingClient.SendAlertMessage("Parcel WindLight is disabled in this region.");
                        return responsedata;
                    }

                    OSDMap map = land.LandData.GenericDataMap;

                    OSDMap innerMap = new OSDMap();
                    if (land.LandData.GenericDataMap.ContainsKey("WindLight"))
                        innerMap = (OSDMap)map["WindLight"];

                    string removeThisMap = "";

                    foreach (KeyValuePair<string, OSD> kvp in innerMap)
                    {
                        OSDMap lsdMap = (OSDMap)kvp.Value;
                        RegionLightShareData parcelLSD = new RegionLightShareData();
                        parcelLSD.FromOSD(lsdMap);

                        string message = "";
                        if (checkAltitude(lsd, parcelLSD, out message))
                        {
                            SP.ControllingClient.SendAlertMessage(message);
                            return responsedata;
                        }
                    }

                    if (removeThisMap != "")
                        innerMap.Remove(removeThisMap);

                    innerMap[lsd.minEffectiveAltitude.ToString()] = lsd.ToOSD();

                    land.LandData.AddGenericData("WindLight", innerMap);
                    //Update the client
                    SendProfileToClient(SP, lsd);
                }
            }
            SP.ControllingClient.SendAlertMessage("WindLight Settings updated.");
            return responsedata;
        }
Exemple #20
0
 public void RemoveGenericData(string Key)
 {
     OSD osd = OSDParser.DeserializeLLSDXml(m_GenericData);
     OSDMap map = new OSDMap();
     if (osd.Type == OSDType.Map)
     {
         map = (OSDMap)osd;
         map.Remove(Key);
         m_GenericData = OSDParser.SerializeLLSDXmlString(map);
     }
 }