diff --git a/src/dusk/imgui/ImGuiMenuRandomizer.cpp b/src/dusk/imgui/ImGuiMenuRandomizer.cpp index 2f12dbd88b..ba6852fae8 100644 --- a/src/dusk/imgui/ImGuiMenuRandomizer.cpp +++ b/src/dusk/imgui/ImGuiMenuRandomizer.cpp @@ -234,7 +234,7 @@ namespace dusk { } if (randomizer_IsActive()) { - auto currentItems = getSaveItemPool(trackerRando->GetWorlds()[0].get()); + auto currentItems = getSaveItemPool(trackerRando->GetWorld()); m_currentSearch = randomizer::logic::search::Search::AccessibleNoStartingInventory(&trackerRando->GetWorlds(), currentItems); } m_currentSearch.SearchWorlds(); @@ -252,7 +252,7 @@ namespace dusk { ImGui::InputText("Location Filter", m_locationFilter, 100); // Show total number of available locations - auto locations = trackerRando->GetWorlds()[0]->GetAllLocations(); + auto locations = trackerRando->GetWorld()->GetAllLocations(); auto numProgressionLocations = std::ranges::count_if(locations, [](auto* location) {return location->IsProgression();}); auto numAvailableLocations = m_currentSearch._visitedLocations.size(); ImGui::Text("Locations Available: %zu / %zu", numAvailableLocations, numProgressionLocations); @@ -318,7 +318,7 @@ namespace dusk { void ImGuiMenuRandomizer::generateLocationInfo() { auto trackerRando = getTrackerRando(); - auto locations = trackerRando->GetWorlds()[0]->GetAllLocations(); + auto locations = trackerRando->GetWorld()->GetAllLocations(); m_LocationInfo.clear(); diff --git a/src/dusk/randomizer/game/randomizer_context.cpp b/src/dusk/randomizer/game/randomizer_context.cpp index bca6f07e6f..09e05f5b55 100644 --- a/src/dusk/randomizer/game/randomizer_context.cpp +++ b/src/dusk/randomizer/game/randomizer_context.cpp @@ -915,7 +915,7 @@ void parseObjPatchData(stage_tgsc_data_class& object, const YAML::Node& patchNod } } -RandomizerContext WriteSeedData(const std::unique_ptr& world) { +RandomizerContext WriteSeedData(randomizer::logic::world::World* world) { RandomizerContext randoData{}; // Settings we need to check ingame @@ -1248,7 +1248,7 @@ void GenerateAndWriteSeed(std::string& generationStatusMsg) { return; } - const auto& world = r.GetWorlds()[0]; + const auto world = r.GetWorld(); RandomizerContext randoData{}; try { randoData = WriteSeedData(world); diff --git a/src/dusk/randomizer/generator/randomizer.cpp b/src/dusk/randomizer/generator/randomizer.cpp index b49239b74b..96403eb017 100644 --- a/src/dusk/randomizer/generator/randomizer.cpp +++ b/src/dusk/randomizer/generator/randomizer.cpp @@ -19,6 +19,15 @@ namespace randomizer { + logic::world::World* Randomizer::GetWorld(int worldId /*= 1*/) { + auto worldIndex = worldId - 1; + if (worldIndex < this->_worlds.size()) { + return this->_worlds.at(worldIndex).get(); + } + + return nullptr; + } + std::optional Randomizer::Generate() { try diff --git a/src/dusk/randomizer/generator/randomizer.hpp b/src/dusk/randomizer/generator/randomizer.hpp index 3f1d75eefc..4fef986968 100644 --- a/src/dusk/randomizer/generator/randomizer.hpp +++ b/src/dusk/randomizer/generator/randomizer.hpp @@ -23,6 +23,12 @@ namespace randomizer auto& GetConfig() { return this->_config; } auto& GetWorlds() { return this->_worlds; } + /** + * @param worldId + * @return The world with the specified Id. If no Id is specified, the first world will + * be returned. If a world with the Id does not exist, a nullptr will be returned. + */ + logic::world::World* GetWorld(int worldId = 1); int GetNewEventID() { return ++(this->_eventIdCounter); } int GetNewAreaID() { return ++(this->_areaIdCounter); }