diff --git a/src/game.c b/src/game.c index a307c04..0720884 100644 --- a/src/game.c +++ b/src/game.c @@ -89,11 +89,18 @@ int long_comparator(const void *a, const void *b, void *non) { return A - B; } +int win_long_comparator(void *context_unused, const void *a, const void *b) { + long A = *(long *)a; + long B = *(long *)b; + + return A - B; +} + void sort_times(void) { #ifdef __linux__ qsort_r(save_times_lst.times, save_times_lst.size, sizeof(long), long_comparator, NULL); #elif WIN32 - qsort_s(save_times_lst.times, save_times_lst.size, sizeof(long), long_comparator, NULL); + qsort_s(save_times_lst.times, save_times_lst.size, sizeof(long), win_long_comparator, NULL); #endif } @@ -155,8 +162,11 @@ int load_score_times(char *filename) { } token = strtok_r(NULL, "\n", &saveptr); } - save_times_lst = (struct sg_times_list){.size=i, .capacity = count, .times=times, .sort=sort_times}; - save_times_lst.sort(); + /* here somweher? */ + + struct sg_times_list stl = {.size=i, .capacity = count, .times=times, .sort=sort_times}; + save_times_lst = stl; + sort_times(); free(text); } else { perror("loading times"); diff --git a/src/main.c b/src/main.c index b73b7ca..3438b92 100644 --- a/src/main.c +++ b/src/main.c @@ -154,7 +154,7 @@ int main (int argc, char** argv) { struct stat status; stat("saves", &status ); if ((status.st_mode & S_IFDIR) == 0) { - mkdir("saves"); + _mkdir("saves"); } } #endif