--- a/src/newgrf_config.cpp Tue Jul 22 18:29:06 2008 +0300
+++ b/src/newgrf_config.cpp Tue Jul 22 21:51:14 2008 +0300
@@ -267,10 +267,14 @@
return res;
}
-static bool ScanPathAddGrf(const char *filename)
+static bool ScanPathAddGrf(const char *filename, Subdirectory subdir)
{
GRFConfig *c = CallocT<GRFConfig>(1);
c->filename = strdup(filename);
+
+ // flag GRFs that are loaded from cache
+ if (subdir == CACHE_DIR)
+ SetBit(c->flags, GCF_CACHE);
bool added = true;
if (FillGRFDetails(c, false)) {
@@ -314,7 +318,7 @@
}
/* Scan a path for NewGRFs */
-static uint ScanPath(const char *path, size_t basepath_length)
+static uint ScanPath(const char *path, size_t basepath_length, Subdirectory subdir)
{
extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb);
@@ -337,7 +341,7 @@
/* Directory */
if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue;
AppendPathSeparator(filename, lengthof(filename));
- num += ScanPath(filename, basepath_length);
+ num += ScanPath(filename, basepath_length, subdir);
} else if (sb.st_mode & S_IFREG) {
/* File */
char *ext = strrchr(filename, '.');
@@ -346,7 +350,7 @@
if (ext == NULL) continue;
if (strcasecmp(ext, ".grf") != 0) continue;
- if (ScanPathAddGrf(filename + basepath_length)) num++;
+ if (ScanPathAddGrf(filename + basepath_length, subdir)) num++;
}
}
@@ -365,7 +369,7 @@
if (ext == NULL) return false;
if (strcasecmp(ext, ".grf") != 0) return false;
- if (ScanPathAddGrf(filename)) num++;
+ if (ScanPathAddGrf(filename, (*tar).second.tar->subdir)) num++;
return num;
}
@@ -398,7 +402,7 @@
DEBUG(grf, 1, "Scanning for NewGRFs");
FOR_ALL_SEARCHPATHS(sp) {
FioAppendDirectory(path, MAX_PATH, sp, DATA_DIR);
- num += ScanPath(path, strlen(path));
+ num += ScanPath(path, strlen(path), DATA_DIR);
}
FOR_ALL_TARS(tar) {
num += ScanTar(tar);