From 4a621fec6380c29103945fe25261dafd63b904f2 Mon Sep 17 00:00:00 2001 From: truelight Date: Sun, 16 Sep 2007 18:10:52 +0000 Subject: (svn r11119) -Codechange: analyze .tar files upon loading, remembering their files and offsets, which speeds up .tar handling with a big factor -Fix: several win32 .tar support problems -Fix: better checking of .tar versions and other minor things -Codechange: don't call fclose() but FioFClose to close a file --- src/newgrf_config.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/newgrf_config.cpp') diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 0db3c67aa..2642a93ba 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -51,7 +51,7 @@ static bool CalcGRFMD5Sum(GRFConfig *config) } md5_finish(&md5state, config->md5sum); - fclose(f); + FioFCloseFile(f); return true; } @@ -356,26 +356,18 @@ static uint ScanPath(const char *path, int basepath_length) return num; } -bool FioTarFileListScanNewGRFCallback(const char *filename, int size, void *userdata) +static uint ScanTar(TarFileList::iterator tar) { - uint *num = (uint *)userdata; + uint num = 0; + const char *filename = (*tar).first.c_str(); const 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; + if (ScanPathAddGrf(filename)) num++; - FioTarFileList(filename, "rb", NULL, FioTarFileListScanNewGRFCallback, &num); return num; } @@ -384,7 +376,7 @@ void ScanNewGRFFiles() { Searchpath sp; char path[MAX_PATH]; - const char *tar; + TarFileList::iterator tar; uint num = 0; ClearGRFConfigList(&_all_grfs); -- cgit v1.2.3-54-g00ecf