From 4bf35086802f6f778e987cf0a4ca377068cb27ed Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 10 Apr 2009 20:20:37 +0000 Subject: (svn r16023) -Fix (r15615) [FS#2817]: 32 bpp sprites in tars would also be shown in the list of heightmaps. --- src/fios.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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 @@ -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; } -- cgit v1.2.3-70-g09d2