diff --git a/gui/desktop/tracker/tracker.cpp b/gui/desktop/tracker/tracker.cpp index b315fac9..14567767 100644 --- a/gui/desktop/tracker/tracker.cpp +++ b/gui/desktop/tracker/tracker.cpp @@ -1046,7 +1046,7 @@ void MainWindow::check_special_accessibility_conditions() void MainWindow::update_tracker_areas_and_autosave() { - getAccessibleLocations(trackerWorlds, trackerInventory, trackerLocations); + getAccessibleLocations(trackerWorlds, trackerInventory, trackerLocations, -1, true); check_special_accessibility_conditions(); // Apply any own dungeon items after we get the accessible locations @@ -1078,7 +1078,7 @@ void MainWindow::update_tracker_areas_and_autosave() if (addedItems) { - getAccessibleLocations(trackerWorlds, trackerInventoryExtras, trackerLocations); + getAccessibleLocations(trackerWorlds, trackerInventoryExtras, trackerLocations, -1, true); check_special_accessibility_conditions(); } } @@ -1666,7 +1666,7 @@ void MainWindow::calculate_own_dungeon_key_locations() } // Find all possible locations for this key in the dungeon - auto accessibleLocations = getAccessibleLocations(trackerWorlds, itemPool, trackerLocations); + auto accessibleLocations = getAccessibleLocations(trackerWorlds, itemPool, trackerLocations, -1, true); auto potentialKeyLocations = filterFromPool(accessibleLocations, [&](Location* loc){return loc->getName().starts_with(dungeonName);}); // Save the possible locations for this key diff --git a/logic/Search.cpp b/logic/Search.cpp index 1ef48a4b..195011ca 100644 --- a/logic/Search.cpp +++ b/logic/Search.cpp @@ -10,7 +10,7 @@ #include // Recursively explore new areas based on the given areaEntry -void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet& ownedItems, const EventSet& ownedEvents, Area* area, std::list& eventsToTry, std::list& exitsToTry, std::list& locationsToTry) +void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet& ownedItems, const EventSet& ownedEvents, Area* area, std::list& eventsToTry, std::list& exitsToTry, std::list& locationsToTry, bool tracker) { for (auto& eventAccess : area->events) { @@ -18,13 +18,13 @@ void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet } for (auto& exit : area->exits) { - // If the exit is disconnected, then ignore it + // If the exit is disconnected, then ignore it unless we're searching for the tracker if (exit.getConnectedArea() == nullptr) { // Evaluate the exit still for tracker purposes - if (!exit.hasBeenFound() && evaluateRequirement(exit.getWorld(), exit.getRequirement(), &ownedItems, &ownedEvents)) + if (tracker) { - exit.setFound(true); + exitsToTry.push_front(&exit); } continue; } @@ -63,7 +63,7 @@ void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet { exit.setFound(true); connectedArea->isAccessible = true; - explore(searchMode, worlds, ownedItems, ownedEvents, connectedArea, eventsToTry, exitsToTry, locationsToTry); + explore(searchMode, worlds, ownedItems, ownedEvents, connectedArea, eventsToTry, exitsToTry, locationsToTry, tracker); } else { @@ -72,11 +72,6 @@ void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet exitsToTry.push_front(&exit); } } - // If this exit hasn't been found, but is now found, mark it as such (for the tracker) - else if (!exit.hasBeenFound() && evaluateRequirement(exit.getWorld(), exit.getRequirement(), &ownedItems, &ownedEvents)) - { - exit.setFound(true); - } } for (auto& locAccess : area->locations) { @@ -89,7 +84,7 @@ void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet // Argument 2 is a copy of the passed in ItemPool since we want to modify // it locally. If worldToSearch is not -1 then only the world with that worldId // will be searched. -LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool items, int worldToSearch /* = -1 */) +LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool items, int worldToSearch /* = -1 */, bool tracker /*= false*/) { // Add starting inventory items to the pool of items for (auto& world : worlds) @@ -220,7 +215,7 @@ LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool it newThingsFound = true; newEventsOrExits = true; connectedArea->isAccessible = true; - explore(searchMode, worlds, ownedItems, ownedEvents, connectedArea, eventsToTry, exitsToTry, locationsToTry); + explore(searchMode, worlds, ownedItems, ownedEvents, connectedArea, eventsToTry, exitsToTry, locationsToTry, tracker); } } else @@ -290,9 +285,9 @@ LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool it return accessibleLocations; } -LocationPool getAccessibleLocations(WorldPool& worlds, ItemPool& items, LocationPool& allowedLocations, int worldToSearch /*= -1*/) +LocationPool getAccessibleLocations(WorldPool& worlds, ItemPool& items, LocationPool& allowedLocations, int worldToSearch /*= -1*/, bool tracker /*= false*/) { - auto accessibleLocations = search(SearchMode::AccessibleLocations, worlds, items, worldToSearch); + auto accessibleLocations = search(SearchMode::AccessibleLocations, worlds, items, worldToSearch, tracker); // Filter to only those locations which are allowed return filterFromPool(accessibleLocations, [allowedLocations](Location* loc){return elementInPool(loc, allowedLocations) && loc->currentItem.getGameItemId() == GameItem::INVALID;}); } diff --git a/logic/Search.hpp b/logic/Search.hpp index 21b26cb1..962bf140 100644 --- a/logic/Search.hpp +++ b/logic/Search.hpp @@ -12,8 +12,8 @@ enum struct SearchMode GeneratePlaythrough, }; -LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool items, int worldToSearch = -1); -LocationPool getAccessibleLocations(WorldPool& worlds, ItemPool& items, LocationPool& allowedLocations, int worldToSearch = -1); +LocationPool search(const SearchMode& searchMode, WorldPool& worlds, ItemPool items, int worldToSearch = -1, bool tracker = false); +LocationPool getAccessibleLocations(WorldPool& worlds, ItemPool& items, LocationPool& allowedLocations, int worldToSearch = -1, bool tracker = false); void runGeneralSearch(WorldPool& worlds, int worldToSearch = -1); bool gameBeatable(WorldPool& worlds); void generatePlaythrough(WorldPool& worlds);