Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        public override void Add(IObject obj)
        {
            var objgroup = obj as ObjectGroup;

            if (objgroup != null)
            {
                UGUI uui = objgroup.LastOwner;
                if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                {
                    objgroup.LastOwner = uui;
                }
                foreach (ObjectPart part in objgroup.Values)
                {
                    uui = part.Owner;
                    if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                    {
                        part.Owner = uui;
                    }
                    uui = part.Creator;
                    if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                    {
                        part.Creator = uui;
                    }
                    foreach (ObjectPartInventoryItem item in part.Inventory.ValuesByKey1)
                    {
                        uui = item.Owner;
                        if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                        {
                            item.Owner = uui;
                        }
                        uui = item.LastOwner;
                        if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                        {
                            item.LastOwner = uui;
                        }
                        uui = item.Creator;
                        if (uui.HomeURI == null && AvatarNameService.TryGetValue(uui, out uui))
                        {
                            item.Creator = uui;
                        }
                    }
                    part.RezDate = Date.Now;
                }

                var removeAgain = new List <ObjectPart>();

                AddLegacyMaterials(objgroup);

                try
                {
                    objgroup.Scene = this;
                    foreach (ObjectPart objpart in objgroup.Values)
                    {
                        AddNewLocalID(objpart);
                        m_Primitives.Add(objpart.ID, objpart.LocalID[ID], objpart);
                        removeAgain.Add(objpart);
                    }
                    m_Objects.Add(objgroup.ID, objgroup);

                    foreach (ObjectPart objpart in objgroup.Values)
                    {
                        Interlocked.Increment(ref m_PrimitiveCount);
                        objpart.SendObjectUpdate();
                    }
                    Interlocked.Increment(ref m_ObjectCount);
                }
                catch (Exception e)
                {
                    m_Log.DebugFormat("Failed to add object: {0}: {1}\n{2}", e.GetType().FullName, e.Message, e.StackTrace);
                    m_Objects.Remove(objgroup.ID);
                    foreach (ObjectPart objpart in removeAgain)
                    {
                        m_Primitives.Remove(objpart.ID);
                        RemoveLocalID(objpart);
                    }
                    objgroup.Scene = null;
                }
            }
            else
            {
                AddNewLocalID(obj);
                try
                {
                    m_Objects.Add(obj.ID, obj);
                    if (obj.GetType().GetInterfaces().Contains(typeof(IAgent)))
                    {
                        var agent = (IAgent)obj;
                        m_Agents.Add(obj.ID, agent);
                        Interlocked.Increment(ref m_AgentCount);
                        foreach (IAgentListener aglistener in AgentListeners)
                        {
                            try
                            {
                                aglistener.AddedAgent(agent);
                            }
                            catch (Exception e)
                            {
                                m_Log.DebugFormat("Exception {0}\n{1}", e.Message, e.StackTrace);
                            }
                        }
                    }
                }
                catch
                {
                    if (m_Agents.Remove(obj.ID))
                    {
                        Interlocked.Decrement(ref m_AgentCount);
                    }
                    m_Objects.Remove(obj.ID);
                    RemoveLocalID(obj);
                }
            }
        }