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.
This commit is contained in:
Nunuhara Cabbage
2021-04-21 20:53:48 -07:00
parent 052ca908b3
commit 1aaa7eec5a
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -16,11 +16,13 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <zlib.h>
#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;
}