aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/lscript/lscript_alloc.h72
-rw-r--r--linden/indra/lscript/lscript_compile/lscript_compile.vcproj6
-rw-r--r--linden/indra/lscript/lscript_execute/lscript_execute.vcproj6
-rw-r--r--linden/indra/lscript/lscript_library/lscript_alloc.cpp59
-rw-r--r--linden/indra/lscript/lscript_library/lscript_library.cpp2
-rw-r--r--linden/indra/lscript/lscript_library/lscript_library.vcproj6
6 files changed, 71 insertions, 80 deletions
diff --git a/linden/indra/lscript/lscript_alloc.h b/linden/indra/lscript/lscript_alloc.h
index 67e3dc0..4d69e8e 100644
--- a/linden/indra/lscript/lscript_alloc.h
+++ b/linden/indra/lscript/lscript_alloc.h
@@ -246,7 +246,7 @@ inline LLScriptLibData *lsa_bubble_sort(LLScriptLibData *src, S32 stride, S32 as
246 return retval; 246 return retval;
247 } 247 }
248 248
249 LLScriptLibData **sortarray = (LLScriptLibData **)new U32[number]; 249 LLScriptLibData **sortarray = new LLScriptLibData*[number];
250 250
251 LLScriptLibData *temp = src->mListp; 251 LLScriptLibData *temp = src->mListp;
252 while (temp) 252 while (temp)
@@ -290,74 +290,6 @@ inline LLScriptLibData *lsa_bubble_sort(LLScriptLibData *src, S32 stride, S32 as
290} 290}
291 291
292 292
293inline LLScriptLibData *lsa_randomize(LLScriptLibData *src, S32 stride) 293LLScriptLibData* lsa_randomize(LLScriptLibData* src, S32 stride);
294{
295 S32 number = src->getListLength();
296
297 if (number <= 0)
298 {
299 return NULL;
300 }
301
302 if (stride <= 0)
303 {
304 stride = 1;
305 }
306
307 if (number % stride)
308 {
309 LLScriptLibData *retval = src->mListp;
310 src->mListp = NULL;
311 return retval;
312 }
313
314 LLScriptLibData **sortarray = (LLScriptLibData **)new U32[number];
315
316 LLScriptLibData *temp = src->mListp;
317 S32 i = 0;
318 while (temp)
319 {
320 sortarray[i] = temp;
321 i++;
322 temp = temp->mListp;
323 }
324
325 S32 k, j, s;
326
327 for (k = 0; k < 20; k++)
328 {
329 for (i = 0; i < number; i += stride)
330 {
331 for (j = i; j < number; j += stride)
332 {
333 if (frand(1.f) > 0.5)
334 {
335 for (s = 0; s < stride; s++)
336 {
337 temp = sortarray[i + s];
338 sortarray[i + s] = sortarray[j + s];
339 sortarray[j + s] = temp;
340 }
341 }
342 }
343 }
344 }
345
346 i = 1;
347 temp = sortarray[0];
348 while (i < number)
349 {
350 temp->mListp = sortarray[i++];
351 temp = temp->mListp;
352 }
353 temp->mListp = NULL;
354
355 src->mListp = NULL;
356
357 LLScriptLibData *ret_value = sortarray[0];
358 delete [] sortarray;
359
360 return ret_value;
361}
362 294
363#endif 295#endif
diff --git a/linden/indra/lscript/lscript_compile/lscript_compile.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile.vcproj
index 581fa27..fd03fa0 100644
--- a/linden/indra/lscript/lscript_compile/lscript_compile.vcproj
+++ b/linden/indra/lscript/lscript_compile/lscript_compile.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory" 22 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG"
24 MinimalRebuild="TRUE" 24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3" 25 BasicRuntimeChecks="3"
@@ -63,7 +63,7 @@
63 CharacterSet="1"> 63 CharacterSet="1">
64 <Tool 64 <Tool
65 Name="VCCLCompilerTool" 65 Name="VCCLCompilerTool"
66 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory" 66 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
68 RuntimeLibrary="0" 68 RuntimeLibrary="0"
69 StructMemberAlignment="0" 69 StructMemberAlignment="0"
@@ -106,7 +106,7 @@
106 <Tool 106 <Tool
107 Name="VCCLCompilerTool" 107 Name="VCCLCompilerTool"
108 Optimization="0" 108 Optimization="0"
109 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory" 109 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;..\..\llvfs;..\..\llmessage;..\..\llinventory;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
111 RuntimeLibrary="0" 111 RuntimeLibrary="0"
112 StructMemberAlignment="0" 112 StructMemberAlignment="0"
diff --git a/linden/indra/lscript/lscript_execute/lscript_execute.vcproj b/linden/indra/lscript/lscript_execute/lscript_execute.vcproj
index 1ae15ea..c61ad89 100644
--- a/linden/indra/lscript/lscript_execute/lscript_execute.vcproj
+++ b/linden/indra/lscript/lscript_execute/lscript_execute.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 22 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG"
24 MinimalRebuild="TRUE" 24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3" 25 BasicRuntimeChecks="3"
@@ -63,7 +63,7 @@
63 CharacterSet="1"> 63 CharacterSet="1">
64 <Tool 64 <Tool
65 Name="VCCLCompilerTool" 65 Name="VCCLCompilerTool"
66 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 66 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
68 RuntimeLibrary="0" 68 RuntimeLibrary="0"
69 StructMemberAlignment="0" 69 StructMemberAlignment="0"
@@ -106,7 +106,7 @@
106 <Tool 106 <Tool
107 Name="VCCLCompilerTool" 107 Name="VCCLCompilerTool"
108 Optimization="0" 108 Optimization="0"
109 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 109 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath;&quot;..\..\..\libraries\i686-win32\include&quot;;..\..\..\libraries\include"
110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
111 RuntimeLibrary="0" 111 RuntimeLibrary="0"
112 StructMemberAlignment="0" 112 StructMemberAlignment="0"
diff --git a/linden/indra/lscript/lscript_library/lscript_alloc.cpp b/linden/indra/lscript/lscript_library/lscript_alloc.cpp
index 978d7f2..4636c0b 100644
--- a/linden/indra/lscript/lscript_library/lscript_alloc.cpp
+++ b/linden/indra/lscript/lscript_library/lscript_alloc.cpp
@@ -1119,3 +1119,62 @@ S32 lsa_postadd_lists(U8 *buffer, S32 offset1, LLScriptLibData *data, S32 heapsi
1119 return lsa_heap_add_data(buffer, list1, heapsize, TRUE); 1119 return lsa_heap_add_data(buffer, list1, heapsize, TRUE);
1120} 1120}
1121 1121
1122
1123LLScriptLibData* lsa_randomize(LLScriptLibData* src, S32 stride)
1124{
1125 S32 number = src->getListLength();
1126 if (number <= 0)
1127 {
1128 return NULL;
1129 }
1130 if (stride <= 0)
1131 {
1132 stride = 1;
1133 }
1134 if(number % stride)
1135 {
1136 LLScriptLibData* retval = src->mListp;
1137 src->mListp = NULL;
1138 return retval;
1139 }
1140 S32 buckets = number / stride;
1141
1142 // Copy everything into a special vector for sorting;
1143 std::vector<LLScriptLibData*> sort_array;
1144 sort_array.reserve(number);
1145 LLScriptLibData* temp = src->mListp;
1146 while(temp)
1147 {
1148 sort_array.push_back(temp);
1149 temp = temp->mListp;
1150 }
1151
1152 // We cannot simply call random_shuffle or similar algorithm since
1153 // we need to obey the stride. So, we iterate over what we have
1154 // and swap each with a random other segment.
1155 S32 index = 0;
1156 S32 ii = 0;
1157 for(; ii < number; ii += stride)
1158 {
1159 index = ll_rand(buckets) * stride;
1160 for(S32 jj = 0; jj < stride; ++jj)
1161 {
1162 std::swap(sort_array[ii + jj], sort_array[index + jj]);
1163 }
1164 }
1165
1166 // copy the pointers back out
1167 ii = 1;
1168 temp = sort_array[0];
1169 while (ii < number)
1170 {
1171 temp->mListp = sort_array[ii++];
1172 temp = temp->mListp;
1173 }
1174 temp->mListp = NULL;
1175
1176 src->mListp = NULL;
1177
1178 LLScriptLibData* ret_value = sort_array[0];
1179 return ret_value;
1180}
diff --git a/linden/indra/lscript/lscript_library/lscript_library.cpp b/linden/indra/lscript/lscript_library/lscript_library.cpp
index 098c836..1b92608 100644
--- a/linden/indra/lscript/lscript_library/lscript_library.cpp
+++ b/linden/indra/lscript/lscript_library/lscript_library.cpp
@@ -467,7 +467,7 @@ LLScriptLibraryFunction::~LLScriptLibraryFunction()
467 467
468void LLScriptLibrary::addFunction(LLScriptLibraryFunction *func) 468void LLScriptLibrary::addFunction(LLScriptLibraryFunction *func)
469{ 469{
470 LLScriptLibraryFunction **temp = (LLScriptLibraryFunction **)new U32[mNextNumber + 1]; 470 LLScriptLibraryFunction **temp = new LLScriptLibraryFunction*[mNextNumber + 1];
471 if (mNextNumber) 471 if (mNextNumber)
472 { 472 {
473 memcpy(temp, mFunctions, sizeof(LLScriptLibraryFunction *)*mNextNumber); 473 memcpy(temp, mFunctions, sizeof(LLScriptLibraryFunction *)*mNextNumber);
diff --git a/linden/indra/lscript/lscript_library/lscript_library.vcproj b/linden/indra/lscript/lscript_library/lscript_library.vcproj
index f4861c7..1a340da 100644
--- a/linden/indra/lscript/lscript_library/lscript_library.vcproj
+++ b/linden/indra/lscript/lscript_library/lscript_library.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 22 AdditionalIncludeDirectories="..\;..\..\llmath;..\..\llcommon;&quot;..\..\..\libraries\i686-win32&quot;;..\..\..\libraries\include"
23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG"
24 MinimalRebuild="TRUE" 24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3" 25 BasicRuntimeChecks="3"
@@ -63,7 +63,7 @@
63 CharacterSet="1"> 63 CharacterSet="1">
64 <Tool 64 <Tool
65 Name="VCCLCompilerTool" 65 Name="VCCLCompilerTool"
66 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 66 AdditionalIncludeDirectories="..\;..\..\llmath;..\..\llcommon;&quot;..\..\..\libraries\i686-win32&quot;;..\..\..\libraries\include"
67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
68 RuntimeLibrary="0" 68 RuntimeLibrary="0"
69 StructMemberAlignment="0" 69 StructMemberAlignment="0"
@@ -106,7 +106,7 @@
106 <Tool 106 <Tool
107 Name="VCCLCompilerTool" 107 Name="VCCLCompilerTool"
108 Optimization="0" 108 Optimization="0"
109 AdditionalIncludeDirectories="..;..\..\llcommon;..\..\llmath" 109 AdditionalIncludeDirectories="..\;..\..\llmath;..\..\llcommon;&quot;..\..\..\libraries\i686-win32&quot;;..\..\..\libraries\include"
110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE" 110 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
111 RuntimeLibrary="0" 111 RuntimeLibrary="0"
112 StructMemberAlignment="0" 112 StructMemberAlignment="0"