fix command line hosting of scenario files

This commit is contained in:
IntelOrca 2016-03-05 12:20:02 +00:00
parent 4c60c124c9
commit a99a2f0cf4
4 changed files with 13 additions and 10 deletions

View File

@ -208,7 +208,7 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
const char * parkUri;
if (!enumerator->TryPopString(&parkUri))
{
Console::Error::WriteLine("Expected path or URL to a saved park.");
Console::Error::WriteLine("Expected path or URL to a scenario or saved park.");
return EXITCODE_FAIL;
}

View File

@ -277,8 +277,9 @@ void openrct2_launch()
break;
case STARTUP_ACTION_OPEN:
assert(gOpenRCT2StartupActionPath != NULL);
if (rct2_open_file(gOpenRCT2StartupActionPath) == 0)
if (!rct2_open_file(gOpenRCT2StartupActionPath)) {
break;
}
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING;

View File

@ -345,30 +345,32 @@ static void rct2_draw_fps()
gfx_set_dirty_blocks(x - 16, y - 4, gLastDrawStringX + 16, 16);
}
int rct2_open_file(const char *path)
bool rct2_open_file(const char *path)
{
char *extension = strrchr(path, '.');
if (extension == NULL)
return 0;
if (extension == NULL) {
return false;
}
extension++;
if (_stricmp(extension, "sv6") == 0) {
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, path);
game_load_save(path);
return 1;
return true;
} else if (_stricmp(extension, "sc6") == 0) {
// TODO scenario install
rct_scenario_basic scenarioBasic;
strcpy(scenarioBasic.path, path);
scenario_load_and_play_from_path(scenarioBasic.path);
return true;
} else if (_stricmp(extension, "td6") == 0 || _stricmp(extension, "td4") == 0) {
return 1;
return true;
} else if (!_stricmp(extension, "td6") || !_stricmp(extension, "td4")) {
// TODO track design install
return 1;
return true;
}
return 0;
return false;
}
/**

View File

@ -275,6 +275,6 @@ int check_files_integrity();
const char *get_file_path(int pathId);
void rct2_quit();
int rct2_open_file(const char *path);
bool rct2_open_file(const char *path);
#endif