diff options
author | truelight <truelight@openttd.org> | 2007-09-14 22:25:00 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-09-14 22:25:00 +0000 |
commit | 5647bd5157b623348feb202623057fd84eb9c3c5 (patch) | |
tree | 2f8a55c487d1c409dbbfdb98adfc4ab13904ef6f /src/newgrf_config.cpp | |
parent | b25c661ce6c932c341c1d5055e94a142a34816a9 (diff) | |
download | openttd-5647bd5157b623348feb202623057fd84eb9c3c5.tar.xz |
(svn r11106) -Add: added .tar support; you can pack all files in your data/ dir in how ever many .tar files you like, keeping the dir-structure equal to the unpacked version, and OpenTTD can handle them just like the files were unpacked
-Note: useful for GRF-packs and 32bpp PNGs. Don't forget to keep the dir-structure alive for 32bpp PNGs!
-Note: file-loading-order: search-paths, .tar-files in the order found on disk (can be anything at all, don't depend on it.. use 'openttd -d1' to see which order they are added)
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r-- | src/newgrf_config.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index acd471d64..1a363b5ef 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -356,12 +356,35 @@ static uint ScanPath(const char *path, int basepath_length) return num; } +bool FioTarFileListScanNewGRFCallback(const char *filename, int size, void *userdata) +{ + uint *num = (uint *)userdata; + char *ext = strrchr(filename, '.'); + + /* If no extension or extension isn't .grf, skip the file */ + if (ext == NULL) return false; + if (strcasecmp(ext, ".grf") != 0) return false; + + if (ScanPathAddGrf(filename)) (*num)++; + + /* Always return false, as we don't want to stop with listing all the files */ + return false; +} + +static uint ScanTar(const char *filename) +{ + uint num = 0; + + FioTarFileList(filename, "rb", NULL, FioTarFileListScanNewGRFCallback, &num); + return num; +} /* Scan for all NewGRFs */ void ScanNewGRFFiles() { Searchpath sp; char path[MAX_PATH]; + const char *tar; uint num = 0; ClearGRFConfigList(&_all_grfs); @@ -371,6 +394,9 @@ void ScanNewGRFFiles() FioAppendDirectory(path, MAX_PATH, sp, DATA_DIR); num += ScanPath(path, strlen(path)); } + FOR_ALL_TARS(tar) { + num += ScanTar(tar); + } DEBUG(grf, 1, "Scan complete, found %d files", num); } |