mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Implement osAgentSaveAppearance() to save the appearance of an avatar in the region to a notecard
This is separate from osOwnerSaveAppearance() so that owner saves can be allowed without allowing arbitrary avatar saves
This commit is contained in:
@@ -184,5 +184,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
|
||||
Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsAgentSaveAppearance()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UUID ownerId = TestHelpers.ParseTail(0x1);
|
||||
UUID nonOwnerId = TestHelpers.ParseTail(0x2);
|
||||
float newHeight = 1.9f;
|
||||
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
|
||||
sp.Appearance.AvatarHeight = newHeight;
|
||||
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
|
||||
SceneObjectPart part = so.RootPart;
|
||||
m_scene.AddSceneObject(so);
|
||||
|
||||
OSSL_Api osslApi = new OSSL_Api();
|
||||
osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
|
||||
|
||||
string notecardName = "appearanceNc";
|
||||
|
||||
osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName);
|
||||
|
||||
IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
|
||||
Assert.That(items.Count, Is.EqualTo(1));
|
||||
|
||||
TaskInventoryItem ncItem = items[0];
|
||||
Assert.That(ncItem.Name, Is.EqualTo(notecardName));
|
||||
|
||||
AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
|
||||
Assert.That(ncAsset, Is.Not.Null);
|
||||
|
||||
AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
|
||||
anc.Decode();
|
||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
|
||||
AvatarAppearance savedAppearance = new AvatarAppearance();
|
||||
savedAppearance.Unpack(appearanceOsd);
|
||||
|
||||
Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user