diff --git a/src/openrct2-ui/windows/TitleEditor.cpp b/src/openrct2-ui/windows/TitleEditor.cpp index 746e7ec75b..160f90d32f 100644 --- a/src/openrct2-ui/windows/TitleEditor.cpp +++ b/src/openrct2-ui/windows/TitleEditor.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -374,10 +375,16 @@ static void window_title_editor_mouseup(rct_window * w, rct_widgetindex widgetIn case WIDX_TITLE_EDITOR_LOAD_SAVE: if (w->selected_list_item >= 0 && w->selected_list_item < (sint16)_editingTitleSequence->NumSaves) { - TitleSequenceParkHandle * handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item); - const utf8 * extension = path_get_extension(handle->HintPath); - bool isScenario = park_importer_extension_is_scenario(extension); - park_importer_load_from_stream(handle->Stream, handle->HintPath); + 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(ParkImporter::Create(hintPath)); + auto result = parkImporter->LoadFromStream(stream, isScenario); + objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size()); + parkImporter->Import(); if (isScenario) scenario_begin(); diff --git a/src/openrct2/ParkImporter.cpp b/src/openrct2/ParkImporter.cpp index fd22b97d43..4ff65a2f1d 100644 --- a/src/openrct2/ParkImporter.cpp +++ b/src/openrct2/ParkImporter.cpp @@ -52,20 +52,3 @@ namespace ParkImporter String::Equals(extension, ".sc6", true); } } - -void park_importer_load_from_stream(void * stream_c, const utf8 * hintPath_c) -{ - IStream * stream = (IStream *)stream_c; - std::string hintPath = String::ToStd(hintPath_c); - - bool isScenario = ParkImporter::ExtensionIsScenario(hintPath); - - auto parkImporter = std::unique_ptr(ParkImporter::Create(hintPath)); - parkImporter->LoadFromStream(stream, isScenario); - parkImporter->Import(); -} - -bool park_importer_extension_is_scenario(const utf8 * extension) -{ - return ParkImporter::ExtensionIsScenario(String::ToStd(extension)); -} diff --git a/src/openrct2/ParkImporter.h b/src/openrct2/ParkImporter.h index 96c4cd59a7..7e04fa0542 100644 --- a/src/openrct2/ParkImporter.h +++ b/src/openrct2/ParkImporter.h @@ -101,13 +101,3 @@ public: { } }; - -void park_importer_load_from_stream(void * stream, const utf8 * hintPath); -bool park_importer_extension_is_scenario(const utf8 * extension); - -PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t); -size_t ParkLoadResult_GetMissingObjectsCount(const ParkLoadResult * t); -const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t); -uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t); -void ParkLoadResult_Delete(ParkLoadResult * t); -ParkLoadResult * ParkLoadResult_CreateInvalidExtension(); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 03a4c32897..c3546c08d6 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2856,17 +2856,19 @@ std::unique_ptr ParkImporter::CreateS4() void load_from_sv4(const utf8 * path) { + auto objectMgr = GetContext()->GetObjectManager(); auto s4Importer = std::make_unique(); auto result = s4Importer->LoadSavedGame(path); - // TODO load objects + objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size()); s4Importer->Import(); } void load_from_sc4(const utf8 * path) { + auto objectMgr = GetContext()->GetObjectManager(); auto s4Importer = std::make_unique(); auto result = s4Importer->LoadScenario(path); - // TODO load objects + objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size()); s4Importer->Import(); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index a91361fdfc..268a721a00 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -439,11 +439,6 @@ public: // pad_13CE778 // Fix and set dynamic variables - // TODO objects should already be loaded - // if (!_objectManager->LoadObjects(_s6.objects, OBJECT_ENTRY_COUNT)) - // { - // throw ObjectLoadException(); - // } map_strip_ghost_flag_from_elements(); map_update_tile_pointers(); game_convert_strings_to_utf8(); @@ -851,8 +846,9 @@ void load_from_sv6(const char * path) auto s6Importer = std::make_unique(context->GetObjectRepository(), context->GetObjectManager()); try { + auto objectMgr = context->GetObjectManager(); auto result = s6Importer->LoadSavedGame(path); - // TODO load objects + objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size()); s6Importer->Import(); game_fix_save_vars(); sprite_position_tween_reset();