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.
0.8.0.3
Justin Clark-Casey (justincc) 2014-03-22 00:29:13 +00:00
parent 178a5a5585
commit a5800f479e
2 changed files with 44 additions and 12 deletions

View File

@ -272,7 +272,10 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 lastPhysGroupPos;
private Quaternion lastPhysGroupRot;
private bool m_isBackedUp;
/// <summary>
/// Is this entity set to be saved in persistent storage?
/// </summary>
public bool Backup { get; private set; }
protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>();
@ -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
/// <param name="datastore"></param>
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<OpenMetaverse.UUID, SceneObjectPart>();
// Warning, The following code related to previousAttachmentStatus is needed so that clones of
@ -2537,10 +2540,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="objectGroup"></param>
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)
{
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();
}

View File

@ -57,6 +57,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
}
[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()
{