From 86a429bc44b6fc503b3303a946d088d796d5c530 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 24 Dec 2009 18:18:14 +0100 Subject: Add the LSL List Size property --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 3f38bb6..faf9c40 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -422,13 +422,52 @@ namespace OpenSim.Region.ScriptEngine.Shared public int Length { - get { + get + { if (m_data == null) m_data=new Object[0]; return m_data.Length; } } + public int Size + { + get + { + if (m_data == null) + m_data=new Object[0]; + + int size = 0; + + foreach (Object o in m_data) + { + if (o is LSL_Types.LSLInteger) + size += 4; + else if (o is LSL_Types.LSLFloat) + size += 8; + else if (o is LSL_Types.LSLString) + size += ((LSL_Types.LSLString)o).m_string.Length; + else if (o is LSL_Types.key) + size += ((LSL_Types.key)o).value.Length; + else if (o is LSL_Types.Vector3) + size += 32; + else if (o is LSL_Types.Quaternion) + size += 64; + else if (o is int) + size += 4; + else if (o is string) + size += ((string)o).Length; + else if (o is float) + size += 8; + else if (o is double) + size += 16; + else + throw new Exception("Unknown type in List.Size: " + o.GetType().ToString()); + } + return size; + } + } + public object[] Data { get { -- cgit v1.1