aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-08-13 19:20:47 +0100
committerMelanie2012-08-13 19:20:47 +0100
commit2a5077ef7e406b723142639c01705ee87f75ea77 (patch)
treed6275d7fd82ca70cdcbadd9fce5210e1eea23171 /OpenSim
parentMerge branch 'master' into careminster (diff)
parentattempt at replicating behaviour of llList2thing functions in SL (diff)
downloadopensim-SC_OLD-2a5077ef7e406b723142639c01705ee87f75ea77.zip
opensim-SC_OLD-2a5077ef7e406b723142639c01705ee87f75ea77.tar.gz
opensim-SC_OLD-2a5077ef7e406b723142639c01705ee87f75ea77.tar.bz2
opensim-SC_OLD-2a5077ef7e406b723142639c01705ee87f75ea77.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs74
1 files changed, 68 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7237d1d..8cbebbb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5375,12 +5375,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5375 { 5375 {
5376 return 0; 5376 return 0;
5377 } 5377 }
5378
5379 // Vectors & Rotations always return zero in SL, but
5380 // keys don't always return zero, it seems to be a bit complex.
5381 else if (src.Data[index] is LSL_Vector ||
5382 src.Data[index] is LSL_Rotation)
5383 {
5384 return 0;
5385 }
5378 try 5386 try
5379 { 5387 {
5388
5380 if (src.Data[index] is LSL_Integer) 5389 if (src.Data[index] is LSL_Integer)
5381 return (LSL_Integer) src.Data[index]; 5390 return (LSL_Integer)src.Data[index];
5382 else if (src.Data[index] is LSL_Float) 5391 else if (src.Data[index] is LSL_Float)
5383 return Convert.ToInt32(((LSL_Float) src.Data[index]).value); 5392 return Convert.ToInt32(((LSL_Float)src.Data[index]).value);
5384 return new LSL_Integer(src.Data[index].ToString()); 5393 return new LSL_Integer(src.Data[index].ToString());
5385 } 5394 }
5386 catch (FormatException) 5395 catch (FormatException)
@@ -5400,12 +5409,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5400 { 5409 {
5401 return 0.0; 5410 return 0.0;
5402 } 5411 }
5412
5413 // Vectors & Rotations always return zero in SL
5414 else if (src.Data[index] is LSL_Vector ||
5415 src.Data[index] is LSL_Rotation)
5416 {
5417 return 0;
5418 }
5419 // valid keys seem to get parsed as integers then converted to floats
5420 else
5421 {
5422 UUID uuidt;
5423 if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt))
5424 {
5425 return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value);
5426 }
5427 }
5403 try 5428 try
5404 { 5429 {
5405 if (src.Data[index] is LSL_Integer) 5430 if (src.Data[index] is LSL_Integer)
5406 return Convert.ToDouble(((LSL_Integer) src.Data[index]).value); 5431 return Convert.ToDouble(((LSL_Integer)src.Data[index]).value);
5407 else if (src.Data[index] is LSL_Float) 5432 else if (src.Data[index] is LSL_Float)
5408 return Convert.ToDouble(((LSL_Float) src.Data[index]).value); 5433 return Convert.ToDouble(((LSL_Float)src.Data[index]).value);
5409 else if (src.Data[index] is LSL_String) 5434 else if (src.Data[index] is LSL_String)
5410 { 5435 {
5411 string str = ((LSL_String) src.Data[index]).m_string; 5436 string str = ((LSL_String) src.Data[index]).m_string;
@@ -5443,17 +5468,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5443 return src.Data[index].ToString(); 5468 return src.Data[index].ToString();
5444 } 5469 }
5445 5470
5446 public LSL_String llList2Key(LSL_List src, int index) 5471 public LSL_Key llList2Key(LSL_List src, int index)
5447 { 5472 {
5448 m_host.AddScriptLPS(1); 5473 m_host.AddScriptLPS(1);
5449 if (index < 0) 5474 if (index < 0)
5450 { 5475 {
5451 index = src.Length + index; 5476 index = src.Length + index;
5452 } 5477 }
5478
5453 if (index >= src.Length || index < 0) 5479 if (index >= src.Length || index < 0)
5454 { 5480 {
5455 return ""; 5481 return "";
5456 } 5482 }
5483
5484 // SL spits out an empty string for types other than key & string
5485 // At the time of patching, LSL_Key is currently LSL_String,
5486 // so the OR check may be a little redundant, but it's being done
5487 // for completion and should LSL_Key ever be implemented
5488 // as it's own struct
5489 else if (!(src.Data[index] is LSL_String ||
5490 src.Data[index] is LSL_Key))
5491 {
5492 return "";
5493 }
5494
5457 return src.Data[index].ToString(); 5495 return src.Data[index].ToString();
5458 } 5496 }
5459 5497
@@ -5472,6 +5510,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5472 { 5510 {
5473 return (LSL_Vector)src.Data[index]; 5511 return (LSL_Vector)src.Data[index];
5474 } 5512 }
5513
5514 // SL spits always out ZERO_VECTOR for anything other than
5515 // strings or vectors. Although keys always return ZERO_VECTOR,
5516 // it is currently difficult to make the distinction between
5517 // a string, a key as string and a string that by coincidence
5518 // is a string, so we're going to leave that up to the
5519 // LSL_Vector constructor.
5520 else if (!(src.Data[index] is LSL_String ||
5521 src.Data[index] is LSL_Vector))
5522 {
5523 return new LSL_Vector(0, 0, 0);
5524 }
5475 else 5525 else
5476 { 5526 {
5477 return new LSL_Vector(src.Data[index].ToString()); 5527 return new LSL_Vector(src.Data[index].ToString());
@@ -5489,7 +5539,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5489 { 5539 {
5490 return new LSL_Rotation(0, 0, 0, 1); 5540 return new LSL_Rotation(0, 0, 0, 1);
5491 } 5541 }
5492 if (src.Data[index].GetType() == typeof(LSL_Rotation)) 5542
5543 // SL spits always out ZERO_ROTATION for anything other than
5544 // strings or vectors. Although keys always return ZERO_ROTATION,
5545 // it is currently difficult to make the distinction between
5546 // a string, a key as string and a string that by coincidence
5547 // is a string, so we're going to leave that up to the
5548 // LSL_Rotation constructor.
5549 else if (!(src.Data[index] is LSL_String ||
5550 src.Data[index] is LSL_Rotation))
5551 {
5552 return new LSL_Rotation(0, 0, 0, 1);
5553 }
5554 else if (src.Data[index].GetType() == typeof(LSL_Rotation))
5493 { 5555 {
5494 return (LSL_Rotation)src.Data[index]; 5556 return (LSL_Rotation)src.Data[index];
5495 } 5557 }