summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-08-24 13:33:49 +0000
committerrubidium <rubidium@openttd.org>2011-08-24 13:33:49 +0000
commit0061b5f1842776ff4d69bf9f3bcdfb348b2f5a76 (patch)
tree3f45b215933b577fb159c9df743926ebdca1d126
parentbbdc8fdba7d30099d80227659919930f3dedf84b (diff)
downloadopenttd-0061b5f1842776ff4d69bf9f3bcdfb348b2f5a76.tar.xz
(svn r22822) -Codechange: make a distinction between base sets and newgrfs for their directory
-rw-r--r--src/ai/ai_scanner.cpp2
-rw-r--r--src/base_media_base.h4
-rw-r--r--src/fileio.cpp8
-rw-r--r--src/fileio_func.h4
-rw-r--r--src/fileio_type.h3
-rw-r--r--src/gfxinit.cpp6
-rw-r--r--src/ini.cpp2
-rw-r--r--src/network/network_content.cpp6
-rw-r--r--src/newgrf_config.cpp4
-rw-r--r--src/openttd.cpp2
10 files changed, 22 insertions, 19 deletions
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 9eb018b3a..424746c07 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -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... */
diff --git a/src/base_media_base.h b/src/base_media_base.h
index e0c02887d..f83d644ca 100644
--- a/src/base_media_base.h
+++ b/src/base_media_base.h
@@ -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 */
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 2215f3705..4bc475857 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -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);
diff --git a/src/fileio_func.h b/src/fileio_func.h
index 1580fd6cc..7f39f09e8 100644
--- a/src/fileio_func.h
+++ b/src/fileio_func.h
@@ -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);
diff --git a/src/fileio_type.h b/src/fileio_type.h
index 66c02be6b..355ff36d1 100644
--- a/src/fileio_type.h
+++ b/src/fileio_type.h
@@ -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
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 0a2d82973..98d0ad390 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -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;
diff --git a/src/ini.cpp b/src/ini.cpp
index 8173d3733..016e382c9 100644
--- a/src/ini.cpp
+++ b/src/ini.cpp
@@ -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)
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 5cf4aa724..3c7730684 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -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;
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index ad73f5b3d..edd64745c 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -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;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 9d363f231..b884d6229 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -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);