aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-12 00:14:06 +0100
committerJustin Clark-Casey (justincc)2011-08-12 00:14:06 +0100
commit0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09 (patch)
treec88a450a101b792e9faaa2b7761c4cf47bf681c8 /OpenSim/Region/ScriptEngine/Shared
parentimplement osNpcGetPos() (diff)
downloadopensim-SC_OLD-0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09.zip
opensim-SC_OLD-0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09.tar.gz
opensim-SC_OLD-0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09.tar.bz2
opensim-SC_OLD-0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09.tar.xz
Allow the osNpcCreate() function to accept a notecard name or asset for initial appearance
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs4
2 files changed, 26 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b1066b5..90c4636 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2130,20 +2130,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2130 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) 2130 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
2131 { 2131 {
2132 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 2132 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
2133 //QueueUserWorkItem
2134 2133
2135 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2134 INPCModule module = World.RequestModuleInterface<INPCModule>();
2136 if (module != null) 2135 if (module != null)
2137 { 2136 {
2138 ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); 2137 AvatarAppearance appearance = null;
2139 if (clonePresence == null) 2138
2139 UUID cloneId;
2140 if (UUID.TryParse(cloneFrom, out cloneId))
2141 {
2142 ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string));
2143 if (clonePresence != null)
2144 appearance = clonePresence.Appearance;
2145 }
2146
2147 if (appearance == null)
2148 {
2149 string appearanceSerialized = LoadNotecard(cloneFrom.m_string);
2150
2151 if (appearanceSerialized != null)
2152 {
2153 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2154 appearance = new AvatarAppearance();
2155 appearance.Unpack(appearanceOsd);
2156 }
2157 }
2158
2159 if (appearance == null)
2140 return new LSL_Key(UUID.Zero.ToString()); 2160 return new LSL_Key(UUID.Zero.ToString());
2141 2161
2142 UUID x = module.CreateNPC(firstname, 2162 UUID x = module.CreateNPC(firstname,
2143 lastname, 2163 lastname,
2144 new Vector3((float) position.x, (float) position.y, (float) position.z), 2164 new Vector3((float) position.x, (float) position.y, (float) position.z),
2145 World, 2165 World,
2146 clonePresence.Appearance); 2166 appearance);
2147 2167
2148 return new LSL_Key(x.ToString()); 2168 return new LSL_Key(x.ToString());
2149 } 2169 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index 85cf507..7573dff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -78,11 +78,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
78 /// <summary> 78 /// <summary>
79 /// Test creation of an NPC where the appearance data comes from a notecard 79 /// Test creation of an NPC where the appearance data comes from a notecard
80 /// </summary> 80 /// </summary>
81 //[Test] 81 [Test]
82 public void TestOsNpcCreateFromNotecard() 82 public void TestOsNpcCreateFromNotecard()
83 { 83 {
84 TestHelpers.InMethod(); 84 TestHelpers.InMethod();
85 log4net.Config.XmlConfigurator.Configure(); 85// log4net.Config.XmlConfigurator.Configure();
86 86
87 // Store an avatar with a different height from default in a notecard. 87 // Store an avatar with a different height from default in a notecard.
88 UUID userId = TestHelpers.ParseTail(0x1); 88 UUID userId = TestHelpers.ParseTail(0x1);