Пример #1
0
            public void BeginLoadModuleFromArchive(IScene scene)
            {
                IBackupModule backup = scene.RequestModuleInterface <IBackupModule>();

                IScriptModule[]         modules      = scene.RequestModuleInterfaces <IScriptModule>();
                IParcelManagementModule parcelModule = scene.RequestModuleInterface <IParcelManagementModule>();

                //Disable the script engine so that it doesn't load in the background and kill OAR loading
                foreach (IScriptModule module in modules)
                {
                    if (module != null)
                    {
                        module.Disabled = true;
                    }
                }
                //Disable backup for now as well
                if (backup != null)
                {
                    backup.LoadingPrims = true;
                    m_loadAssets        = MainConsole.Instance.Prompt("Should any stored assets be loaded? (If you got this .abackup from another grid, choose yes", "no").ToLower() == "yes";
                    m_merge             = MainConsole.Instance.Prompt("Should we merge prims together (keep the prims from the old region too)?", "no").ToLower() == "yes";
                    if (!m_merge)
                    {
                        DateTime before = DateTime.Now;
                        MainConsole.Instance.Info("[ARCHIVER]: Clearing all existing scene objects");
                        backup.DeleteAllSceneObjects();
                        MainConsole.Instance.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds);
                        if (parcelModule != null)
                        {
                            parcelModule.ClearAllParcels();
                        }
                    }
                }
            }
Пример #2
0
        private void killTrees()
        {
            foreach (Copse copse in m_copse)
            {
                if (!copse.m_frozen && copse.m_trees.Count >= copse.m_tree_quantity)
                {
                    List <SceneObjectGroup> groups = new List <SceneObjectGroup>();
                    foreach (UUID tree in copse.m_trees)
                    {
                        double killLikelyhood = 0.0;

                        IEntity entity;
                        if (m_scene.Entities.TryGetValue(tree, out entity) && entity is SceneObjectGroup)
                        {
                            SceneObjectPart selectedTree      = ((SceneObjectGroup)entity).RootPart;
                            double          selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
                                                                          Math.Pow(selectedTree.Scale.Y, 2) +
                                                                          Math.Pow(selectedTree.Scale.Z, 2));

                            foreach (UUID picktree in copse.m_trees)
                            {
                                if (picktree != tree)
                                {
                                    IEntity ent;
                                    if (m_scene.Entities.TryGetValue(tree, out ent) && ent is SceneObjectGroup)
                                    {
                                        SceneObjectPart pickedTree = ((SceneObjectGroup)ent).RootPart;

                                        double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
                                                                           Math.Pow(pickedTree.Scale.Y, 2) +
                                                                           Math.Pow(pickedTree.Scale.Z, 2));

                                        double pickedTreeDistance = Vector3.Distance(pickedTree.AbsolutePosition, selectedTree.AbsolutePosition);

                                        killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1;
                                    }
                                }
                            }

                            if (Util.RandomClass.NextDouble() < killLikelyhood)
                            {
                                groups.Add(selectedTree.ParentGroup);
                                copse.m_trees.Remove(selectedTree.ParentGroup.UUID);

                                break;
                            }
                        }
                        else
                        {
                            m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree);
                        }
                    }
                    IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                    if (backup != null)
                    {
                        backup.DeleteSceneObjects(groups.ToArray(), true);
                    }
                }
            }
        }
Пример #3
0
            public void EndLoadModuleFromArchive(IScene scene)
            {
                IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();

                IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>();
                //Reeanble now that we are done
                foreach (IScriptModule module in modules)
                {
                    module.Disabled = false;
                }
                //Reset backup too
                if (backup != null)
                {
                    backup.LoadingPrims = false;
                }

                //Update the database as well!
                IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>();

                if (parcelManagementModule != null && !m_merge) //Only if we are not merging
                {
                    m_scene.EventManager.TriggerIncomingLandDataFromStorage(m_parcels);
                    foreach (LandData parcel in m_parcels)
                    {
                        parcelManagementModule.UpdateLandObject(parcel.LocalID, parcel);
                    }
                    m_parcels.Clear();
                }
                m_validUserUuids.Clear();
            }
Пример #4
0
        public void ResetRegion(IScene scene)
        {
            if (scene == null)
            {
                MainConsole.Instance.Warn("You must use this command on a region. Use 'change region' to change to the region you would like to change");
                return;
            }

            IBackupModule backup = scene.RequestModuleInterface <IBackupModule> ();

            if (backup != null)
            {
                backup.DeleteAllSceneObjects();//Remove all the objects from the region
            }
            ITerrainModule module = scene.RequestModuleInterface <ITerrainModule> ();

            if (module != null)
            {
                module.ResetTerrain();//Then remove the terrain
            }
            //Then reset the textures
            scene.RegionInfo.RegionSettings.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
            scene.RegionInfo.RegionSettings.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
            scene.RegionInfo.RegionSettings.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
            scene.RegionInfo.RegionSettings.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
            scene.RegionInfo.RegionSettings.Save();
            MainConsole.Instance.Warn("Region " + scene.RegionInfo.RegionName + " was reset");
        }
Пример #5
0
            public void BeginLoadModuleFromArchive(IScene scene)
            {
                IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();

                IScriptModule[]         modules      = m_scene.RequestModuleInterfaces <IScriptModule>();
                IParcelManagementModule parcelModule = scene.RequestModuleInterface <IParcelManagementModule>();

                //Disable the script engine so that it doesn't load in the background and kill OAR loading
                foreach (IScriptModule module in modules)
                {
                    if (module != null)
                    {
                        module.Disabled = true;
                    }
                }
                //Disable backup for now as well
                if (backup != null)
                {
                    backup.LoadingPrims = true;
                    m_merge             = MainConsole.Instance.CmdPrompt("Should we merge prims together (keep the prims from the old region too)?", "false") == "true";
                    if (!m_merge)
                    {
                        DateTime before = DateTime.Now;
                        m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
                        backup.DeleteAllSceneObjects();
                        m_log.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds);
                        if (parcelModule != null)
                        {
                            parcelModule.ResetSimLandObjects();
                        }
                    }
                }
            }
Пример #6
0
        void OnStartupComplete(IScene scene, List <string> data)
        {
            int num = 0;

            while (num < data.Count - 1)
            {
                string type = data[num].ToString();
                int    len  = Convert.ToInt32(data[num + 1]);
                num += 2;
                if (type == "ScriptEngine")
                {
                    if (m_firstEmptyCompileQueue || m_oarFileLoading)
                    {
                        OSChatMessage c = new OSChatMessage();
                        if (m_firstEmptyCompileQueue)
                        {
                            c.Message = "server_startup,";
                        }
                        else
                        {
                            c.Message = "oar_file_load,";
                        }
                        m_firstEmptyCompileQueue = false;
                        m_oarFileLoading         = false;

                        IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                        if (backup != null)
                        {
                            backup.ProcessPrimBackupTaints(false, false);
                        }

                        c.From = "RegionReady";
                        if (m_lastOarLoadedOk)
                        {
                            c.Message += "1,";
                        }
                        else
                        {
                            c.Message += "0,";
                        }
                        c.Channel = m_channelNotify;
                        //Equiv of 'c.Message += numScriptsFailed.ToString() + "," + message;'
                        c.Message   += data[num] + "," + data[num + 1];
                        c.Type       = ChatTypeEnum.Region;
                        c.Position   = new Vector3((m_scene.RegionInfo.RegionSizeX * 0.5f), (m_scene.RegionInfo.RegionSizeY * 0.5f), 30);
                        c.Sender     = null;
                        c.SenderUUID = UUID.Zero;
                        c.Scene      = m_scene;

                        m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}",
                                         m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
                        m_scene.EventManager.TriggerOnChatBroadcast(this, c);
                    }
                }
                else
                {
                    num += len;
                }
            }
        }
Пример #7
0
        public bool EventSchProcessQIS(ref QueueItemStruct QIS)
        {
            try
            {
                Exception      ex      = null;
                EnumeratorInfo Running = QIS.ID.Script.ExecuteEvent(QIS.State,
                                                                    QIS.functionName,
                                                                    QIS.param, QIS.CurrentlyAt, out ex);

                if (ex != null)
                {
                    //Check exceptions, some are ours to deal with, and others are to be logged
                    if (ex.Message.Contains("SelfDeleteException"))
                    {
                        if (QIS.ID.Part != null && QIS.ID.Part.ParentEntity != null)
                        {
                            IBackupModule backup =
                                QIS.ID.Part.ParentEntity.Scene.RequestModuleInterface <IBackupModule>();
                            if (backup != null)
                            {
                                backup.DeleteSceneObjects(
                                    new ISceneEntity[1] {
                                    QIS.ID.Part.ParentEntity
                                }, true, true);
                            }
                        }
                    }
                    else if (ex.Message.Contains("ScriptDeleteException"))
                    {
                        if (QIS.ID.Part != null && QIS.ID.Part.ParentEntity != null)
                        {
                            QIS.ID.Part.Inventory.RemoveInventoryItem(QIS.ID.ItemID);
                        }
                    }
                    //Log it for the user
                    else if (!(ex.Message.Contains("EventAbortException")) &&
                             !(ex.Message.Contains("MinEventDelayException")))
                    {
                        QIS.ID.DisplayUserNotification(ex.ToString(), "executing", false, true);
                    }
                    EventManager.EventComplete(QIS);
                    return(false);
                }
                else if (Running != null)
                {
                    //Did not finish so requeue it
                    QIS.CurrentlyAt = Running;
                    QIS.RunningNumber++;
                    return(true); //Do the return... otherwise we open the queue for this event back up
                }
            }
            catch (Exception ex)
            {
                //Error, tell the user
                QIS.ID.DisplayUserNotification(ex.ToString(), "executing", false, true);
            }
            //Tell the event manager about it so that the events will be removed from the queue
            EventManager.EventComplete(QIS);
            return(false);
        }
Пример #8
0
        public void SuspendAvatar(IScenePresence presence, GridRegion destination)
        {
            IAvatarAppearanceModule appearance = presence.RequestModuleInterface <IAvatarAppearanceModule>();

            presence.AttachmentsLoaded = false;
            ISceneEntity[] attachments = GetAttachmentsForAvatar(presence.UUID);
            foreach (ISceneEntity group in attachments)
            {
                if (group.RootChild.AttachedPos != group.RootChild.SavedAttachedPos ||
                    group.RootChild.SavedAttachmentPoint != group.RootChild.AttachmentPoint)
                {
                    group.RootChild.SavedAttachedPos     = group.RootChild.AttachedPos;
                    group.RootChild.SavedAttachmentPoint = group.RootChild.AttachmentPoint;
                    //Make sure we get updated
                    group.HasGroupChanged = true;
                }

                // If an item contains scripts, it's always changed.
                // This ensures script state is saved on detach
                foreach (ISceneChildEntity p in group.ChildrenEntities())
                {
                    if (p.Inventory.ContainsScripts())
                    {
                        group.HasGroupChanged = true;
                        break;
                    }
                }
                if (group.HasGroupChanged)
                {
                    UUID assetID = UpdateKnownItem(presence.ControllingClient, group,
                                                   group.RootChild.FromUserInventoryItemID,
                                                   group.OwnerID);
                    group.RootChild.FromUserInventoryAssetID = assetID;
                }
            }
            if (appearance != null)
            {
                appearance.Appearance.SetAttachments(attachments);
                presence.Scene.AvatarService.SetAppearance(presence.UUID,
                                                           appearance.Appearance);
            }
            IBackupModule backup = presence.Scene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                bool sendUpdates = destination == null;
                if (!sendUpdates)
                {
                    List <GridRegion> regions =
                        presence.Scene.RequestModuleInterface <IGridRegisterModule>()
                        .GetNeighbors(presence.Scene);
                    regions.RemoveAll((r) => r.RegionID != destination.RegionID);
                    sendUpdates = regions.Count == 0;
                }
                backup.DeleteSceneObjects(attachments, false, sendUpdates);
            }
        }
Пример #9
0
        public bool DeleteObject()
        {
            DeleteToInventoryHolder x = null;

            try
            {
                if (m_removeFromSimQueue.TryDequeue(out x))
                {
                    MainConsole.Instance.DebugFormat(
                        "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.",
                        m_removeFromSimQueue.Count);

                    if (x.permissionToTake)
                    {
                        try
                        {
                            IInventoryAccessModule invAccess = m_scene.RequestModuleInterface <IInventoryAccessModule>();
                            UUID itemID;
                            if (invAccess != null)
                            {
                                invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroups, x.agentId, out itemID);
                            }
                        }
                        catch (Exception e)
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[ASYNC DELETER]: Exception background sending object: {0}{1}", e.Message, e.StackTrace);
                        }
                    }

                    //Moved Delete To After Object Taken To Inventory. Prevents script variables not being updated before taken to inventory
                    if (x.permissionToDelete)
                    {
                        IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                        if (backup != null)
                        {
                            backup.DeleteSceneObjects(x.objectGroups.ToArray(), true, true);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                // We can't put the object group details in here since the root part may have disappeared (which is where these sit).
                // FIXME: This needs to be fixed.
                MainConsole.Instance.ErrorFormat(
                    "[SCENE]: Queued sending of scene object to agent {0} {1} failed: {2}",
                    (x != null ? x.agentId.ToString() : "unavailable"),
                    (x != null ? x.agentId.ToString() : "unavailable"), e);
            }

            //MainConsole.Instance.Debug("[SCENE]: No objects left in delete queue.");
            return(false);
        }
Пример #10
0
        /// <summary>
        /// Kill an object given its UUID.
        /// </summary>
        /// <param name="cmdparams"></param>
        protected void KillUUID(string module, string[] cmdparams)
        {
            if (cmdparams.Length > 2)
            {
                UUID         id  = UUID.Zero;
                ISceneEntity grp = null;
                Scene        sc  = null;

                if (!UUID.TryParse(cmdparams[2], out id))
                {
                    m_log.Info("[KillUUID]: Error bad UUID format!");
                    return;
                }

                ForEachScene(delegate(Scene scene)
                {
                    ISceneChildEntity part = scene.GetSceneObjectPart(id);
                    if (part == null)
                    {
                        return;
                    }

                    grp = part.ParentEntity;
                    sc  = scene;
                });

                if (grp == null)
                {
                    m_log.Info(String.Format("[KillUUID]: Given UUID {0} not found!", id));
                }
                else
                {
                    m_log.Info(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
                    try
                    {
                        IBackupModule backup = sc.RequestModuleInterface <IBackupModule>();
                        if (backup != null)
                        {
                            backup.DeleteSceneObjects(new ISceneEntity[1] {
                                grp
                            }, true);
                        }
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
                    }
                }
            }
            else
            {
                m_log.Info("[KillUUID]: Usage: kill uuid <UUID>");
            }
        }
Пример #11
0
        public void DetachSingleAttachmentToInventory(UUID itemID, IClientAPI remoteClient)
        {
            ISceneEntity[] attachments = GetAttachmentsForAvatar(remoteClient.AgentId);
            IScenePresence presence;

            if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
            {
                IAvatarAppearanceModule appearance = presence.RequestModuleInterface <IAvatarAppearanceModule>();
                if (!appearance.Appearance.DetachAttachment(itemID))
                {
                    bool found = false;
                    foreach (ISceneEntity grp in attachments)
                    {
                        if (grp.RootChild.FromUserInventoryItemID == itemID)
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        return; //Its not attached! What are we doing!
                    }
                }

                MainConsole.Instance.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId +
                                           ", ItemID: " + itemID);
                if (AvatarFactory != null)
                {
                    AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
                }
            }

            DetachSingleAttachmentToInventoryInternal(itemID, remoteClient, true);
            //Find the attachment we are trying to edit by ItemID
            foreach (ISceneEntity grp in attachments)
            {
                if (grp.RootChild.FromUserInventoryItemID == itemID)
                {
                    //And from storage as well
                    IBackupModule backup = presence.Scene.RequestModuleInterface <IBackupModule>();
                    if (backup != null)
                    {
                        backup.DeleteSceneObjects(new[] { grp }, false, true);
                    }
                }
            }
        }
Пример #12
0
        private void HandleTreeRemove(string module, string[] cmd)
        {
            if (MainConsole.Instance.ConsoleScene != m_scene)
            {
                return;
            }
            string copsename     = (cmd[2]).Trim();
            Copse  copseIdentity = null;

            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copsename)
                {
                    copseIdentity = cp;
                }
            }

            if (copseIdentity != null)
            {
                List <SceneObjectGroup> groups = new List <SceneObjectGroup>();
                foreach (UUID tree in copseIdentity.m_trees)
                {
                    IEntity entity;
                    if (m_scene.Entities.TryGetValue(tree, out entity))
                    {
                        if (entity is SceneObjectGroup)
                        {
                            groups.Add((SceneObjectGroup)entity);
                        }
                    }
                }
                IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                if (backup != null)
                {
                    backup.DeleteSceneObjects(groups.ToArray(), true);
                }
                copseIdentity.m_trees = new List <UUID>();
                m_copse.Remove(copseIdentity);
                m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
            }
            else
            {
                m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
            }
        }
Пример #13
0
        /// <summary>
        ///     Adds a Scene Object group to the Scene.
        ///     Verifies that the creator of the object is not banned from the simulator.
        ///     Checks if the item is an Attachment
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="sceneObject"></param>
        /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
        public bool AddSceneObject(IScene scene, ISceneEntity sceneObject)
        {
            // If the user is banned, we won't let any of their objects
            // enter. Period.
            //
            if (scene.RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
            {
                MainConsole.Instance.Info("[EntityTransferModule]: Denied prim crossing for banned avatar");

                return(false);
            }

            //if (!sceneObject.IsAttachmentCheckFull()) // Not Attachment
            {
                if (!scene.Permissions.CanObjectEntry(sceneObject.UUID,
                                                      true, sceneObject.AbsolutePosition, sceneObject.OwnerID))
                {
                    // Deny non attachments based on parcel settings
                    //
                    MainConsole.Instance.Info("[EntityTransferModule]: Denied prim crossing " +
                                              "because of parcel settings");

                    IBackupModule backup = scene.RequestModuleInterface <IBackupModule>();
                    if (backup != null)
                    {
                        backup.DeleteSceneObjects(new[] { sceneObject }, true, true);
                    }

                    return(false);
                }

                sceneObject.IsInTransit = false; //Reset this now that it's entering here
                if (scene.SceneGraph.AddPrimToScene(sceneObject))
                {
                    if (sceneObject.IsSelected)
                    {
                        sceneObject.RootChild.CreateSelected = true;
                    }
                    sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                    return(true);
                }
            }
            return(false);
        }
Пример #14
0
        /// <summary>
        /// We havn't loaded prims, we need to do this now!
        /// We also need to kick start the heartbeat, so run it as well
        /// </summary>
        private void SoftStartup()
        {
            //Only start up one at a time
            if (m_isStartingUp)
            {
                return;
            }
            m_isStartingUp = true;
            IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule> ();

            if (backup != null)
            {
                backup.LoadPrims = true;
                backup.LoadPrimsFromStorage();
                backup.CreateScriptInstances();
            }
            GenericStartup();
            m_isStartingUp = false;
        }
Пример #15
0
        public void ResetScene()
        {
            if (m_currentScene == null)
            {
                m_log.Warn("You must use this command on a region. Use 'change region' to change to the region you would like to change");
                return;
            }
            IBackupModule backup = m_currentScene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                backup.DeleteAllSceneObjects();
            }
            ITerrainModule module = m_currentScene.RequestModuleInterface <ITerrainModule>();

            if (module != null)
            {
                module.ResetTerrain();
            }
        }
Пример #16
0
        public void ResetRegion(IScene scene)
        {
            IBackupModule backup = scene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                backup.DeleteAllSceneObjects(); //Remove all the objects from the region
            }
            ITerrainModule module = scene.RequestModuleInterface <ITerrainModule>();

            if (module != null)
            {
                module.ResetTerrain(); //Then remove the terrain
            }
            //Then reset the textures
            scene.RegionInfo.RegionSettings.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
            scene.RegionInfo.RegionSettings.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
            scene.RegionInfo.RegionSettings.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
            scene.RegionInfo.RegionSettings.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
            MainConsole.Instance.Warn("Region " + scene.RegionInfo.RegionName + " was reset");
        }
Пример #17
0
        public void AddRegion(Scene scene)
        {
            if (scene.RegionInfo.Startup != StartupType.Normal)
            {
                m_scene = scene;
                //Disable the heartbeat for this region
                scene.ShouldRunHeartbeat = false;

                scene.EventManager.OnRemovePresence     += OnRemovePresence;
                scene.AuroraEventManager.OnGenericEvent += OnGenericEvent;

                if (scene.RegionInfo.Startup == StartupType.Soft)
                {
                    //If the region startup is soft, we arn't to load prims until they are needed, so kill it
                    IBackupModule backup = scene.RequestModuleInterface <IBackupModule> ();
                    if (backup != null)
                    {
                        backup.LoadPrims = false;
                    }
                }
            }
        }
Пример #18
0
        public void RemoveRegion(Scene scene, bool cleanup)
        {
            IBackupModule backup = ((Scene)scene).RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                backup.DeleteAllSceneObjects();
            }

            CloseRegion(scene);

            if (!cleanup)
            {
                return;
            }

            IRegionLoader[] loaders = m_OpenSimBase.ApplicationRegistry.RequestModuleInterfaces <IRegionLoader>();
            foreach (IRegionLoader loader in loaders)
            {
                loader.DeleteRegion(scene.RegionInfo);
            }
        }
Пример #19
0
        private void KillAttachments(IScenePresence agent)
        {
            IAttachmentsModule attModule = agent.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                ISceneEntity[] attachments = attModule.GetAttachmentsForAvatar(agent.UUID);
                foreach (ISceneEntity grp in attachments)
                {
                    //Kill in all clients as it will be readded in the other region
                    KillEntities(agent.Scene, grp.ChildrenEntities().ToArray());
                    //Now remove it from the Scene so that it will not come back
                    agent.Scene.SceneGraph.DeleteEntity(grp);
                    //And from storage as well
                    IBackupModule backup = agent.Scene.RequestModuleInterface <IBackupModule>();
                    if (backup != null)
                    {
                        backup.DeleteFromStorage(grp.UUID);
                    }
                }
            }
        }
Пример #20
0
        private void SoftShutdown()
        {
            //Only shut down one at a time
            if (m_isShuttingDown)
            {
                return;
            }
            m_isShuttingDown = true;

            //We need to remove all the prims from the region, but not from the database
            IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule> ();

            if (backup != null)
            {
                //This removes all the prims from the script engine
                // and the in memory caches and turns off backup for the region
                backup.ResetRegionToStartupDefault();
            }

            GenericShutdown();

            m_isShuttingDown = false;
        }
Пример #21
0
        /// <summary>
        /// Shuts down and permanently removes all info associated with the region
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="cleanup"></param>
        public void RemoveRegion(IScene scene, bool cleanup)
        {
            IBackupModule backup = scene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                backup.DeleteAllSceneObjects();
            }

            scene.RegionInfo.HasBeenDeleted = true;
            CloseRegion(scene, ShutdownType.Immediate, 0);

            if (!cleanup)
            {
                return;
            }

            IRegionLoader[] loaders = m_OpenSimBase.ApplicationRegistry.RequestModuleInterfaces <IRegionLoader>();
            foreach (IRegionLoader loader in loaders)
            {
                loader.DeleteRegion(scene.RegionInfo);
            }
        }
Пример #22
0
        public void SuspendAvatar(IScenePresence presence)
        {
            ISceneEntity[] attachments = GetAttachmentsForAvatar(presence.UUID);
            foreach (ISceneEntity group in attachments)
            {
                if (group.RootChild.AttachedPos != group.RootChild.SavedAttachedPos ||
                    group.RootChild.SavedAttachmentPoint != group.RootChild.AttachmentPoint)
                {
                    group.RootChild.SavedAttachedPos     = group.RootChild.AttachedPos;
                    group.RootChild.SavedAttachmentPoint = group.RootChild.AttachmentPoint;
                    //Make sure we get updated
                    group.HasGroupChanged = true;
                }

                // If an item contains scripts, it's always changed.
                // This ensures script state is saved on detach
                foreach (ISceneChildEntity p in group.ChildrenEntities())
                {
                    if (p.Inventory.ContainsScripts())
                    {
                        group.HasGroupChanged = true;
                        break;
                    }
                }
                if (group.HasGroupChanged)
                {
                    UpdateKnownItem(presence.ControllingClient, group,
                                    group.RootChild.FromUserInventoryItemID, group.OwnerID);
                }
            }
            IBackupModule backup = presence.Scene.RequestModuleInterface <IBackupModule>();

            if (backup != null)
            {
                backup.DeleteSceneObjects(attachments, false, true);
            }
        }
Пример #23
0
        private void DearchiveRegion0DotStar()
        {
            if (m_loadStream == null)
            {
                return;
            }
            int      successfulAssetRestores = 0;
            int      failedAssetRestores     = 0;
            string   filePath = "NONE";
            DateTime start    = DateTime.Now;

            TarArchiveReader archive = new TarArchiveReader(m_loadStream);

            if (!m_skipAssets)
            {
                m_threadpool = new AuroraThreadPool(new AuroraThreadPoolStartInfo()
                {
                    Threads  = 1,
                    priority =
                        System.Threading.ThreadPriority
                        .BelowNormal
                });
            }

            IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();

            if (!m_merge)
            {
                DateTime before = DateTime.Now;
                MainConsole.Instance.Info("[ARCHIVER]: Clearing all existing scene objects");
                if (backup != null)
                {
                    backup.DeleteAllSceneObjects();
                }
                MainConsole.Instance.Info("[ARCHIVER]: Cleared all existing scene objects in " +
                                          (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds);
            }

            IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>();
            //Disable the script engine so that it doesn't load in the background and kill OAR loading
            foreach (IScriptModule module in modules)
            {
                module.Disabled = true;
            }
            //Disable backup for now as well
            if (backup != null)
            {
                backup.LoadingPrims = true;
            }

            IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface <IRegionSerialiserModule>();
            int sceneObjectsLoadedCount        = 0;

            //We save the groups so that we can back them up later
            List <ISceneEntity> groupsToBackup = new List <ISceneEntity>();
            List <LandData>     landData       = new List <LandData>();

            // must save off some stuff until after assets have been saved and recieved new uuids
            // keeping these collection local because I am sure they will get large and garbage collection is better that way
            List <byte[]>           seneObjectGroups        = new List <byte[]>();
            Dictionary <UUID, UUID> assetBinaryChangeRecord = new Dictionary <UUID, UUID>();
            Queue <UUID>            assets2Save             = new Queue <UUID>();

            try
            {
                byte[] data;
                TarArchiveReader.TarEntryType entryType;
                while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
                {
                    if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    {
                        continue;
                    }

                    if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
                    {
                        seneObjectGroups.Add(data);
                    }
                    else if (!m_skipAssets && filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
                    {
                        AssetBase asset;
                        if (LoadAsset(filePath, data, out asset))
                        {
                            successfulAssetRestores++;
                            if (m_useAsync)
                            {
                                lock (AssetsToAdd) AssetsToAdd.Add(asset);
                            }
                            else
                            {
                                if (asset.IsBinaryAsset)
                                {
                                    UUID aid = asset.ID;
                                    asset.ID = m_scene.AssetService.Store(asset);
                                    if (asset.ID != aid && asset.ID != UUID.Zero)
                                    {
                                        assetBinaryChangeRecord.Add(aid, asset.ID);
                                    }
                                }
                                else
                                {
                                    if (!assetNonBinaryCollection.ContainsKey(asset.ID))
                                    {
                                        assetNonBinaryCollection.Add(asset.ID, asset);
                                        // I need something I can safely loop through
                                        assets2Save.Enqueue(asset.ID);
                                    }
                                }
                            }
                        }
                        else
                        {
                            failedAssetRestores++;
                        }

                        if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
                        {
                            MainConsole.Instance.Info("[ARCHIVER]: Loaded " + successfulAssetRestores +
                                                      " assets and failed to load " + failedAssetRestores + " assets...");
                        }
                    }
                    else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
                    {
                        LoadTerrain(filePath, data);
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
                    {
                        LoadRegionSettings(filePath, data);
                    }
                    else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
                    {
                        LandData parcel = LandDataSerializer.Deserialize(m_utf8Encoding.GetString(data));
                        parcel.OwnerID = ResolveUserUuid(parcel.OwnerID, UUID.Zero, "", Vector3.Zero, null);
                        landData.Add(parcel);
                    }
                    else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
                    {
                        LoadControlFile(data);
                    }
                }
                // Save Assets
                int savingAssetsCount = 0;
                while (assets2Save.Count > 0)
                {
                    try
                    {
                        UUID assetid = assets2Save.Dequeue();
                        SaveNonBinaryAssets(assetid, assetNonBinaryCollection[assetid], assetBinaryChangeRecord);
                        savingAssetsCount++;
                        if ((savingAssetsCount) % 250 == 0)
                        {
                            MainConsole.Instance.Info("[ARCHIVER]: Saving " + savingAssetsCount + " assets...");
                        }
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.Info("[ARCHIVER]: Exception in saving an asset: " + ex.ToString());
                    }
                }

                foreach (byte[] data2 in seneObjectGroups)
                {
                    byte[] data3 = data2;

                    string          stringData = Utils.BytesToString(data3);
                    MatchCollection mc         = Regex.Matches(stringData, sPattern);
                    bool            didChange  = false;
                    if (mc.Count >= 1)
                    {
                        foreach (Match match in mc)
                        {
                            UUID thematch = new UUID(match.Value);
                            UUID newvalue = thematch;
                            if (assetNonBinaryCollection.ContainsKey(thematch))
                            {
                                newvalue = assetNonBinaryCollection[thematch].ID;
                            }
                            else if (assetBinaryChangeRecord.ContainsKey(thematch))
                            {
                                newvalue = assetBinaryChangeRecord[thematch];
                            }
                            if (thematch == newvalue)
                            {
                                continue;
                            }
                            stringData = stringData.Replace(thematch.ToString().Trim(), newvalue.ToString().Trim());
                            didChange  = true;
                        }
                    }
                    if (didChange)
                    {
                        data3 = Utils.StringToBytes(stringData);
                    }

                    ISceneEntity sceneObject = serialiser.DeserializeGroupFromXml2(data3, m_scene);

                    if (sceneObject == null)
                    {
                        //! big error!
                        MainConsole.Instance.Error("Error reading SOP XML (Please mantis this!): " +
                                                   m_asciiEncoding.GetString(data3));
                        continue;
                    }

                    foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        if (string.IsNullOrEmpty(part.CreatorData))
                        {
                            part.CreatorID = ResolveUserUuid(part.CreatorID, part.CreatorID, part.CreatorData,
                                                             part.AbsolutePosition, landData);
                        }

                        part.OwnerID = ResolveUserUuid(part.OwnerID, part.CreatorID, part.CreatorData,
                                                       part.AbsolutePosition, landData);

                        part.LastOwnerID = ResolveUserUuid(part.LastOwnerID, part.CreatorID, part.CreatorData,
                                                           part.AbsolutePosition, landData);

                        // And zap any troublesome sit target information
                        part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
                        part.SitTargetPosition    = new Vector3(0, 0, 0);

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory)
                        {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                            {
                                kvp.Value.OwnerID = ResolveUserUuid(kvp.Value.OwnerID, kvp.Value.CreatorID,
                                                                    kvp.Value.CreatorData, part.AbsolutePosition,
                                                                    landData);
                                if (string.IsNullOrEmpty(kvp.Value.CreatorData))
                                {
                                    kvp.Value.CreatorID = ResolveUserUuid(kvp.Value.CreatorID, kvp.Value.CreatorID,
                                                                          kvp.Value.CreatorData, part.AbsolutePosition,
                                                                          landData);
                                }
                            }
                        }
                    }

                    //Add the offsets of the region
                    Vector3 newPos = new Vector3(sceneObject.AbsolutePosition.X + m_offsetX,
                                                 sceneObject.AbsolutePosition.Y + m_offsetY,
                                                 sceneObject.AbsolutePosition.Z + m_offsetZ);
                    if (m_flipX)
                    {
                        newPos.X = m_scene.RegionInfo.RegionSizeX - newPos.X;
                    }
                    if (m_flipY)
                    {
                        newPos.Y = m_scene.RegionInfo.RegionSizeY - newPos.Y;
                    }
                    sceneObject.SetAbsolutePosition(false, newPos);

                    if (m_scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        groupsToBackup.Add(sceneObject);
                        sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                        sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero, true);
                    }
                    sceneObjectsLoadedCount++;
                    if (sceneObjectsLoadedCount % 250 == 0)
                    {
                        MainConsole.Instance.Info("[ARCHIVER]: Loaded " + sceneObjectsLoadedCount + " objects...");
                    }
                }
                assetNonBinaryCollection.Clear();
                assetBinaryChangeRecord.Clear();
                seneObjectGroups.Clear();
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat(
                    "[ARCHIVER]: Aborting load with error in archive file {0}.  {1}", filePath, e);
                m_errorMessage += e.ToString();
                m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
                return;
            }
            finally
            {
                archive.Close();
                m_loadStream.Close();
                m_loadStream.Dispose();

                //Reeanble now that we are done
                foreach (IScriptModule module in modules)
                {
                    module.Disabled = false;
                }
                //Reset backup too
                if (backup != null)
                {
                    backup.LoadingPrims = false;
                }
            }

            //Now back up the prims
            foreach (ISceneEntity grp in groupsToBackup)
            {
                //Backup!
                grp.HasGroupChanged = true;
            }

            if (!m_skipAssets && m_useAsync && !AssetSaverIsRunning)
            {
                m_threadpool.QueueEvent(SaveAssets, 0);
            }

            if (!m_skipAssets)
            {
                MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);

                if (failedAssetRestores > 0)
                {
                    MainConsole.Instance.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
                    m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
                }
            }

            // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
            // otherwise, use the master avatar uuid instead

            // Reload serialized parcels
            MainConsole.Instance.InfoFormat("[ARCHIVER]: Loading {0} parcels.  Please wait.", landData.Count);

            IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagementModule != null)
            {
                parcelManagementModule.IncomingLandDataFromOAR(landData, m_merge, new Vector2(m_offsetX, m_offsetY));
            }

            MainConsole.Instance.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);

            //Clean it out
            landData.Clear();

            MainConsole.Instance.InfoFormat("[ARCHIVER]: Successfully loaded archive in " +
                                            (DateTime.Now - start).Minutes + ":" + (DateTime.Now - start).Seconds);

            m_validUserUuids.Clear();
            m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
        }
        /// <summary>
        ///   Save a backup of the sim
        /// </summary>
        /// <param name = "appendedFilePath">The file path where the backup will be saved</param>
        protected virtual void SaveBackup(string appendedFilePath, bool saveAssets)
        {
            if (appendedFilePath == "/")
            {
                appendedFilePath = "";
            }
            if (m_scene.RegionInfo.HasBeenDeleted)
            {
                return;
            }
            IBackupModule backupModule = m_scene.RequestModuleInterface <IBackupModule>();

            if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims
            {
                MainConsole.Instance.Info("[Backup]: Not saving backup because the backup module is loading prims");
                return;
            }

            //Save any script state saves that might be around
            IScriptModule[] engines = m_scene.RequestModuleInterfaces <IScriptModule>();
            try
            {
                if (engines != null)
                {
#if (!ISWIN)
                    foreach (IScriptModule engine in engines)
                    {
                        if (engine != null)
                        {
                            engine.SaveStateSaves();
                        }
                    }
#else
                    foreach (IScriptModule engine in engines.Where(engine => engine != null))
                    {
                        engine.SaveStateSaves();
                    }
#endif
                }
            }
            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
            }

            MainConsole.Instance.Info("[FileBasedSimulationData]: Saving backup for region " + m_scene.RegionInfo.RegionName);
            string fileName = appendedFilePath + m_scene.RegionInfo.RegionName + m_saveAppendedFileName + ".abackup";
            if (File.Exists(fileName))
            {
                //Do new style saving here!
                GZipStream m_saveStream = new GZipStream(new FileStream(fileName + ".tmp", FileMode.Create),
                                                         CompressionMode.Compress);
                TarArchiveWriter writer       = new TarArchiveWriter(m_saveStream);
                GZipStream       m_loadStream = new GZipStream(new FileStream(fileName, FileMode.Open),
                                                               CompressionMode.Decompress);
                TarArchiveReader reader = new TarArchiveReader(m_loadStream);

                writer.WriteDir("parcels");

                IParcelManagementModule module = m_scene.RequestModuleInterface <IParcelManagementModule>();
                if (module != null)
                {
                    List <ILandObject> landObject = module.AllParcels();
                    foreach (ILandObject parcel in landObject)
                    {
                        OSDMap parcelMap = parcel.LandData.ToOSD();
                        var    binary    = OSDParser.SerializeLLSDBinary(parcelMap);
                        writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(),
                                         binary);
                        binary    = null;
                        parcelMap = null;
                    }
                }

                writer.WriteDir("newstyleterrain");
                writer.WriteDir("newstylerevertterrain");

                writer.WriteDir("newstylewater");
                writer.WriteDir("newstylerevertwater");

                ITerrainModule tModule = m_scene.RequestModuleInterface <ITerrainModule>();
                if (tModule != null)
                {
                    try
                    {
                        byte[] sdata = WriteTerrainToStream(tModule.TerrainMap);
                        writer.WriteFile("newstyleterrain/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata);
                        sdata = null;

                        sdata = WriteTerrainToStream(tModule.TerrainRevertMap);
                        writer.WriteFile(
                            "newstylerevertterrain/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata);
                        sdata = null;

                        if (tModule.TerrainWaterMap != null)
                        {
                            sdata = WriteTerrainToStream(tModule.TerrainWaterMap);
                            writer.WriteFile("newstylewater/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain",
                                             sdata);
                            sdata = null;

                            sdata = WriteTerrainToStream(tModule.TerrainWaterRevertMap);
                            writer.WriteFile(
                                "newstylerevertwater/" + m_scene.RegionInfo.RegionID.ToString() + ".terrain", sdata);
                            sdata = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
                    }
                }

                IDictionary <UUID, AssetType> assets = new Dictionary <UUID, AssetType>();
                UuidGatherer assetGatherer           = new UuidGatherer(m_scene.AssetService);

                ISceneEntity[] saveentities   = m_scene.Entities.GetEntities();
                List <UUID>    entitiesToSave = new List <UUID>();
                foreach (ISceneEntity entity in saveentities)
                {
                    try
                    {
                        if (entity.IsAttachment ||
                            ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary) ||
                            ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez))
                        {
                            continue;
                        }
                        if (entity.HasGroupChanged)
                        {
                            entity.HasGroupChanged = false;
                            //Write all entities
                            byte[] xml = ((ISceneObject)entity).ToBinaryXml2();
                            writer.WriteFile("entities/" + entity.UUID.ToString(), xml);
                            xml = null;
                        }
                        else
                        {
                            entitiesToSave.Add(entity.UUID);
                        }
                        if (saveAssets)
                        {
                            assetGatherer.GatherAssetUuids(entity, assets, m_scene);
                        }
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
                        entitiesToSave.Add(entity.UUID);
                    }
                }


                byte[] data;
                string filePath;
                TarArchiveReader.TarEntryType entryType;
                //Load the archive data that we need
                try
                {
                    while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
                    {
                        if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                        {
                            continue;
                        }
                        if (filePath.StartsWith("entities/"))
                        {
                            UUID entityID = UUID.Parse(filePath.Remove(0, 9));
                            if (entitiesToSave.Contains(entityID))
                            {
                                writer.WriteFile(filePath, data);
                                entitiesToSave.Remove(entityID);
                            }
                        }
                        data = null;
                    }
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
                }

                if (entitiesToSave.Count > 0)
                {
                    MainConsole.Instance.Fatal(entitiesToSave.Count + " PRIMS WERE NOT GOING TO BE SAVED! FORCE SAVING NOW! ");
                    foreach (ISceneEntity entity in saveentities)
                    {
                        if (entitiesToSave.Contains(entity.UUID))
                        {
                            if (entity.IsAttachment ||
                                ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary) ||
                                ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez))
                            {
                                continue;
                            }
                            //Write all entities
                            byte[] xml = ((ISceneObject)entity).ToBinaryXml2();
                            writer.WriteFile("entities/" + entity.UUID.ToString(), xml);
                            xml = null;
                        }
                    }
                }

                if (saveAssets)
                {
                    foreach (UUID assetID in new List <UUID>(assets.Keys))
                    {
                        try
                        {
                            WriteAsset(assetID.ToString(), m_scene.AssetService.Get(assetID.ToString()), writer);
                        }
                        catch (Exception ex)
                        {
                            MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
                        }
                    }
                }

                reader.Close();
                writer.Close();
                m_loadStream.Close();
                m_saveStream.Close();
                GC.Collect();

                if (m_keepOldSave && !m_oldSaveHasBeenSaved)
                {
                    //Havn't moved it yet, so make sure the directory exists, then move it
                    m_oldSaveHasBeenSaved = true;
                    if (!Directory.Exists(m_oldSaveDirectory))
                    {
                        Directory.CreateDirectory(m_oldSaveDirectory);
                    }
                    File.Copy(fileName + ".tmp",
                              Path.Combine(m_oldSaveDirectory,
                                           m_scene.RegionInfo.RegionName + SerializeDateTime() + m_saveAppendedFileName +
                                           ".abackup"));
                }
                //Just remove the file
                File.Delete(fileName);
            }
            else
            {
                //Add the .temp since we might need to make a backup and so that if something goes wrong, we don't corrupt the main backup
                GZipStream m_saveStream = new GZipStream(new FileStream(fileName + ".tmp", FileMode.Create),
                                                         CompressionMode.Compress);
                TarArchiveWriter      writer   = new TarArchiveWriter(m_saveStream);
                IAuroraBackupArchiver archiver = m_scene.RequestModuleInterface <IAuroraBackupArchiver>();

                //Turn off prompting so that we don't ask the user questions every time we need to save the backup
                archiver.AllowPrompting = false;
                archiver.SaveRegionBackup(writer, m_scene);
                archiver.AllowPrompting = true;

                m_saveStream.Close();
                writer.Close();
                GC.Collect();
            }
            File.Move(fileName + ".tmp", fileName);
            ISceneEntity[] entities = m_scene.Entities.GetEntities();
            try
            {
#if (!ISWIN)
                foreach (ISceneEntity entity in entities)
                {
                    if (entity.HasGroupChanged)
                    {
                        entity.HasGroupChanged = false;
                    }
                }
#else
                foreach (ISceneEntity entity in entities.Where(entity => entity.HasGroupChanged))
                {
                    entity.HasGroupChanged = false;
                }
#endif
            }
            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
            }
            //Now make it the full file again
            MapTileNeedsGenerated = true;
            MainConsole.Instance.Info("[FileBasedSimulationData]: Saved Backup for region " + m_scene.RegionInfo.RegionName);
        }
Пример #25
0
        // What makes this method odd and unique is it tries to detach using an UUID....     Yay for standards.
        // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
        protected void DetachSingleAttachmentToInventoryInternal(UUID itemID, IClientAPI remoteClient, bool fireEvent)
        {
            if (itemID == UUID.Zero) // If this happened, someone made a mistake....
            {
                return;
            }

            // We can NOT use the dictionaries here, as we are looking
            // for an entity by the fromAssetID, which is NOT the prim UUID
            ISceneEntity[] attachments = GetAttachmentsForAvatar(remoteClient.AgentId);

            foreach (ISceneEntity group in attachments)
            {
                if (group.RootChild.FromUserInventoryItemID == itemID)
                {
                    if (fireEvent)
                    {
                        m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);

                        group.DetachToInventoryPrep();
                    }

                    IScenePresence presence = m_scene.GetScenePresence(remoteClient.AgentId);
                    if (presence != null)
                    {
                        AvatarAttachments attModule = presence.RequestModuleInterface <AvatarAttachments>();
                        if (attModule != null)
                        {
                            attModule.RemoveAttachment(group);
                        }
                    }

                    m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());

                    //Update the saved attach points
                    if (group.RootChild.AttachedPos != group.RootChild.SavedAttachedPos ||
                        group.RootChild.SavedAttachmentPoint != group.RootChild.AttachmentPoint)
                    {
                        group.RootChild.SavedAttachedPos     = group.RootChild.AttachedPos;
                        group.RootChild.SavedAttachmentPoint = group.RootChild.AttachmentPoint;
                        //Make sure we get updated
                        group.HasGroupChanged = true;
                    }

                    // If an item contains scripts, it's always changed.
                    // This ensures script state is saved on detach
                    foreach (ISceneChildEntity p in group.ChildrenEntities())
                    {
                        if (p.Inventory.ContainsScripts())
                        {
                            group.HasGroupChanged = true;
                            break;
                        }
                    }

                    UpdateKnownItem(remoteClient, group, group.RootChild.FromUserInventoryItemID, group.OwnerID);

                    IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                    if (backup != null)
                    {
                        backup.DeleteSceneObjects(new ISceneEntity[1] {
                            group
                        }, true);
                    }
                    return; //All done, end
                }
            }
        }
Пример #26
0
        /// <summary>
        ///     Save a backup of the sim
        /// </summary>
        /// <param name="isOldSave"></param>
        protected virtual void SaveBackup(bool isOldSave)
        {
            if (m_scene == null || m_scene.RegionInfo.HasBeenDeleted)
            {
                return;
            }
            IBackupModule backupModule = m_scene.RequestModuleInterface <IBackupModule>();

            if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims
            {
                MainConsole.Instance.Info("[Backup]: Not saving backup because the backup module is loading prims");
                return;
            }

            //Save any script state saves that might be around
            IScriptModule[] engines = m_scene.RequestModuleInterfaces <IScriptModule>();
            try
            {
                if (engines != null)
                {
                    foreach (IScriptModule engine in engines.Where(engine => engine != null))
                    {
                        engine.SaveStateSaves();
                    }
                }
            }
            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
            }

            MainConsole.Instance.Info("[FileBasedSimulationData]: Saving backup for region " +
                                      m_scene.RegionInfo.RegionName);

            RegionData regiondata = new RegionData();

            regiondata.Init();

            regiondata.RegionInfo = m_scene.RegionInfo;
            IParcelManagementModule module = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (module != null)
            {
                List <ILandObject> landObject = module.AllParcels();
                foreach (ILandObject parcel in landObject)
                {
                    regiondata.Parcels.Add(parcel.LandData);
                }
            }

            ITerrainModule tModule = m_scene.RequestModuleInterface <ITerrainModule>();

            if (tModule != null)
            {
                try
                {
                    regiondata.Terrain       = WriteTerrainToStream(tModule.TerrainMap);
                    regiondata.RevertTerrain = WriteTerrainToStream(tModule.TerrainRevertMap);

                    if (tModule.TerrainWaterMap != null)
                    {
                        regiondata.Water       = WriteTerrainToStream(tModule.TerrainWaterMap);
                        regiondata.RevertWater = WriteTerrainToStream(tModule.TerrainWaterRevertMap);
                    }
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
                }
            }

            ISceneEntity[] entities = m_scene.Entities.GetEntities();
            regiondata.Groups = new List <SceneObjectGroup>(entities.Cast <SceneObjectGroup>().Where((entity) =>
            {
                return
                (!(entity
                   .IsAttachment ||
                   ((entity
                     .RootChild
                     .Flags &
                     PrimFlags
                     .Temporary) ==
                    PrimFlags
                    .Temporary)
                   ||
                   ((entity
                     .RootChild
                     .Flags &
                     PrimFlags
                     .TemporaryOnRez) ==
                    PrimFlags
                    .TemporaryOnRez)));
            }));
            try
            {
                foreach (ISceneEntity entity in regiondata.Groups.Where(ent => ent.HasGroupChanged))
                {
                    entity.HasGroupChanged = false;
                }
            }
            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Backup]: Exception caught: {0}", ex);
            }
            string filename = isOldSave ? BuildOldSaveFileName() : BuildSaveFileName();

            if (File.Exists(filename + (isOldSave ? "" : ".tmp")))
            {
                File.Delete(filename + (isOldSave ? "" : ".tmp")); //Remove old tmp files
            }
            if (!_regionLoader.SaveBackup(filename + (isOldSave ? "" : ".tmp"), regiondata))
            {
                if (File.Exists(filename + (isOldSave ? "" : ".tmp")))
                {
                    File.Delete(filename + (isOldSave ? "" : ".tmp")); //Remove old tmp files
                }
                MainConsole.Instance.Error("[FileBasedSimulationData]: Failed to save backup for region " +
                                           m_scene.RegionInfo.RegionName + "!");
                return;
            }

            //RegionData data = _regionLoader.LoadBackup(filename + ".tmp");
            if (!isOldSave)
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                File.Move(filename + ".tmp", filename);

                if (m_keepOldSave && !m_oldSaveHasBeenSaved)
                {
                    //Havn't moved it yet, so make sure the directory exists, then move it
                    m_oldSaveHasBeenSaved = true;
                    if (!Directory.Exists(m_oldSaveDirectory))
                    {
                        Directory.CreateDirectory(m_oldSaveDirectory);
                    }
                    File.Copy(filename, BuildOldSaveFileName());
                }
            }
            regiondata.Dispose();
            //Now make it the full file again
            MapTileNeedsGenerated = true;
            MainConsole.Instance.Info("[FileBasedSimulationData]: Saved Backup for region " +
                                      m_scene.RegionInfo.RegionName);
        }
        /// <summary>
        ///     Move the given scene object into a new region
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="grp">Scene Object Group that we're crossing</param>
        /// <param name="attemptedPos"></param>
        /// <returns>
        ///     true if the crossing itself was successful, false on failure
        /// </returns>
        protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, ISceneEntity grp, Vector3 attemptedPos)
        {
            bool successYN = false;

            if (destination != null)
            {
                if (grp.SitTargetAvatar.Count != 0)
                {
                    foreach (UUID avID in grp.SitTargetAvatar)
                    {
                        IScenePresence SP = grp.Scene.GetScenePresence(avID);
                        SP.Velocity = grp.RootChild.PhysActor.Velocity;
                        InternalCross(SP, attemptedPos, false, destination);
                    }
                    foreach (ISceneChildEntity part in grp.ChildrenEntities())
                    {
                        part.SitTargetAvatar = new List <UUID> ();
                    }

                    IBackupModule backup = grp.Scene.RequestModuleInterface <IBackupModule> ();
                    if (backup != null)
                    {
                        return(backup.DeleteSceneObjects(new [] { grp }, false, false));
                    }
                    return(true); //They do all the work adding the prim in the other region
                }

                ISceneEntity copiedGroup = grp.Copy(false);
                copiedGroup.SetAbsolutePosition(true, attemptedPos);
                if (grp.Scene != null)
                {
                    successYN = grp.Scene.RequestModuleInterface <ISimulationService> ()
                                .CreateObject(destination, copiedGroup);
                }

                if (successYN)
                {
                    // We remove the object here
                    try {
                        IBackupModule backup = grp.Scene.RequestModuleInterface <IBackupModule> ();
                        if (backup != null)
                        {
                            return(backup.DeleteSceneObjects(new [] { grp }, false, true));
                        }
                    } catch (Exception e) {
                        MainConsole.Instance.ErrorFormat(
                            "[Entity transfer]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
                            grp, e);
                    }
                }
                else
                {
                    if (!grp.IsDeleted)
                    {
                        if (grp.RootChild.PhysActor != null)
                        {
                            grp.RootChild.PhysActor.CrossingFailure();
                        }
                    }

                    MainConsole.Instance.ErrorFormat("[Entity transfer]r]: Prim crossing failed for {0}", grp);
                }
            }
            else
            {
                MainConsole.Instance.Error(
                    "[Entity transfer]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()");
            }

            return(successYN);
        }
        /// <summary>
        ///     Move the given scene object into a new region depending on which region its absolute position has moved
        ///     into.
        ///     This method locates the new region handle and offsets the prim position for the new region
        /// </summary>
        /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
        /// <param name="grp">the scene object that we're crossing</param>
        /// <param name="destination"></param>
        public bool CrossGroupToNewRegion(ISceneEntity grp, Vector3 attemptedPosition, GridRegion destination)
        {
            if (grp == null)
            {
                return(false);
            }
            if (grp.IsDeleted)
            {
                return(false);
            }

            if (grp.Scene == null)
            {
                return(false);
            }
            if (grp.RootChild.DIE_AT_EDGE)
            {
                // We remove the object here
                try {
                    IBackupModule backup = grp.Scene.RequestModuleInterface <IBackupModule> ();
                    if (backup != null)
                    {
                        return(backup.DeleteSceneObjects(new [] { grp }, true, true));
                    }
                } catch (Exception) {
                    MainConsole.Instance.Warn(
                        "[Database]: exception when trying to remove the prim that crossed the border.");
                }
                return(false);
            }

            if (grp.RootChild.RETURN_AT_EDGE)
            {
                // We remove the object here
                try {
                    List <ISceneEntity> objects = new List <ISceneEntity> {
                        grp
                    };
                    ILLClientInventory inventoryModule = grp.Scene.RequestModuleInterface <ILLClientInventory> ();
                    if (inventoryModule != null)
                    {
                        return(inventoryModule.ReturnObjects(objects.ToArray(), UUID.Zero));
                    }
                } catch (Exception) {
                    MainConsole.Instance.Warn(
                        "[Scene]: exception when trying to return the prim that crossed the border.");
                }
                return(false);
            }

            Vector3 oldGroupPosition = grp.RootChild.GroupPosition;

            // If we fail to cross the border, then reset the position of the scene object on that border.
            if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, attemptedPosition))
            {
                grp.OffsetForNewRegion(oldGroupPosition);
                grp.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);

                return(false);
            }
            return(true);
        }
Пример #29
0
        private void DearchiveRegion0DotStar()
        {
            int successfulAssetRestores = 0;
            int failedAssetRestores     = 0;
            //List<string> serialisedSceneObjects = new List<string>();
            List <string> serialisedParcels = new List <string>();
            string        filePath          = "NONE";
            DateTime      start             = DateTime.Now;

            TarArchiveReader archive = new TarArchiveReader(m_loadStream);

            byte[] data;
            TarArchiveReader.TarEntryType entryType;

            if (!m_skipAssets)
            {
                m_threadpool = new Aurora.Framework.AuroraThreadPool(new Aurora.Framework.AuroraThreadPoolStartInfo()
                {
                    Threads  = 1,
                    priority = System.Threading.ThreadPriority.BelowNormal
                });
            }

            IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();

            if (!m_merge)
            {
                DateTime before = DateTime.Now;
                m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
                if (backup != null)
                {
                    backup.DeleteAllSceneObjects();
                }
                m_log.Info("[ARCHIVER]: Cleared all existing scene objects in " + (DateTime.Now - before).Minutes + ":" + (DateTime.Now - before).Seconds);
            }

            IScriptModule[] modules = m_scene.RequestModuleInterfaces <IScriptModule>();
            //Disable the script engine so that it doesn't load in the background and kill OAR loading
            foreach (IScriptModule module in modules)
            {
                module.Disabled = true;
            }
            //Disable backup for now as well
            if (backup != null)
            {
                backup.LoadingPrims = true;
            }

            IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface <IRegionSerialiserModule>();
            int sceneObjectsLoadedCount        = 0;

            //We save the groups so that we can back them up later
            List <SceneObjectGroup> groupsToBackup = new List <SceneObjectGroup>();

            try
            {
                while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
                {
                    //m_log.DebugFormat(
                    //    "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length);

                    if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    {
                        continue;
                    }

                    if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
                    {
                        string sogdata = m_utf8Encoding.GetString(data);
                        //serialisedSceneObjects.Add(m_utf8Encoding.GetString(data));

                        /*
                         * m_log.DebugFormat("[ARCHIVER]: Loading xml with raw size {0}", serialisedSceneObject.Length);
                         *
                         * // Really large xml files (multi megabyte) appear to cause
                         * // memory problems
                         * // when loading the xml.  But don't enable this check yet
                         *
                         * if (serialisedSceneObject.Length > 5000000)
                         * {
                         * m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);");
                         * continue;
                         * }
                         */

                        string           serialisedSceneObject = sogdata;
                        SceneObjectGroup sceneObject           = (SceneObjectGroup)serialiser.DeserializeGroupFromXml2(serialisedSceneObject, m_scene);

                        if (sceneObject == null)
                        {
                            //! big error!
                            m_log.Error("Error reading SOP XML (Please mantis this!): " + serialisedSceneObject);
                            continue;
                        }

                        foreach (SceneObjectPart part in sceneObject.ChildrenList)
                        {
                            if (!ResolveUserUuid(part.CreatorID))
                            {
                                part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                            }

                            if (!ResolveUserUuid(part.OwnerID))
                            {
                                part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                            }

                            if (!ResolveUserUuid(part.LastOwnerID))
                            {
                                part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                            }

                            // And zap any troublesome sit target information
                            part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
                            part.SitTargetPosition    = new Vector3(0, 0, 0);

                            // Fix ownership/creator of inventory items
                            // Not doing so results in inventory items
                            // being no copy/no mod for everyone
                            lock (part.TaskInventory)
                            {
                                TaskInventoryDictionary inv = part.TaskInventory;
                                foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                                {
                                    if (!ResolveUserUuid(kvp.Value.OwnerID))
                                    {
                                        kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                                    }
                                    if (!ResolveUserUuid(kvp.Value.CreatorID))
                                    {
                                        kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                                    }
                                }
                            }
                        }

                        //Add the offsets of the region
                        Vector3 newPos = new Vector3(sceneObject.AbsolutePosition.X + m_offsetX,
                                                     sceneObject.AbsolutePosition.Y + m_offsetY,
                                                     sceneObject.AbsolutePosition.Z + m_offsetZ);
                        if (m_flipX)
                        {
                            newPos.X = m_scene.RegionInfo.RegionSizeX - newPos.X;
                        }
                        if (m_flipY)
                        {
                            newPos.Y = m_scene.RegionInfo.RegionSizeY - newPos.Y;
                        }
                        sceneObject.SetAbsolutePosition(false, newPos);

                        if (m_scene.SceneGraph.AddPrimToScene(sceneObject))
                        {
                            groupsToBackup.Add(sceneObject);
                            sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate);
                            sceneObjectsLoadedCount++;
                            sceneObject.CreateScriptInstances(0, false, 0, UUID.Zero);
                            sceneObject.ResumeScripts();
                        }
                        sceneObjectsLoadedCount++;
                        if (sceneObjectsLoadedCount % 250 == 0)
                        {
                            m_log.Debug("[ARCHIVER]: Loaded " + sceneObjectsLoadedCount + " objects...");
                        }
                    }
                    else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
                    {
                        if (!m_skipAssets)
                        {
                            if (LoadAsset(filePath, data))
                            {
                                successfulAssetRestores++;
                            }
                            else
                            {
                                failedAssetRestores++;
                            }

                            if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
                            {
                                m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
                            }
                        }
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
                    {
                        LoadTerrain(filePath, data);
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
                    {
                        LoadRegionSettings(filePath, data);
                    }
                    else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
                    {
                        serialisedParcels.Add(m_utf8Encoding.GetString(data));
                    }
                    else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
                    {
                        LoadControlFile(filePath, data);
                    }
                    else
                    {
                        m_log.Debug("[ARCHIVER]:UNKNOWN PATH: " + filePath);
                    }
                }

                //m_log.Debug("[ARCHIVER]: Reached end of archive");
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[ARCHIVER]: Aborting load with error in archive file {0}.  {1}", filePath, e);
                m_errorMessage += e.ToString();
                m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
                return;
            }
            finally
            {
                archive.Close();
                m_loadStream.Close();
                m_loadStream.Dispose();
            }
            //Reeanble now that we are done
            foreach (IScriptModule module in modules)
            {
                module.Disabled = false;
            }
            //Reset backup too
            if (backup != null)
            {
                backup.LoadingPrims = false;
            }

            //Now back up the prims
            foreach (SceneObjectGroup grp in groupsToBackup)
            {
                //Backup!
                grp.HasGroupChanged = true;
            }

            if (!m_skipAssets)
            {
                if (m_useAsync && !AssetSaverIsRunning)
                {
                    m_threadpool.QueueEvent(SaveAssets, 0);
                }
                else if (!AssetSaverIsRunning)
                {
                    SaveAssets();
                }
            }

            if (!m_skipAssets)
            {
                m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);

                if (failedAssetRestores > 0)
                {
                    m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
                    m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
                }
            }

            // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
            // otherwise, use the master avatar uuid instead

            // Reload serialized parcels
            m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels.  Please wait.", serialisedParcels.Count);
            List <LandData> landData = new List <LandData>();

            foreach (string serialisedParcel in serialisedParcels)
            {
                LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
                if (!ResolveUserUuid(parcel.OwnerID))
                {
                    parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                }
                landData.Add(parcel);
            }
            m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
            //Update the database as well!
            IParcelManagementModule parcelManagementModule = m_scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagementModule != null)
            {
                foreach (LandData parcel in landData)
                {
                    parcelManagementModule.UpdateLandObject(parcel.LocalID, parcel);
                }
            }

            m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);

            //Clean it out
            landData.Clear();
            serialisedParcels.Clear();

            m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive in " + (DateTime.Now - start).Minutes + ":" + (DateTime.Now - start).Seconds);

            m_validUserUuids.Clear();
            m_scene.EventManager.TriggerOarFileLoaded(UUID.Zero.Guid, m_errorMessage);
        }
Пример #30
0
            public void EndLoadModuleFromArchive(IScene scene)
            {
                IBackupModule backup = scene.RequestModuleInterface <IBackupModule> ();

                IScriptModule [] modules = scene.RequestModuleInterfaces <IScriptModule> ();

                //Reeanble now that we are done
                foreach (IScriptModule module in modules)
                {
                    module.Disabled = false;
                }

                //Reset backup too
                if (backup != null)
                {
                    backup.LoadingPrims = false;
                }

                //Update the database as well!
                IParcelManagementModule parcelManagementModule = scene.RequestModuleInterface <IParcelManagementModule> ();

                if (parcelManagementModule != null && !m_merge) //Only if we are not merging
                {
                    if (m_parcels.Count > 0)
                    {
                        scene.EventManager.TriggerIncomingLandDataFromStorage(m_parcels, Vector2.Zero);
                        //Update the database as well!
                        foreach (LandData parcel in m_parcels)
                        {
                            parcelManagementModule.UpdateLandObject(parcelManagementModule.GetLandObject(parcel.LocalID));
                        }
                    }
                    else
                    {
                        parcelManagementModule.ResetSimLandObjects();
                    }

                    m_parcels.Clear();
                }

                foreach (ISceneEntity sceneObject in m_groups)
                {
                    foreach (ISceneChildEntity part in sceneObject.ChildrenEntities())
                    {
                        if (!ResolveUserUuid(part.CreatorID))
                        {
                            part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.OwnerID))
                        {
                            part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        if (!ResolveUserUuid(part.LastOwnerID))
                        {
                            part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
                        }

                        // Fix ownership/creator of inventory items
                        // Not doing so results in inventory items
                        // being no copy/no mod for everyone
                        lock (part.TaskInventory) {
                            TaskInventoryDictionary inv = part.TaskInventory;
                            foreach (KeyValuePair <UUID, TaskInventoryItem> kvp in inv)
                            {
                                if (!ResolveUserUuid(kvp.Value.OwnerID))
                                {
                                    kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                                if (!ResolveUserUuid(kvp.Value.CreatorID))
                                {
                                    kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
                                }
                            }
                        }
                    }

                    if (scene.SceneGraph.AddPrimToScene(sceneObject))
                    {
                        sceneObject.HasGroupChanged = true;
                        sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                        sceneObject.CreateScriptInstances(0, false, StateSource.RegionStart, UUID.Zero, false);
                    }
                }
            }