This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository minilauncher-for-slippi.
View the commit online.
commit e87249de96c31182f74a138e1c6339e3c398e289
Author: Nekobit <m...@ow.nekobit.net>
AuthorDate: Wed Sep 13 01:34:04 2023 -0400
Sort replays now efficiently and effectively (wrong, let's believe though)
---
Makefile | 2 +-
home.c | 2 ++
replay.c | 33 +++++++++++++++++++++++++--------
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index 88c4de3..3956b24 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CC=cc
-CFLAGS=-g `pkg-config --cflags efl ecore elementary libusb-1.0` `sdl2-config --cflags` `curl-config --cflags`
+CFLAGS=--std=c99 -g `pkg-config --cflags efl ecore elementary libusb-1.0` `sdl2-config --cflags` `curl-config --cflags`
LDFLAGS=`pkg-config --libs efl ecore elementary libusb-1.0` `sdl2-config --libs` `curl-config --libs` -lcjson
OBJS=main.o replay.o home.o input.o
diff --git a/home.c b/home.c
index c24001d..bc6c64e 100644
--- a/home.c
+++ b/home.c
@@ -66,6 +66,8 @@ releases_result(struct memory_chunk chunk)
elm_frame_collapse_set(release_fr, EINA_TRUE);
elm_box_pack_end(tab_home_content, release_fr);
cJSON* title = cJSON_GetObjectItemCaseSensitive(c, "name");
+ if (!title) // (((Rate limit))) and/or whatever bullshit crops up.
+ return 1;
elm_object_text_set(release_fr, title->valuestring);
evas_object_show(release_fr);
diff --git a/replay.c b/replay.c
index 7636b44..3a94539 100644
--- a/replay.c
+++ b/replay.c
@@ -1,5 +1,9 @@
#include <stdio.h>
+#include <stdlib.h>
#include <stdint.h>
+#include <time.h>
+#include <sys/types.h>
+#include <assert.h>
#include "replay.h"
Evas_Object* tab_replays = NULL;
@@ -86,7 +90,9 @@ parse_replay(struct replay* rpy)
perror("fopen");
return 1;
}
-
+ // We used stat at some point, but a filename comparison is easier to write
+ //assert(stat(filename, &(rpy->attr)) == 0);
+
long filesize = fsize(SLP);
// Skip begin header and raw data
@@ -124,11 +130,18 @@ abort:
return 0;
}
+int
+order_filename_greatest(void const* _rpy1, void const* _rpy2)
+{
+ struct replay* rpy1 = _rpy1, * rpy2 = _rpy2;
+ return -strcmp(rpy1->filename, rpy2->filename);
+}
+
static int
recurse_replay_files()
{
DIR *dp;
- struct dirent *ep;
+ struct dirent *ep;
dp = opendir(replays_dir);
if (dp != NULL)
{
@@ -136,15 +149,19 @@ recurse_replay_files()
{
if (ep->d_name && ep->d_name[0] != '.')
{
- replays = realloc(replays, sizeof(struct replay) * (replays_len+2));
+ replays = realloc(replays, sizeof(struct replay) * (replays_len + 2));
struct replay* rpy = replays + replays_len++;
rpy->filename = strdup(ep->d_name);
- // End
+
+ // We used to parse replays as is, but now we sort by date.
parse_replay(rpy);
- //puts(ep->d_name);
}
}
-
+
+ // Lol. Lmao, even.
+ qsort(replays, replays_len, sizeof(struct replay),
+ order_filename_greatest);
+
closedir(dp);
return 0;
}
@@ -173,7 +190,7 @@ replays_strings(void* data, Evas_Object* obj, const char* part)
(replays[idx].p1 != NULL && replays[idx].p2 != NULL))
{
char* c;
- asprintf(&c, "[[%s]] %s [%s] Vs. %s [%s]", gameend2str(replays[idx].game_state),
+ asprintf(&c, "%s (%s) Vs. %s (%s)",
replays[idx].p1, replays[idx].p1code,
replays[idx].p2, replays[idx].p2code);
return c;
@@ -191,7 +208,7 @@ _launch_replay_job_cb(void *data, Ecore_Thread *thread)
{
extern char* dolphin_replay_file;
extern char* game_path;
- char const* argv[64] = {dolphin_replay_file, "-e", game_path, "-i", "play.json", "-b", NULL};
+ char const* argv[] = {dolphin_replay_file, "-e", game_path, "-i", "play.json", "-b", NULL};
if (fork() == 0)
{
execvp(argv[0], argv);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.