From 94c7e41ef1978a5be21e1a063c68ffc1c8a89b97 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 10 Aug 2007 13:59:19 +0000 Subject: Made a few changes so that once we enable the sqlite data store (simple line change in OpenSimMain), then basic ( with a few limits at moment) prim database backup will work. --- OpenSim/Region/Environment/Scenes/Scene.cs | 33 +++++++------ .../Region/Environment/Scenes/SceneObjectGroup.cs | 56 ++++++++++++++++++++-- .../Region/Environment/Scenes/SceneObjectPart.cs | 8 ++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 1 + 4 files changed, 80 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index c2eac60..ef7346d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -151,15 +151,6 @@ namespace OpenSim.Region.Environment.Scenes Avatars = new Dictionary(); Prims = new Dictionary(); - MainLog.Instance.Verbose("Loading objects from datastore"); - List PrimsFromDB = storageManager.DataStore.LoadObjects(); - foreach (SceneObjectGroup prim in PrimsFromDB) - { - AddEntity(prim); - } - MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)"); - - MainLog.Instance.Verbose("Creating LandMap"); Terrain = new TerrainEngine((int)this.RegionInfo.RegionLocX, (int)this.RegionInfo.RegionLocY); @@ -238,7 +229,7 @@ namespace OpenSim.Region.Environment.Scenes //backup scene data storageCount++; - if (storageCount > 1200) //set to how often you want to backup + if (storageCount > 600) //set to how often you want to backup { Backup(); storageCount = 0; @@ -462,12 +453,13 @@ namespace OpenSim.Region.Environment.Scenes /// public void LoadPrimsFromStorage() { - MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); - List NewObjectsList = storageManager.DataStore.LoadObjects(); - foreach (SceneObjectGroup obj in NewObjectsList) + MainLog.Instance.Verbose("Loading objects from datastore"); + List PrimsFromDB = storageManager.DataStore.LoadObjects(); + foreach (SceneObjectGroup prim in PrimsFromDB) { - this.Objects.Add(obj.UUID, obj); + AddEntityFromStorage(prim); } + MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)"); } /// @@ -520,6 +512,17 @@ namespace OpenSim.Region.Environment.Scenes } } + public void AddEntityFromStorage(SceneObjectGroup sceneObject) + { + sceneObject.RegionHandle = this.m_regionHandle; + sceneObject.SetScene(this); + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + part.LocalID = this.PrimIDAllocate(); + } + this.AddEntity(sceneObject); + } + public void AddEntity(SceneObjectGroup sceneObject) { Entities.Add(sceneObject.UUID, sceneObject); @@ -781,7 +784,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - // ((SceneObject) ent).SendAllChildPrimsToClient(client); + ((SceneObjectGroup) ent).SendFullUpdateToClient(client); } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 78dd69c..8b761f6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -44,6 +44,27 @@ namespace OpenSim.Region.Environment.Scenes set { m_parts = value; } } + public SceneObjectPart RootPart + { + set { m_rootPart = value; } + } + + public ulong RegionHandle + { + get { return m_regionHandle; } + set + { + m_regionHandle = value; + lock (this.m_parts) + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.RegionHandle = m_regionHandle; + } + } + } + } + public override LLVector3 Pos { get { return m_rootPart.GroupPosition; } @@ -79,9 +100,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// Added because the Parcel code seems to use it /// but not sure a object should have this - /// as what does it tell us? that some avatar has selected it + /// as what does it tell us? that some avatar has selected it (but not what Avatar/user) /// think really there should be a list (or whatever) in each scenepresence - /// saying what prim(s) that user has selected at any time. + /// saying what prim(s) that user has selected. /// protected bool m_isSelected = false; public bool IsSelected @@ -114,7 +135,7 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = regionHandle; m_scene = scene; - this.Pos = pos; + // this.Pos = pos; LLVector3 rootOffset = new LLVector3(0, 0, 0); SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset); this.m_parts.Add(newPart.UUID, newPart); @@ -136,6 +157,7 @@ namespace OpenSim.Region.Environment.Scenes dupe.m_regionHandle = this.m_regionHandle; dupe.CopyRootPart(this.m_rootPart); + m_scene.EventManager.OnBackup += dupe.ProcessBackup; foreach (SceneObjectPart part in this.m_parts.Values) { @@ -148,6 +170,23 @@ namespace OpenSim.Region.Environment.Scenes } /// + /// Added as a way for the storage provider to reset the scene, + /// most likely a better way to do this sort of thing but for now... + /// + /// + public void SetScene(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnBackup += this.ProcessBackup; + } + + public void AddPart(SceneObjectPart part) + { + part.SetParent(this); + this.m_parts.Add(part.UUID, part); + } + + /// /// /// /// @@ -619,6 +658,17 @@ namespace OpenSim.Region.Environment.Scenes return m_scene.RequestAvatarList(); } + public void SendFullUpdateToClient(IClientAPI remoteClient) + { + lock (this.m_parts) + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + this.SendPartFullUpdate(remoteClient, part); + } + } + } + /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 5e62082..1b373aa 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -249,6 +249,14 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + /// + /// + /// + public void SetParent(SceneObjectGroup parent) + { + m_parentGroup = parent; + } + #region Copying /// /// diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index b021b44..114623a 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -556,6 +556,7 @@ namespace OpenSim.Region.Environment.Scenes } } #endregion + #region Border Crossing Methods /// /// -- cgit v1.1