From 1aaa7eec5a4c41f2f18f268ef2d403de0d8a9c4e Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Wed, 21 Apr 2021 20:53:48 -0700 Subject: [PATCH] Handle incorrectly cased .acx file names Fixes an issue in Tsuma Shibori (and probably other games) where .acx file lookup fails because the actual file name contains characters which differ in case from the name given in the code. --- src/hll/ACXLoader.c | 22 +++++++++++++++++++++- subprojects/libsys4 | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/hll/ACXLoader.c b/src/hll/ACXLoader.c index 80426f6..42776e5 100644 --- a/src/hll/ACXLoader.c +++ b/src/hll/ACXLoader.c @@ -16,11 +16,13 @@ #include #include +#include #include #include "system4.h" #include "system4/string.h" #include "system4/acx.h" +#include "system4/file.h" #include "hll.h" #include "little_endian.h" @@ -31,8 +33,26 @@ struct acx *acx = NULL; static bool ACXLoader_Load(struct string *filename) { + int error = ACX_SUCCESS; char *path = gamedir_path(filename->text); - acx = acx_load(path); + acx = acx_load(path, &error); + + // XXX: Fix for games (e.g. Tsuma Shibori) that shipped with incorrectly + // cased file names + if (error == ACX_ERROR_FILE) { + char *ipath = path_get_icase(path); + if (ipath) { + free(path); + path = ipath; + acx = acx_load(path, &error); + } + } + + if (error == ACX_ERROR_FILE) { + WARNING("acx_load(\"%s\"): %s", path, strerror(errno)); + } else if (error == ACX_ERROR_INVALID) { + WARNING("acx_load(\"%s\"): invalid .acx file"); + } free(path); return !!acx; } diff --git a/subprojects/libsys4 b/subprojects/libsys4 index 2e8b581..7b08a56 160000 --- a/subprojects/libsys4 +++ b/subprojects/libsys4 @@ -1 +1 @@ -Subproject commit 2e8b581636a1004298b4f2c6aeea61b3c8b0d099 +Subproject commit 7b08a56babe700fdcc07cc3bdbd0132a55733a84