Mercurial > hg > openttd
changeset 18757:8fb3d74f1cd1 draft
(svn r23605) -Add: GAME_DIR and CONTENT_TYPE_GAME, and read gamescript from that directory
author | truebrain <truebrain@openttd.org> |
---|---|
date | Mon, 19 Dec 2011 20:54:37 +0000 |
parents | 57f6fb58e30a |
children | 456d0db1f47b |
files | src/console_cmds.cpp src/fileio.cpp src/fileio_func.h src/fileio_type.h src/network/core/tcp_content.h src/network/network_content.cpp src/script/squirrel.cpp |
diffstat | 7 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1732,7 +1732,7 @@ if (strcasecmp(argv[1], "state") == 0) { IConsolePrintF(CC_WHITE, "id, type, state, name"); for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) { - static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" }; + static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music", "Game script" }; assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN); static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" }; static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
--- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -281,6 +281,7 @@ "lang" PATHSEP, "ai" PATHSEP, "ai" PATHSEP "library" PATHSEP, + "game" PATHSEP, }; assert_compile(lengthof(_subdirs) == NUM_SUBDIRS); @@ -675,6 +676,9 @@ num += fs.DoScan(AI_DIR); num += fs.DoScan(AI_LIBRARY_DIR); } + if (mode & TarScanner::GAME) { + num += fs.DoScan(GAME_DIR); + } if (mode & TarScanner::SCENARIO) { num += fs.DoScan(SCENARIO_DIR); } @@ -1195,7 +1199,7 @@ #endif static const Subdirectory default_subdirs[] = { - SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR + SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR }; for (uint i = 0; i < lengthof(default_subdirs); i++) { @@ -1210,7 +1214,7 @@ 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 }; + const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR }; for (uint i = 0; i < lengthof(dirs); i++) { char *tmp = str_fmt("%s%s", _searchpaths[SP_AUTODOWNLOAD_DIR], _subdirs[dirs[i]]); FioCreateDirectory(tmp);
--- a/src/fileio_func.h +++ b/src/fileio_func.h @@ -100,7 +100,8 @@ NEWGRF = 1 << 1, ///< Scan for non-base sets. AI = 1 << 2, ///< Scan for AIs and its libraries. SCENARIO = 1 << 3, ///< Scan for scenarios and heightmaps. - ALL = BASESET | NEWGRF | AI | SCENARIO, ///< Scan for everything. + GAME = 1 << 4, ///< Scan for game scripts. + ALL = BASESET | NEWGRF | AI | SCENARIO | GAME, ///< Scan for everything. }; /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL);
--- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -30,6 +30,7 @@ LANG_DIR, ///< Subdirectory for all translation files AI_DIR, ///< Subdirectory for all AI files AI_LIBRARY_DIR,///< Subdirectory for all AI libraries + GAME_DIR, ///< Subdirectory for all game scripts NUM_SUBDIRS, ///< Number of subdirectories NO_DIRECTORY, ///< A path without any base directory };
--- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -32,6 +32,7 @@ CONTENT_TYPE_HEIGHTMAP = 6, ///< The content consists of a heightmap CONTENT_TYPE_BASE_SOUNDS = 7, ///< The content consists of base sounds CONTENT_TYPE_BASE_MUSIC = 8, ///< The content consists of base music + CONTENT_TYPE_GAME = 9, ///< The content consists of a game script CONTENT_TYPE_END, ///< Helper to mark the end of the types };
--- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -182,6 +182,7 @@ this->RequestContentList(CONTENT_TYPE_HEIGHTMAP); this->RequestContentList(CONTENT_TYPE_AI); this->RequestContentList(CONTENT_TYPE_AI_LIBRARY); + this->RequestContentList(CONTENT_TYPE_GAME); this->RequestContentList(CONTENT_TYPE_NEWGRF); return; } @@ -384,6 +385,7 @@ case CONTENT_TYPE_AI_LIBRARY: dir = AI_LIBRARY_DIR; break; case CONTENT_TYPE_SCENARIO: dir = SCENARIO_DIR; break; case CONTENT_TYPE_HEIGHTMAP: dir = HEIGHTMAP_DIR; break; + case CONTENT_TYPE_GAME: dir = GAME_DIR; break; } static char buf[MAX_PATH]; @@ -546,6 +548,10 @@ sd = AI_LIBRARY_DIR; break; + case CONTENT_TYPE_GAME: + sd = GAME_DIR; + break; + case CONTENT_TYPE_BASE_GRAPHICS: case CONTENT_TYPE_BASE_SOUNDS: case CONTENT_TYPE_BASE_MUSIC:
--- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -449,6 +449,8 @@ if (strncmp(this->GetAPIName(), "AI", 2) == 0) { file = FioFOpenFile(filename, "rb", AI_DIR, &size); if (file == NULL) file = FioFOpenFile(filename, "rb", AI_LIBRARY_DIR, &size); + } else if (strncmp(this->GetAPIName(), "GS", 2) == 0) { + file = FioFOpenFile(filename, "rb", GAME_DIR, &size); } else { NOT_REACHED(); }