improvements to sort_random

This commit is contained in:
nova
2026-04-04 21:58:43 +02:00
parent acb7db1617
commit 6372dbba69
3 changed files with 16 additions and 16 deletions

View File

@@ -7,7 +7,7 @@
#include "defines.h"
extern time_t *seed;
extern time_t seed;
int skip_hidden_files(const struct dirent *entry){
@@ -117,15 +117,19 @@ int sort_random(const void *file0, const void *file1){
if (!(((file*)file0)->file_type & FILE_TYPE_DIR) && (((file*)file1)->file_type & FILE_TYPE_DIR)) {
return 1;
}
time_t num = ((time_t)&sort_random)^((time_t)sort_natural);
int i = 1;
for (; i < 6; i++) {
num += *seed;
num ^= num << ((((time_t)&seed)%6)+i);
num ^= num >> ((((time_t)&num)%9)+i);
time_t num = ((time_t)&sort_random) + (time_t)seed + getpid();
int i;
for (i = 1; i < (((time_t)&seed)%10); i++) {
num += getpid() / seed;
num ^= num << ((((time_t)seed)%11)+i);
num += ((file*)file0)->file_size;
num ^= num >> ((((time_t)seed)%7)+i);
num -= ((file*)file1)->file_size;
}
return ((num%3) - 1);
/*printf("%ld\n", ((num & (3 << seed%16)) >> seed%16) - 1);*/
return (((num & (3 << seed%32)) >> seed%32) - 1);
/*return ((num%3) - 1);*/
}
int sort_type(const void *file0, const void *file1){