aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-11 22:26:47 +0100
committerJustin Clark-Casey (justincc)2011-08-11 22:26:47 +0100
commitb1ae930c6b8e7d985e2c148a4e18a59ac880dcbd (patch)
tree22bcbbd9275672651699420ee0b4f347ec2c8c8f /OpenSim
parentadd regression test for osNpcCreate when cloning an in-region avatar (diff)
downloadopensim-SC_OLD-b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd.zip
opensim-SC_OLD-b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd.tar.gz
opensim-SC_OLD-b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd.tar.bz2
opensim-SC_OLD-b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd.tar.xz
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
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs41
4 files changed, 78 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b18aa3b..939602a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2165,7 +2165,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2165 2165
2166 if (npcModule != null) 2166 if (npcModule != null)
2167 { 2167 {
2168 UUID npcId = new UUID(npc.m_string); 2168 UUID npcId;
2169 if (!UUID.TryParse(npc.m_string, out npcId))
2170 return new LSL_Key(UUID.Zero.ToString());
2169 2171
2170 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) 2172 if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
2171 return new LSL_Key(UUID.Zero.ToString()); 2173 return new LSL_Key(UUID.Zero.ToString());
@@ -2273,14 +2275,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2273 return SaveAppearanceToNotecard(m_host.OwnerID, notecardName); 2275 return SaveAppearanceToNotecard(m_host.OwnerID, notecardName);
2274 } 2276 }
2275 2277
2276 protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName) 2278 public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecardName)
2279 {
2280 CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
2281
2282 return SaveAppearanceToNotecard(avatarId, notecardName);
2283 }
2284
2285 protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecardName)
2277 { 2286 {
2278 IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>(); 2287 IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
2279 2288
2280 if (appearanceModule != null) 2289 if (appearanceModule != null)
2281 { 2290 {
2282 appearanceModule.SaveBakedTextures(m_host.OwnerID); 2291 appearanceModule.SaveBakedTextures(sp.UUID);
2283 ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
2284 OSDMap appearancePacked = sp.Appearance.Pack(); 2292 OSDMap appearancePacked = sp.Appearance.Pack();
2285 2293
2286 TaskInventoryItem item 2294 TaskInventoryItem item
@@ -2293,6 +2301,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2293 return new LSL_Key(UUID.Zero.ToString()); 2301 return new LSL_Key(UUID.Zero.ToString());
2294 } 2302 }
2295 } 2303 }
2304
2305 protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
2306 {
2307 ScenePresence sp = World.GetScenePresence(avatarId);
2308
2309 if (sp == null || sp.IsChildAgent)
2310 return new LSL_Key(UUID.Zero.ToString());
2311
2312 return SaveAppearanceToNotecard(sp, notecardName);
2313 }
2314
2315 protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecardName)
2316 {
2317 UUID avatarId;
2318 if (!UUID.TryParse(rawAvatarId, out avatarId))
2319 return new LSL_Key(UUID.Zero.ToString());
2320
2321 return SaveAppearanceToNotecard(avatarId, notecardName);
2322 }
2296 2323
2297 /// <summary> 2324 /// <summary>
2298 /// Get current region's map texture UUID 2325 /// Get current region's map texture UUID
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index f4a618b..88e1f15 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -168,7 +168,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
168 168
169 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); 169 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
170 170
171
172 key osNpcCreate(string user, string name, vector position, key cloneFrom); 171 key osNpcCreate(string user, string name, vector position, key cloneFrom);
173 LSL_Key osNpcSaveAppearance(key npc, string notecardName); 172 LSL_Key osNpcSaveAppearance(key npc, string notecardName);
174 void osNpcLoadAppearance(key npc, string notecardNameOrUuid); 173 void osNpcLoadAppearance(key npc, string notecardNameOrUuid);
@@ -179,6 +178,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
179 void osNpcRemove(key npc); 178 void osNpcRemove(key npc);
180 179
181 LSL_Key osOwnerSaveAppearance(string notecardName); 180 LSL_Key osOwnerSaveAppearance(string notecardName);
181 LSL_Key osAgentSaveAppearance(key agentId, string notecardName);
182 182
183 key osGetMapTexture(); 183 key osGetMapTexture();
184 key osGetRegionMapTexture(string regionName); 184 key osGetRegionMapTexture(string regionName);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 84d61f4..4701736 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -523,6 +523,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
523 return m_OSSL_Functions.osOwnerSaveAppearance(notecardName); 523 return m_OSSL_Functions.osOwnerSaveAppearance(notecardName);
524 } 524 }
525 525
526 public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecardName)
527 {
528 return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecardName);
529 }
530
526 public OSSLPrim Prim; 531 public OSSLPrim Prim;
527 532
528 [Serializable] 533 [Serializable]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index 7f778d7..85cf507 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -184,5 +184,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
184 184
185 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); 185 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
186 } 186 }
187
188 [Test]
189 public void TestOsAgentSaveAppearance()
190 {
191 TestHelpers.InMethod();
192// log4net.Config.XmlConfigurator.Configure();
193
194 UUID ownerId = TestHelpers.ParseTail(0x1);
195 UUID nonOwnerId = TestHelpers.ParseTail(0x2);
196 float newHeight = 1.9f;
197
198 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
199 sp.Appearance.AvatarHeight = newHeight;
200 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
201 SceneObjectPart part = so.RootPart;
202 m_scene.AddSceneObject(so);
203
204 OSSL_Api osslApi = new OSSL_Api();
205 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
206
207 string notecardName = "appearanceNc";
208
209 osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName);
210
211 IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
212 Assert.That(items.Count, Is.EqualTo(1));
213
214 TaskInventoryItem ncItem = items[0];
215 Assert.That(ncItem.Name, Is.EqualTo(notecardName));
216
217 AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
218 Assert.That(ncAsset, Is.Not.Null);
219
220 AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
221 anc.Decode();
222 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
223 AvatarAppearance savedAppearance = new AvatarAppearance();
224 savedAppearance.Unpack(appearanceOsd);
225
226 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
227 }
187 } 228 }
188} \ No newline at end of file 229} \ No newline at end of file