Example #1
0
 public BuyPoint(UUID uuid, string name, Vector3 position, ILandObject parcel)
     : this(uuid)
 {
     Name = name;
     Location.LocalPosition = position;
     Location.Parcel = parcel;
 }
Example #2
0
        public BuyPoint CreateBuyPoint(UUID uuid, string name, Vector3 pos, ILandObject osParcel, RegionInfo regionInfo)
        {
            BuyPoint bp = new BuyPoint(uuid, name, pos, osParcel) { Game = m_controller.Game };
            bp.Location.RegionName = regionInfo.RegionName;
            bp.Location.RegionId = regionInfo.RegionID;
            bp.Location.RegionX = regionInfo.RegionLocX;
            bp.Location.RegionY = regionInfo.RegionLocY;

            return bp;
        }
Example #3
0
 public void SetUp()
 {
     m_pcm = new PrimCountModule();
     LandManagementModule lmm = new LandManagementModule();
     m_scene = SceneHelpers.SetupScene();            
     SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm);             
                 
     int xParcelDivider = (int)Constants.RegionSize - 1;
     
     ILandObject lo = new LandObject(m_userId, false, m_scene);
     lo.LandData.Name = "m_lo";
     lo.SetLandBitmap(
         lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize));
     m_lo = lmm.AddLandObject(lo);          
     
     ILandObject lo2 = new LandObject(m_userId, false, m_scene);
     lo2.SetLandBitmap(
         lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
     lo2.LandData.Name = "m_lo2";
     m_lo2 = lmm.AddLandObject(lo2);
 } 
 public bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene)
 {
     return(m_rootScene.Permissions.CanDeedParcel(user, parcel));
 }
Example #5
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName       = c.From;
            string  fromNamePrefix = "";
            UUID    fromID         = UUID.Zero;
            UUID    ownerID        = UUID.Zero;
            string  message        = c.Message;
            Scene   scene          = c.Scene as Scene;
            UUID    destination    = c.Destination;
            Vector3 fromPos        = c.Position;
            Vector3 regionPos      = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);

            bool    checkParcelHide = false;
            UUID    sourceParcelID  = UUID.Zero;
            Vector3 hidePos         = fromPos;

            if (c.Channel == DEBUG_CHANNEL)
            {
                c.Type = ChatTypeEnum.DebugChannel;
            }

            if (!m_scenes.Contains(scene))
            {
                m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
                                 scene.RegionInfo.RegionName);
                return;
            }

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos  = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID   = c.Sender.AgentId;
                if (avatar.IsViewerUIGod)
                {     // let gods speak to outside or things may get confusing
                    fromNamePrefix  = m_adminPrefix;
                    checkParcelHide = false;
                }
                else
                {
                    checkParcelHide = true;
                }
                destination = UUID.Zero;     // Avatars cant "SayTo"
                ownerID     = c.Sender.AgentId;

                hidePos = fromPos;
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                {
                    ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                    if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
                    {
                        checkParcelHide = true;
                        hidePos         = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
                    }
                }
                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet <UUID> receiverIDs = new HashSet <UUID>();

            if (checkParcelHide)
            {
                checkParcelHide = false;
                if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
                {
                    ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
                    if (srcland != null && !srcland.LandData.SeeAVs)
                    {
                        sourceParcelID  = srcland.LandData.GlobalID;
                        checkParcelHide = true;
                    }
                }
            }

            scene.ForEachScenePresence(
                delegate(ScenePresence presence)
            {
                if (destination != UUID.Zero && presence.UUID != destination)
                {
                    return;
                }

                if (presence.IsChildAgent)
                {
                    if (checkParcelHide)
                    {
                        return;
                    }
                    if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                           ownerID, fromNamePrefix + fromName, c.Type,
                                           message, sourceType, (destination != UUID.Zero)))
                    {
                        receiverIDs.Add(presence.UUID);
                    }
                    return;
                }

                ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
                if (Presencecheck != null)
                {
                    if (checkParcelHide)
                    {
                        if (sourceParcelID != Presencecheck.LandData.GlobalID && !presence.IsViewerUIGod)
                        {
                            return;
                        }
                    }
                    if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
                    {
                        if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                               ownerID, fromNamePrefix + fromName, c.Type,
                                               message, sourceType, (destination != UUID.Zero)))
                        {
                            receiverIDs.Add(presence.UUID);
                        }
                    }
                }
            });

            scene.EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
Example #6
0
        private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land,  out string reason)
        {
            bool banned = land.IsBannedFromLand(agent.AgentID);
            bool restricted = land.IsRestrictedFromLand(agent.AgentID);

            if (banned || restricted)
            {
                ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y);
                if (nearestParcel != null)
                {
                    //Move agent to nearest allowed
                    Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
                    agent.startpos.X = newPosition.X;
                    agent.startpos.Y = newPosition.Y;
                }
                else
                {
                    if (banned)
                    {
                        reason = "Cannot regioncross into banned parcel.";
                    }
                    else
                    {
                        reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
                                   RegionInfo.RegionName);
                    }
                    return false;
                }
            }
            reason = "";
            return true;
        }
Example #7
0
 public Vector3 GetParcelCenterAtGround(ILandObject parcel)
 {
     Vector2 center = GetParcelCenter(parcel);
     return GetPositionAtGround(center.X, center.Y);
 }
        private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            GroupPowers powers;
            ILandObject l;

            ScenePresence sp = scene.GetScenePresence(user);
            if (sp == null)
                return false;

            IClientAPI client = sp.ControllingClient;

            foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
            {
                // Any user can return their own objects at any time
                //
                if (GenericObjectPermission(user, g.UUID, false))
                    continue;

                // This is a short cut for efficiency. If land is non-null,
                // then all objects are on that parcel and we can save
                // ourselves the checking for each prim. Much faster.
                //
                if (land != null)
                {
                    l = land;
                }
                else
                {
                    Vector3 pos = g.AbsolutePosition;

                    l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
                }

                // If it's not over any land, then we can't do a thing
                if (l == null)
                {
                    objects.Remove(g);
                    continue;
                }

                // If we own the land outright, then allow
                //
                if (l.LandData.OwnerID == user)
                    continue;

                // Group voodoo
                //
                if (l.LandData.IsGroupOwned)
                {
                    powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID);
                    // Not a group member, or no rights at all
                    //
                    if (powers == (GroupPowers)0)
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // Group deeded object?
                    //
                    if (g.OwnerID == l.LandData.GroupID &&
                        (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0)
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // Group set object?
                    //
                    if (g.GroupID == l.LandData.GroupID &&
                        (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0)
                    {
                        objects.Remove(g);
                        continue;
                    }

                    if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0)
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // So we can remove all objects from this group land.
                    // Fine.
                    //
                    continue;
                }

                // By default, we can't remove
                //
                objects.Remove(g);
            }

            if (objects.Count == 0)
                return false;

            return true;
        }
 private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene)
 {
     DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
     if (m_bypassPermissions) return m_bypassPermissionsValue;
 
     return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease);
 }
Example #10
0
        //Find the correct WL settings to send to the client
        public void SendProfileToClient(IScenePresence presence, bool checkAltitudesOnly)
        {
            if (presence == null)
            {
                return;
            }
            ILandObject land = null;

            if (!checkAltitudesOnly)
            {
                IParcelManagementModule parcelManagement =
                    presence.Scene.RequestModuleInterface <IParcelManagementModule>();
                if (parcelManagement != null)
                {
                    land = parcelManagement.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
                }
                OSDMap map = land != null ? land.LandData.GenericData : new OSDMap();
                if (map.ContainsKey("WindLight"))
                {
                    IOpenRegionSettingsModule ORSM = presence.Scene.RequestModuleInterface <IOpenRegionSettingsModule>();
                    if (ORSM != null && ORSM.AllowParcelWindLight)
                    {
                        if (CheckOverRideParcels(presence))
                        {
                            //Overrides all
                            SendProfileToClient(presence, FindRegionWindLight(presence));
                        }
                        else
                        {
                            OSDMap innerMap = (OSDMap)map["WindLight"];
                            foreach (KeyValuePair <string, OSD> kvp in innerMap)
                            {
                                int minEffectiveAltitude = int.Parse(kvp.Key);
                                if (presence.AbsolutePosition.Z > minEffectiveAltitude)
                                {
                                    OSDMap lsdMap = (OSDMap)kvp.Value;
                                    RegionLightShareData parcelLSD = new RegionLightShareData();
                                    parcelLSD.FromOSD(lsdMap);
                                    if (presence.AbsolutePosition.Z < parcelLSD.maxEffectiveAltitude)
                                    {
                                        //They are between both altitudes
                                        SendProfileToClient(presence, parcelLSD);
                                        return; //End it
                                    }
                                }
                            }
                            //Send region since no parcel claimed the user
                            SendProfileToClient(presence, FindRegionWindLight(presence));
                        }
                    }
                    else
                    {
                        //Only region allowed
                        SendProfileToClient(presence, FindRegionWindLight(presence));
                    }
                }
                else
                {
                    //Send the region by default to override any previous settings
                    SendProfileToClient(presence, FindRegionWindLight(presence));
                }
            }
            else
            {
                //Send the region by default to override any previous settings
                SendProfileToClient(presence, FindRegionWindLight(presence));
            }
        }
Example #11
0
        protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
        {
            if (parcel.landData.OwnerID == user)
                return true;

            if ((parcel.landData.GroupID != UUID.Zero) && IsAgentInGroupRole(parcel.landData.GroupID, user, groupPowers))
                return true;

            if (m_scene.IsEstateManager(user))
                return true;

            if (IsGodUser(user))
                return true;

            return false;
        }
Example #12
0
        private Hashtable RetrieveWindLightSettings(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
            }
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

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

            if (rm.ContainsKey("RegionID"))
            {
                //For the region, just add all of them
                OSDArray array = new OSDArray();
                foreach (RegionLightShareData rlsd in m_WindlightSettings.Values)
                {
                    OSDMap m = rlsd.ToOSD();
                    m.Add("Name",
                          OSD.FromString("(Region Settings), Min: " + rlsd.minEffectiveAltitude + ", Max: " +
                                         rlsd.maxEffectiveAltitude));
                    array.Add(m);
                }
                retVal.Add("WindLight", array);
                retVal.Add("Type", OSD.FromInteger(1));
            }
            else if (rm.ContainsKey("ParcelID"))
            {
                OSDArray retVals = new OSDArray();
                //-1 is all parcels
                if (rm["ParcelID"].AsInteger() == -1)
                {
                    //All parcels
                    if (parcelManagement != null)
                    {
                        foreach (ILandObject land in parcelManagement.AllParcels())
                        {
                            OSDMap map = land.LandData.GenericData;
                            if (map.ContainsKey("WindLight"))
                            {
                                OSDMap parcelWindLight = (OSDMap)map["WindLight"];
                                foreach (OSD innerMap in parcelWindLight.Values)
                                {
                                    RegionLightShareData rlsd = new RegionLightShareData();
                                    rlsd.FromOSD((OSDMap)innerMap);
                                    OSDMap imap = new OSDMap();
                                    imap = rlsd.ToOSD();
                                    imap.Add("Name",
                                             OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude +
                                                            ", Max: " + rlsd.maxEffectiveAltitude));
                                    retVals.Add(imap);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Only the given parcel parcel given by localID
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject(rm["ParcelID"].AsInteger());
                        OSDMap      map  = land.LandData.GenericData;
                        if (map.ContainsKey("WindLight"))
                        {
                            OSDMap parcelWindLight = (OSDMap)map["WindLight"];
                            foreach (OSD innerMap in parcelWindLight.Values)
                            {
                                RegionLightShareData rlsd = new RegionLightShareData();
                                rlsd.FromOSD((OSDMap)innerMap);
                                OSDMap imap = new OSDMap();
                                imap = rlsd.ToOSD();
                                imap.Add("Name",
                                         OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude +
                                                        ", Max: " + rlsd.maxEffectiveAltitude));
                                retVals.Add(imap);
                            }
                        }
                    }
                }
                retVal.Add("WindLight", retVals);
                retVal.Add("Type", OSD.FromInteger(2));
            }

            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(retVal);
            return(responsedata);
        }
Example #13
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
            }
            MainConsole.Instance.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
                    }
#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(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.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(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.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(responsedata);
                            }
                        }

                        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);
        }
Example #14
0
        // NOTE: Call under Taint Lock
        private void RemoveObject(ISceneEntity obj)
        {
            if (obj.IsAttachment)
            {
                return;
            }
            if (((obj.RootChild.Flags & PrimFlags.TemporaryOnRez) != 0))
            {
                return;
            }

            Vector3     pos        = obj.AbsolutePosition;
            ILandObject landObject = m_Scene.RequestModuleInterface <IParcelManagementModule>().GetLandObject(pos.X,
                                                                                                              pos.Y);

            if (landObject == null)
            {
                landObject = m_Scene.RequestModuleInterface <IParcelManagementModule>().GetNearestAllowedParcel(
                    UUID.Zero, pos.X, pos.Y);
            }

            if (landObject == null)
            {
                return;
            }
            LandData landData = landObject.LandData;

            ParcelCounts parcelCounts;

            if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
            {
                UUID landOwner = landData.OwnerID;

                foreach (ISceneChildEntity child in obj.ChildrenEntities())
                {
                    if (!parcelCounts.Objects.ContainsKey(child.UUID))
                    {
                        //Well... now what?
                    }
                    else
                    {
                        parcelCounts.Objects.Remove(child.UUID);
                        if (m_SimwideCounts.ContainsKey(landOwner))
                        {
                            m_SimwideCounts[landOwner] -= 1;
                        }
                        if (parcelCounts.Users.ContainsKey(obj.OwnerID))
                        {
                            parcelCounts.Users[obj.OwnerID] -= 1;
                        }

                        if (landData.IsGroupOwned)
                        {
                            if (obj.OwnerID == landData.GroupID)
                            {
                                parcelCounts.Owner -= 1;
                            }
                            else if (obj.GroupID == landData.GroupID)
                            {
                                parcelCounts.Group -= 1;
                            }
                            else
                            {
                                parcelCounts.Others -= 1;
                            }
                        }
                        else
                        {
                            if (obj.OwnerID == landData.OwnerID)
                            {
                                parcelCounts.Owner -= 1;
                            }
                            else if (obj.GroupID == landData.GroupID)
                            {
                                parcelCounts.Group -= 1;
                            }
                            else
                            {
                                parcelCounts.Others -= 1;
                            }
                        }
                    }
                }
            }
        }
Example #15
0
        // NOTE: Call under Taint Lock
        private void AddObject(ISceneEntity obj)
        {
            if (obj.IsAttachment)
            {
                return;
            }
            if (((obj.RootChild.Flags & PrimFlags.TemporaryOnRez) != 0))
            {
                return;
            }

            Vector3     pos        = obj.AbsolutePosition;
            ILandObject landObject = m_Scene.RequestModuleInterface <IParcelManagementModule>().GetLandObject(pos.X,
                                                                                                              pos.Y);

            if (landObject == null)
            {
                return;
            }
            LandData landData = landObject.LandData;

            ParcelCounts parcelCounts;

            if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
            {
                UUID landOwner = landData.OwnerID;

                parcelCounts.Objects[obj.UUID] = obj;
                m_SimwideCounts[landOwner]    += obj.PrimCount;

                if (parcelCounts.Users.ContainsKey(obj.OwnerID))
                {
                    parcelCounts.Users[obj.OwnerID] += obj.PrimCount;
                }
                else
                {
                    parcelCounts.Users[obj.OwnerID] = obj.PrimCount;
                }

                if (landData.IsGroupOwned)
                {
                    if (obj.OwnerID == landData.GroupID)
                    {
                        parcelCounts.Owner += obj.PrimCount;
                    }
                    else if (obj.GroupID == landData.GroupID)
                    {
                        parcelCounts.Group += obj.PrimCount;
                    }
                    else
                    {
                        parcelCounts.Others += obj.PrimCount;
                    }
                }
                else
                {
                    if (obj.OwnerID == landData.OwnerID)
                    {
                        parcelCounts.Owner += obj.PrimCount;
                    }
                    else if (obj.GroupID == landData.GroupID)
                    {
                        parcelCounts.Group += obj.PrimCount;
                    }
                    else
                    {
                        parcelCounts.Others += obj.PrimCount;
                    }
                }
            }
        }
Example #16
0
        /**
         * See if permitted by configuration file.
         * See OSSL_Api.CheckThreatLevelTest().
         */
        public string CheckFetchbinaryAllowed()
        {
            string ownerPerm = m_Engine.Config.GetString("Allow_fetchbinary", "");
            UUID   ownerID   = m_Item.OwnerID;

            string[] ids = ownerPerm.Split(new char[] { ',' });
            foreach (string id in ids)
            {
                string curuc = id.Trim().ToUpperInvariant();

                switch (curuc)
                {
                case "ESTATE_MANAGER": {
                    if (m_Engine.m_Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) &&
                        (m_Engine.m_Scene.RegionInfo.EstateSettings.EstateOwner != ownerID))
                    {
                        return(null);
                    }
                    break;
                }

                case "ESTATE_OWNER": {
                    if (m_Engine.m_Scene.RegionInfo.EstateSettings.EstateOwner == ownerID)
                    {
                        return(null);
                    }
                    break;
                }

                case "PARCEL_GROUP_MEMBER": {
                    ILandObject land = m_Engine.m_Scene.LandChannel.GetLandObject(m_Part.AbsolutePosition);
                    if (land.LandData.GroupID == m_Item.GroupID && land.LandData.GroupID != UUID.Zero)
                    {
                        return(null);
                    }
                    break;
                }

                case "PARCEL_OWNER": {
                    ILandObject land = m_Engine.m_Scene.LandChannel.GetLandObject(m_Part.AbsolutePosition);
                    if (land.LandData.OwnerID == ownerID)
                    {
                        return(null);
                    }
                    break;
                }

                case "TRUE": {
                    return(null);
                }

                default: {
                    UUID uuid;
                    if (UUID.TryParse(curuc, out uuid))
                    {
                        if (uuid == ownerID)
                        {
                            return(null);
                        }
                    }
                    break;
                }
                }
            }

            string creatorPerm = m_Engine.Config.GetString("Creators_fetchbinary", "");
            UUID   creatorID   = m_Item.CreatorID;

            ids = creatorPerm.Split(new char[] { ',' });
            foreach (string id in ids)
            {
                string current = id.Trim();
                UUID   uuid;
                if (UUID.TryParse(current, out uuid))
                {
                    if (uuid != UUID.Zero)
                    {
                        if (creatorID == uuid)
                        {
                            return(null);
                        }
                    }
                }
            }

            return("fetchbinary not enabled for owner " + ownerID + " creator " + creatorID);
        }
Example #17
0
        private bool CanSellParcel(UUID user, ILandObject parcel, IScene scene)
        {
            DebugPermissionInformation(MethodBase.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            return GenericParcelPermission(user, parcel, (ulong) GroupPowers.LandSetSale);
        }
Example #18
0
        private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
            int parcelid = -1;

            if (httpRequest.Query.Count > 0)
            {
                if (httpRequest.Query.ContainsKey("parcelid"))
                {
                    Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid);
                }
            }

            ScenePresence sp = m_scene.GetScenePresence(agentID);

            if (sp == null)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
                httpResponse.AddHeader("Retry-After", "5");
                return;
            }

            ViewerEnvironment VEnv = null;

            if (sp.Environment != null)
            {
                VEnv = sp.Environment;
            }
            else if (parcelid == -1)
            {
                VEnv = GetRegionEnvironment();
            }
            else
            {
                if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
                {
                    ILandObject land = m_scene.LandChannel.GetLandObject(parcelid);
                    if (land != null && land.LandData != null && land.LandData.Environment != null)
                    {
                        VEnv = land.LandData.Environment;
                    }
                }
                if (VEnv == null)
                {
                    OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
                    httpResponse.RawBuffer  = OSDParser.SerializeLLSDXmlToBytes(def);
                    httpResponse.StatusCode = (int)HttpStatusCode.OK;
                    return;
                }
            }

            byte[] envBytes = VEnv.ToCapBytes(regionID, parcelid);
            if (envBytes == null)
            {
                osUTF8 sb = LLSDxmlEncode2.Start();
                LLSDxmlEncode2.AddArray(sb);
                LLSDxmlEncode2.AddMap(sb);
                LLSDxmlEncode2.AddElem("messageID", UUID.Zero, sb);
                LLSDxmlEncode2.AddElem("regionID", regionID, sb);
                LLSDxmlEncode2.AddEndMap(sb);
                LLSDxmlEncode2.AddEndArray(sb);
                httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(sb);
            }
            else
            {
                httpResponse.RawBuffer = envBytes;
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }
Example #19
0
        // If objectID is specified (not UUID.Zero), then that object (owned by "owner") is trying to rez another object.
        // pass 0 for landImpact if you do not want this method to do any Land Impact limit checks.
        private bool CheckRezPerms(ILandObject parcel, UUID owner, UUID objectID, Vector3 objectPosition, bool isTemp, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);

            if (m_bypassPermissions) return m_bypassPermissionsValue;

            // User or object owner is an admin?
            if (IsGodUser(owner))
                return true;    // we're done here, no need to check more

            // This code block handles the Scenic option of EO (and partner) only.
            if (scene.RegionInfo.AllowRezzers == ProductRulesWho.OnlyEO)
            {
                // only the estate OWNER or PARTNER can rez in scenic regions unless it's a temprez object
                if (scene.IsEstateOwner(owner))
                    return true;
                if (scene.RegionInfo.AllowPartnerRez)
                    if (scene.IsEstateOwnerPartner(owner))
                        return true;
                if (!isTemp)    // non-temp rezzing not allowed
                    return false;
            }

            // At this point, we need to test a specific parcel.
            if (parcel == null) return false;

            // Is this a Plus region?
            if (scene.RegionInfo.Product == ProductRulesUse.PlusUse)
            {
                // If this is an unclaimed Plus parcel (or community land)
                if (scene.IsEstateOwner(parcel.landData.OwnerID))
                    return scene.IsEstateManager(owner);    // only EM can rez
                // Else only the Plus user (and possibly partner) can rez in a Plus parcel.
                if (owner == parcel.landData.OwnerID)
                    return true;
                // Otherwise, only the Plus user's partner can rez in a Plus parcel.
                if (scene.RegionInfo.AllowPartnerRez)
                {
                    UserProfileData parcelOwner = m_scene.CommsManager.UserService.GetUserProfile(parcel.landData.OwnerID);
                    if (parcelOwner != null)
                        if (parcelOwner.Partner != UUID.Zero)
                            if (parcelOwner.Partner == owner)
                                return true;
                }
                return false;
            }

            // Create enabled for everyone?
            if ((parcel.landData.Flags & ((int)ParcelFlags.CreateObjects)) == (uint)ParcelFlags.CreateObjects)
                return true;    // we're done here, no need to check more

            ulong roleNeeded = (ulong)GroupPowers.AllowRez;
            if ((parcel.landData.Flags & (uint)ParcelFlags.CreateGroupObjects) == (uint)ParcelFlags.CreateGroupObjects)
                roleNeeded = (ulong)GroupPowers.None; // if group rezzing is enabled, we just need to be a member, no specific role ability

            // Is an object rezzing the other object?
            if (objectID != UUID.Zero)
            {   // A scripted object is doing the rezzing...
                SceneObjectGroup group = this.FindObjectGroup(objectID);
                if (group == null) return false;

                // Now continue the rezzing permissions checks
                if (group.OwnerID == parcel.landData.OwnerID)
                    return true;
                // Owner doesn't match the land parcel, check partner perms.
                if (scene.RegionInfo.AllowPartnerRez)
                {   // this one is will not be called based on current products (Scenic, Plus) but completes the rule set for objects.
                    UserProfileData parcelOwner = m_scene.CommsManager.UserService.GetUserProfile(parcel.landData.OwnerID);
                    if (parcelOwner != null)
                        if (parcelOwner.Partner != UUID.Zero)
                            if (parcelOwner.Partner == group.OwnerID)
                                return true;
                }

                // Owner doesn't match the land parcel, check group perms.
                UUID activeGroupId = group.GroupID;
                // Handle the special case of active group for a worn attachment
                if (group.RootPart.IsAttachment)
                {
                    ScenePresence sp = m_scene.GetScenePresence(group.RootPart.AttachedAvatar);
                    if (sp == null)
                        return false;
                    IClientAPI client = sp.ControllingClient;
                    activeGroupId = client.ActiveGroupId;
                }

                // See if the agent or object doing the rezzing has permission itself.
                if ((parcel.landData.Flags & (uint)ParcelFlags.CreateGroupObjects) == (uint)ParcelFlags.CreateGroupObjects)
                {
                    if (activeGroupId == parcel.landData.GroupID)
                        return true;
                }

                // Create role enabled for this group member on group land?
                if (GenericParcelPermission(group.OwnerID, parcel, roleNeeded))
                    return true;    // we're done here, no need to check more

                return false;
            }

            // An agent/avatar is doing the rezzing...

            // Create role enabled for this group member on group land, or parcel is group-enabled?
            if (GenericParcelPermission(owner, parcel, roleNeeded))
                return true;    // we're done here, no need to check more

            // Owner doesn't match the land parcel, check partner perms.
            if (scene.RegionInfo.AllowPartnerRez)
            {
                // this one is will not be called based on current products (Scenic, Plus) but completes the rule set for the remaining cases.
                UserProfileData parcelOwner = m_scene.CommsManager.UserService.GetUserProfile(parcel.landData.OwnerID);
                if (parcelOwner != null)
                    if (parcelOwner.Partner != UUID.Zero)
                        if (parcelOwner.Partner == owner)
                            return true;
            } 
            
            return false;
        }
        void EventManager_OnGroupCrossedToNewParcel(SceneObjectGroup group, ILandObject oldParcel, ILandObject newParcel)
        {
            if (group.IsAttachment)
            {
                //attachment scripts always run and are unaffected by crossings
                return;
            }

            bool scriptsCouldRun = false;
            bool scriptsCanRun   = false;

            bool oldParcelAllowedOtherScripts = oldParcel != null && (oldParcel.landData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0;
            bool oldParcelAllowedGroupScripts = oldParcel != null && (oldParcel.landData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0;
            bool oldParcelMatchesObjectGroup  = oldParcel != null && oldParcel.landData.GroupID == group.GroupID;
            bool ownerOwnedOldParcel          = oldParcel != null && oldParcel.landData.OwnerID == group.OwnerID;

            bool newParcelAllowsOtherScripts = newParcel != null && (newParcel.landData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0;
            bool newParcelAllowsGroupScripts = newParcel != null && (newParcel.landData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0;
            bool newParcelMatchesObjectGroup = newParcel != null && newParcel.landData.GroupID == group.GroupID;
            bool ownerOwnsNewParcel          = newParcel != null && newParcel.landData.OwnerID == group.OwnerID;

            if (oldParcel == null ||
                ownerOwnedOldParcel ||
                oldParcelAllowedOtherScripts ||
                (oldParcelAllowedGroupScripts && oldParcelMatchesObjectGroup))
            {
                scriptsCouldRun = true;
            }

            if (ownerOwnsNewParcel ||
                newParcelAllowsOtherScripts ||
                (newParcelAllowsGroupScripts && newParcelMatchesObjectGroup))
            {
                scriptsCanRun = true;
            }

            List <TaskInventoryItem> scripts = new List <TaskInventoryItem>();

            if (scriptsCanRun != scriptsCouldRun)
            {
                EnableDisableFlag flag =
                    scriptsCanRun ? EnableDisableFlag.ParcelEnable : EnableDisableFlag.ParcelDisable;

                if (flag == EnableDisableFlag.ParcelDisable)
                {
                    //do not parcel disable any scripted group that is holding avatar controls
                    if (group.HasAvatarControls)
                    {
                        return;
                    }
                }

                group.ForEachPart(delegate(SceneObjectPart part)
                {
                    foreach (TaskInventoryItem script in part.Inventory.GetScripts())
                    {
                        _exeScheduler.ChangeEnabledStatus(script.ItemID, flag);
                    }
                });
            }
        }
Example #21
0
        public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel)
        {
            //triggerLandObjectRemoved(localParcelID);

            TriggerLandObjectAdded(newParcel);
        }
        protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
        {
            bool permission = false;

            if (parcel.LandData.OwnerID == user)
            {
                permission = true;
            }

            if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
            {
                permission = true;
            }

            if (IsEstateManager(user))
            {
                permission = true;
            }

            if (IsAdministrator(user))
            {
                permission = true;
            }

            if (m_SimpleBuildPermissions &&
                (parcel.LandData.Flags & (uint)ParcelFlags.UseAccessList) == 0 && parcel.IsInLandAccessList(user))
                permission = true;

            return permission;
        }
Example #23
0
 /// <summary>
 ///     When an avatar enters the region, it's probably a good idea to send them the current sun info
 /// </summary>
 /// <param name="avatar"></param>
 /// <param name="oldParcel"></param>
 void AvatarEnteringParcel(IScenePresence avatar, ILandObject oldParcel)
 {
     SunToClient(avatar.ControllingClient);
 }
        private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            if (parcel.LandData.OwnerID != user) // Only the owner can deed!
                return false;

            ScenePresence sp = scene.GetScenePresence(user);
            IClientAPI client = sp.ControllingClient;

            if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
                return false;

            return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed);
        }
        /// <summary>
        /// Do pre-rez processing when the object comes from an item.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="item"></param>
        /// <param name="objlist"></param>
        /// <param name="pos"></param>
        /// <param name="veclist">
        /// List of vector position adjustments for a coalesced objects.  For ordinary objects
        /// this list will contain just Vector3.Zero.  The order of adjustments must match the order of objlist
        /// </param>
        /// <param name="isAttachment"></param>
        /// <returns>true if we can processed with rezzing, false if we need to abort</returns>
        private bool DoPreRezWhenFromItem(
            IClientAPI remoteClient, InventoryItemBase item, List <SceneObjectGroup> objlist,
            Vector3 pos, List <Vector3> veclist, bool isAttachment)
        {
            UUID fromUserInventoryItemId = UUID.Zero;

            // If we have permission to copy then link the rezzed object back to the user inventory
            // item that it came from.  This allows us to enable 'save object to inventory'
            if (!m_Scene.Permissions.BypassPermissions())
            {
                if ((item.CurrentPermissions & (uint)PermissionMask.Copy)
                    == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
                {
                    fromUserInventoryItemId = item.ID;
                }
            }
            else
            {
                if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
                {
                    // Brave new fullperm world
                    fromUserInventoryItemId = item.ID;
                }
            }

            for (int i = 0; i < objlist.Count; i++)
            {
                SceneObjectGroup g = objlist[i];

                if (!m_Scene.Permissions.CanRezObject(
                        g.PrimCount, remoteClient.AgentId, pos + veclist[i]) &&
                    !isAttachment)
                {
                    // The client operates in no fail mode. It will
                    // have already removed the item from the folder
                    // if it's no copy.
                    // Put it back if it's not an attachment
                    //
                    if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
                    {
                        remoteClient.SendBulkUpdateInventory(item);
                    }

                    ILandObject land = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
                    remoteClient.SendAlertMessage(string.Format(
                                                      "Can't rez object '{0}' at <{1:F3}, {2:F3}, {3:F3}> on parcel '{4}' in region {5}.",
                                                      item.Name, pos.X, pos.Y, pos.Z, land != null ? land.LandData.Name : "Unknown", m_Scene.Name));

                    return(false);
                }
            }

            for (int i = 0; i < objlist.Count; i++)
            {
                SceneObjectGroup so       = objlist[i];
                SceneObjectPart  rootPart = so.RootPart;

                // Since renaming the item in the inventory does not
                // affect the name stored in the serialization, transfer
                // the correct name from the inventory to the
                // object itself before we rez.
                //
                // Only do these for the first object if we are rezzing a coalescence.
                if (i == 0)
                {
                    rootPart.Name           = item.Name;
                    rootPart.Description    = item.Description;
                    rootPart.ObjectSaleType = item.SaleType;
                    rootPart.SalePrice      = item.SalePrice;
                }

                so.FromFolderID = item.Folder;

//                m_log.DebugFormat(
//                    "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
//                    rootPart.OwnerID, item.Owner, item.CurrentPermissions);

                if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & SceneObjectGroup.SLAM) != 0)
                {
                    //Need to kill the for sale here
                    rootPart.ObjectSaleType = 0;
                    rootPart.SalePrice      = 10;
                }

                foreach (SceneObjectPart part in so.Parts)
                {
                    part.FromUserInventoryItemID = fromUserInventoryItemId;
                    part.ApplyPermissionsOnRez(item, true, m_Scene);
                }

                rootPart.TrimPermissions();

                if (isAttachment)
                {
                    so.FromItemID = item.ID;
                }
            }

            return(true);
        }
Example #26
0
 public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel)
 {
     TriggerLandObjectAdded(newParcel);
 }
Example #27
0
        /// <summary>
        /// Updates the userpicks
        /// </summary>
        /// <param name='remoteClient'>
        /// Remote client.
        /// </param>
        /// <param name='pickID'>
        /// Pick I.
        /// </param>
        /// <param name='creatorID'>
        /// the creator of the pick
        /// </param>
        /// <param name='topPick'>
        /// Top pick.
        /// </param>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <param name='desc'>
        /// Desc.
        /// </param>
        /// <param name='snapshotID'>
        /// Snapshot I.
        /// </param>
        /// <param name='sortOrder'>
        /// Sort order.
        /// </param>
        /// <param name='enabled'>
        /// Enabled.
        /// </param>
        public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
        {
            //TODO: See how this works with NPC, May need to test
            m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());

            UserProfilePick pick      = new UserProfilePick();
            string          serverURI = string.Empty;

            GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
            ScenePresence p = FindPresence(remoteClient.AgentId);

            Vector3 avaPos = p.AbsolutePosition;
            // Getting the global position for the Avatar
            Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.WorldLocX + avaPos.X,
                                            remoteClient.Scene.RegionInfo.WorldLocY + avaPos.Y,
                                            avaPos.Z);

            string landParcelName = "My Parcel";
            UUID   landParcelID   = p.currentParcelUUID;

            ILandObject land = p.Scene.LandChannel.GetLandObject(avaPos.X, avaPos.Y);

            if (land != null)
            {
                // If land found, use parcel uuid from here because the value from SP will be blank if the avatar hasnt moved
                landParcelName = land.LandData.Name;
                landParcelID   = land.LandData.GlobalID;
            }
            else
            {
                m_log.WarnFormat(
                    "[PROFILES]: PickInfoUpdate found no parcel info at {0},{1} in {2}",
                    avaPos.X, avaPos.Y, p.Scene.Name);
            }


            pick.PickId     = pickID;
            pick.CreatorId  = creatorID;
            pick.TopPick    = topPick;
            pick.Name       = name;
            pick.Desc       = desc;
            pick.ParcelId   = landParcelID;
            pick.SnapshotId = snapshotID;
            pick.ParcelName = landParcelName;
            pick.SimName    = remoteClient.Scene.RegionInfo.RegionName;
            pick.Gatekeeper = MyGatekeeper;
            pick.GlobalPos  = posGlobal.ToString();
            pick.SortOrder  = sortOrder;
            pick.Enabled    = enabled;

            object Pick = (object)pick;

            if (!rpc.JsonRpcRequest(ref Pick, "picks_update", serverURI, UUID.Random().ToString()))
            {
                remoteClient.SendAgentAlertMessage(
                    "Error updating pick", false);
                return;
            }

            m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString());
        }
Example #28
0
 private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y)
 {
     return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel));
 }
Example #29
0
        private bool CanDeedParcel(UUID user, ILandObject parcel, IScene scene)
        {
            DebugPermissionInformation(MethodBase.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            if (parcel.LandData.OwnerID != user) // Only the owner can deed!
                return false;

            return GenericParcelPermission(user, parcel, (ulong) GroupPowers.LandDeed);
        }
Example #30
0
 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
 {
 }
Example #31
0
        private void HandleDeleteObject(string module, string[] cmd)
        {
            if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
            {
                return;
            }

            if (cmd.Length < 3)
            {
                return;
            }

            string mode = cmd[2];
            string o    = "";

            if (mode != "outside")
            {
                if (cmd.Length < 4)
                {
                    return;
                }

                o = cmd[3];
            }

            List <SceneObjectGroup> deletes = null;
            UUID match;
            bool requireConfirmation = true;

            switch (mode)
            {
            case "owner":
                if (!UUID.TryParse(o, out match))
                {
                    return;
                }

                deletes = new List <SceneObjectGroup>();

                m_scene.ForEachSOG(delegate(SceneObjectGroup g)
                {
                    if (g.OwnerID == match && !g.IsAttachment)
                    {
                        deletes.Add(g);
                    }
                });

                //                if (deletes.Count == 0)
                //                    m_console.OutputFormat("No objects were found with owner {0}", match);

                break;

            case "creator":
                if (!UUID.TryParse(o, out match))
                {
                    return;
                }

                deletes = new List <SceneObjectGroup>();

                m_scene.ForEachSOG(delegate(SceneObjectGroup g)
                {
                    if (g.RootPart.CreatorID == match && !g.IsAttachment)
                    {
                        deletes.Add(g);
                    }
                });

                //                if (deletes.Count == 0)
                //                    m_console.OutputFormat("No objects were found with creator {0}", match);

                break;

            case "id":
                UUID uuid;
                uint localId;
                if (!ConsoleUtil.TryParseConsoleId(m_console, o, out uuid, out localId))
                {
                    return;
                }

                requireConfirmation = false;
                deletes             = new List <SceneObjectGroup>();

                SceneObjectGroup so;
                if (localId == ConsoleUtil.LocalIdNotFound)
                {
                    so = m_scene.GetSceneObjectGroup(uuid);
                }
                else
                {
                    so = m_scene.GetSceneObjectGroup(localId);
                }

                if (!so.IsAttachment)
                {
                    deletes.Add(so);
                }

                //                if (deletes.Count == 0)
                //                    m_console.OutputFormat("No objects were found with uuid {0}", match);

                break;

            case "name":
                deletes = GetDeleteCandidatesByName(module, cmd);
                break;

            case "outside":
                deletes = new List <SceneObjectGroup>();

                m_scene.ForEachSOG(delegate(SceneObjectGroup g)
                {
                    SceneObjectPart rootPart = g.RootPart;
                    bool delete = false;

                    if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0)
                    {
                        delete = true;
                    }
                    else
                    {
                        ILandObject parcel
                            = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y);

                        if (parcel == null || parcel.LandData.Name == "NO LAND")
                        {
                            delete = true;
                        }
                    }

                    if (delete && !g.IsAttachment && !deletes.Contains(g))
                    {
                        deletes.Add(g);
                    }
                });

                if (deletes.Count == 0)
                {
                    m_console.OutputFormat("No objects were found outside region bounds");
                }

                break;

            case "pos":
                deletes = GetDeleteCandidatesByPos(module, cmd);
                break;

            default:
                m_console.OutputFormat("Unrecognized mode {0}", mode);
                return;
            }

            if (deletes == null || deletes.Count <= 0)
            {
                return;
            }

            if (requireConfirmation)
            {
                string response = MainConsole.Instance.CmdPrompt(
                    string.Format(
                        "Are you sure that you want to delete {0} objects from {1}",
                        deletes.Count, m_scene.RegionInfo.RegionName),
                    "y/N");

                if (response.ToLower() != "y")
                {
                    MainConsole.Instance.OutputFormat(
                        "Aborting delete of {0} objects from {1}", deletes.Count, m_scene.RegionInfo.RegionName);

                    return;
                }
            }

            m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName);

            foreach (SceneObjectGroup g in deletes)
            {
                m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name);
                m_scene.DeleteSceneObject(g, false);
            }
        }
Example #32
0
        protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
        {
            if (parcel.LandData.OwnerID == user)
                return true;

            if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
                return true;

            if (GenericEstatePermission(user))
                return true;

            return false;
        }
Example #33
0
        public virtual void TriggerSound(
            UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle,
            float radius)
        {
            bool                    LocalOnly        = false;
            ILandObject             ILO              = null;
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(position.X, position.Y);
                if (ILO != null) //Check only if null, otherwise this breaks megaregions
                {
                    LocalOnly = (ILO.LandData.Flags & (uint)ParcelFlags.SoundLocal) == (uint)ParcelFlags.SoundLocal;
                }
            }
            ISceneChildEntity part = m_scene.GetSceneObjectPart(objectID);

            if (part == null)
            {
                IScenePresence sp;
                if (!m_scene.TryGetScenePresence(objectID, out sp))
                {
                    return;
                }
            }
            else
            {
                ISceneEntity grp = part.ParentEntity;

                if (grp.IsAttachment && grp.GetAttachmentPoint() > 30)
                {
                    objectID = ownerID;
                    parentID = ownerID;
                }
            }

            m_scene.ForEachScenePresence(delegate(IScenePresence sp)
            {
                if (Cones.Count != 0)
                {
                    foreach (ConeOfSilence CS in Cones.Values)
                    {
                        if (Util.GetDistanceTo(sp.AbsolutePosition, CS.Position) >
                            CS.Radius)
                        {
                            // Presence is outside of the Cone of silence

                            if (Util.GetDistanceTo(CS.Position, position) < CS.Radius)
                            {
                                //Sound was triggered inside the cone, but avatar is outside
                                continue;
                            }
                        }
                        else
                        {
                            // Avatar is inside the cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) > CS.Radius)
                            {
                                //Sound was triggered outside of the cone, but avatar is inside of the cone.
                                continue;
                            }
                        }
                    }
                }
                if (sp.IsChildAgent)
                {
                    return;
                }

                float dis = (float)Util.GetDistanceTo(sp.AbsolutePosition, position);
                if (dis > 100.0f)                                  // Max audio distance
                {
                    return;
                }

                //Check to see if the person is local and the av is in the same parcel
                if (LocalOnly && sp.CurrentParcelUUID != ILO.LandData.GlobalID)
                {
                    return;
                }

                // Scale by distance
                float thisSPGain;
                if (radius == 0)
                {
                    thisSPGain = (float)(gain * ((100.0f - dis) / 100.0f));
                }
                else
                {
                    thisSPGain = (float)(gain * ((radius - dis) / radius));
                }

                sp.ControllingClient.SendTriggeredSound(
                    soundId, ownerID, objectID, parentID, handle, position,
                    thisSPGain);
            });
        }
Example #34
0
        private bool CanReturnObjects(ILandObject land, UUID user, List<ISceneEntity> objects, IScene scene)
        {
            DebugPermissionInformation(MethodBase.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            ILandObject l;

            IScenePresence sp = scene.GetScenePresence(user);
            if (sp == null)
                return false;

            IClientAPI client = sp.ControllingClient;

            //Make a copy so that it doesn't get modified outside of this loop
#if (!ISWIN)
            foreach (ISceneEntity g in new List<ISceneEntity>(objects))
            {
                if (!GenericObjectPermission(user, g.UUID, false))
                {
                    // This is a short cut for efficiency. If land is non-null,
                    // then all objects are on that parcel and we can save
                    // ourselves the checking for each prim. Much faster.
                    //
                    if (land != null)
                    {
                        l = land;
                    }
                    else
                    {
                        Vector3 pos = g.AbsolutePosition;
                        if (m_parcelManagement == null)
                            continue;

                        l = m_parcelManagement.GetLandObject(pos.X, pos.Y);
                    }

                    // If it's not over any land, then we can't do a thing
                    if (l == null)
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // If we own the land outright, then allow
                    //
                    if (l.LandData.OwnerID == user)
                        continue;

                    // Group voodoo
                    //
                    if (l.LandData.IsGroupOwned)
                    {
                        // Not a group member, or no rights at all
                        //
                        if (!m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.None))
                        {
                            objects.Remove(g);
                            continue;
                        }

                        // Group deeded object?
                        //
                        if (g.OwnerID == l.LandData.GroupID && !m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnGroupOwned))
                        {
                            objects.Remove(g);
                            continue;
                        }

                        // Group set object?
                        //
                        if (g.GroupID == l.LandData.GroupID && !m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnGroupSet))
                        {
                            objects.Remove(g);
                            continue;
                        }

                        if (!m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnNonGroup))
                        {
                            objects.Remove(g);
                            continue;
                        }

                        // So we can remove all objects from this group land.
                        // Fine.
                        //
                        continue;
                    }

                    // By default, we can't remove
                    //
                    objects.Remove(g);
                }
            }
#else
            foreach (ISceneEntity g in new List<ISceneEntity>(objects).Where(g => !GenericObjectPermission(user, g.UUID, false)))
            {
                // This is a short cut for efficiency. If land is non-null,
                // then all objects are on that parcel and we can save
                // ourselves the checking for each prim. Much faster.
                //
                if (land != null)
                {
                    l = land;
                }
                else
                {
                    Vector3 pos = g.AbsolutePosition;
                    if (m_parcelManagement == null)
                        continue;

                    l = m_parcelManagement.GetLandObject(pos.X, pos.Y);
                }

                // If it's not over any land, then we can't do a thing
                if (l == null)
                {
                    objects.Remove(g);
                    continue;
                }

                // If we own the land outright, then allow
                //
                if (l.LandData.OwnerID == user)
                    continue;

                // Group voodoo
                //
                if (l.LandData.IsGroupOwned)
                {
                    // Not a group member, or no rights at all
                    //
                    if (!m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.None))
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // Group deeded object?
                    //
                    if (g.OwnerID == l.LandData.GroupID &&
                        !m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnGroupOwned))
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // Group set object?
                    //
                    if (g.GroupID == l.LandData.GroupID &&
                        !m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnGroupSet))
                    {
                        objects.Remove(g);
                        continue;
                    }

                    if (!m_groupsModule.GroupPermissionCheck(client.AgentId, g.GroupID, GroupPowers.ReturnNonGroup))
                    {
                        objects.Remove(g);
                        continue;
                    }

                    // So we can remove all objects from this group land.
                    // Fine.
                    //
                    continue;
                }

                // By default, we can't remove
                //
                objects.Remove(g);
            }
#endif

            if (objects.Count == 0)
                return false;

            return true;
        }
Example #35
0
        public virtual void PlayAttachedSound(
            UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
        {
            ISceneChildEntity part = m_scene.GetSceneObjectPart(objectID);

            if (part == null)
            {
                return;
            }

            bool                    LocalOnly        = false;
            ILandObject             ILO              = null;
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(position.X, position.Y);
                if (ILO != null)
                {
                    LocalOnly = (ILO.LandData.Flags & (uint)ParcelFlags.SoundLocal) == (uint)ParcelFlags.SoundLocal;
                }
            }

            m_scene.ForEachScenePresence(delegate(IScenePresence sp)
            {
                if (Cones.Count != 0)
                {
                    foreach (ConeOfSilence CS in Cones.Values)
                    {
                        if (Util.GetDistanceTo(sp.AbsolutePosition, CS.Position) >
                            CS.Radius)
                        {
                            // Presence is outside of the Cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) < CS.Radius)
                            {
                                //Sound was triggered inside the cone, but avatar is outside
                                continue;
                            }
                        }
                        else
                        {
                            // Avatar is inside the cone of silence
                            if (Util.GetDistanceTo(CS.Position, position) > CS.Radius)
                            {
                                //Sound was triggered outside of the cone, but avatar is inside of the cone.
                                continue;
                            }
                        }
                    }
                }
                if (sp.IsChildAgent)
                {
                    return;
                }

                double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
                if (dis > 100.0)                                  // Max audio distance
                {
                    return;
                }

                if (part.IsAttachment)
                {
                    if (part.ParentEntity.GetAttachmentPoint() >=
                        (uint)OpenMetaverse.AttachmentPoint.HUDCenter2 &&
                        part.ParentEntity.GetAttachmentPoint() <=
                        (uint)OpenMetaverse.AttachmentPoint.HUDBottomRight)                                   // HUD
                    {
                        if (sp.ControllingClient.AgentId != part.OwnerID)
                        {
                            return;
                        }
                    }

                    if (sp.ControllingClient.AgentId == part.OwnerID)
                    {
                        dis = 0;
                    }
                }

                //Check to see if the person is local and the av is in the same parcel
                if (LocalOnly && sp.CurrentParcelUUID != ILO.LandData.GlobalID)
                {
                    return;
                }

                if ((sp.CurrentParcelUUID != ILO.LandData.GlobalID &&
                     (sp.CurrentParcel.LandData.Private || ILO.LandData.Private)))
                {
                    return;
                }
                //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message

                float thisSpGain;

                // Scale by distance
                if (radius == 0)
                {
                    thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
                }
                else
                {
                    thisSpGain = (float)((double)gain * ((radius - dis) / radius));
                }

                if (sp.Scene.GetSceneObjectPart(objectID).UseSoundQueue == 1 &&
                    (flags & (int)SoundFlags.Queue) == 0)
                {
                    flags |= (int)SoundFlags.Queue;
                }

                sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID,
                                                           thisSpGain, flags);
            });
        }
Example #36
0
        private bool CanPushObject(UUID userID, ILandObject parcel)
        {
            //This is used to check who is pusing objects in the parcel
            //When this is called, the AllowPushObject flag has already been checked

            return GenericParcelPermission(userID, parcel, (ulong) GroupPowers.ObjectManipulate);
        }
        public void ClassifiedInfoUpdate(UUID queryClassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IScheduledMoneyModule scheduledMoneyModule = p.Scene.RequestModuleInterface <IScheduledMoneyModule>();
            IMoneyModule          moneyModule          = p.Scene.RequestModuleInterface <IMoneyModule>();
            Classified            classcheck           = ProfileFrontend.GetClassified(queryClassifiedID);

            if (((queryclassifiedFlags & 32) != 32) && moneyModule != null)
            {
                //Single week
                if (!moneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified", TransactionType.ClassifiedCharge))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }
            else if (scheduledMoneyModule != null)
            {
                //Auto-renew
                if (classcheck != null)
                {
                    scheduledMoneyModule.RemoveFromScheduledCharge("[Classified: " + queryClassifiedID + "]");
                }

                var payOK = scheduledMoneyModule.Charge(
                    remoteClient.AgentId,                                                       // who to charge
                    queryclassifiedPrice,                                                       // how much
                    "Add Reoccurring Classified (" + queryClassifiedID + ")",                   // description
                    TransactionType.ClassifiedCharge,                                           // transaction type
                    "[Classified: " + queryClassifiedID + "]",                                  // scheduler identifier
                    true,                                                                       // charger immediately
                    false);                                                                     // run once
                if (!payOK)
                {
                    remoteClient.SendAlertMessage("You do not have enough money to create this classified.");
                    return;
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryClassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement = remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.GlobalID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified
            {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }
Example #38
0
        private bool CanUseObjectReturn(ILandObject parcel, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            ulong powers = 0;
            if (parcel.landData.GroupID != UUID.Zero)
                powers = client.GetGroupPowers(parcel.landData.GroupID);

            switch (type)
            {
            case (uint)ObjectReturnType.Owner:
                // Don't let group members return owner's objects, ever
                //
                if (parcel.landData.IsGroupOwned)
                {
                    if ((powers & (ulong)GroupPowers.ReturnGroupOwned) != 0)
                        return true;
                }
                else
                {
                    if (parcel.landData.OwnerID != client.AgentId)
                        return false;
                }
        return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupOwned);
            case (uint)ObjectReturnType.Group:
                if (parcel.landData.OwnerID != client.AgentId)
                {
                    // If permissionis granted through a group...
                    //
                    if ((powers & (long)GroupPowers.ReturnGroupSet) != 0)
                    {
                        foreach (SceneObjectGroup g in new List<SceneObjectGroup>(retlist))
                        {
                            // check for and remove group owned objects unless
                            // the user also has permissions to return those
                            //
                            if (g.OwnerID == g.GroupID &&
                                    ((powers & (long)GroupPowers.ReturnGroupOwned) == 0))
                            {
                                retlist.Remove(g);
                            }
                        }
                        // And allow the operation
                        //
                        return true;
                    }
                }
                return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnNonGroup);
            case (uint)ObjectReturnType.Other:
                if ((powers & (long)GroupPowers.ReturnNonGroup) != 0)
                    return true;
                return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnNonGroup);
            case (uint)ObjectReturnType.List:
                    foreach (SceneObjectGroup g in new List<SceneObjectGroup>(retlist))
                    {
                        if (!CanReturnObject(g.UUID, client.AgentId, scene))
                        {
                            retlist.Remove(g);
                        }
                    }
                    // And allow the operation
                    //
                    return true;
            }

            return GenericParcelPermission(client.AgentId, parcel, 0);
        }
Example #39
0
 public void TaintPrimCount(ILandObject land)
 {
     m_Tainted = true;
 }
Example #40
0
        protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers)
        {
            if (parcel == null)
                return false;

            // First the simple check, calling context matches the land owner.
            // This also includes group-deeded objects on group-deeded land.
            if (parcel.landData.OwnerID == user)
                return true;

            if (parcel.landData.IsGroupOwned)
            {
                // Normally the check above should have matched in the case of group-owned land, but this extra
                // check avoids the inconsistencies with group-owned land where the ownerID is not set to the group.
                if (parcel.landData.GroupID == user)
                    return true;

                // The context is not a matching group, let's see if it's a user context that is allowed on group land
                if (IsAgentInGroupRole(parcel.landData.GroupID, user, groupPowers))
                    return true;
            }
            else
            {   // not group-owned land

                if ((parcel.landData.GroupID != UUID.Zero) && (groupPowers == (ulong)GroupPowers.AllowSetHome))
                {
                    // AllowSetHome has a special exception. It doesn't need to be group-owned land, just group-tagged.
                    if (IsAgentInGroupRole(parcel.landData.GroupID, user, (ulong)GroupPowers.AllowSetHome))
                        return true;
                }
            }

            if (m_scene.IsEstateManager(user))
                return true;

            if (IsGodUser(user))
                return true;

            return false;
        }
Example #41
0
 public void TaintPrimCount(ILandObject land)
 {
     lock (m_TaintLock)
         m_Tainted = true;
 }
        private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            return GenericParcelOwnerPermission(user, parcel, (ulong)p);
        }
Example #43
0
        // NOTE: Call under Taint Lock
        private void AddObject(SceneObjectGroup obj)
        {
            if (obj.IsAttachment)
            {
                return;
            }
            if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
            {
                return;
            }

            Vector3     pos        = obj.AbsolutePosition;
            ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);

            // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
            if (landObject == null)
            {
//                m_log.WarnFormat(
//                    "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}",
//                    obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName);

                return;
            }

            LandData landData = landObject.LandData;

//            m_log.DebugFormat(
//                "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}",
//                obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName);

//            m_log.DebugFormat(
//                "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
//                obj.Name, obj.OwnerID, landData.OwnerID);

            ParcelCounts parcelCounts;

            if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
            {
                UUID landOwner = landData.OwnerID;
                int  partCount = obj.Parts.Length;

                m_SimwideCounts[landOwner] += partCount;
                if (parcelCounts.Users.ContainsKey(obj.OwnerID))
                {
                    parcelCounts.Users[obj.OwnerID] += partCount;
                }
                else
                {
                    parcelCounts.Users[obj.OwnerID] = partCount;
                }

                if (obj.IsSelected)
                {
                    parcelCounts.Selected += partCount;
                }
                else
                {
                    if (landData.IsGroupOwned)
                    {
                        if (obj.OwnerID == landData.GroupID)
                        {
                            parcelCounts.Owner += partCount;
                        }
                        else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
                        {
                            parcelCounts.Group += partCount;
                        }
                        else
                        {
                            parcelCounts.Others += partCount;
                        }
                    }
                    else
                    {
                        if (obj.OwnerID == landData.OwnerID)
                        {
                            parcelCounts.Owner += partCount;
                        }
                        else
                        {
                            parcelCounts.Others += partCount;
                        }
                    }
                }
            }
        }
        private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            return true;
        }
 public void StoreLandObject(ILandObject Parcel)
 {
     m_database.StoreLandObject(Parcel);
 }
        protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers)
        {
            if (parcel.LandData.OwnerID == user)
            {
                // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
                // the subsequent redundant checks when using lParcelMediaCommandList()
                // See http://opensimulator.org/mantis/view.php?id=3999 for more details
                return true;
            }

            if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
            {
                return true;
            }
    
            if (IsEstateManager(user))
            {
                return true;
            }

            if (IsAdministrator(user))
            {
                return true;
            }

            return false;
        }
Example #47
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, uint TeleportFlags,
                                               out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }


            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                MainConsole.Instance.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            IAgentConnector AgentConnector = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(false);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                    //We found a place for them, but we don't need to check any further on positions here
                    //return true;
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
            }

            EstateSettings      ES             = scene.RegionInfo.EstateSettings;
            TeleportFlags       tpflags        = (TeleportFlags)TeleportFlags;
            const TeleportFlags allowableFlags =
                OpenMetaverse.TeleportFlags.ViaLandmark | OpenMetaverse.TeleportFlags.ViaHome |
                OpenMetaverse.TeleportFlags.ViaLure |
                OpenMetaverse.TeleportFlags.ForceRedirect |
                OpenMetaverse.TeleportFlags.Godlike | OpenMetaverse.TeleportFlags.NineOneOne;

            //If the user wants to force landing points on crossing, we act like they are not crossing, otherwise, check the child property and that the ViaRegionID is set
            bool isCrossing = !ForceLandingPointsOnCrossing && (Sp != null && Sp.IsChildAgent &&
                                                                ((tpflags & OpenMetaverse.TeleportFlags.ViaRegionID) ==
                                                                 OpenMetaverse.TeleportFlags.ViaRegionID));

            //Move them to the nearest landing point
            if (!((tpflags & allowableFlags) != 0) && !isCrossing && !ES.AllowDirectTeleport)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID,
                                                                  scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] +
                                       new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            else if (!((tpflags & allowableFlags) != 0) && !isCrossing &&
                     !scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            //Telehubs override parcels
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity();                           //If we are moving the agent, clear their velocity
                }
                if (ILO.LandData.LandingType == (int)LandingType.None) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count > 1)
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels.Where(Parcel => !Parcel.IsBannedFromLand(userID)))
                        {
                            //Now we have to check their userloc
                            if (ILO.LandData.LandingType == (int)LandingType.None)
                            {
                                continue; //Blocked, check next one
                            }
                            else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)
                            {
                                //Use their landing spot
                                newPosition = Parcel.LandData.UserLocation;
                            }
                            else //They allow for anywhere, so dump them in the center at the ground
                            {
                                newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                            }
                            found = true;
                        }

                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(false);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)  //Move to tp spot
                {
                    newPosition = ILO.LandData.UserLocation != Vector3.Zero
                                      ? ILO.LandData.UserLocation
                                      : parcelManagement.GetNearestRegionEdgePosition(Sp);
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                if (scene.RegionInfo.RegionFlags != -1 &&
                    ((scene.RegionInfo.RegionFlags & (int)RegionFlags.Prelude) == (int)RegionFlags.Prelude) &&
                    agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID,
                                                            OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo);
                    }
                }
                if (agentInfo.OtherAgentInformation.ContainsKey("LimitedToEstate"))
                {
                    int LimitedToEstate = agentInfo.OtherAgentInformation["LimitedToEstate"];
                    if (scene.RegionInfo.EstateSettings.EstateID != LimitedToEstate)
                    {
                        reason = "You may not enter this reason, as it is outside of the estate you are limited to.";
                        return(false);
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if (account != null &&
                    (account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) ==
                    (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            //Check that we are not underground as well
            ITerrainChannel chan = scene.RequestModuleInterface <ITerrainChannel>();

            if (chan != null)
            {
                float posZLimit = chan[(int)newPosition.X, (int)newPosition.Y] + (float)1.25;

                if (posZLimit >= (newPosition.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
                {
                    newPosition.Z = posZLimit;
                }
            }

            reason = "";
            return(true);
        }
        private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene)
        {
            DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
            if (m_bypassPermissions) return m_bypassPermissionsValue;

            return GenericParcelOwnerPermission(user, parcel, 0);
        }
Example #49
0
        private bool FindUnBannedParcel(Vector3 Position, IScenePresence Sp, UUID AgentID, out ILandObject ILO,
                                        out Vector3 newPosition, out string reason)
        {
            ILO = null;
            IParcelManagementModule parcelManagement = Sp.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                if (Parcels.Count == 0)
                {
                    newPosition = Sp == null ? new Vector3(0, 0, 0) : parcelManagement.GetNearestRegionEdgePosition(Sp);
                    ILO         = null;

                    //Dumped in the region corner, we will leave them there
                    reason = "";
                    return(false);
                }
                else
                {
                    bool FoundParcel = false;

                    foreach (ILandObject lo in Parcels.Where(lo => !lo.IsEitherBannedOrRestricted(AgentID)))
                    {
                        newPosition = lo.LandData.UserLocation;
                        ILO         = lo; //Update the parcel settings
                        FoundParcel = true;
                        break;
                    }

                    if (!FoundParcel)
                    {
                        //Dump them in the region corner as they are banned from all nearby parcels
                        newPosition = Sp == null
                                          ? new Vector3(0, 0, 0)
                                          : parcelManagement.GetNearestRegionEdgePosition(Sp);
                        reason = "";
                        ILO    = null;
                        return(false);
                    }
                }
            }
            newPosition = Position;
            reason      = "";
            return(true);
        }
 public void StoreLandObject(ILandObject Parcel)
 {
     m_database.StoreLandObject(Parcel);
 }
Example #51
0
        public void TestLoadOarDeededLand()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID landID = TestHelpers.ParseTail(0x10);

            MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();

            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Groups");

            config.Set("Enabled", true);
            config.Set("Module", "GroupsModule");
            config.Set("DebugEnabled", true);
            SceneHelpers.SetupSceneModules(
                m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });

            // Create group in scene for loading
            // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
            UUID groupID
                = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);

            // Construct OAR
            MemoryStream     oarStream = new MemoryStream();
            TarArchiveWriter tar       = new TarArchiveWriter(oarStream);

            tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            LandObject lo = new LandObject(groupID, true, m_scene);

            lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
            LandData ld = lo.LandData;

            ld.GlobalID = landID;

            string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
            Dictionary <string, object> options = new Dictionary <string, object>();

            tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
            tar.Close();

            oarStream = new MemoryStream(oarStream.ToArray());

            // Load OAR
            m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
            m_oarEvent.Reset();
            m_archiverModule.DearchiveRegion(oarStream);

            m_oarEvent.WaitOne(60000);

            ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
            LandData    rLd = rLo.LandData;

            Assert.That(rLd.GlobalID, Is.EqualTo(landID));
            Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
            Assert.That(rLd.GroupID, Is.EqualTo(groupID));
            Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
        }
Example #52
0
 public void TriggerLandObjectAdded(ILandObject newParcel)
 {
     LandObjectAdded handlerLandObjectAdded = OnLandObjectAdded;
     if (handlerLandObjectAdded != null)
     {
         foreach (LandObjectAdded d in handlerLandObjectAdded.GetInvocationList())
         {
             try
             {
                 d(newParcel);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerLandObjectAdded failed - continuing.  {0} {1}", 
                     e.Message, e.StackTrace);
             }
         }
     }
 }
Example #53
0
        private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
            int parcelid = -1;

            if (httpRequest.Query.Count > 0)
            {
                if (httpRequest.Query.ContainsKey("parcelid"))
                {
                    Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid);
                }
            }

            ViewerEnvironment VEnv = null;
            ScenePresence     sp   = m_scene.GetScenePresence(agentID);

            if (sp != null && sp.Environment != null)
            {
                //if (parcelid == -1)
                VEnv = sp.Environment;
                //else
                //{
                //    OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
                //    httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def);
                //    httpResponse.StatusCode = (int)HttpStatusCode.OK;
                //    return;
                //}
            }
            else if (parcelid == -1)
            {
                VEnv = GetRegionEnvironment();
            }
            else
            {
                if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
                {
                    ILandObject land = m_scene.LandChannel.GetLandObject(parcelid);
                    if (land != null && land.LandData != null && land.LandData.Environment != null)
                    {
                        VEnv = land.LandData.Environment;
                    }
                }
                if (VEnv == null)
                {
                    OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
                    httpResponse.RawBuffer  = OSDParser.SerializeLLSDXmlToBytes(def);
                    httpResponse.StatusCode = (int)HttpStatusCode.OK;
                    return;
                }
            }

            //OSDMap map = new OSDMap();
            //OSDMap cenv = (OSDMap)VEnv.ToOSD();
            //cenv["parcel_id"] = parcelid;
            //cenv["region_id"] = regionID;
            //map["environment"] = cenv;
            //map["parcel_id"] = parcelid;
            //map["success"] = true;

            //string env = OSDParser.SerializeLLSDXmlString(map);

            //if (String.IsNullOrEmpty(env))
            byte[] envBytes = VEnv.ToCapBytes(regionID, parcelid);
            if (envBytes == null)
            {
                StringBuilder sb = LLSDxmlEncode.Start();
                LLSDxmlEncode.AddArray(sb);
                LLSDxmlEncode.AddMap(sb);
                LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
                LLSDxmlEncode.AddElem("regionID", regionID, sb);
                LLSDxmlEncode.AddEndMap(sb);
                LLSDxmlEncode.AddEndArray(sb);
                httpResponse.RawBuffer = LLSDxmlEncode.EndToNBBytes(sb);
            }
            else
            {
                httpResponse.RawBuffer = envBytes;
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }
Example #54
0
        // this is needed for non-convex parcels (example: rectangular parcel, and in the exact center
        // another, smaller rectangular parcel). Both will have the same initial coordinates.
        private void findPointInParcel(ILandObject land, ref uint refX, ref uint refY)
        {
            m_log.DebugFormat("[DATASNAPSHOT] trying {0}, {1}", refX, refY);
            // the point we started with already is in the parcel
            if (land.ContainsPoint((int)refX, (int)refY)) return;

            // ... otherwise, we have to search for a point within the parcel
            uint startX = (uint)land.LandData.AABBMin.X;
            uint startY = (uint)land.LandData.AABBMin.Y;
            uint endX = (uint)land.LandData.AABBMax.X;
            uint endY = (uint)land.LandData.AABBMax.Y;

            // default: center of the parcel
            refX = (startX + endX) / 2;
            refY = (startY + endY) / 2;
            // If the center point is within the parcel, take that one
            if (land.ContainsPoint((int)refX, (int)refY)) return;

            // otherwise, go the long way.
            for (uint y = startY; y <= endY; ++y)
            {
                for (uint x = startX; x <= endX; ++x)
                {
                    if (land.ContainsPoint((int)x, (int)y))
                    {
                        // found a point
                        refX = x;
                        refY = y;
                        return;
                    }
                }
            }
        }
Example #55
0
        private void SetEnvironmentSettings(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
        {
            // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}",
            //       Name, agentID, caps.RegionName);

            bool   success     = false;
            string fail_reason = "";

            if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                fail_reason = "Insufficient estate permissions, settings has not been saved.";
                goto Error;
            }

            ScenePresence sp = m_scene.GetScenePresence(agentID);

            if (sp == null || sp.IsChildAgent || sp.IsNPC)
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            if (sp.Environment != null)
            {
                fail_reason = "The environment you see is a forced one. Disable if on control object or tp out and back to region";
                goto Error;
            }

            ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y);

            if (land != null && land.LandData != null && land.LandData.Environment != null)
            {
                fail_reason = "The parcel where you are has own environment set. You need a updated viewer to change environment";
                goto Error;
            }
            try
            {
                ViewerEnvironment VEnv = new ViewerEnvironment();
                OSD env = OSDParser.Deserialize(request.InputStream);
                VEnv.FromWLOSD(env);

                StoreOnRegion(VEnv);

                WindlightRefresh(0);

                m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
                                 Name, agentID, m_scene.Name);
                success = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
                                  Name, m_scene.Name, e.Message, e.StackTrace);

                success     = false;
                fail_reason = String.Format("Environment Set for region {0} has failed, settings not saved.", m_scene.Name);
            }

Error:
            StringBuilder sb = LLSDxmlEncode.Start();

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
            LLSDxmlEncode.AddElem("regionID", regionID, sb);
            LLSDxmlEncode.AddElem("success", success, sb);
            if (!success)
            {
                LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb);
            }
            LLSDxmlEncode.AddEndMap(sb);
            response.RawBuffer  = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb));
            response.StatusCode = (int)HttpStatusCode.OK;
        }
Example #56
0
 private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel)
 {
     Vector3 unitDirection = Vector3.Normalize(direction);
     //Making distance to search go through some sane limit of distance
     for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f)
     {
         Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
         if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
         {
             return testPos;
         }
     }
     return null;
 }
Example #57
0
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
            {
                return; //Just fail
            }
            IMoneyModule money = p.Scene.RequestModuleInterface <IMoneyModule>();

            if (money != null)
            {
                if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified"))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to complete this upload.");
                    return;
                }
            }

            UUID    creatorUUID     = remoteClient.AgentId;
            UUID    classifiedUUID  = queryclassifiedID;
            uint    category        = queryCategory;
            string  name            = queryName;
            string  description     = queryDescription;
            uint    parentestate    = queryParentEstate;
            UUID    snapshotUUID    = querySnapshotID;
            string  simname         = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos       = queryGlobalPos;
            byte    classifiedFlags = queryclassifiedFlags;
            int     classifiedPrice = queryclassifiedPrice;

            UUID   parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.InfoUUID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified
            {
                ClassifiedUUID  = classifiedUUID,
                CreatorUUID     = creatorUUID,
                CreationDate    = creationdate,
                ExpirationDate  = expirationdate,
                Category        = category,
                Name            = name,
                Description     = description,
                ParcelUUID      = parceluuid,
                ParentEstate    = parentestate,
                SnapshotUUID    = snapshotUUID,
                SimName         = simname,
                GlobalPos       = globalpos,
                ParcelName      = parcelname,
                ClassifiedFlags = classifiedFlags,
                PriceForListing = classifiedPrice,
                ScopeID         = remoteClient.ScopeID
            };

            ProfileFrontend.AddClassified(classified);
        }
Example #58
0
 //calculate the average center point of a parcel
 private Vector2 GetParcelCenter(ILandObject parcel)
 {
     int count = 0;
     int avgx = 0;
     int avgy = 0;
     for (int x = 0; x < Constants.RegionSize; x++)
     {
         for (int y = 0; y < Constants.RegionSize; y++)
         {
             //Just keep a running average as we check if all the points are inside or not
             if (parcel.ContainsPoint(x, y))
             {
                 if (count == 0)
                 {
                     avgx = x;
                     avgy = y;
                 }
                 else
                 {
                     avgx = (avgx * count + x) / (count + 1);
                     avgy = (avgy * count + y) / (count + 1);
                 }
                 count += 1;
             }
         }
     }
     return new Vector2(avgx, avgy);
 }
 public bool CanReturnObjects(ILandObject land, UUID user, List <SceneObjectGroup> objects, Scene scene)
 {
     return(m_rootScene.Permissions.CanReturnObjects(land, user, objects));
 }