Just replace all m_data accesses with accesses to Data, which is

protected against nullrefs
0.8.2-post-fixes
Melanie Thielker 2015-08-24 00:08:08 +02:00
parent a9beee7050
commit 87247dc2c9
1 changed files with 62 additions and 62 deletions

View File

@ -581,7 +581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
/// <param name='itemIndex'></param>
public Type GetLSLListItemType(int itemIndex)
{
return m_data[itemIndex].GetType();
return Data[itemIndex].GetType();
}
/// <summary>
@ -598,107 +598,107 @@ namespace OpenSim.Region.ScriptEngine.Shared
/// <param name='itemIndex'></param>
public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex)
{
if (m_data[itemIndex] is LSL_Types.LSLInteger)
if (Data[itemIndex] is LSL_Types.LSLInteger)
{
return (LSL_Types.LSLInteger)m_data[itemIndex];
return (LSL_Types.LSLInteger)Data[itemIndex];
}
else if (m_data[itemIndex] is Int32)
else if (Data[itemIndex] is Int32)
{
return new LSL_Types.LSLFloat((int)m_data[itemIndex]);
return new LSL_Types.LSLFloat((int)Data[itemIndex]);
}
else if (m_data[itemIndex] is float)
else if (Data[itemIndex] is float)
{
return new LSL_Types.LSLFloat((float)m_data[itemIndex]);
return new LSL_Types.LSLFloat((float)Data[itemIndex]);
}
else if (m_data[itemIndex] is Double)
else if (Data[itemIndex] is Double)
{
return new LSL_Types.LSLFloat((Double)m_data[itemIndex]);
return new LSL_Types.LSLFloat((Double)Data[itemIndex]);
}
else if (m_data[itemIndex] is LSL_Types.LSLString)
else if (Data[itemIndex] is LSL_Types.LSLString)
{
return new LSL_Types.LSLFloat(m_data[itemIndex].ToString());
return new LSL_Types.LSLFloat(Data[itemIndex].ToString());
}
else
{
return (LSL_Types.LSLFloat)m_data[itemIndex];
return (LSL_Types.LSLFloat)Data[itemIndex];
}
}
public LSL_Types.LSLString GetLSLStringItem(int itemIndex)
{
if (m_data[itemIndex] is LSL_Types.key)
if (Data[itemIndex] is LSL_Types.key)
{
return (LSL_Types.key)m_data[itemIndex];
return (LSL_Types.key)Data[itemIndex];
}
else
{
return new LSL_Types.LSLString(m_data[itemIndex].ToString());
return new LSL_Types.LSLString(Data[itemIndex].ToString());
}
}
public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
{
if (m_data[itemIndex] is LSL_Types.LSLInteger)
return (LSL_Types.LSLInteger)m_data[itemIndex];
if (m_data[itemIndex] is LSL_Types.LSLFloat)
return new LSLInteger((int)m_data[itemIndex]);
else if (m_data[itemIndex] is Int32)
return new LSLInteger((int)m_data[itemIndex]);
else if (m_data[itemIndex] is LSL_Types.LSLString)
return new LSLInteger(m_data[itemIndex].ToString());
if (Data[itemIndex] is LSL_Types.LSLInteger)
return (LSL_Types.LSLInteger)Data[itemIndex];
if (Data[itemIndex] is LSL_Types.LSLFloat)
return new LSLInteger((int)Data[itemIndex]);
else if (Data[itemIndex] is Int32)
return new LSLInteger((int)Data[itemIndex]);
else if (Data[itemIndex] is LSL_Types.LSLString)
return new LSLInteger(Data[itemIndex].ToString());
else
throw new InvalidCastException(string.Format(
"{0} expected but {1} given",
typeof(LSL_Types.LSLInteger).Name,
m_data[itemIndex] != null ?
m_data[itemIndex].GetType().Name : "null"));
Data[itemIndex] != null ?
Data[itemIndex].GetType().Name : "null"));
}
public LSL_Types.Vector3 GetVector3Item(int itemIndex)
{
if (m_data[itemIndex] is LSL_Types.Vector3)
if (Data[itemIndex] is LSL_Types.Vector3)
{
return (LSL_Types.Vector3)m_data[itemIndex];
return (LSL_Types.Vector3)Data[itemIndex];
}
else if(m_data[itemIndex] is OpenMetaverse.Vector3)
else if(Data[itemIndex] is OpenMetaverse.Vector3)
{
return new LSL_Types.Vector3(
(OpenMetaverse.Vector3)m_data[itemIndex]);
(OpenMetaverse.Vector3)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"));
Data[itemIndex] != null ?
Data[itemIndex].GetType().Name : "null"));
}
}
public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
{
if (m_data[itemIndex] is LSL_Types.Quaternion)
if (Data[itemIndex] is LSL_Types.Quaternion)
{
return (LSL_Types.Quaternion)m_data[itemIndex];
return (LSL_Types.Quaternion)Data[itemIndex];
}
else if(m_data[itemIndex] is OpenMetaverse.Quaternion)
else if(Data[itemIndex] is OpenMetaverse.Quaternion)
{
return new LSL_Types.Quaternion(
(OpenMetaverse.Quaternion)m_data[itemIndex]);
(OpenMetaverse.Quaternion)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"));
Data[itemIndex] != null ?
Data[itemIndex].GetType().Name : "null"));
}
}
public LSL_Types.key GetKeyItem(int itemIndex)
{
return (LSL_Types.key)m_data[itemIndex];
return (LSL_Types.key)Data[itemIndex];
}
public static list operator +(list a, list b)
@ -794,53 +794,53 @@ namespace OpenSim.Region.ScriptEngine.Shared
Object[] ret;
if (start < 0)
start=m_data.Length+start;
start=Data.Length+start;
if (start < 0)
start=0;
if (end < 0)
end=m_data.Length+end;
end=Data.Length+end;
if (end < 0)
end=0;
if (start > end)
{
if (end >= m_data.Length)
if (end >= Data.Length)
return new list(new Object[0]);
if (start >= m_data.Length)
start=m_data.Length-1;
if (start >= Data.Length)
start=Data.Length-1;
return GetSublist(end, start);
}
// start >= 0 && end >= 0 here
if (start >= m_data.Length)
if (start >= Data.Length)
{
ret=new Object[m_data.Length];
Array.Copy(m_data, 0, ret, 0, m_data.Length);
ret=new Object[Data.Length];
Array.Copy(Data, 0, ret, 0, Data.Length);
return new list(ret);
}
if (end >= m_data.Length)
end=m_data.Length-1;
if (end >= Data.Length)
end=Data.Length-1;
// now, this makes the math easier
int remove=end+1-start;
ret=new Object[m_data.Length-remove];
ret=new Object[Data.Length-remove];
if (ret.Length == 0)
return new list(ret);
int src;
int dest=0;
for (src = 0; src < m_data.Length; src++)
for (src = 0; src < Data.Length; src++)
{
if (src < start || src > end)
ret[dest++]=m_data[src];
ret[dest++]=Data[src];
}
return new list(ret);
@ -860,12 +860,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
if (start < 0)
{
start = m_data.Length + start;
start = Data.Length + start;
}
if (end < 0)
{
end = m_data.Length + end;
end = Data.Length + end;
}
// The conventional case is start <= end
@ -879,15 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared
// Start sublist beyond length
// Also deals with start AND end still negative
if (start >= m_data.Length || end < 0)
if (start >= Data.Length || end < 0)
{
return new list();
}
// Sublist extends beyond the end of the supplied list
if (end >= m_data.Length)
if (end >= Data.Length)
{
end = m_data.Length - 1;
end = Data.Length - 1;
}
// Sublist still starts before the beginning of the list
@ -898,7 +898,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
ret = new object[end - start + 1];
Array.Copy(m_data, start, ret, 0, end - start + 1);
Array.Copy(Data, start, ret, 0, end - start + 1);
return new list(ret);
@ -931,7 +931,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
// If start is outside of list, then just return
// the prefix, whatever it is.
if (start >= m_data.Length)
if (start >= Data.Length)
{
return result;
}
@ -1109,11 +1109,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
{
string output;
output = String.Empty;
if (m_data.Length == 0)
if (Data.Length == 0)
{
return String.Empty;
}
foreach (object o in m_data)
foreach (object o in Data)
{
output = output + o.ToString();
}
@ -1308,12 +1308,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public string ToPrettyString()
{
string output;
if (m_data.Length == 0)
if (Data.Length == 0)
{
return "[]";
}
output = "[";
foreach (object o in m_data)
foreach (object o in Data)
{
if (o is String)
{