diff options
author | rubidium <rubidium@openttd.org> | 2007-04-04 12:03:10 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-04-04 12:03:10 +0000 |
commit | db915888459efb46775299c84e0a78ffa23e6076 (patch) | |
tree | c43d134ecdffb49cfa20069d19250e6a2d89b769 /src/fileio.cpp | |
parent | a1b7fb8909cae096e6b3277ee2c0fb35f3b5e81d (diff) | |
download | openttd-db915888459efb46775299c84e0a78ffa23e6076.tar.xz |
(svn r9560) -Codechange: add support for multiple 'base' directories for newgrf searching.
-Codechange: do not add duplicate files to the newgrf list.
Diffstat (limited to 'src/fileio.cpp')
-rw-r--r-- | src/fileio.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp index 8ab41b31a..3a5a02322 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -170,7 +170,7 @@ void FioOpenFile(int slot, const char *filename) FioFreeHandle(); #endif /* LIMITED_FDS */ f = FioFOpenFile(filename); - if (f == NULL) error("Cannot open file '%s%s'", _paths.data_dir, filename); + if (f == NULL) error("Cannot open file '%s'", filename); FioCloseFile(slot); // if file was opened before, close it _fio.handles[slot] = f; @@ -206,12 +206,16 @@ FILE *FioFOpenFile(const char *filename) FILE *f; char buf[MAX_PATH]; - snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, filename); + if (strrchr(filename, PATHSEPCHAR) == NULL) { + snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, filename); + } else { + ttd_strlcpy(buf, filename, lengthof(buf)); + } f = fopen(buf, "rb"); #if !defined(WIN32) if (f == NULL) { - strtolower(buf + strlen(_paths.data_dir) - 1); + strtolower(strrchr(buf, PATHSEPCHAR)); f = fopen(buf, "rb"); #if defined SECOND_DATA_DIR @@ -308,6 +312,8 @@ void DetermineBasePaths(const char *exe) #if defined(SECOND_DATA_DIR) _paths.second_data_dir = MallocT<char>(MAX_PATH); ttd_strlcpy(_paths.second_data_dir, SECOND_DATA_DIR, MAX_PATH); +#else + _paths.second_data_dir = NULL; #endif #if defined(USE_HOMEDIR) |