Change for novelty: randomize channel programming order on launch

This commit is contained in:
markmental 2026-03-28 21:09:09 -04:00
commit 680f9b694d
4 changed files with 8 additions and 1 deletions

View file

@ -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

Binary file not shown.

View file

@ -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;

Binary file not shown.