Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gui/desktop/tracker/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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
Expand Down
23 changes: 9 additions & 14 deletions logic/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
#include <command/Log.hpp>

// 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<EventAccess*>& eventsToTry, std::list<Entrance*>& exitsToTry, std::list<LocationAccess*>& locationsToTry)
void explore(const SearchMode& searchMode, WorldPool& worlds, const ItemMultiSet& ownedItems, const EventSet& ownedEvents, Area* area, std::list<EventAccess*>& eventsToTry, std::list<Entrance*>& exitsToTry, std::list<LocationAccess*>& locationsToTry, bool tracker)
{
for (auto& eventAccess : area->events)
{
eventsToTry.push_back(&eventAccess);
}
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;
}
Expand Down Expand Up @@ -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
{
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;});
}
Expand Down
4 changes: 2 additions & 2 deletions logic/Search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down