From 796111cc6e4cd8af9d04a3ea385d35a8a5b60ea7 Mon Sep 17 00:00:00 2001 From: djoslin0 Date: Sat, 29 Nov 2025 16:22:21 -0800 Subject: [PATCH] Normalize paths in smlua_find_mod_file() (#1042) * 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. * Address peachy's comment --------- Co-authored-by: MysterD --- src/pc/lua/smlua_require.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pc/lua/smlua_require.c b/src/pc/lua/smlua_require.c index 5852ac54a..c331a0570 100644 --- a/src/pc/lua/smlua_require.c +++ b/src/pc/lua/smlua_require.c @@ -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 normalizedRelative[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(normalizedRelative, file->relativePath); + normalize_path(normalizedRelative); + if (!strcmp(normalizedRelative, luaName) || !strcmp(normalizedRelative, luacName)) { return file; } }