Changeset - r18747:12d6e8d373e7
[Not reviewed]
master
0 7 0
truebrain - 12 years ago 2011-12-19 20:54:37
truebrain@openttd.org
(svn r23605) -Add: GAME_DIR and CONTENT_TYPE_GAME, and read gamescript from that directory
7 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -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 };
src/fileio.cpp
Show inline comments
 
@@ -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);
src/fileio_func.h
Show inline comments
 
@@ -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);
src/fileio_type.h
Show inline comments
 
@@ -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
 
};
src/network/core/tcp_content.h
Show inline comments
 
@@ -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
 
};
 

	
src/network/network_content.cpp
Show inline comments
 
@@ -182,6 +182,7 @@ void ClientNetworkContentSocketHandler::
 
		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 Conte
 
		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::
 
					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:
src/script/squirrel.cpp
Show inline comments
 
@@ -449,6 +449,8 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM 
 
	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();
 
	}
0 comments (0 inline, 0 general)