(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)
This commit is contained in:
truelight
2007-09-14 22:25:00 +00:00
parent b25c661ce6
commit 5647bd5157
3 changed files with 208 additions and 0 deletions

View File

@@ -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);
}