public bool DeRezObject(SimClient simClient, Packet packet)
        {
            DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;

            //Needs to delete object from physics at a later date
            if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
            {
                //currently following code not used (or don't know of any case of destination being zero
                libsecondlife.LLUUID[] DeRezEnts;
                DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length];
                int i = 0;
                foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
                {
                    //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
                    foreach (Entity ent in this.Entities.Values)
                    {
                        if (ent.localid == Data.ObjectLocalID)
                        {
                            DeRezEnts[i++] = ent.uuid;
                            this.localStorage.RemovePrim(ent.uuid);
                            KillObjectPacket kill = new KillObjectPacket();
                            kill.ObjectData       = new KillObjectPacket.ObjectDataBlock[1];
                            kill.ObjectData[0]    = new KillObjectPacket.ObjectDataBlock();
                            kill.ObjectData[0].ID = ent.localid;
                            foreach (SimClient client in m_clientThreads.Values)
                            {
                                client.OutPacket(kill);
                            }
                            //Uncommenting this means an old UUID will be re-used, thus crashing the asset server
                            //Uncomment when prim/object UUIDs are random or such
                            //2007-03-22 - Randomskk
                            //this._primCount--;
                            OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Deleted UUID " + ent.uuid);
                        }
                    }
                }
                foreach (libsecondlife.LLUUID uuid in DeRezEnts)
                {
                    lock (Entities)
                    {
                        Entities.Remove(uuid);
                    }
                }
            }
            else
            {
                foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
                {
                    Entity selectedEnt = null;
                    //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
                    foreach (Entity ent in this.Entities.Values)
                    {
                        if (ent.localid == Data.ObjectLocalID)
                        {
                            AssetBase primAsset = new AssetBase();
                            primAsset.FullID      = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
                            primAsset.InvType     = 6;
                            primAsset.Type        = 6;
                            primAsset.Name        = "Prim";
                            primAsset.Description = "";
                            primAsset.Data        = ((Primitive)ent).GetByteArray();
                            this._assetCache.AddAsset(primAsset);
                            this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
                            selectedEnt = ent;
                            break;
                        }
                    }
                    if (selectedEnt != null)
                    {
                        this.localStorage.RemovePrim(selectedEnt.uuid);
                        KillObjectPacket kill = new KillObjectPacket();
                        kill.ObjectData       = new KillObjectPacket.ObjectDataBlock[1];
                        kill.ObjectData[0]    = new KillObjectPacket.ObjectDataBlock();
                        kill.ObjectData[0].ID = selectedEnt.localid;
                        foreach (SimClient client in m_clientThreads.Values)
                        {
                            client.OutPacket(kill);
                        }
                        lock (Entities)
                        {
                            Entities.Remove(selectedEnt.uuid);
                        }
                    }
                }
            }
            return(true);
        }
Пример #2
0
        /// <summary>
        /// DeRez an object from the simulator and return to inventory
        /// </summary>
        /// <param name="objectLocalID">The simulator Local ID of the object</param>
        /// <param name="destType">The type of destination from the <seealso cref="DeRezDestination"/> enum</param>
        /// <param name="destFolder">The destination inventory folders <seealso cref="UUID"/> -or- 
        /// if DeRezzing object to a tasks Inventory, the Tasks <seealso cref="UUID"/></param>
        /// <param name="transactionID">The transaction ID for this request which
        /// can be used to correlate this request with other packets</param>
        /// <remarks>If objectLocalID is a child primitive in a linkset, the entire linkset will be derezzed</remarks>
        public void RequestDeRezToInventory(uint objectLocalID, DeRezDestination destType, UUID destFolder, UUID transactionID)
        {
            DeRezObjectPacket take = new DeRezObjectPacket();

            take.AgentData.AgentID = Client.Self.AgentID;
            take.AgentData.SessionID = Client.Self.SessionID;
            take.AgentBlock = new DeRezObjectPacket.AgentBlockBlock();
            take.AgentBlock.GroupID = UUID.Zero;
            take.AgentBlock.Destination = (byte)destType;
            take.AgentBlock.DestinationID = destFolder;
            take.AgentBlock.PacketCount = 1;
            take.AgentBlock.PacketNumber = 1;
            take.AgentBlock.TransactionID = transactionID;

            take.ObjectData = new DeRezObjectPacket.ObjectDataBlock[1];
            take.ObjectData[0] = new DeRezObjectPacket.ObjectDataBlock();
            take.ObjectData[0].ObjectLocalID = objectLocalID;

            Client.Network.SendPacket(take);
        }
Пример #3
0
        void DeRezObjectHandler(Packet packet, Agent agent)
        {
            DeRezObjectPacket derez       = (DeRezObjectPacket)packet;
            DeRezDestination  destination = (DeRezDestination)derez.AgentBlock.Destination;

            // TODO: Check permissions

            for (int i = 0; i < derez.ObjectData.Length; i++)
            {
                uint localID = derez.ObjectData[i].ObjectLocalID;

                SimulationObject obj;
                if (server.Scene.TryGetObject(localID, out obj))
                {
                    switch (destination)
                    {
                    case DeRezDestination.AgentInventorySave:
                        Logger.Log("DeRezObject: Got an AgentInventorySave, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.AgentInventoryCopy:
                        Logger.Log("DeRezObject: Got an AgentInventorySave, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.TaskInventory:
                        Logger.Log("DeRezObject: Got a TaskInventory, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.Attachment:
                        Logger.Log("DeRezObject: Got an Attachment, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.AgentInventoryTake:
                        Logger.Log("DeRezObject: Got an AgentInventoryTake, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.ForceToGodInventory:
                        Logger.Log("DeRezObject: Got a ForceToGodInventory, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.TrashFolder:
                        InventoryObject invObj;
                        if (server.Inventory.TryGetInventory(agent.AgentID, derez.AgentBlock.DestinationID, out invObj) &&
                            invObj is InventoryFolder)
                        {
                            // FIXME: Handle children
                            InventoryFolder trash = (InventoryFolder)invObj;
                            server.Inventory.CreateItem(agent.AgentID, obj.Prim.Properties.Name, obj.Prim.Properties.Description, InventoryType.Object,
                                                        AssetType.Object, obj.Prim.ID, trash.ID, PermissionMask.All, PermissionMask.All, agent.AgentID,
                                                        obj.Prim.Properties.CreatorID, derez.AgentBlock.TransactionID, 0, true);
                            server.Scene.ObjectRemove(this, obj);

                            Logger.DebugLog(String.Format("Derezzed prim {0} to agent inventory trash", obj.Prim.LocalID));
                        }
                        else
                        {
                            Logger.Log("DeRezObject: Got a TrashFolder with an invalid trash folder: " +
                                       derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        }
                        break;

                    case DeRezDestination.AttachmentToInventory:
                        Logger.Log("DeRezObject: Got an AttachmentToInventory, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.AttachmentExists:
                        Logger.Log("DeRezObject: Got an AttachmentExists, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.ReturnToOwner:
                        Logger.Log("DeRezObject: Got a ReturnToOwner, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;

                    case DeRezDestination.ReturnToLastOwner:
                        Logger.Log("DeRezObject: Got a ReturnToLastOwner, DestID: " +
                                   derez.AgentBlock.DestinationID.ToString(), Helpers.LogLevel.Warning);
                        break;
                    }
                }
            }
        }