Fix #8841: Catch exceptions when loading parks from title editor (#8843)

This commit is contained in:
Ted John 2019-03-11 16:31:02 +00:00 committed by GitHub
parent 25eb403c78
commit 85c1ec8fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 12 deletions

View File

@ -363,21 +363,27 @@ static void window_title_editor_mouseup(rct_window* w, rct_widgetindex widgetInd
auto handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
auto stream = (IStream*)handle->Stream;
auto hintPath = String::ToStd(handle->HintPath);
bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager();
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
auto result = parkImporter->LoadFromStream(stream, isScenario);
objectMgr.LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
parkImporter->Import();
try
{
auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager();
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
auto result = parkImporter->LoadFromStream(stream, isScenario);
objectMgr.LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
parkImporter->Import();
if (isScenario)
scenario_begin();
else
game_load_init();
if (isScenario)
scenario_begin();
else
game_load_init();
TitleSequenceCloseParkHandle(handle);
window_title_editor_open(WINDOW_TITLE_EDITOR_TAB_SAVES);
TitleSequenceCloseParkHandle(handle);
window_title_editor_open(WINDOW_TITLE_EDITOR_TAB_SAVES);
}
catch (const std::exception&)
{
context_show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
}
}
break;