From aa78df4a79e4e357f8424a0163525c3254b2c146 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 26 Oct 2012 11:22:00 +0100 Subject: Scipt modules get the OpenMetaverse types, so lists passed as arguments to script module functions which then later call LSL_Types.list.GetVector3Item() or LSL_Types.list.GetQuaternionItem() methods would then trigger an InvalidCastException, which is now avoided. --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index fcb98a5..44fdd1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -631,19 +631,44 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSL_Types.Vector3 GetVector3Item(int itemIndex) { - if(m_data[itemIndex] is LSL_Types.Vector3) + if (m_data[itemIndex] is LSL_Types.Vector3) + { return (LSL_Types.Vector3)m_data[itemIndex]; + } + else if(m_data[itemIndex] is OpenMetaverse.Vector3) + { + return new LSL_Types.Vector3( + (OpenMetaverse.Vector3)m_data[itemIndex]); + } else + { throw new InvalidCastException(string.Format( "{0} expected but {1} given", typeof(LSL_Types.Vector3).Name, m_data[itemIndex] != null ? m_data[itemIndex].GetType().Name : "null")); + } } public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) { - return (LSL_Types.Quaternion)m_data[itemIndex]; + if (m_data[itemIndex] is LSL_Types.Quaternion) + { + return (LSL_Types.Quaternion)m_data[itemIndex]; + } + else if(m_data[itemIndex] is OpenMetaverse.Quaternion) + { + return new LSL_Types.Quaternion( + (OpenMetaverse.Quaternion)m_data[itemIndex]); + } + else + { + throw new InvalidCastException(string.Format( + "{0} expected but {1} given", + typeof(LSL_Types.Quaternion).Name, + m_data[itemIndex] != null ? + m_data[itemIndex].GetType().Name : "null")); + } } public LSL_Types.key GetKeyItem(int itemIndex) -- cgit v1.1