|
@@ -262,48 +262,49 @@ void FioOpenFile(int slot, const char *f
|
|
|
strtolower(_fio.shortnames[slot]);
|
|
|
|
|
|
#if defined(LIMITED_FDS)
|
|
|
_fio.usage_count[slot] = 0;
|
|
|
_fio.open_handles++;
|
|
|
#endif /* LIMITED_FDS */
|
|
|
FioSeekToFile(slot, pos);
|
|
|
}
|
|
|
|
|
|
static const char * const _subdirs[] = {
|
|
|
"",
|
|
|
"save" PATHSEP,
|
|
|
"save" PATHSEP "autosave" PATHSEP,
|
|
|
"scenario" PATHSEP,
|
|
|
"scenario" PATHSEP "heightmap" PATHSEP,
|
|
|
"gm" PATHSEP,
|
|
|
"data" PATHSEP,
|
|
|
"baseset" PATHSEP,
|
|
|
"newgrf" PATHSEP,
|
|
|
"lang" PATHSEP,
|
|
|
"ai" PATHSEP,
|
|
|
"ai" PATHSEP "library" PATHSEP,
|
|
|
"game" PATHSEP,
|
|
|
"game" PATHSEP "library" PATHSEP,
|
|
|
"screenshot" PATHSEP,
|
|
|
};
|
|
|
assert_compile(lengthof(_subdirs) == NUM_SUBDIRS);
|
|
|
|
|
|
const char *_searchpaths[NUM_SEARCHPATHS];
|
|
|
TarList _tar_list[NUM_SUBDIRS];
|
|
|
TarFileList _tar_filelist[NUM_SUBDIRS];
|
|
|
|
|
|
typedef std::map<std::string, std::string> TarLinkList;
|
|
|
static TarLinkList _tar_linklist[NUM_SUBDIRS]; ///< List of directory links
|
|
|
|
|
|
/**
|
|
|
* Check whether the given file exists
|
|
|
* @param filename the file to try for existence.
|
|
|
* @param subdir the subdirectory to look in
|
|
|
* @return true if and only if the file can be opened
|
|
|
*/
|
|
|
bool FioCheckFileExists(const char *filename, Subdirectory subdir)
|
|
|
{
|
|
|
FILE *f = FioFOpenFile(filename, "rb", subdir);
|
|
|
if (f == NULL) return false;
|
|
|
|
|
|
FioFCloseFile(f);
|
|
|
return true;
|
|
|
}
|
|
@@ -1181,49 +1182,49 @@ void DeterminePaths(const char *exe)
|
|
|
};
|
|
|
|
|
|
for (uint i = 0; i < lengthof(new_openttd_cfg_order); i++) {
|
|
|
if (IsValidSearchPath(new_openttd_cfg_order[i])) {
|
|
|
_personal_dir = strdup(_searchpaths[new_openttd_cfg_order[i]]);
|
|
|
_config_file = str_fmt("%sopenttd.cfg", _personal_dir);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DEBUG(misc, 3, "%s found as personal directory", _personal_dir);
|
|
|
|
|
|
_highscore_file = str_fmt("%shs.dat", _personal_dir);
|
|
|
extern char *_hotkeys_file;
|
|
|
_hotkeys_file = str_fmt("%shotkeys.cfg", _personal_dir);
|
|
|
|
|
|
/* Make the necessary folders */
|
|
|
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && defined(WITH_PERSONAL_DIR)
|
|
|
FioCreateDirectory(_personal_dir);
|
|
|
#endif
|
|
|
|
|
|
static const Subdirectory default_subdirs[] = {
|
|
|
SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR
|
|
|
SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR
|
|
|
};
|
|
|
|
|
|
for (uint i = 0; i < lengthof(default_subdirs); i++) {
|
|
|
char *dir = str_fmt("%s%s", _personal_dir, _subdirs[default_subdirs[i]]);
|
|
|
FioCreateDirectory(dir);
|
|
|
free(dir);
|
|
|
}
|
|
|
|
|
|
/* If we have network we make a directory for the autodownloading of content */
|
|
|
_searchpaths[SP_AUTODOWNLOAD_DIR] = str_fmt("%s%s", _personal_dir, "content_download" PATHSEP);
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
|
|
|
|
|
|
/* Create the directory for each of the types of content */
|
|
|
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR };
|
|
|
for (uint i = 0; i < lengthof(dirs); i++) {
|
|
|
char *tmp = str_fmt("%s%s", _searchpaths[SP_AUTODOWNLOAD_DIR], _subdirs[dirs[i]]);
|
|
|
FioCreateDirectory(tmp);
|
|
|
free(tmp);
|
|
|
}
|
|
|
|
|
|
extern char *_log_file;
|
|
|
_log_file = str_fmt("%sopenttd.log", _personal_dir);
|
|
|
#else /* ENABLE_NETWORK */
|