summaryrefslogtreecommitdiff
path: root/src/fios.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-10 20:20:37 +0000
committerrubidium <rubidium@openttd.org>2009-04-10 20:20:37 +0000
commit4bf35086802f6f778e987cf0a4ca377068cb27ed (patch)
treefe82ca1f90bc64614e60e92123ea6fffca31a368 /src/fios.cpp
parent2663ad302f366ecd2498a43470855c4cf73839d6 (diff)
downloadopenttd-4bf35086802f6f778e987cf0a4ca377068cb27ed.tar.xz
(svn r16023) -Fix (r15615) [FS#2817]: 32 bpp sprites in tars would also be shown in the list of heightmaps.
Diffstat (limited to 'src/fios.cpp')
-rw-r--r--src/fios.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/fios.cpp b/src/fios.cpp
index 3299b223e..162fabf52 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -8,6 +8,7 @@
#include "openttd.h"
#include "fios.h"
#include "fileio_func.h"
+#include "tar_type.h"
#include "string_func.h"
#include <sys/stat.h>
@@ -469,7 +470,31 @@ static FiosType FiosGetHeightmapListCallback(SaveLoadDialogMode mode, const char
if (strcasecmp(ext, ".bmp") == 0) type = FIOS_TYPE_BMP;
- if (type != FIOS_TYPE_INVALID) GetFileTitle(file, title, last);
+ if (type == FIOS_TYPE_INVALID) return FIOS_TYPE_INVALID;
+
+ TarFileList::iterator it = _tar_filelist.find(file);
+ if (it != _tar_filelist.end()) {
+ /* If the file is in a tar and that tar is not in a heightmap
+ * directory we are for sure not supposed to see it.
+ * Examples of this are pngs part of documentation within
+ * collections of NewGRFs or 32 bpp graphics replacement PNGs.
+ */
+ bool match = false;
+ Searchpath sp;
+ FOR_ALL_SEARCHPATHS(sp) {
+ char buf[MAX_PATH];
+ FioAppendDirectory(buf, sizeof(buf), sp, HEIGHTMAP_DIR);
+
+ if (strncmp(buf, it->second.tar_filename, strlen(buf)) == 0) {
+ match = true;
+ break;
+ }
+ }
+
+ if (!match) return FIOS_TYPE_INVALID;
+ }
+
+ GetFileTitle(file, title, last);
return type;
}