(svn r23605) -Add: GAME_DIR and CONTENT_TYPE_GAME, and read gamescript from that directory

pull/155/head
truebrain 13 years ago
parent f66f27d249
commit 14325e2391

@ -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 };

@ -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);

@ -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);

@ -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
};

@ -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
};

@ -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:

@ -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();
}

Loading…
Cancel
Save