Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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;
        }
        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];
        }