Change for novelty: randomize channel programming order on launch
This commit is contained in:
parent
6f310c7720
commit
680f9b694d
4 changed files with 8 additions and 1 deletions
|
|
@ -396,6 +396,7 @@ int app_init(App *app) {
|
|||
|
||||
app->app_start_time = time(NULL);
|
||||
app->app_start_ticks = SDL_GetTicks64();
|
||||
srand((unsigned int)app->app_start_time);
|
||||
|
||||
if (TTF_Init() != 0) {
|
||||
fprintf(stderr, "SDL_ttf init failed: %s\n", TTF_GetError());
|
||||
|
|
|
|||
BIN
src/app.o
BIN
src/app.o
Binary file not shown.
|
|
@ -213,7 +213,13 @@ static int load_channel_programs(Channel *channel, const char *channel_dir) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
qsort(channel->programs, (size_t) channel->program_count, sizeof(ProgramEntry), compare_programs);
|
||||
for (int i = channel->program_count - 1; i > 0; i--) {
|
||||
int j = rand() % (i + 1);
|
||||
ProgramEntry temp = channel->programs[i];
|
||||
channel->programs[i] = channel->programs[j];
|
||||
channel->programs[j] = temp;
|
||||
}
|
||||
|
||||
channel->total_duration_seconds = 0.0;
|
||||
for (int i = 0; i < channel->program_count; ++i) {
|
||||
channel->programs[i].start_offset_seconds = channel->total_duration_seconds;
|
||||
|
|
|
|||
BIN
src/channel.o
BIN
src/channel.o
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue