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 bd72b7bf3a7a7ac692c5eade18090468354b8ffd
Author: Nekobit <m...@ow.nekobit.net>
AuthorDate: Sun Sep 24 01:07:37 2023 -0400
Fix broken replay files from computer crashes
Thanks amdgpu.
---
.jedproject | 3 +++
replay.c | 23 +++++++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/.jedproject b/.jedproject
new file mode 100644
index 0000000..e04169f
--- /dev/null
+++ b/.jedproject
@@ -0,0 +1,3 @@
+Compile_Command = "make -f " + Project_Root + "Makefile";
+Run_Command = Project_Root + "minilauncher4slippi";
+Cleanup_Command = "";
diff --git a/replay.c b/replay.c
index 3c8f2e8..d2441b7 100644
--- a/replay.c
+++ b/replay.c
@@ -94,7 +94,7 @@ ubjson_search(unsigned char* buf, long length, char const* key, long* offset)
static int
parse_replay(struct replay* rpy)
{
- unsigned char buf[1024] = {0};
+ unsigned char buf[4096] = {0};
char* filename;
asprintf(&filename, "%s%s", replays_dir, rpy->filename);
FILE* SLP = fopen(filename, "r");
@@ -105,13 +105,15 @@ parse_replay(struct replay* rpy)
}
// We used stat at some point, but a filename comparison is easier to write
//assert(stat(filename, &(rpy->attr)) == 0);
+
+ long data_skip;
long filesize = fsize(SLP);
// Skip begin header and raw data
fseek(SLP, 11, SEEK_CUR);
fread(buf, 1, 4, SLP);
- fseek(SLP, dec_uint_be(buf, 4), SEEK_CUR);
+ fseek(SLP, (data_skip = dec_uint_be(buf, 4)), SEEK_CUR);
fseek(SLP, -6, SEEK_CUR);
fread(buf, 1, 1, SLP);
fseek(SLP, 5, SEEK_CUR);
@@ -119,6 +121,13 @@ parse_replay(struct replay* rpy)
// debug
long length = filesize - ftell(SLP);
+ // Sometimes, your computer will crash (this happened to me :^) and the file
+ // will of course, just be corrupted or F-ed up
+ if (length > 4096)
+ {
+ goto abort;
+ }
+
fread(buf, 1, length, SLP);
long off;
char* bufx = buf;
@@ -138,9 +147,15 @@ parse_replay(struct replay* rpy)
rpy->p2code = p2code;
//printf("Reading %s\n", filename);
-abort:
fclose(SLP);
return 0;
+abort:
+ rpy->p1 = NULL;
+ rpy->p1code = NULL;
+ rpy->p2 = NULL;
+ rpy->p2code = NULL;
+ fclose(SLP);
+ return 3;
}
int
@@ -368,7 +383,7 @@ tab_replays_setup(Evas_Object* parent)
i, // Item data
NULL, // Parent item for trees, NULL if none
ELM_GENLIST_ITEM_TREE, // Item type; this is the common one
- NULL, // Callback on selection of the item
+ _item_select_cb, // Callback on selection of the item
(long)i // Data for that callback function
);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.