be a bit more clever trying to find a custom lua startup file

This commit is contained in:
Tim Felgentreff 2015-12-04 10:44:12 +01:00
parent 6739208bbe
commit 13db0d48c9
2 changed files with 14 additions and 0 deletions

View file

@ -615,6 +615,16 @@ static void LibraryFileName(const char *file, char(&buffer)[PATH_MAX])
return;
}
// Support for scripts in default scripts dir.
sprintf(buffer, "scripts/%s", file);
if (FindFileWithExtension(buffer)) {
return;
}
sprintf(buffer, "%s/scripts/%s", StratagusLibPath.c_str(), file);
if (FindFileWithExtension(buffer)) {
return;
}
DebugPrint("File `%s' not found\n" _C_ file);
strcpy_s(buffer, PATH_MAX, file);
}

View file

@ -540,6 +540,10 @@ void ParseCommandLine(int argc, char **argv, Parameters &parameters)
continue;
case 'c':
parameters.luaStartFilename = optarg;
if (strlen(optarg) > 4 &&
!(strstr(optarg, ".lua") == optarg + strlen(optarg) - 4)) {
parameters.luaStartFilename += ".lua";
}
continue;
case 'd': {
StratagusLibPath = optarg;