summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-16 18:10:52 +0000
committertruelight <truelight@openttd.org>2007-09-16 18:10:52 +0000
commit4a621fec6380c29103945fe25261dafd63b904f2 (patch)
treee90824fc3128a0ec0f50cddb2f481db5dfd08158 /src/newgrf_config.cpp
parenteebcc8968e72a670fccad8bdba8d46c58a796202 (diff)
downloadopenttd-4a621fec6380c29103945fe25261dafd63b904f2.tar.xz
(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
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp20
1 files changed, 6 insertions, 14 deletions
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);