diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 0ca5ff3..d501979 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -100,21 +100,32 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
100 | 100 | ||
101 | #region Overriders | 101 | #region Overriders |
102 | 102 | ||
103 | public static implicit operator Boolean(Vector3 vec) | ||
104 | { | ||
105 | if (vec.x != 0) | ||
106 | return true; | ||
107 | if (vec.y != 0) | ||
108 | return true; | ||
109 | if (vec.z != 0) | ||
110 | return true; | ||
111 | return false; | ||
112 | } | ||
113 | |||
103 | public override string ToString() | 114 | public override string ToString() |
104 | { | 115 | { |
105 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | 116 | string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); |
106 | return s; | 117 | return s; |
107 | } | 118 | } |
108 | 119 | ||
109 | public static explicit operator LSLString(Vector3 vec) | 120 | public static explicit operator LSLString(Vector3 vec) |
110 | { | 121 | { |
111 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 122 | string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
112 | return new LSLString(s); | 123 | return new LSLString(s); |
113 | } | 124 | } |
114 | 125 | ||
115 | public static explicit operator string(Vector3 vec) | 126 | public static explicit operator string(Vector3 vec) |
116 | { | 127 | { |
117 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 128 | string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
118 | return s; | 129 | return s; |
119 | } | 130 | } |
120 | 131 | ||
@@ -397,6 +408,18 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
397 | #endregion | 408 | #endregion |
398 | 409 | ||
399 | #region Overriders | 410 | #region Overriders |
411 | public static implicit operator Boolean(Quaternion q) | ||
412 | { | ||
413 | if (q.x != 0) | ||
414 | return true; | ||
415 | if (q.y != 0) | ||
416 | return true; | ||
417 | if (q.z != 0) | ||
418 | return true; | ||
419 | if (q.s != 1.0f) | ||
420 | return true; | ||
421 | return false; | ||
422 | } | ||
400 | 423 | ||
401 | public override int GetHashCode() | 424 | public override int GetHashCode() |
402 | { | 425 | { |
@@ -414,19 +437,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
414 | 437 | ||
415 | public override string ToString() | 438 | public override string ToString() |
416 | { | 439 | { |
417 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | 440 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); |
418 | return st; | 441 | return st; |
419 | } | 442 | } |
420 | 443 | ||
421 | public static explicit operator string(Quaternion r) | 444 | public static explicit operator string(Quaternion r) |
422 | { | 445 | { |
423 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 446 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
424 | return s; | 447 | return s; |
425 | } | 448 | } |
426 | 449 | ||
427 | public static explicit operator LSLString(Quaternion r) | 450 | public static explicit operator LSLString(Quaternion r) |
428 | { | 451 | { |
429 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 452 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
430 | return new LSLString(s); | 453 | return new LSLString(s); |
431 | } | 454 | } |
432 | 455 | ||
@@ -537,7 +560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
537 | else if (o is LSL_Types.LSLFloat) | 560 | else if (o is LSL_Types.LSLFloat) |
538 | size += 8; | 561 | size += 8; |
539 | else if (o is LSL_Types.LSLString) | 562 | else if (o is LSL_Types.LSLString) |
540 | size += ((LSL_Types.LSLString)o).m_string.Length; | 563 | size += ((LSL_Types.LSLString)o).m_string == null ? 0 : ((LSL_Types.LSLString)o).m_string.Length; |
541 | else if (o is LSL_Types.key) | 564 | else if (o is LSL_Types.key) |
542 | size += ((LSL_Types.key)o).value.Length; | 565 | size += ((LSL_Types.key)o).value.Length; |
543 | else if (o is LSL_Types.Vector3) | 566 | else if (o is LSL_Types.Vector3) |
@@ -546,6 +569,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
546 | size += 64; | 569 | size += 64; |
547 | else if (o is int) | 570 | else if (o is int) |
548 | size += 4; | 571 | size += 4; |
572 | else if (o is uint) | ||
573 | size += 4; | ||
549 | else if (o is string) | 574 | else if (o is string) |
550 | size += ((string)o).Length; | 575 | size += ((string)o).Length; |
551 | else if (o is float) | 576 | else if (o is float) |
@@ -719,6 +744,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
719 | Data = tmp; | 744 | Data = tmp; |
720 | } | 745 | } |
721 | 746 | ||
747 | public static implicit operator Boolean(list l) | ||
748 | { | ||
749 | return l.Length != 0; | ||
750 | } | ||
751 | |||
722 | public static list operator +(list a, LSLString s) | 752 | public static list operator +(list a, LSLString s) |
723 | { | 753 | { |
724 | a.ExtendAndAdd(s); | 754 | a.ExtendAndAdd(s); |
@@ -755,7 +785,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
755 | int lb = -1; | 785 | int lb = -1; |
756 | try { la = a.Length; } | 786 | try { la = a.Length; } |
757 | catch (NullReferenceException) { } | 787 | catch (NullReferenceException) { } |
758 | try {lb = b.Length;} | 788 | try { lb = b.Length; } |
759 | catch (NullReferenceException) { } | 789 | catch (NullReferenceException) { } |
760 | 790 | ||
761 | return la != lb; | 791 | return la != lb; |
@@ -1023,6 +1053,9 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1023 | stride = 1; | 1053 | stride = 1; |
1024 | } | 1054 | } |
1025 | 1055 | ||
1056 | if ((Data.Length % stride) != 0) | ||
1057 | return new list(ret); | ||
1058 | |||
1026 | // we can optimize here in the case where stride == 1 and the list | 1059 | // we can optimize here in the case where stride == 1 and the list |
1027 | // consists of homogeneous types | 1060 | // consists of homogeneous types |
1028 | 1061 | ||
@@ -1537,8 +1570,6 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1537 | } | 1570 | } |
1538 | } | 1571 | } |
1539 | 1572 | ||
1540 | |||
1541 | |||
1542 | static public implicit operator String(LSLString s) | 1573 | static public implicit operator String(LSLString s) |
1543 | { | 1574 | { |
1544 | return s.m_string; | 1575 | return s.m_string; |