Added llParseString2List (and a few extra methods to LSL_Types.list).

ThreadPoolClientBranch
alondria 2008-02-02 18:52:07 +00:00
parent e2680342d1
commit 0ea708c133
4 changed files with 74 additions and 5 deletions

View File

@ -1244,9 +1244,9 @@ namespace OpenSim.Region.ScriptEngine.Common
m_LSL_Functions.llEjectFromLand(pest);
}
public void llParseString2List()
public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
{
m_LSL_Functions.llParseString2List();
return m_LSL_Functions.llParseString2List(str,separators,spacers);
}
public int llOverMyLand(string id)

View File

@ -2039,9 +2039,55 @@ namespace OpenSim.Region.ScriptEngine.Common
NotImplemented("llEjectFromLand");
}
public void llParseString2List()
public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
{
NotImplemented("llParseString2List");
LSL_Types.list ret = new LSL_Types.list();
object[] delimeters = new object[separators.Length + spacers.Length];
separators.Data.CopyTo(delimeters, 0);
spacers.Data.CopyTo(delimeters, separators.Length);
bool dfound = false;
do
{
dfound = false;
int cindex = -1;
string cdeli = "";
for (int i = 0; i < delimeters.Length; i++)
{
int index = str.IndexOf(delimeters[i].ToString());
bool found = index != -1;
if (found)
{
if ((cindex > index) || (cindex == -1))
{
cindex = index;
cdeli = (string)delimeters[i];
}
dfound = dfound || found;
}
}
if (cindex != -1)
{
if (cindex > 0)
{
ret.Add(str.Substring(0, cindex));
if (spacers.Contains(cdeli))
{
ret.Add(cdeli);
}
}
if (cindex == 0 && spacers.Contains(cdeli))
{
ret.Add(cdeli);
}
str = str.Substring(cindex + 1);
}
}
while (dfound);
if (str != "")
{
ret.Add(str);
}
return ret;
}
public int llOverMyLand(string id)

View File

@ -409,7 +409,7 @@ namespace OpenSim.Region.ScriptEngine.Common
//wiki: llEjectFromLand(key pest)
void llEjectFromLand(string pest);
void llParseString2List();
LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers);
//wiki: integer llOverMyLand(key id)
int llOverMyLand(string id);
//wiki: key llGetLandOwnerAt(vector pos)

View File

@ -354,6 +354,29 @@ namespace OpenSim.Region.ScriptEngine.Common
return new list(tmp);
}
public void Add(object o)
{
object[] tmp;
tmp = new object[m_data.Length + 1];
m_data.CopyTo(tmp, 0);
tmp[m_data.Length] = o;
m_data = tmp;
}
public bool Contains(object o)
{
bool ret = false;
foreach (object i in Data)
{
if (i == o)
{
ret = true;
break;
}
}
return ret;
}
public list GetSublist(int start, int end)
{
Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")");