LSL llListFindList fix: check types as well as content. Items must be same type

to be found.
avinationmerge
Melanie Thielker 2014-08-10 22:00:01 +02:00
parent 52dc27991f
commit 4707c48828
1 changed files with 10 additions and 2 deletions

View File

@ -6001,17 +6001,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
int needle = llGetListEntryType(test, 0).value;
int haystack = llGetListEntryType(src, i).value;
// Why this piece of insanity? This is because most script constants are C# value types (e.g. int) // Why this piece of insanity? This is because most script constants are C# value types (e.g. int)
// rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code
// and so the comparison fails even if the LSL_Integer conceptually has the same value. // and so the comparison fails even if the LSL_Integer conceptually has the same value.
// Therefore, here we test Equals on both the source and destination objects. // Therefore, here we test Equals on both the source and destination objects.
// However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)).
if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])))
{ {
int j; int j;
for (j = 1; j < test.Length; j++) for (j = 1; j < test.Length; j++)
if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) {
needle = llGetListEntryType(test, j).value;
haystack = llGetListEntryType(src, i+j).value;
if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))))
break; break;
}
if (j == test.Length) if (j == test.Length)
{ {