From a5800f479e7b784a3b1cbba51fdab0a5b872a9d2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 22 Mar 2014 00:29:13 +0000
Subject: If an object has it's temporary flag unset after being set, put it
back in the persistence list.
Effectively uses the patch in http://opensimulator.org/mantis/view.php?id=7060
But also adds a regression test and exposes the necessary property to allow this to work.
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 37 +++++++++++++++-------
.../Scenes/Tests/SceneObjectStatusTests.cs | 19 +++++++++++
2 files changed, 44 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 73a30f3..567c6ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -272,7 +272,10 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 lastPhysGroupPos;
private Quaternion lastPhysGroupRot;
- private bool m_isBackedUp;
+ ///
+ /// Is this entity set to be saved in persistent storage?
+ ///
+ public bool Backup { get; private set; }
protected MapAndArray m_parts = new MapAndArray();
@@ -882,10 +885,10 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Attaching object {0} {1} to scene presistence sweep", Name, UUID);
- if (!m_isBackedUp)
+ if (!Backup)
m_scene.EventManager.OnBackup += ProcessBackup;
- m_isBackedUp = true;
+ Backup = true;
}
}
@@ -1555,7 +1558,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public virtual void ProcessBackup(ISimulationDataService datastore, bool forcedBackup)
{
- if (!m_isBackedUp)
+ if (!Backup)
{
// m_log.DebugFormat(
// "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID);
@@ -1677,7 +1680,7 @@ namespace OpenSim.Region.Framework.Scenes
public SceneObjectGroup Copy(bool userExposed)
{
SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone();
- dupe.m_isBackedUp = false;
+ dupe.Backup = false;
dupe.m_parts = new MapAndArray();
// Warning, The following code related to previousAttachmentStatus is needed so that clones of
@@ -2537,10 +2540,10 @@ namespace OpenSim.Region.Framework.Scenes
///
public virtual void DetachFromBackup()
{
- if (m_isBackedUp && Scene != null)
+ if (Backup && Scene != null)
m_scene.EventManager.OnBackup -= ProcessBackup;
- m_isBackedUp = false;
+ Backup = false;
}
// This links an SOP from a previous linkset into my linkset.
@@ -2816,12 +2819,22 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart selectionPart = GetPart(localID);
- if (SetTemporary && Scene != null)
+ if (Scene != null)
{
- DetachFromBackup();
- // Remove from database and parcel prim count
- //
- m_scene.DeleteFromStorage(UUID);
+ if (SetTemporary)
+ {
+ DetachFromBackup();
+ // Remove from database and parcel prim count
+ //
+ m_scene.DeleteFromStorage(UUID);
+ }
+ else if (!Backup)
+ {
+ // Previously been temporary now switching back so make it
+ // available for persisting again
+ AttachToBackup();
+ }
+
m_scene.EventManager.TriggerParcelPrimCountTainted();
}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 8eb3191..6985766 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -58,6 +58,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
}
[Test]
+ public void TestSetTemporary()
+ {
+ TestHelpers.InMethod();
+
+ m_scene.AddSceneObject(m_so1);
+ m_so1.ScriptSetTemporaryStatus(true);
+
+ // Is this really the correct flag?
+ Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
+ Assert.That(m_so1.Backup, Is.False);
+
+ // Test setting back to non-temporary
+ m_so1.ScriptSetTemporaryStatus(false);
+
+ Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
+ Assert.That(m_so1.Backup, Is.True);
+ }
+
+ [Test]
public void TestSetPhantomSinglePrim()
{
TestHelpers.InMethod();
--
cgit v1.1