From b4f832f29f44dcd48e8f0806d47ce78b1963d639 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 20:54:37 +0000 Subject: (svn r23605) -Add: GAME_DIR and CONTENT_TYPE_GAME, and read gamescript from that directory --- src/console_cmds.cpp | 2 +- src/fileio.cpp | 8 ++++++-- src/fileio_func.h | 3 ++- src/fileio_type.h | 1 + src/network/core/tcp_content.h | 1 + src/network/network_content.cpp | 6 ++++++ src/script/squirrel.cpp | 2 ++ 7 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 5927f78ab..1844c552e 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1732,7 +1732,7 @@ DEF_CONSOLE_CMD(ConContent) 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 }; diff --git a/src/fileio.cpp b/src/fileio.cpp index 82b2f7c7e..95f3a1594 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -281,6 +281,7 @@ static const char * const _subdirs[] = { "lang" PATHSEP, "ai" PATHSEP, "ai" PATHSEP "library" PATHSEP, + "game" PATHSEP, }; assert_compile(lengthof(_subdirs) == NUM_SUBDIRS); @@ -675,6 +676,9 @@ uint TarScanner::DoScan(Subdirectory sd) 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 @@ void DeterminePaths(const char *exe) #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 @@ 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, 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); diff --git a/src/fileio_func.h b/src/fileio_func.h index 4c12bafee..6dea50e9c 100644 --- a/src/fileio_func.h +++ b/src/fileio_func.h @@ -100,7 +100,8 @@ public: 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); diff --git a/src/fileio_type.h b/src/fileio_type.h index 0673bfc6d..83826b70d 100644 --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -30,6 +30,7 @@ enum Subdirectory { 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 }; diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index 263ce6ba6..dc56f1ad9 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -32,6 +32,7 @@ enum ContentType { 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 }; diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 0e08cb705..28700b69c 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -182,6 +182,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type) 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 @@ static char *GetFullFilename(const ContentInfo *ci, bool compressed) 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 @@ void ClientNetworkContentSocketHandler::AfterDownload() 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: diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 0465bd31c..bc02be5f4 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -449,6 +449,8 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer 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(); } -- cgit v1.2.3-70-g09d2