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.cs271
1 files changed, 248 insertions, 23 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 236458c..a711ebf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2111,7 +2111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2111 return; 2111 return;
2112 2112
2113 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2113 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
2114 LSL_Vector currentPos = llGetLocalPos(); 2114 LSL_Vector currentPos = GetPartLocalPos(part);
2115 2115
2116 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); 2116 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
2117 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); 2117 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
@@ -2144,33 +2144,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2144 public LSL_Vector llGetLocalPos() 2144 public LSL_Vector llGetLocalPos()
2145 { 2145 {
2146 m_host.AddScriptLPS(1); 2146 m_host.AddScriptLPS(1);
2147 if (m_host.IsAttachment == true) { 2147 return GetPartLocalPos(m_host);
2148 if (m_host.IsRoot == true) 2148 }
2149 {
2150 return new LSL_Vector(m_host.AbsolutePosition.X,
2151 m_host.AbsolutePosition.Y,
2152 m_host.AbsolutePosition.Z);
2153
2154 }
2155 else
2156 {
2157 return new LSL_Vector(m_host.OffsetPosition.X,
2158 m_host.OffsetPosition.Y,
2159 m_host.OffsetPosition.Z);
2160 }
2161 }
2162 2149
2163 if (m_host.ParentID != 0) 2150 protected LSL_Vector GetPartLocalPos(SceneObjectPart part)
2151 {
2152 m_host.AddScriptLPS(1);
2153 if (part.ParentID != 0)
2164 { 2154 {
2165 return new LSL_Vector(m_host.OffsetPosition.X, 2155 return new LSL_Vector(part.OffsetPosition.X,
2166 m_host.OffsetPosition.Y, 2156 part.OffsetPosition.Y,
2167 m_host.OffsetPosition.Z); 2157 part.OffsetPosition.Z);
2168 } 2158 }
2169 else 2159 else
2170 { 2160 {
2171 return new LSL_Vector(m_host.AbsolutePosition.X, 2161 return new LSL_Vector(part.AbsolutePosition.X,
2172 m_host.AbsolutePosition.Y, 2162 part.AbsolutePosition.Y,
2173 m_host.AbsolutePosition.Z); 2163 part.AbsolutePosition.Z);
2174 } 2164 }
2175 } 2165 }
2176 2166
@@ -8300,6 +8290,241 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8300 return res; 8290 return res;
8301 } 8291 }
8302 8292
8293 public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
8294 {
8295 m_host.AddScriptLPS(1);
8296 ScriptSleep(1000);
8297
8298 // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
8299 // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
8300 // Assuming silently fail means give back an empty list. Ideally, need to check this.
8301 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
8302 return new LSL_List();
8303
8304 return GetPrimMediaParams(face, rules);
8305 }
8306
8307 private LSL_List GetPrimMediaParams(int face, LSL_List rules)
8308 {
8309 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8310 if (null == module)
8311 throw new Exception("Media on a prim functions not available");
8312
8313 MediaEntry me = module.GetMediaEntry(m_host, face);
8314
8315 // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
8316 if (null == me)
8317 return new LSL_List();
8318
8319 LSL_List res = new LSL_List();
8320
8321 for (int i = 0; i < rules.Length; i++)
8322 {
8323 int code = (int)rules.GetLSLIntegerItem(i);
8324
8325 switch (code)
8326 {
8327 case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
8328 // Not implemented
8329 res.Add(new LSL_Integer(0));
8330 break;
8331
8332 case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
8333 if (me.Controls == MediaControls.Standard)
8334 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
8335 else
8336 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
8337 break;
8338
8339 case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
8340 res.Add(new LSL_String(me.CurrentURL));
8341 break;
8342
8343 case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
8344 res.Add(new LSL_String(me.HomeURL));
8345 break;
8346
8347 case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
8348 res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8349 break;
8350
8351 case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
8352 res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8353 break;
8354
8355 case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
8356 res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8357 break;
8358
8359 case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
8360 res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8361 break;
8362
8363 case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
8364 res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8365 break;
8366
8367 case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
8368 res.Add(new LSL_Integer(me.Width));
8369 break;
8370
8371 case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
8372 res.Add(new LSL_Integer(me.Height));
8373 break;
8374
8375 case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
8376 res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
8377 break;
8378
8379 case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
8380 string[] urls = (string[])me.WhiteList.Clone();
8381
8382 for (int j = 0; j < urls.Length; j++)
8383 urls[j] = Uri.EscapeDataString(urls[j]);
8384
8385 res.Add(new LSL_String(string.Join(", ", urls)));
8386 break;
8387
8388 case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
8389 res.Add(new LSL_Integer((int)me.InteractPermissions));
8390 break;
8391
8392 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8393 res.Add(new LSL_Integer((int)me.ControlPermissions));
8394 break;
8395 }
8396 }
8397
8398 return res;
8399 }
8400
8401 public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
8402 {
8403 m_host.AddScriptLPS(1);
8404 ScriptSleep(1000);
8405
8406 // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
8407 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
8408 // Don't perform the media check directly
8409 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
8410 return ScriptBaseClass.LSL_STATUS_OK;
8411
8412 return SetPrimMediaParams(face, rules);
8413 }
8414
8415 private LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
8416 {
8417 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8418 if (null == module)
8419 throw new Exception("Media on a prim functions not available");
8420
8421 MediaEntry me = module.GetMediaEntry(m_host, face);
8422 if (null == me)
8423 me = new MediaEntry();
8424
8425 int i = 0;
8426
8427 while (i < rules.Length - 1)
8428 {
8429 int code = rules.GetLSLIntegerItem(i++);
8430
8431 switch (code)
8432 {
8433 case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
8434 me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
8435 break;
8436
8437 case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
8438 int v = rules.GetLSLIntegerItem(i++);
8439 if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
8440 me.Controls = MediaControls.Standard;
8441 else
8442 me.Controls = MediaControls.Mini;
8443 break;
8444
8445 case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
8446 me.CurrentURL = rules.GetLSLStringItem(i++);
8447 break;
8448
8449 case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
8450 me.HomeURL = rules.GetLSLStringItem(i++);
8451 break;
8452
8453 case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
8454 me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8455 break;
8456
8457 case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
8458 me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8459 break;
8460
8461 case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
8462 me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8463 break;
8464
8465 case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
8466 me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8467 break;
8468
8469 case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
8470 me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8471 break;
8472
8473 case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
8474 me.Width = (int)rules.GetLSLIntegerItem(i++);
8475 break;
8476
8477 case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
8478 me.Height = (int)rules.GetLSLIntegerItem(i++);
8479 break;
8480
8481 case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
8482 me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8483 break;
8484
8485 case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
8486 string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
8487 List<string> whiteListUrls = new List<string>();
8488 Array.ForEach(
8489 rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
8490 me.WhiteList = whiteListUrls.ToArray();
8491 break;
8492
8493 case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
8494 me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8495 break;
8496
8497 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8498 me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8499 break;
8500 }
8501 }
8502
8503 module.SetMediaEntry(m_host, face, me);
8504
8505 return ScriptBaseClass.LSL_STATUS_OK;
8506 }
8507
8508 public LSL_Integer llClearPrimMedia(LSL_Integer face)
8509 {
8510 m_host.AddScriptLPS(1);
8511 ScriptSleep(1000);
8512
8513 // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
8514 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
8515 // FIXME: Don't perform the media check directly
8516 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
8517 return ScriptBaseClass.LSL_STATUS_OK;
8518
8519 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8520 if (null == module)
8521 throw new Exception("Media on a prim functions not available");
8522
8523 module.ClearMediaEntry(m_host, face);
8524
8525 return ScriptBaseClass.LSL_STATUS_OK;
8526 }
8527
8303 // <remarks> 8528 // <remarks>
8304 // <para> 8529 // <para>
8305 // The .NET definition of base 64 is: 8530 // The .NET definition of base 64 is: