Пример #1
0
 private void ApplyPermissions(ObjectPart prim, ObjectPermissions.Data d, InventoryPermissionsMask setmask, InventoryPermissionsMask clrmask,
                               ObjectPropertiesSendHandler propHandler)
 {
     if ((d.Field & ObjectPermissions.ChangeFieldMask.Base) != 0)
     {
         prim.SetClrBaseMask(setmask, clrmask);
     }
     if ((d.Field & ObjectPermissions.ChangeFieldMask.Everyone) != 0)
     {
         prim.SetClrEveryoneMask(setmask, clrmask);
     }
     if ((d.Field & ObjectPermissions.ChangeFieldMask.Group) != 0)
     {
         prim.SetClrGroupMask(setmask, clrmask);
     }
     if ((d.Field & ObjectPermissions.ChangeFieldMask.NextOwner) != 0)
     {
         prim.SetClrNextOwnerMask(setmask, clrmask);
     }
     if ((d.Field & ObjectPermissions.ChangeFieldMask.Owner) != 0)
     {
         prim.SetClrOwnerMask(setmask, clrmask);
     }
     propHandler.Send(prim);
 }
Пример #2
0
        public void HandleObjectIncludeInSearch(Message m)
        {
            var req = (ObjectIncludeInSearch)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (ObjectIncludeInSearch.Data d in req.ObjectData)
                {
                    ObjectPart part;
                    if (!Primitives.TryGetValue(d.ObjectLocalID, out part))
                    {
                        continue;
                    }

                    part.ObjectGroup.IsIncludedInSearch = d.IncludeInSearch;
                    propHandler.Send(part);
                }
            }
        }
Пример #3
0
        public void HandleObjectGroup(Message m)
        {
            var req = (Viewer.Messages.Object.ObjectGroup)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            if (GroupsService == null)
            {
                return;
            }

            UGI ugi;

            if (req.GroupID == UUID.Zero)
            {
                ugi = UGI.Unknown;
            }
            else if (!GroupsService.Groups.TryGetValue(agent.Owner, req.GroupID, out ugi) ||
                     !GroupsService.TryRequestAuthorization(agent.Owner, ugi))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (uint d in req.ObjectList)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectGroup localid={0}", d);
#endif

                    ObjectPart prim;
                    if (!Primitives.TryGetValue(d, out prim))
                    {
                        continue;
                    }

                    if (!CanChangeGroup(agent, prim.ObjectGroup, prim.ObjectGroup.GlobalPosition))
                    {
                        continue;
                    }

                    prim.ObjectGroup.Group = ugi;
                    propHandler.Send(prim);
                }
            }
        }
Пример #4
0
 public void SendObjectPropertiesToAgent(IAgent agent, ObjectPart part)
 {
     if (agent.SelectedObjects(ID).Contains(part.ID))
     {
         using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
         {
             propHandler.Send(part);
         }
     }
 }
Пример #5
0
        public void HandleObjectOwner(Message m)
        {
            var req = (ObjectOwner)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!RootAgents.TryGetValue(req.AgentID, out agent) || !agent.IsActiveGod)
            {
                return;
            }

            UGUI owner;
            UGI  group = UGI.Unknown;

            if (!AvatarNameService.TryGetValue(req.OwnerID, out owner))
            {
                return;
            }

            if (UUID.Zero != group.ID && !GroupsNameService.TryGetValue(req.GroupID, out group))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (uint d in req.ObjectList)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectOwner localid={0}", d);
#endif

                    ObjectPart prim;
                    if (!Primitives.TryGetValue(d, out prim))
                    {
                        continue;
                    }

                    prim.Owner = owner;
                    prim.Group = group;

                    propHandler.Send(prim);
                }
            }
        }
Пример #6
0
        public void HandleObjectName(Message m)
        {
            var req = (ObjectName)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (ObjectName.Data d in req.ObjectData)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectName localid={0}", d.ObjectLocalID);
#endif

                    ObjectPart prim;
                    if (!Primitives.TryGetValue(d.ObjectLocalID, out prim))
                    {
                        continue;
                    }

                    if (!CanEdit(agent, prim.ObjectGroup, prim.ObjectGroup.GlobalPosition))
                    {
                        continue;
                    }
                    prim.Name = d.Name;

                    propHandler.Send(prim);
                }
            }
        }
Пример #7
0
        public void HandleObjectCategory(Message m)
        {
            var req = (ObjectCategory)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (ObjectCategory.Data data in req.ObjectData)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectCategory localid={0}", data.ObjectLocalID);
#endif

                    ObjectPart part;
                    if (Primitives.TryGetValue(data.ObjectLocalID, out part))
                    {
                        if (!CanEdit(agent, part.ObjectGroup, part.ObjectGroup.GlobalPosition))
                        {
                            continue;
                        }

                        part.ObjectGroup.Category = data.Category;
                        propHandler.Send(part);
                    }
                }
            }
        }
Пример #8
0
        public void HandleObjectPermissions(Message m)
        {
            var req = (ObjectPermissions)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!RootAgents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            bool isGod = agent.IsActiveGod && agent.IsInScene(this);

            using (ObjectPropertiesSendHandler propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (ObjectPermissions.Data d in req.ObjectData)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectPermissions localid={0} field={1} change={2} mask=({3})", d.ObjectLocalID, d.Field.ToString(), d.ChangeType.ToString(), d.Mask.ToString());
#endif

                    ObjectPart prim;
                    if (!Primitives.TryGetValue(d.ObjectLocalID, out prim))
                    {
                        continue;
                    }
                    var grp     = prim.ObjectGroup;
                    var setmask = InventoryPermissionsMask.Every;
                    if (!isGod)
                    {
                        setmask = grp.RootPart.OwnerMask;
                    }

                    var clrmask = InventoryPermissionsMask.None;

                    switch (d.ChangeType)
                    {
                    case ObjectPermissions.ChangeType.Set:
                        setmask &= d.Mask;
                        break;

                    case ObjectPermissions.ChangeType.Clear:
                    default:
                        setmask = InventoryPermissionsMask.None;
                        clrmask = d.Mask;
                        break;
                    }

                    if (agent.IsActiveGod)
                    {
                        foreach (ObjectPart part in grp.ValuesByKey1)
                        {
                            ApplyPermissions(part, d, setmask, clrmask, propHandler);
                        }
                    }
                    else if (grp.RootPart.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Modify))
                    {
                        ApplyPermissions(grp.RootPart, d, setmask, clrmask, propHandler);
                    }

#if DEBUG
                    m_Log.DebugFormat("changed {5} => base=({0}) owner=({1}) group=({2}) everyone=({3}) nextowner=({4})",
                                      grp.RootPart.BaseMask.ToString(),
                                      grp.RootPart.OwnerMask.ToString(),
                                      grp.RootPart.GroupMask.ToString(),
                                      grp.RootPart.EveryoneMask.ToString(),
                                      grp.RootPart.NextOwnerMask.ToString(),
                                      grp.RootPart.LocalID);
#endif
                }
            }
        }
Пример #9
0
        public void HandleObjectSaleInfo(Message m)
        {
            var req = (ObjectSaleInfo)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (ObjectSaleInfo.Data d in req.ObjectData)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectSaleInfo localid={0}", d.ObjectLocalID);
#endif

                    ObjectPart         prim;
                    Object.ObjectGroup grp;
                    if (!Primitives.TryGetValue(d.ObjectLocalID, out prim))
                    {
                        continue;
                    }

                    grp = prim.ObjectGroup;
                    if (grp == null)
                    {
                        continue;
                    }

                    if (!CanEdit(agent, grp, grp.GlobalPosition))
                    {
                        continue;
                    }

                    if (d.SaleType == InventoryItem.SaleInfoData.SaleType.Original &&
                        prim.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Copy))
                    {
                        agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "UnableToSellNoCopyItemAsACopy", "Unable to sell no copy item as a copy."), ID);
                        continue;
                    }

                    if (d.SaleType == InventoryItem.SaleInfoData.SaleType.Copy || d.SaleType == InventoryItem.SaleInfoData.SaleType.Original)
                    {
                        bool foundNoTransfer = false;
                        foreach (ObjectPart part in grp.Values)
                        {
                            if (!part.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Transfer))
                            {
                                agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "UnableToSellNoTransferItem", "Unable to sell no transfer item."), ID);
                                foundNoTransfer = true;
                                break;
                            }
                            foreach (ObjectPartInventoryItem item in part.Inventory.Values)
                            {
                                if (item.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Transfer))
                                {
                                    agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "UnableToSellNoTransferItem", "Unable to sell no transfer item."), ID);
                                    foundNoTransfer = true;
                                    break;
                                }
                            }
                        }
                        if (foundNoTransfer)
                        {
                            continue;
                        }
                    }

                    if (d.SaleType != InventoryItem.SaleInfoData.SaleType.NoSale)
                    {
                        bool foundNoCopyInventory = false;
                        bool foundNoTransfer      = false;
                        foreach (ObjectPartInventoryItem item in prim.Inventory.Values)
                        {
                            if (item.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Transfer))
                            {
                                agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "UnableToSellNoTransferItem", "Unable to sell no transfer item."), ID);
                                foundNoTransfer = true;
                                break;
                            }
                            if (!item.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Copy))
                            {
                                foundNoCopyInventory = true;
                            }
                        }
                        if (foundNoTransfer)
                        {
                            continue;
                        }

                        if (foundNoCopyInventory)
                        {
                            agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "WarningInventoryWillBeSoldAsOriginalAndNotAsCopy", "Warning! Object inventory will be sold as original and not as copy."), ID);
                            continue;
                        }
                    }

                    prim.ObjectGroup.SalePrice = d.SalePrice;
                    prim.ObjectGroup.SaleType  = d.SaleType;
                    propHandler.Send(prim);
                }
            }
        }