Allowed manually appending .lua to the end of a file name to avoid confusion with extensionless files

This commit is contained in:
xLuigiGamerx 2025-12-21 01:21:15 +03:00
parent 093d179408
commit bb4f3fc581

View file

@ -120,8 +120,13 @@ static struct ModFile* smlua_find_mod_file(const char* moduleName) {
char luaName[SYS_MAX_PATH] = "";
char luacName[SYS_MAX_PATH] = "";
snprintf(luaName, SYS_MAX_PATH, "%s.lua", absolutePath);
snprintf(luacName, SYS_MAX_PATH, "%s.luac", absolutePath);
if (!path_ends_with(absolutePath, ".lua") && !path_ends_with(absolutePath, ".luac")) {
snprintf(luaName, SYS_MAX_PATH, "%s.lua", absolutePath);
snprintf(luacName, SYS_MAX_PATH, "%s.luac", absolutePath);
} else {
snprintf(luaName, SYS_MAX_PATH, "%s", absolutePath);
snprintf(luacName, SYS_MAX_PATH, "%s", absolutePath);
}
// since mods' relativePaths are relative to the mod's root, we can do a direct comparison
for (int i = 0; i < gLuaActiveMod->fileCount; i++) {
@ -201,6 +206,11 @@ static struct ModFile* smlua_find_file(const char* fileName) {
for (int i = 0; i < gLuaActiveMod->fileCount; i++) {
struct ModFile* file = &gLuaActiveMod->files[i];
// exclude lua files
if (path_ends_with(file->relativePath, ".lua") || path_ends_with(file->relativePath, ".luac")) {
continue;
}
// check for match, normalizing to system separators
strcpy(normalizedRelative, file->relativePath);
normalize_path(normalizedRelative);