aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript/lscript_alloc.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:48 -0500
committerJacek Antonelli2008-08-15 23:44:48 -0500
commit9b4f54c826ffa4f94efa866068c9d6ecdfb4b424 (patch)
tree2f8ae193ab487088962e628f1ee9dee2f5901f01 /linden/indra/lscript/lscript_alloc.h
parentSecond Life viewer sources 1.13.2.12 (diff)
downloadmeta-impy-9b4f54c826ffa4f94efa866068c9d6ecdfb4b424.zip
meta-impy-9b4f54c826ffa4f94efa866068c9d6ecdfb4b424.tar.gz
meta-impy-9b4f54c826ffa4f94efa866068c9d6ecdfb4b424.tar.bz2
meta-impy-9b4f54c826ffa4f94efa866068c9d6ecdfb4b424.tar.xz
Second Life viewer sources 1.13.2.15
Diffstat (limited to '')
-rw-r--r--linden/indra/lscript/lscript_alloc.h72
1 files changed, 2 insertions, 70 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