mirror of https://github.com/OpenTTD/OpenTTD
(svn r22827) -Codechange: pass the/a more proper sub directory when opening (some) files instead of the default one
parent
8e5f433b22
commit
b4edc30c64
|
@ -48,8 +48,8 @@ static inline bool IsValidSearchPath(Searchpath sp)
|
|||
#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
|
||||
|
||||
void FioFCloseFile(FILE *f);
|
||||
FILE *FioFOpenFile(const char *filename, const char *mode = "rb", Subdirectory subdir = NEWGRF_DIR, size_t *filesize = NULL);
|
||||
bool FioCheckFileExists(const char *filename, Subdirectory subdir = NEWGRF_DIR);
|
||||
FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize = NULL);
|
||||
bool FioCheckFileExists(const char *filename, Subdirectory subdir);
|
||||
char *FioGetFullPath(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir, const char *filename);
|
||||
char *FioFindFullPath(char *buf, size_t buflen, Subdirectory subdir, const char *filename);
|
||||
char *FioAppendDirectory(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir);
|
||||
|
|
|
@ -599,7 +599,7 @@ public:
|
|||
|
||||
/* virtual */ bool AddFile(const char *filename, size_t basepath_length)
|
||||
{
|
||||
FILE *f = FioFOpenFile(filename, "r");
|
||||
FILE *f = FioFOpenFile(filename, "r", SCENARIO_DIR);
|
||||
if (f == NULL) return false;
|
||||
|
||||
ScenarioIdentifier id;
|
||||
|
|
|
@ -105,7 +105,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
|
|||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
|
||||
fp = FioFOpenFile(filename, "rb");
|
||||
fp = FioFOpenFile(filename, "rb", HEIGHTMAP_DIR);
|
||||
if (fp == NULL) {
|
||||
ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_FILE_NOT_FOUND, WL_ERROR);
|
||||
return false;
|
||||
|
@ -228,7 +228,7 @@ static bool ReadHeightmapBMP(char *filename, uint *x, uint *y, byte **map)
|
|||
/* Init BmpData */
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
f = FioFOpenFile(filename, "rb");
|
||||
f = FioFOpenFile(filename, "rb", HEIGHTMAP_DIR);
|
||||
if (f == NULL) {
|
||||
ShowErrorMessage(STR_ERROR_BMPMAP, STR_ERROR_PNGMAP_FILE_NOT_FOUND, WL_ERROR);
|
||||
return false;
|
||||
|
|
|
@ -281,7 +281,7 @@ bool LoadOldSaveGame(const char *file)
|
|||
InitLoading(&ls);
|
||||
|
||||
/* Open file */
|
||||
ls.file = FioFOpenFile(file, "rb");
|
||||
ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY);
|
||||
|
||||
if (ls.file == NULL) {
|
||||
DEBUG(oldloader, 0, "Cannot open file '%s'", file);
|
||||
|
@ -320,7 +320,7 @@ bool LoadOldSaveGame(const char *file)
|
|||
|
||||
void GetOldSaveGameName(const char *file, char *title, const char *last)
|
||||
{
|
||||
FILE *f = FioFOpenFile(file, "rb");
|
||||
FILE *f = FioFOpenFile(file, "rb", NO_DIRECTORY);
|
||||
|
||||
if (f == NULL) {
|
||||
*title = '\0';
|
||||
|
|
|
@ -42,7 +42,7 @@ static bool OpenPNGFile(const char *filename, uint32 id, bool mask)
|
|||
/* Add path separator after 'sprites' if not present */
|
||||
const char *sep = (filename[0] == PATHSEPCHAR) ? "" : PATHSEP;
|
||||
snprintf(png_file, sizeof(png_file), "sprites%s%s" PATHSEP "%d%s.png", sep, filename, id, mask ? "m" : "");
|
||||
if (FioCheckFileExists(png_file)) {
|
||||
if (FioCheckFileExists(png_file, NEWGRF_DIR)) {
|
||||
FioOpenFile(PNG_SLOT, png_file, NEWGRF_DIR);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue