aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs140
1 files changed, 111 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0bdd84a..525c3c3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3845,7 +3845,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3845 // Single prim 3845 // Single prim
3846 if (m_host.LinkNum == 0) 3846 if (m_host.LinkNum == 0)
3847 { 3847 {
3848 if (linknum == 0) 3848 if (linknum == 0 || linknum == ScriptBaseClass.LINK_ROOT)
3849 return m_host.Name; 3849 return m_host.Name;
3850 else 3850 else
3851 return UUID.Zero.ToString(); 3851 return UUID.Zero.ToString();
@@ -6376,16 +6376,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6376 } 6376 }
6377 } 6377 }
6378 6378
6379 public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) 6379 protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot)
6380 { 6380 {
6381 m_host.AddScriptLPS(1);
6382 // LSL quaternions can normalize to 0, normal Quaternions can't. 6381 // LSL quaternions can normalize to 0, normal Quaternions can't.
6383 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) 6382 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
6384 rot.z = 1; // ZERO_ROTATION = 0,0,0,1 6383 rot.z = 1; // ZERO_ROTATION = 0,0,0,1
6385 6384
6386 m_host.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); 6385 part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
6387 m_host.SitTargetOrientation = Rot2Quaternion(rot); 6386 part.SitTargetOrientation = Rot2Quaternion(rot);
6388 m_host.ParentGroup.HasGroupChanged = true; 6387 part.ParentGroup.HasGroupChanged = true;
6388 }
6389
6390 public void llSitTarget(LSL_Vector offset, LSL_Rotation rot)
6391 {
6392 m_host.AddScriptLPS(1);
6393 SitTarget(m_host, offset, rot);
6394 }
6395
6396 public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot)
6397 {
6398 m_host.AddScriptLPS(1);
6399 if (link == ScriptBaseClass.LINK_ROOT)
6400 SitTarget(m_host.ParentGroup.RootPart, offset, rot);
6401 else if (link == ScriptBaseClass.LINK_THIS)
6402 SitTarget(m_host, offset, rot);
6403 else
6404 {
6405 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
6406 if (null != part)
6407 {
6408 SitTarget(part, offset, rot);
6409 }
6410 }
6389 } 6411 }
6390 6412
6391 public LSL_String llAvatarOnSitTarget() 6413 public LSL_String llAvatarOnSitTarget()
@@ -8151,23 +8173,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8151 { 8173 {
8152 m_host.AddScriptLPS(1); 8174 m_host.AddScriptLPS(1);
8153 ScriptSleep(1000); 8175 ScriptSleep(1000);
8176 return GetPrimMediaParams(m_host, face, rules);
8177 }
8154 8178
8179 public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
8180 {
8181 m_host.AddScriptLPS(1);
8182 ScriptSleep(1000);
8183 if (link == ScriptBaseClass.LINK_ROOT)
8184 return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
8185 else if (link == ScriptBaseClass.LINK_THIS)
8186 return GetPrimMediaParams(m_host, face, rules);
8187 else
8188 {
8189 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
8190 if (null != part)
8191 return GetPrimMediaParams(part, face, rules);
8192 }
8193
8194 return new LSL_List();
8195 }
8196
8197 private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules)
8198 {
8155 // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid 8199 // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
8156 // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). 8200 // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
8157 // Assuming silently fail means give back an empty list. Ideally, need to check this. 8201 // Assuming silently fail means give back an empty list. Ideally, need to check this.
8158 if (face < 0 || face > m_host.GetNumberOfSides() - 1) 8202 if (face < 0 || face > part.GetNumberOfSides() - 1)
8159 return new LSL_List(); 8203 return new LSL_List();
8160 8204
8161 return GetPrimMediaParams(face, rules);
8162 }
8163
8164 private LSL_List GetPrimMediaParams(int face, LSL_List rules)
8165 {
8166 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); 8205 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8167 if (null == module) 8206 if (null == module)
8168 throw new Exception("Media on a prim functions not available"); 8207 return new LSL_List();
8169 8208
8170 MediaEntry me = module.GetMediaEntry(m_host, face); 8209 MediaEntry me = module.GetMediaEntry(part, face);
8171 8210
8172 // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams 8211 // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
8173 if (null == me) 8212 if (null == me)
@@ -8249,33 +8288,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8249 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: 8288 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8250 res.Add(new LSL_Integer((int)me.ControlPermissions)); 8289 res.Add(new LSL_Integer((int)me.ControlPermissions));
8251 break; 8290 break;
8291
8292 default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
8252 } 8293 }
8253 } 8294 }
8254 8295
8255 return res; 8296 return res;
8256 } 8297 }
8257 8298
8258 public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules) 8299 public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules)
8259 { 8300 {
8260 m_host.AddScriptLPS(1); 8301 m_host.AddScriptLPS(1);
8261 ScriptSleep(1000); 8302 ScriptSleep(1000);
8303 return SetPrimMediaParams(m_host, face, rules);
8304 }
8262 8305
8263 // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid 8306 public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
8264 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. 8307 {
8265 // Don't perform the media check directly 8308 m_host.AddScriptLPS(1);
8266 if (face < 0 || face > m_host.GetNumberOfSides() - 1) 8309 ScriptSleep(1000);
8267 return ScriptBaseClass.LSL_STATUS_OK; 8310 if (link == ScriptBaseClass.LINK_ROOT)
8311 return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
8312 else if (link == ScriptBaseClass.LINK_THIS)
8313 return SetPrimMediaParams(m_host, face, rules);
8314 else
8315 {
8316 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
8317 if (null != part)
8318 return SetPrimMediaParams(part, face, rules);
8319 }
8268 8320
8269 return SetPrimMediaParams(face, rules); 8321 return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
8270 } 8322 }
8271 8323
8272 private LSL_Integer SetPrimMediaParams(int face, LSL_List rules) 8324 private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules)
8273 { 8325 {
8326 // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
8327 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
8328 // Don't perform the media check directly
8329 if (face < 0 || face > part.GetNumberOfSides() - 1)
8330 return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
8331
8274 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); 8332 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8275 if (null == module) 8333 if (null == module)
8276 throw new Exception("Media on a prim functions not available"); 8334 return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;
8277 8335
8278 MediaEntry me = module.GetMediaEntry(m_host, face); 8336 MediaEntry me = module.GetMediaEntry(part, face);
8279 if (null == me) 8337 if (null == me)
8280 me = new MediaEntry(); 8338 me = new MediaEntry();
8281 8339
@@ -8354,10 +8412,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8354 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: 8412 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8355 me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); 8413 me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8356 break; 8414 break;
8415
8416 default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
8357 } 8417 }
8358 } 8418 }
8359 8419
8360 module.SetMediaEntry(m_host, face, me); 8420 module.SetMediaEntry(part, face, me);
8361 8421
8362 return ScriptBaseClass.LSL_STATUS_OK; 8422 return ScriptBaseClass.LSL_STATUS_OK;
8363 } 8423 }
@@ -8366,18 +8426,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8366 { 8426 {
8367 m_host.AddScriptLPS(1); 8427 m_host.AddScriptLPS(1);
8368 ScriptSleep(1000); 8428 ScriptSleep(1000);
8429 return ClearPrimMedia(m_host, face);
8430 }
8369 8431
8432 public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face)
8433 {
8434 m_host.AddScriptLPS(1);
8435 ScriptSleep(1000);
8436 if (link == ScriptBaseClass.LINK_ROOT)
8437 return ClearPrimMedia(m_host.ParentGroup.RootPart, face);
8438 else if (link == ScriptBaseClass.LINK_THIS)
8439 return ClearPrimMedia(m_host, face);
8440 else
8441 {
8442 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
8443 if (null != part)
8444 return ClearPrimMedia(part, face);
8445 }
8446
8447 return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
8448 }
8449
8450 private LSL_Integer ClearPrimMedia(SceneObjectPart part, LSL_Integer face)
8451 {
8370 // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid 8452 // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
8371 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. 8453 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
8372 // FIXME: Don't perform the media check directly 8454 // FIXME: Don't perform the media check directly
8373 if (face < 0 || face > m_host.GetNumberOfSides() - 1) 8455 if (face < 0 || face > part.GetNumberOfSides() - 1)
8374 return ScriptBaseClass.LSL_STATUS_OK; 8456 return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
8375 8457
8376 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); 8458 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8377 if (null == module) 8459 if (null == module)
8378 throw new Exception("Media on a prim functions not available"); 8460 return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;
8379 8461
8380 module.ClearMediaEntry(m_host, face); 8462 module.ClearMediaEntry(part, face);
8381 8463
8382 return ScriptBaseClass.LSL_STATUS_OK; 8464 return ScriptBaseClass.LSL_STATUS_OK;
8383 } 8465 }