(svn r22822) -Codechange: make a distinction between base sets and newgrfs for their directory

This commit is contained in:
rubidium 2011-08-24 13:33:49 +00:00
parent bbdc8fdba7
commit 0061b5f184
10 changed files with 22 additions and 19 deletions

View File

@ -384,7 +384,7 @@ struct AIFileChecksumCreator : FileScanner {
byte tmp_md5sum[16];
/* Open the file ... */
FILE *f = FioFOpenFile(filename, "rb", DATA_DIR, &size);
FILE *f = FioFOpenFile(filename, "rb", AI_DIR, &size);
if (f == NULL) return false;
/* ... calculate md5sum... */

View File

@ -198,7 +198,7 @@ enum GraphicsFileType {
};
/** All data of a graphics set. */
struct GraphicsSet : BaseSet<GraphicsSet, MAX_GFT, DATA_DIR> {
struct GraphicsSet : BaseSet<GraphicsSet, MAX_GFT, BASESET_DIR> {
PaletteType palette; ///< Palette of this graphics set
bool FillSetDetails(struct IniFile *ini, const char *path, const char *full_filename);
@ -210,7 +210,7 @@ public:
};
/** All data of a sounds set. */
struct SoundsSet : BaseSet<SoundsSet, 1, DATA_DIR> {
struct SoundsSet : BaseSet<SoundsSet, 1, BASESET_DIR> {
};
/** All data/functions related with replacing the base sounds */

View File

@ -267,7 +267,7 @@ void FioOpenFile(int slot, const char *filename)
FioSeekToFile(slot, pos);
}
static const char * const _subdirs[NUM_SUBDIRS] = {
static const char * const _subdirs[] = {
"",
"save" PATHSEP,
"save" PATHSEP "autosave" PATHSEP,
@ -275,10 +275,12 @@ static const char * const _subdirs[NUM_SUBDIRS] = {
"scenario" PATHSEP "heightmap" PATHSEP,
"gm" PATHSEP,
"data" PATHSEP,
"data" PATHSEP,
"lang" PATHSEP,
"ai" PATHSEP,
"ai" PATHSEP "library" PATHSEP,
};
assert_compile(lengthof(_subdirs) == NUM_SUBDIRS);
const char *_searchpaths[NUM_SEARCHPATHS];
TarList _tar_list;
@ -636,7 +638,7 @@ static void SimplifyFileName(char *name)
DEBUG(misc, 1, "Scanning for tars");
TarScanner fs;
uint num = fs.Scan(".tar", DATA_DIR, false);
uint num = fs.Scan(".tar", NEWGRF_DIR, false);
num += fs.Scan(".tar", AI_DIR, false);
num += fs.Scan(".tar", AI_LIBRARY_DIR, false);
num += fs.Scan(".tar", SCENARIO_DIR, false);
@ -1156,7 +1158,7 @@ void DeterminePaths(const char *exe)
FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
/* Create the directory for each of the types of content */
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, DATA_DIR, AI_DIR, AI_LIBRARY_DIR, GM_DIR };
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GM_DIR };
for (uint i = 0; i < lengthof(dirs); i++) {
char *tmp = str_fmt("%s%s", _searchpaths[SP_AUTODOWNLOAD_DIR], _subdirs[dirs[i]]);
FioCreateDirectory(tmp);

View File

@ -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 = DATA_DIR, size_t *filesize = NULL);
bool FioCheckFileExists(const char *filename, Subdirectory subdir = DATA_DIR);
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);
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);

View File

@ -24,7 +24,8 @@ enum Subdirectory {
SCENARIO_DIR, ///< Base directory for all scenarios
HEIGHTMAP_DIR, ///< Subdirectory of scenario for heightmaps
GM_DIR, ///< Subdirectory for all music
DATA_DIR, ///< Subdirectory for all data (GRFs, sample.cat, intro game)
BASESET_DIR, ///< Subdirectory for all base data (base sets, intro game)
NEWGRF_DIR, ///< Subdirectory for all NewGRFs
LANG_DIR, ///< Subdirectory for all translation files
AI_DIR, ///< Subdirectory for all AI files
AI_LIBRARY_DIR,///< Subdirectory for all AI libraries

View File

@ -108,7 +108,7 @@ void CheckExternalFiles()
/* Not all files were loaded successfully, see which ones */
add_pos += seprintf(add_pos, last, "Trying to load graphics set '%s', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of readme.txt.\n\nThe following files are corrupted or missing:\n", used_set->name);
for (uint i = 0; i < GraphicsSet::NUM_FILES; i++) {
MD5File::ChecksumResult res = used_set->files[i].CheckMD5(DATA_DIR);
MD5File::ChecksumResult res = used_set->files[i].CheckMD5(BASESET_DIR);
if (res != MD5File::CR_MATCH) add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", used_set->files[i].filename, res == MD5File::CR_MISMATCH ? "corrupt" : "missing", used_set->files[i].missing_warning);
}
add_pos += seprintf(add_pos, last, "\n");
@ -121,7 +121,7 @@ void CheckExternalFiles()
assert_compile(SoundsSet::NUM_FILES == 1);
/* No need to loop each file, as long as there is only a single
* sound file. */
add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", sounds_set->files->filename, sounds_set->files->CheckMD5(DATA_DIR) == MD5File::CR_MISMATCH ? "corrupt" : "missing", sounds_set->files->missing_warning);
add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", sounds_set->files->filename, sounds_set->files->CheckMD5(BASESET_DIR) == MD5File::CR_MISMATCH ? "corrupt" : "missing", sounds_set->files->missing_warning);
}
if (add_pos != error_msg) ShowInfoF("%s", error_msg);
@ -208,7 +208,7 @@ void GfxLoadSprites()
bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path, const char *full_filename)
{
bool ret = this->BaseSet<GraphicsSet, MAX_GFT, DATA_DIR>::FillSetDetails(ini, path, full_filename, false);
bool ret = this->BaseSet<GraphicsSet, MAX_GFT, BASESET_DIR>::FillSetDetails(ini, path, full_filename, false);
if (ret) {
IniGroup *metadata = ini->GetGroup("metadata");
IniItem *item;

View File

@ -115,7 +115,7 @@ bool IniFile::SaveToDisk(const char *filename)
{
/* Open the text file in binary mode to prevent end-of-line translations
* done by ftell() and friends, as defined by K&R. */
return FioFOpenFile(filename, "rb", DATA_DIR, size);
return FioFOpenFile(filename, "rb", BASESET_DIR, size);
}
/* virtual */ void IniFile::ReportFileError(const char * const pre, const char * const buffer, const char * const post)

View File

@ -375,10 +375,10 @@ static char *GetFullFilename(const ContentInfo *ci, bool compressed)
Subdirectory dir;
switch (ci->type) {
default: return NULL;
case CONTENT_TYPE_BASE_GRAPHICS: dir = DATA_DIR; break;
case CONTENT_TYPE_BASE_GRAPHICS: dir = BASESET_DIR; break;
case CONTENT_TYPE_BASE_MUSIC: dir = GM_DIR; break;
case CONTENT_TYPE_BASE_SOUNDS: dir = DATA_DIR; break;
case CONTENT_TYPE_NEWGRF: dir = DATA_DIR; break;
case CONTENT_TYPE_BASE_SOUNDS: dir = BASESET_DIR; break;
case CONTENT_TYPE_NEWGRF: dir = NEWGRF_DIR; break;
case CONTENT_TYPE_AI: dir = AI_DIR; break;
case CONTENT_TYPE_AI_LIBRARY: dir = AI_LIBRARY_DIR; break;
case CONTENT_TYPE_SCENARIO: dir = SCENARIO_DIR; break;

View File

@ -292,7 +292,7 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
size_t len, size;
/* open the file */
f = FioFOpenFile(config->filename, "rb", DATA_DIR, &size);
f = FioFOpenFile(config->filename, "rb", NEWGRF_DIR, &size);
if (f == NULL) return false;
/* calculate md5sum */
@ -543,7 +543,7 @@ public:
static uint DoScan()
{
GRFFileScanner fs;
int ret = fs.Scan(".grf", DATA_DIR);
int ret = fs.Scan(".grf", NEWGRF_DIR);
/* The number scanned and the number returned may not be the same;
* duplicate NewGRFs and base sets are ignored in the return value. */
_settings_client.gui.last_newgrf_count = fs.num_scanned;

View File

@ -280,7 +280,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
SetupColoursAndInitialWindow();
/* Load the default opening screen savegame */
if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) {
if (SaveOrLoad("opntitle.dat", SL_LOAD, BASESET_DIR) != SL_OK) {
GenerateWorld(GWM_EMPTY, 64, 64); // if failed loading, make empty world.
WaitTillGeneratedWorld();
SetLocalCompany(COMPANY_SPECTATOR);