Normalize paths in smlua_find_mod_file()

Without normalizing the relative path, the comparison
fails when a mod using require is hosted/joined cross-platform.

Without this fix, any mod using require is effectively not
cross platform. This is critical.
This commit is contained in:
MysterD 2025-11-29 00:25:38 -08:00
parent 14ac356fc2
commit 3b09ad76ae

View file

@ -68,6 +68,7 @@ void smlua_cache_module_result(lua_State* L, struct Mod* mod, struct ModFile* fi
static struct ModFile* smlua_find_mod_file(const char* moduleName) {
char basePath[SYS_MAX_PATH] = "";
char absolutePath[SYS_MAX_PATH] = "";
char normalized_relative[SYS_MAX_PATH] = "";
if (!gLuaActiveMod) {
return NULL;
@ -100,8 +101,10 @@ static struct ModFile* smlua_find_mod_file(const char* moduleName) {
continue;
}
// check for match
if (!strcmp(file->relativePath, luaName) || !strcmp(file->relativePath, luacName)) {
// check for match, normalizing to system separators
strcpy(normalized_relative, file->relativePath);
normalize_path(normalized_relative);
if (!strcmp(normalized_relative, luaName) || !strcmp(normalized_relative, luacName)) {
return file;
}
}