diff --git a/src/dusk/randomizer/logic/area.cpp b/src/dusk/randomizer/logic/area.cpp index c6d627069c..d2eed637a4 100644 --- a/src/dusk/randomizer/logic/area.cpp +++ b/src/dusk/randomizer/logic/area.cpp @@ -7,25 +7,25 @@ #include #include -namespace tphdr::logic::area +namespace randomizer::logic::area { int LocationAccess::_idCounter = 0; int Area::_idCounter = 0; - LocationAccess::LocationAccess(tphdr::logic::location::Location* loc, - const tphdr::logic::requirement::Requirement& req, + LocationAccess::LocationAccess(randomizer::logic::location::Location* loc, + const randomizer::logic::requirement::Requirement& req, Area* area): _loc(loc), _req(std::move(req)), _area(area) { this->_id = this->_idCounter++; } - tphdr::logic::location::Location* LocationAccess::GetLocation() const + randomizer::logic::location::Location* LocationAccess::GetLocation() const { return this->_loc; } - const tphdr::logic::requirement::Requirement& LocationAccess::GetRequirement() + const randomizer::logic::requirement::Requirement& LocationAccess::GetRequirement() { return this->_req; } @@ -38,12 +38,12 @@ namespace tphdr::logic::area return this->_id; } - EventAccess::EventAccess(const tphdr::logic::requirement::Requirement& req, Area* area, const int& eventIndex): + EventAccess::EventAccess(const randomizer::logic::requirement::Requirement& req, Area* area, const int& eventIndex): _req(std::move(req)), _area(area), _eventIndex(eventIndex) { } - const tphdr::logic::requirement::Requirement& EventAccess::GetRequirement() + const randomizer::logic::requirement::Requirement& EventAccess::GetRequirement() { return this->_req; } @@ -61,7 +61,7 @@ namespace tphdr::logic::area return this->_area->GetWorld()->GetEventName(this->_eventIndex); } - Area::Area(const std::string& name, tphdr::logic::world::World* world): _name(name), _world(world) + Area::Area(const std::string& name, randomizer::logic::world::World* world): _name(name), _world(world) { this->_id = this->_idCounter++; } @@ -108,14 +108,14 @@ namespace tphdr::logic::area return locations; } - void Area::SetExits(std::list>& exits) + void Area::SetExits(std::list>& exits) { this->_exits = std::move(exits); } - std::list Area::GetExits() const + std::list Area::GetExits() const { - std::list exits; + std::list exits; for (const auto& exit : this->_exits) { exits.emplace_back(exit.get()); @@ -123,33 +123,33 @@ namespace tphdr::logic::area return exits; } - void Area::AddExit(std::unique_ptr& exit) + void Area::AddExit(std::unique_ptr& exit) { this->_exits.push_back(std::move(exit)); } - void Area::RemoveExit(tphdr::logic::entrance::Entrance* exit) + void Area::RemoveExit(randomizer::logic::entrance::Entrance* exit) { auto removed = std::remove_if(this->_exits.begin(), this->_exits.end(), [&](const auto& e) { return e.get() == exit; }); this->_exits.erase(removed, this->_exits.end()); } - void Area::AddEntrance(tphdr::logic::entrance::Entrance* entrance) + void Area::AddEntrance(randomizer::logic::entrance::Entrance* entrance) { this->_entrances.emplace_back(entrance); } - void Area::RemoveEntrance(tphdr::logic::entrance::Entrance* entrance) + void Area::RemoveEntrance(randomizer::logic::entrance::Entrance* entrance) { auto removed = std::remove(this->_entrances.begin(), this->_entrances.end(), entrance); this->_entrances.erase(removed, this->_entrances.end()); } - std::list Area::GetEntrances() const + std::list Area::GetEntrances() const { return this->_entrances; } - tphdr::logic::world::World* Area::GetWorld() const + randomizer::logic::world::World* Area::GetWorld() const { return this->_world; } @@ -186,12 +186,12 @@ namespace tphdr::logic::area return this->_twilightCompletedMacroIndex; } - bool Area::TwilightCleared(tphdr::logic::search::Search* search) const + bool Area::TwilightCleared(randomizer::logic::search::Search* search) const { - return this->_twilightCompletedMacroIndex == -1 || tphdr::logic::requirement::EvaluateRequirementAtFormTime( + return this->_twilightCompletedMacroIndex == -1 || randomizer::logic::requirement::EvaluateRequirementAtFormTime( this->GetWorld()->GetMacro(this->_twilightCompletedMacroIndex), search, - tphdr::logic::requirement::FormTime::ALL, + randomizer::logic::requirement::FormTime::ALL, this->GetWorld()); } @@ -270,4 +270,4 @@ namespace tphdr::logic::area } } -} // namespace tphdr::logic::area +} // namespace randomizer::logic::area diff --git a/src/dusk/randomizer/logic/area.hpp b/src/dusk/randomizer/logic/area.hpp index d1a5934a32..b56025bd39 100644 --- a/src/dusk/randomizer/logic/area.hpp +++ b/src/dusk/randomizer/logic/area.hpp @@ -7,31 +7,31 @@ #include // Forward Declarations -namespace tphdr::logic::location +namespace randomizer::logic::location { class Location; } -namespace tphdr::logic::search +namespace randomizer::logic::search { class Search; } -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } -namespace tphdr::logic::area +namespace randomizer::logic::area { class Area; class LocationAccess { public: - LocationAccess(tphdr::logic::location::Location* loc, const tphdr::logic::requirement::Requirement& req, Area* area); + LocationAccess(randomizer::logic::location::Location* loc, const randomizer::logic::requirement::Requirement& req, Area* area); - tphdr::logic::location::Location* GetLocation() const; - const tphdr::logic::requirement::Requirement& GetRequirement(); + randomizer::logic::location::Location* GetLocation() const; + const randomizer::logic::requirement::Requirement& GetRequirement(); Area* GetArea() const; int GetID() const; @@ -39,23 +39,23 @@ namespace tphdr::logic::area static int _idCounter; int _id = -1; - tphdr::logic::location::Location* _loc = nullptr; - tphdr::logic::requirement::Requirement _req; + randomizer::logic::location::Location* _loc = nullptr; + randomizer::logic::requirement::Requirement _req; Area* _area = nullptr; }; class EventAccess { public: - EventAccess(const tphdr::logic::requirement::Requirement& req, Area* area, const int& eventIndex); + EventAccess(const randomizer::logic::requirement::Requirement& req, Area* area, const int& eventIndex); - const tphdr::logic::requirement::Requirement& GetRequirement(); + const randomizer::logic::requirement::Requirement& GetRequirement(); Area* GetArea() const; int GetEventIndex() const; std::string GetName() const; private: - tphdr::logic::requirement::Requirement _req; + randomizer::logic::requirement::Requirement _req; Area* _area = nullptr; int _eventIndex = -1; }; @@ -63,7 +63,7 @@ namespace tphdr::logic::area class Area { public: - Area(const std::string& name, tphdr::logic::world::World* world); + Area(const std::string& name, randomizer::logic::world::World* world); std::string GetName() const; void SetHardAssignedRegion(const std::string& _hardAssignedRegion); @@ -72,14 +72,14 @@ namespace tphdr::logic::area std::list GetEvents() const; void SetLocations(std::list>& locations); std::list GetLocations() const; - void SetExits(std::list>& exits); - std::list GetExits() const; - void AddExit(std::unique_ptr& exit); - void RemoveExit(tphdr::logic::entrance::Entrance* exit); - void AddEntrance(tphdr::logic::entrance::Entrance* entrance); - void RemoveEntrance(tphdr::logic::entrance::Entrance* entrance); - std::list GetEntrances() const; - tphdr::logic::world::World* GetWorld() const; + void SetExits(std::list>& exits); + std::list GetExits() const; + void AddExit(std::unique_ptr& exit); + void RemoveExit(randomizer::logic::entrance::Entrance* exit); + void AddEntrance(randomizer::logic::entrance::Entrance* entrance); + void RemoveEntrance(randomizer::logic::entrance::Entrance* entrance); + std::list GetEntrances() const; + randomizer::logic::world::World* GetWorld() const; void SetCanChangeTime(const bool& canChangeTime); bool CanChangeTime() const; void SetCanTransform(const bool& canTransform); @@ -88,7 +88,7 @@ namespace tphdr::logic::area std::set GetHintRegions(); void SetTwilightCompletedMacroIndex(const int& macroIndex); int GetTwilightCompletedMacroIndex() const; - bool TwilightCleared(tphdr::logic::search::Search* search) const; + bool TwilightCleared(randomizer::logic::search::Search* search) const; /** * @brief Assigns this area's hint regions(s) as well as assigns any locations within the area to a dungeon if the @@ -105,12 +105,12 @@ namespace tphdr::logic::area std::set _hintRegions = {}; std::list> _events = {}; std::list> _locations = {}; - std::list> _exits = {}; - std::list _entrances = {}; - tphdr::logic::world::World* _world; + std::list> _exits = {}; + std::list _entrances = {}; + randomizer::logic::world::World* _world; bool _canChangeTime = false; bool _canTransform = false; int _twilightCompletedMacroIndex = -1; }; -} // namespace tphdr::logic::area +} // namespace randomizer::logic::area diff --git a/src/dusk/randomizer/logic/dungeon.cpp b/src/dusk/randomizer/logic/dungeon.cpp index 86965a36bd..1c715db6bc 100644 --- a/src/dusk/randomizer/logic/dungeon.cpp +++ b/src/dusk/randomizer/logic/dungeon.cpp @@ -8,102 +8,102 @@ #include "../utility/container.hpp" #include "../utility/log.hpp" -namespace tphdr::logic::dungeon +namespace randomizer::logic::dungeon { - Dungeon::Dungeon(const std::string& name, tphdr::logic::world::World* world): _name(name), _world(world) {} + Dungeon::Dungeon(const std::string& name, randomizer::logic::world::World* world): _name(name), _world(world) {} std::string Dungeon::GetName() const { return this->_name; } - void Dungeon::SetSmallKey(tphdr::logic::item::Item* item) + void Dungeon::SetSmallKey(randomizer::logic::item::Item* item) { this->_smallKey = item; LOG_TO_DEBUG("Set \"" + item->GetName() + "\" as small key for dungeon " + this->_name); } - tphdr::logic::item::Item* Dungeon::GetSmallKey() const + randomizer::logic::item::Item* Dungeon::GetSmallKey() const { return this->_smallKey; } - void Dungeon::SetBigKey(tphdr::logic::item::Item* item) + void Dungeon::SetBigKey(randomizer::logic::item::Item* item) { this->_bigKey = item; LOG_TO_DEBUG("Set \"" + item->GetName() + "\" as big key for dungeon " + this->_name); } - tphdr::logic::item::Item* Dungeon::GetBigKey() const + randomizer::logic::item::Item* Dungeon::GetBigKey() const { return this->_bigKey; } - void Dungeon::SetCompass(tphdr::logic::item::Item* item) + void Dungeon::SetCompass(randomizer::logic::item::Item* item) { this->_compass = item; LOG_TO_DEBUG("Set \"" + item->GetName() + "\" as compass for dungeon " + this->_name); } - tphdr::logic::item::Item* Dungeon::GetCompass() const + randomizer::logic::item::Item* Dungeon::GetCompass() const { return this->_compass; } - void Dungeon::SetDungeonMap(tphdr::logic::item::Item* item) + void Dungeon::SetDungeonMap(randomizer::logic::item::Item* item) { this->_dungeonMap = item; LOG_TO_DEBUG("Set \"" + item->GetName() + "\" as dungeon map for dungeon " + this->_name); } - tphdr::logic::item::Item* Dungeon::GetDungeonMap() const + randomizer::logic::item::Item* Dungeon::GetDungeonMap() const { return this->_dungeonMap; } - void Dungeon::SetStartingArea(tphdr::logic::area::Area* startingArea) + void Dungeon::SetStartingArea(randomizer::logic::area::Area* startingArea) { this->_startingArea = startingArea; LOG_TO_DEBUG("Set \"" + startingArea->GetName() + "\" as starting area for dungeon " + this->_name) } - tphdr::logic::area::Area* Dungeon::GetStartingAreas() + randomizer::logic::area::Area* Dungeon::GetStartingAreas() { return this->_startingArea; } - void Dungeon::AddStartingEntrance(tphdr::logic::entrance::Entrance* startingEntrance) + void Dungeon::AddStartingEntrance(randomizer::logic::entrance::Entrance* startingEntrance) { this->_startingEntrances.insert(startingEntrance); LOG_TO_DEBUG("Added \"" + startingEntrance->GetOriginalName() + "\" as starting entrance for dungeon " + this->_name) } - std::unordered_set Dungeon::GetStartingEntrances() const + std::unordered_set Dungeon::GetStartingEntrances() const { return this->_startingEntrances; }; - void Dungeon::AddLocation(tphdr::logic::location::Location* location) + void Dungeon::AddLocation(randomizer::logic::location::Location* location) { - if (!tphdr::utility::container::ElementInContainer(this->_locations, location)) + if (!randomizer::utility::container::ElementInContainer(this->_locations, location)) { this->_locations.push_back(location); LOG_TO_DEBUG(location->GetName() + " has been assigned to dungeon " + this->_name); } } - tphdr::logic::location::LocationPool Dungeon::GetLocations() + randomizer::logic::location::LocationPool Dungeon::GetLocations() { return this->_locations; } - void Dungeon::SetGoalLocation(tphdr::logic::location::Location* goalLocation) + void Dungeon::SetGoalLocation(randomizer::logic::location::Location* goalLocation) { this->_goalLocation = goalLocation; LOG_TO_DEBUG(goalLocation->GetName() + " has been assigned as goal location to dungeon " + this->_name); } - tphdr::logic::location::Location* Dungeon::GetGoalLocation() + randomizer::logic::location::Location* Dungeon::GetGoalLocation() { return this->_goalLocation; } @@ -124,4 +124,4 @@ namespace tphdr::logic::dungeon return !this->_required && this->_world->Setting("Unrequired Dungeons Are Barren") == "On"; } -} // namespace tphdr::logic::dungeon +} // namespace randomizer::logic::dungeon diff --git a/src/dusk/randomizer/logic/dungeon.hpp b/src/dusk/randomizer/logic/dungeon.hpp index 08839c51a4..1c11bbf885 100644 --- a/src/dusk/randomizer/logic/dungeon.hpp +++ b/src/dusk/randomizer/logic/dungeon.hpp @@ -5,26 +5,26 @@ #include // Forward declarations -namespace tphdr::logic::item +namespace randomizer::logic::item { class Item; } -namespace tphdr::logic::area +namespace randomizer::logic::area { class Area; } -namespace tphdr::logic::entrance +namespace randomizer::logic::entrance { class Entrance; } -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } -namespace tphdr::logic::dungeon +namespace randomizer::logic::dungeon { /** * @brief Holds dungeon specific data @@ -32,25 +32,25 @@ namespace tphdr::logic::dungeon class Dungeon { public: - Dungeon(const std::string& name, tphdr::logic::world::World* world); + Dungeon(const std::string& name, randomizer::logic::world::World* world); std::string GetName() const; - void SetSmallKey(tphdr::logic::item::Item* item); - tphdr::logic::item::Item* GetSmallKey() const; - void SetBigKey(tphdr::logic::item::Item* item); - tphdr::logic::item::Item* GetBigKey() const; - void SetCompass(tphdr::logic::item::Item* item); - tphdr::logic::item::Item* GetCompass() const; - void SetDungeonMap(tphdr::logic::item::Item* item); - tphdr::logic::item::Item* GetDungeonMap() const; - void SetStartingArea(tphdr::logic::area::Area* startingArea); - tphdr::logic::area::Area* GetStartingAreas(); - void AddStartingEntrance(tphdr::logic::entrance::Entrance* startingEntrance); - std::unordered_set GetStartingEntrances() const; - void AddLocation(tphdr::logic::location::Location* location); - tphdr::logic::location::LocationPool GetLocations(); - void SetGoalLocation(tphdr::logic::location::Location* goalLocation); - tphdr::logic::location::Location* GetGoalLocation(); + void SetSmallKey(randomizer::logic::item::Item* item); + randomizer::logic::item::Item* GetSmallKey() const; + void SetBigKey(randomizer::logic::item::Item* item); + randomizer::logic::item::Item* GetBigKey() const; + void SetCompass(randomizer::logic::item::Item* item); + randomizer::logic::item::Item* GetCompass() const; + void SetDungeonMap(randomizer::logic::item::Item* item); + randomizer::logic::item::Item* GetDungeonMap() const; + void SetStartingArea(randomizer::logic::area::Area* startingArea); + randomizer::logic::area::Area* GetStartingAreas(); + void AddStartingEntrance(randomizer::logic::entrance::Entrance* startingEntrance); + std::unordered_set GetStartingEntrances() const; + void AddLocation(randomizer::logic::location::Location* location); + randomizer::logic::location::LocationPool GetLocations(); + void SetGoalLocation(randomizer::logic::location::Location* goalLocation); + randomizer::logic::location::Location* GetGoalLocation(); void SetRequired(const bool& required); bool IsRequired() const; @@ -62,15 +62,15 @@ namespace tphdr::logic::dungeon private: std::string _name = ""; - tphdr::logic::world::World* _world; - tphdr::logic::item::Item* _smallKey; - tphdr::logic::item::Item* _bigKey; - tphdr::logic::item::Item* _compass; - tphdr::logic::item::Item* _dungeonMap; - tphdr::logic::area::Area* _startingArea; - std::unordered_set _startingEntrances; - tphdr::logic::location::Location* _goalLocation; - tphdr::logic::location::LocationPool _locations = {}; + randomizer::logic::world::World* _world; + randomizer::logic::item::Item* _smallKey; + randomizer::logic::item::Item* _bigKey; + randomizer::logic::item::Item* _compass; + randomizer::logic::item::Item* _dungeonMap; + randomizer::logic::area::Area* _startingArea; + std::unordered_set _startingEntrances; + randomizer::logic::location::Location* _goalLocation; + randomizer::logic::location::LocationPool _locations = {}; bool _required = false; }; -} // namespace tphdr::logic::dungeon +} // namespace randomizer::logic::dungeon diff --git a/src/dusk/randomizer/logic/entrance.cpp b/src/dusk/randomizer/logic/entrance.cpp index 5500642443..7d4833f129 100644 --- a/src/dusk/randomizer/logic/entrance.cpp +++ b/src/dusk/randomizer/logic/entrance.cpp @@ -5,7 +5,7 @@ #include "../utility/log.hpp" #include "../utility/string.hpp" -namespace tphdr::logic::entrance +namespace randomizer::logic::entrance { std::unordered_set NON_ASSUMED_TYPES = {Type::SPAWN, Type::WARP_PORTAL}; @@ -85,10 +85,10 @@ namespace tphdr::logic::entrance return reverse.at(type); } - Entrance::Entrance(tphdr::logic::area::Area* parentArea, - tphdr::logic::area::Area* connectedArea, - const tphdr::logic::requirement::Requirement& req, - tphdr::logic::world::World* world): + Entrance::Entrance(randomizer::logic::area::Area* parentArea, + randomizer::logic::area::Area* connectedArea, + const randomizer::logic::requirement::Requirement& req, + randomizer::logic::world::World* world): _parentArea(parentArea), _connectedArea(connectedArea), _originalConnectedArea(connectedArea), @@ -96,7 +96,7 @@ namespace tphdr::logic::entrance _world(world) { this->_originalName = this->GetCurrentName(); - this->_computedRequirement._type = tphdr::logic::requirement::Type::IMPOSSIBLE; + this->_computedRequirement._type = randomizer::logic::requirement::Type::IMPOSSIBLE; } void Entrance::SetID(const int& id) @@ -123,20 +123,20 @@ namespace tphdr::logic::entrance void Entrance::GeneralizeOriginalName() { - tphdr::utility::str::Erase(this->_originalName, " North", " South", " East", " West", " Right", " Left"); + randomizer::utility::str::Erase(this->_originalName, " North", " South", " East", " West", " Right", " Left"); } - tphdr::logic::area::Area* Entrance::GetParentArea() const + randomizer::logic::area::Area* Entrance::GetParentArea() const { return this->_parentArea; } - tphdr::logic::area::Area* Entrance::GetConnectedArea() const + randomizer::logic::area::Area* Entrance::GetConnectedArea() const { return this->_connectedArea; } - tphdr::logic::area::Area* Entrance::GetOriginalConnectedArea() const + randomizer::logic::area::Area* Entrance::GetOriginalConnectedArea() const { return this->_originalConnectedArea; } @@ -160,27 +160,27 @@ namespace tphdr::logic::entrance return this->_originalType; } - void Entrance::SetRequirement(const tphdr::logic::requirement::Requirement& req) + void Entrance::SetRequirement(const randomizer::logic::requirement::Requirement& req) { this->_req = req; } - const tphdr::logic::requirement::Requirement& Entrance::GetRequirement() + const randomizer::logic::requirement::Requirement& Entrance::GetRequirement() { return this->_req; } - void Entrance::SetComputedRequirement(const tphdr::logic::requirement::Requirement& computedRequirement) + void Entrance::SetComputedRequirement(const randomizer::logic::requirement::Requirement& computedRequirement) { this->_computedRequirement = computedRequirement; } - tphdr::logic::requirement::Requirement Entrance::GetComputedRequirement() + randomizer::logic::requirement::Requirement Entrance::GetComputedRequirement() { return this->_computedRequirement; } - tphdr::logic::world::World* Entrance::GetWorld() const + randomizer::logic::world::World* Entrance::GetWorld() const { return this->_world; } @@ -267,13 +267,13 @@ namespace tphdr::logic::entrance return this->_assumed; } - void Entrance::Connect(tphdr::logic::area::Area* newConnectedArea) + void Entrance::Connect(randomizer::logic::area::Area* newConnectedArea) { this->_connectedArea = newConnectedArea; newConnectedArea->AddEntrance(this); } - tphdr::logic::area::Area* Entrance::Disconnect() + randomizer::logic::area::Area* Entrance::Disconnect() { this->_connectedArea->RemoveEntrance(this); auto previouslyConnected = this->_connectedArea; @@ -291,7 +291,7 @@ namespace tphdr::logic::entrance { auto root = this->_world->GetRootArea(); auto targetEntrance = - std::make_unique(root, nullptr, tphdr::logic::requirement::NO_REQUIREMENT, this->_world); + std::make_unique(root, nullptr, randomizer::logic::requirement::NO_REQUIREMENT, this->_world); auto target = targetEntrance.get(); root->AddExit(targetEntrance); // This moves the variable, so we have to use the pointer for the rest of the function target->Connect(this->_connectedArea); @@ -314,13 +314,13 @@ namespace tphdr::logic::entrance { std::string parentAreaName; std::string connectedAreaName; - if (tphdr::utility::str::Contains(originalName, " -> ")) + if (randomizer::utility::str::Contains(originalName, " -> ")) { auto separatorIndex = originalName.find(" -> "); parentAreaName = originalName.substr(0, separatorIndex); connectedAreaName = originalName.substr(separatorIndex + 4); } - else if (tphdr::utility::str::Contains(originalName, " from ")) + else if (randomizer::utility::str::Contains(originalName, " from ")) { auto separatorIndex = originalName.find(" from "); connectedAreaName = originalName.substr(0, separatorIndex); @@ -334,4 +334,4 @@ namespace tphdr::logic::entrance return {parentAreaName, connectedAreaName}; } -} // namespace tphdr::logic::entrance +} // namespace randomizer::logic::entrance diff --git a/src/dusk/randomizer/logic/entrance.hpp b/src/dusk/randomizer/logic/entrance.hpp index 1c3f8d9042..16601b58ff 100644 --- a/src/dusk/randomizer/logic/entrance.hpp +++ b/src/dusk/randomizer/logic/entrance.hpp @@ -7,17 +7,17 @@ #include // Forward Declarations -namespace tphdr::logic::area +namespace randomizer::logic::area { class Area; } -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } -namespace tphdr::logic::entrance +namespace randomizer::logic::entrance { enum Type { @@ -67,10 +67,10 @@ namespace tphdr::logic::entrance class Entrance { public: - Entrance(tphdr::logic::area::Area* parentArea, - tphdr::logic::area::Area* connectedArea, - const tphdr::logic::requirement::Requirement& req, - tphdr::logic::world::World* world); + Entrance(randomizer::logic::area::Area* parentArea, + randomizer::logic::area::Area* connectedArea, + const randomizer::logic::requirement::Requirement& req, + randomizer::logic::world::World* world); void SetID(const int& id); int GetID() const; @@ -80,17 +80,17 @@ namespace tphdr::logic::entrance * @brief Removes cardinal/direction specifiers from the entrance's name (North, South, East, West, Left, Right) */ void GeneralizeOriginalName(); - tphdr::logic::area::Area* GetParentArea() const; - tphdr::logic::area::Area* GetConnectedArea() const; - tphdr::logic::area::Area* GetOriginalConnectedArea() const; + randomizer::logic::area::Area* GetParentArea() const; + randomizer::logic::area::Area* GetConnectedArea() const; + randomizer::logic::area::Area* GetOriginalConnectedArea() const; void SetType(const Type& type); Type GetType() const; Type GetOriginalType() const; - void SetRequirement(const tphdr::logic::requirement::Requirement& req); - const tphdr::logic::requirement::Requirement& GetRequirement(); - void SetComputedRequirement(const tphdr::logic::requirement::Requirement& computedRequirement); - tphdr::logic::requirement::Requirement GetComputedRequirement(); - tphdr::logic::world::World* GetWorld() const; + void SetRequirement(const randomizer::logic::requirement::Requirement& req); + const randomizer::logic::requirement::Requirement& GetRequirement(); + void SetComputedRequirement(const randomizer::logic::requirement::Requirement& computedRequirement); + randomizer::logic::requirement::Requirement GetComputedRequirement(); + randomizer::logic::world::World* GetWorld() const; bool CanStartAt() const; void SetShuffled(const bool& shuffled); bool IsShuffled() const; @@ -115,7 +115,7 @@ namespace tphdr::logic::entrance * * @param newConnectedArea The area to connect this entrance to */ - void Connect(tphdr::logic::area::Area* newConnectedArea); + void Connect(randomizer::logic::area::Area* newConnectedArea); /** * @brief Disconnect this entrance from the area it leads to. Will also remove this entrance from it's connected area's @@ -123,7 +123,7 @@ namespace tphdr::logic::entrance * * @return The area this entrance was previously connected to */ - tphdr::logic::area::Area* Disconnect(); + randomizer::logic::area::Area* Disconnect(); /** * @brief Links two entrances by setting them as each others' reverse entrance @@ -144,24 +144,24 @@ namespace tphdr::logic::entrance private: int _id = -1; - tphdr::logic::area::Area* _parentArea = nullptr; - tphdr::logic::area::Area* _connectedArea = nullptr; - tphdr::logic::area::Area* _originalConnectedArea = nullptr; + randomizer::logic::area::Area* _parentArea = nullptr; + randomizer::logic::area::Area* _connectedArea = nullptr; + randomizer::logic::area::Area* _originalConnectedArea = nullptr; Type _type = Type::INVALID; Type _originalType = Type::INVALID; std::string _originalName = ""; - tphdr::logic::world::World* _world = nullptr; + randomizer::logic::world::World* _world = nullptr; /** * @brief The local requirement for this entrance assuming we have access to its parent area. */ - tphdr::logic::requirement::Requirement _req; + randomizer::logic::requirement::Requirement _req; /** * @brief The flattened requirement which includes everything necessary to reach this entrance from the root of the * world graph. */ - tphdr::logic::requirement::Requirement _computedRequirement; + randomizer::logic::requirement::Requirement _computedRequirement; // Variables used for entrance shuffling bool _canStartAt = false; @@ -201,4 +201,4 @@ namespace tphdr::logic::entrance using EntrancePools = std::map; std::tuple GetParentAndConnectedAreaNames(const std::string& originalName); -} // namespace tphdr::logic::entrance +} // namespace randomizer::logic::entrance diff --git a/src/dusk/randomizer/logic/entrance_shuffle.cpp b/src/dusk/randomizer/logic/entrance_shuffle.cpp index 0e8f8ce940..e58a6a57a6 100644 --- a/src/dusk/randomizer/logic/entrance_shuffle.cpp +++ b/src/dusk/randomizer/logic/entrance_shuffle.cpp @@ -7,11 +7,11 @@ #include "../utility/random.hpp" #include "../utility/yaml.hpp" -using namespace tphdr::logic::entrance; +using namespace randomizer::logic::entrance; -namespace tphdr::logic::entrance_shuffle +namespace randomizer::logic::entrance_shuffle { - void ShuffleWorldEntrances(tphdr::logic::world::World* world, tphdr::logic::world::WorldPool& worlds) + void ShuffleWorldEntrances(randomizer::logic::world::World* world, randomizer::logic::world::WorldPool& worlds) { SetAllEntrancesData(world); @@ -31,17 +31,17 @@ namespace tphdr::logic::entrance_shuffle } // Validate the world one last time to ensure everything worked - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); ValidateWorld(world, worlds, nullptr, completeItemPool); } - void SetAllEntrancesData(tphdr::logic::world::World* world) + void SetAllEntrancesData(randomizer::logic::world::World* world) { auto filepath = DATA_PATH "entrance_shuffle_data.yaml"; - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); // Keep track of which double door entrances are together - std::unordered_map> coupledDoors = {}; + std::unordered_map> coupledDoors = {}; auto entranceDataTree = LoadYAML(filepath); for (const auto& entranceDataNode : entranceDataTree) @@ -50,8 +50,8 @@ namespace tphdr::logic::entrance_shuffle YAMLVerifyFields(entranceDataNode, "Type", "Forward"); auto typeStr = entranceDataNode["Type"].as(); - auto type = tphdr::logic::entrance::TypeFromStr(typeStr); - if (type == tphdr::logic::entrance::Type::INVALID) + auto type = randomizer::logic::entrance::TypeFromStr(typeStr); + if (type == randomizer::logic::entrance::Type::INVALID) { throw std::runtime_error("Unknown entrance type \"" + typeStr + "\" in entrance shuffle node:\n" + YAML::Dump(entranceDataNode)); @@ -123,7 +123,7 @@ namespace tphdr::logic::entrance_shuffle } } - EntrancePools CreateEntrancePools(tphdr::logic::world::World* world) + EntrancePools CreateEntrancePools(randomizer::logic::world::World* world) { EntrancePools entrancePools = {}; @@ -215,7 +215,7 @@ namespace tphdr::logic::entrance_shuffle mixedPools.begin(), mixedPools.end(), [](const auto& pool) - { return tphdr::utility::container::ElementInContainer(pool, "Overworld"); }); /*Overworld in a mixed pool*/ + { return randomizer::utility::container::ElementInContainer(pool, "Overworld"); }); /*Overworld in a mixed pool*/ entrancePools[Type::OVERWORLD] = world->GetShuffleableEntrances(Type::OVERWORLD, /*onlyPrimary = */ excludeOverworldReverse); } @@ -317,7 +317,7 @@ namespace tphdr::logic::entrance_shuffle // Don't assume we have access to random spawn targets. We're only connecting to one of them // so assuming we have access to all of them would be erroneous. - newTarget->SetRequirement(tphdr::logic::requirement::IMPOSSIBLE_REQUIREMENT); + newTarget->SetRequirement(randomizer::logic::requirement::IMPOSSIBLE_REQUIREMENT); } } targetEntrancePools[type] = spawnPool; @@ -350,13 +350,13 @@ namespace tphdr::logic::entrance_shuffle return assumedPool; } - void SetPlandomizedEntrances(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, + void SetPlandomizedEntrances(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, EntrancePools& entrancePools, EntrancePools& targetEntrancePools) { LOG_TO_DEBUG("Now placing plandomizer entrances"); - auto itemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto itemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); for (auto& [plandoEntrance, plandoTarget] : world->GetPlandomizerEntrances()) { @@ -390,13 +390,13 @@ namespace tphdr::logic::entrance_shuffle // If entrances are coupled, but the user tries to plandomize a non-primary connection, get the primary connection // instead if (world->Setting("Decouple Entrances") == "Off" && - tphdr::utility::container::ElementInContainer(entrancePool, entranceToConnect->GetReverse())) + randomizer::utility::container::ElementInContainer(entrancePool, entranceToConnect->GetReverse())) { entranceToConnect = entranceToConnect->GetReverse(); targetToConnect = targetToConnect->GetReverse(); } - if (tphdr::utility::container::ElementInContainer(entrancePool, entranceToConnect)) + if (randomizer::utility::container::ElementInContainer(entrancePool, entranceToConnect)) { bool validTargetFound = false; for (auto& target : targetPool) @@ -432,8 +432,8 @@ namespace tphdr::logic::entrance_shuffle // If we found our target, delete the entrance and it's now connected target from their respective pools if (validTargetFound) { - tphdr::utility::container::Erase(entrancePool, entranceToConnect); - tphdr::utility::container::Erase(targetPool, targetToConnect->GetAssumed()); + randomizer::utility::container::Erase(entrancePool, entranceToConnect); + randomizer::utility::container::Erase(targetPool, targetToConnect->GetAssumed()); } // Otherwise, the target is invalid else @@ -452,12 +452,12 @@ namespace tphdr::logic::entrance_shuffle LOG_TO_DEBUG("All plandomized entrances have been placed."); } - void ShuffleNonAssumedEntrancesPools(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, + void ShuffleNonAssumedEntrancesPools(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, EntrancePools& entrancePools, EntrancePools& targetEntrancePools) { - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); // The idea here is we want to try shuffling all the non-assumed entrances // at the same time since we can't validate the world after each one individually @@ -478,7 +478,7 @@ namespace tphdr::logic::entrance_shuffle auto& targetEntrancePool = targetEntrancePools.at(entranceType); for (auto& entrance : entrancePool) { - tphdr::utility::random::ShufflePool(targetEntrancePool); + randomizer::utility::random::ShufflePool(targetEntrancePool); // Loop through and find a valid target entrance to connect to for (auto& target : targetEntrancePool) @@ -508,7 +508,7 @@ namespace tphdr::logic::entrance_shuffle for (auto& [entrance, target] : rollbacks) { ConfirmReplacement(entrance, target); - tphdr::utility::container::Erase(targetEntrancePools[entrance->GetType()], target); + randomizer::utility::container::Erase(targetEntrancePools[entrance->GetType()], target); } // Once we've made a valid world, delete all other targets that didn't get used for (auto& [entranceType, targetPool] : targetEntrancePools) @@ -547,8 +547,8 @@ namespace tphdr::logic::entrance_shuffle } } - void ShuffleEntrancePool(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, + void ShuffleEntrancePool(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, EntrancePool& entrancePool, EntrancePool& targetEntrancePool, int retries /* = 20*/) @@ -583,13 +583,13 @@ namespace tphdr::logic::entrance_shuffle "generate successfully."); } - void ShuffleEntrances(tphdr::logic::world::WorldPool& worlds, + void ShuffleEntrances(randomizer::logic::world::WorldPool& worlds, EntrancePool& entrancePool, EntrancePool& targetEntrancePool, std::unordered_map& rollbacks) { - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); - tphdr::utility::random::ShufflePool(entrancePool); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); + randomizer::utility::random::ShufflePool(entrancePool); for (auto& entrance : entrancePool) { @@ -598,7 +598,7 @@ namespace tphdr::logic::entrance_shuffle { continue; } - tphdr::utility::random::ShufflePool(targetEntrancePool); + randomizer::utility::random::ShufflePool(targetEntrancePool); // Loop through and find a valid target entrance to connect to for (auto& target : targetEntrancePool) @@ -638,11 +638,11 @@ namespace tphdr::logic::entrance_shuffle } } - bool ReplaceEntrance(tphdr::logic::world::WorldPool& worlds, + bool ReplaceEntrance(randomizer::logic::world::WorldPool& worlds, Entrance* entrance, Entrance* target, std::unordered_map& rollbacks, - const tphdr::logic::item_pool::ItemPool& completeItemPool) + const randomizer::logic::item_pool::ItemPool& completeItemPool) { try { @@ -723,20 +723,20 @@ namespace tphdr::logic::entrance_shuffle } } - void ValidateWorld(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, + void ValidateWorld(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, Entrance* entrance, - const tphdr::logic::item_pool::ItemPool& completeItemPool) + const randomizer::logic::item_pool::ItemPool& completeItemPool) { // Validate that all logic is still satisfied - auto verifyLogicError = tphdr::logic::search::VerifyLogic(&worlds, completeItemPool); + auto verifyLogicError = randomizer::logic::search::VerifyLogic(&worlds, completeItemPool); if (verifyLogicError.has_value()) { throw EntranceShuffleError("Not all logic is satisfied! Reason:\n" + verifyLogicError.value()); } // Check to make sure there's at least 1 sphere zero location available - auto sphereZeroSearch = tphdr::logic::search::Search::SphereZero(&worlds); + auto sphereZeroSearch = randomizer::logic::search::Search::SphereZero(&worlds); sphereZeroSearch.SearchWorlds(); const auto& foundLocations = sphereZeroSearch._visitedLocations; auto numSphereZeroLocations = std::count_if(foundLocations.begin(), @@ -777,4 +777,4 @@ namespace tphdr::logic::entrance_shuffle } return reverseEntrances; } -} // namespace tphdr::logic::entrance_shuffle +} // namespace randomizer::logic::entrance_shuffle diff --git a/src/dusk/randomizer/logic/entrance_shuffle.hpp b/src/dusk/randomizer/logic/entrance_shuffle.hpp index f4ff2adf24..cde5806db7 100644 --- a/src/dusk/randomizer/logic/entrance_shuffle.hpp +++ b/src/dusk/randomizer/logic/entrance_shuffle.hpp @@ -3,52 +3,52 @@ #include "entrance.hpp" #include "world.hpp" -namespace tphdr::logic::entrance_shuffle +namespace randomizer::logic::entrance_shuffle { - void ShuffleWorldEntrances(tphdr::logic::world::World* world, tphdr::logic::world::WorldPool& worlds); - void SetAllEntrancesData(tphdr::logic::world::World* world); - tphdr::logic::entrance::EntrancePools CreateEntrancePools(tphdr::logic::world::World* world); - tphdr::logic::entrance::EntrancePools CreateTargetPools(tphdr::logic::entrance::EntrancePools& entrancePools); - tphdr::logic::entrance::EntrancePool AssumeEntrancePool(tphdr::logic::entrance::EntrancePool& entrancePool); - void SetPlandomizedEntrances(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::EntrancePools& entrancePools, - tphdr::logic::entrance::EntrancePools& targetEntrancePools); - void ShuffleNonAssumedEntrancesPools(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::EntrancePools& entrancePools, - tphdr::logic::entrance::EntrancePools& targetEntrancePools); - void ShuffleEntrancePool(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::EntrancePool& entrancePool, - tphdr::logic::entrance::EntrancePool& targetEntrancePool, + void ShuffleWorldEntrances(randomizer::logic::world::World* world, randomizer::logic::world::WorldPool& worlds); + void SetAllEntrancesData(randomizer::logic::world::World* world); + randomizer::logic::entrance::EntrancePools CreateEntrancePools(randomizer::logic::world::World* world); + randomizer::logic::entrance::EntrancePools CreateTargetPools(randomizer::logic::entrance::EntrancePools& entrancePools); + randomizer::logic::entrance::EntrancePool AssumeEntrancePool(randomizer::logic::entrance::EntrancePool& entrancePool); + void SetPlandomizedEntrances(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::EntrancePools& entrancePools, + randomizer::logic::entrance::EntrancePools& targetEntrancePools); + void ShuffleNonAssumedEntrancesPools(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::EntrancePools& entrancePools, + randomizer::logic::entrance::EntrancePools& targetEntrancePools); + void ShuffleEntrancePool(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::EntrancePool& entrancePool, + randomizer::logic::entrance::EntrancePool& targetEntrancePool, int retries = 20); - void ShuffleEntrances(tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::EntrancePool& entrancePool, - tphdr::logic::entrance::EntrancePool& targetEntrancePool, - std::unordered_map& rollbacks); - bool ReplaceEntrance(tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::Entrance* entrance, - tphdr::logic::entrance::Entrance* target, - std::unordered_map& rollbacks, - const tphdr::logic::item_pool::ItemPool& completeItemPool); + void ShuffleEntrances(randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::EntrancePool& entrancePool, + randomizer::logic::entrance::EntrancePool& targetEntrancePool, + std::unordered_map& rollbacks); + bool ReplaceEntrance(randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::Entrance* entrance, + randomizer::logic::entrance::Entrance* target, + std::unordered_map& rollbacks, + const randomizer::logic::item_pool::ItemPool& completeItemPool); - void CheckEntrancesCompatibility(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target); - void ChangeConnections(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target); - void RestoreConnections(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target); - void ConfirmReplacement(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target); - void DeleteTargetEntrance(tphdr::logic::entrance::Entrance* target); - void ValidateWorld(tphdr::logic::world::World* world, - tphdr::logic::world::WorldPool& worlds, - tphdr::logic::entrance::Entrance* entrance, - const tphdr::logic::item_pool::ItemPool& completeItemPool); + void CheckEntrancesCompatibility(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target); + void ChangeConnections(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target); + void RestoreConnections(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target); + void ConfirmReplacement(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target); + void DeleteTargetEntrance(randomizer::logic::entrance::Entrance* target); + void ValidateWorld(randomizer::logic::world::World* world, + randomizer::logic::world::WorldPool& worlds, + randomizer::logic::entrance::Entrance* entrance, + const randomizer::logic::item_pool::ItemPool& completeItemPool); - void SetShuffledEntrances(tphdr::logic::entrance::EntrancePools& entrancePools); - tphdr::logic::entrance::EntrancePool GetReverseEntrances(const tphdr::logic::entrance::EntrancePool& entrances); + void SetShuffledEntrances(randomizer::logic::entrance::EntrancePools& entrancePools); + randomizer::logic::entrance::EntrancePool GetReverseEntrances(const randomizer::logic::entrance::EntrancePool& entrances); class EntranceShuffleError: public std::runtime_error { public: explicit EntranceShuffleError(const std::string& message): std::runtime_error(message) {} }; -} // namespace tphdr::logic::entrance_shuffle +} // namespace randomizer::logic::entrance_shuffle diff --git a/src/dusk/randomizer/logic/fill.cpp b/src/dusk/randomizer/logic/fill.cpp index 47d1e48960..fc9e9e3737 100644 --- a/src/dusk/randomizer/logic/fill.cpp +++ b/src/dusk/randomizer/logic/fill.cpp @@ -9,9 +9,9 @@ #include #include -namespace tphdr::logic::fill +namespace randomizer::logic::fill { - void FillWorlds(tphdr::logic::world::WorldPool& worlds) + void FillWorlds(randomizer::logic::world::WorldPool& worlds) { // Place each world's restricted items first for (auto& world : worlds) @@ -19,8 +19,8 @@ namespace tphdr::logic::fill PlaceRestrictedItems(world, worlds); } - tphdr::logic::item_pool::ItemPool itemPool = {}; - tphdr::logic::location::LocationPool locationPool = {}; + randomizer::logic::item_pool::ItemPool itemPool = {}; + randomizer::logic::location::LocationPool locationPool = {}; // Combine all worlds' item pools and location pools for (const auto& world : worlds) @@ -37,15 +37,15 @@ namespace tphdr::logic::fill // Place remaining major items in progress locations auto majorItems = - tphdr::utility::container::FilterAndEraseFromVector(itemPool, [](const auto& item) { return item->IsMajor(); }); + randomizer::utility::container::FilterAndEraseFromVector(itemPool, [](const auto& item) { return item->IsMajor(); }); auto progressLocations = - tphdr::utility::container::FilterFromVector(locationPool, + randomizer::utility::container::FilterFromVector(locationPool, [](const auto& location) { return location->IsProgression(); }); AssumedFill(worlds, majorItems, itemPool, progressLocations); // Place Minor items in progression locations if possible auto minorItems = - tphdr::utility::container::FilterAndEraseFromVector(itemPool, [](const auto& item) { return item->IsMinor(); }); + randomizer::utility::container::FilterAndEraseFromVector(itemPool, [](const auto& item) { return item->IsMinor(); }); FastFill(minorItems, progressLocations); // If there are still minor items left, add them back to the main item pool @@ -58,17 +58,17 @@ namespace tphdr::logic::fill FastFill(itemPool, locationPool); // Verify that all logic is satisfied - auto verifyLogicError = tphdr::logic::search::VerifyLogic(&worlds); + auto verifyLogicError = randomizer::logic::search::VerifyLogic(&worlds); if (verifyLogicError.has_value()) { throw std::runtime_error("Not all logic satisfied! Reason:\n" + verifyLogicError.value()); } } - void AssumedFill(tphdr::logic::world::WorldPool& worlds, - tphdr::logic::item_pool::ItemPool& itemsToPlacePool, - const tphdr::logic::item_pool::ItemPool& itemsNotYetPlaced, - tphdr::logic::location::LocationPool allowedLocations, + void AssumedFill(randomizer::logic::world::WorldPool& worlds, + randomizer::logic::item_pool::ItemPool& itemsToPlacePool, + const randomizer::logic::item_pool::ItemPool& itemsNotYetPlaced, + randomizer::logic::location::LocationPool allowedLocations, const int& worldToFill /* = -1 */) { // Assumed Fill may sometimes place items in such a way that accidentally locks out being able to place specific items @@ -99,9 +99,9 @@ namespace tphdr::logic::fill retries -= 1; unsuccessfulPlacement = false; - tphdr::utility::random::ShufflePool(itemsToPlacePool); + randomizer::utility::random::ShufflePool(itemsToPlacePool); auto itemsToPlace = itemsToPlacePool; - tphdr::logic::location::LocationPool rollbacks = {}; + randomizer::logic::location::LocationPool rollbacks = {}; while (!itemsToPlace.empty()) { @@ -109,13 +109,13 @@ namespace tphdr::logic::fill auto itemToPlace = itemsToPlace.back(); itemsToPlace.pop_back(); - tphdr::utility::random::ShufflePool(allowedLocations); - tphdr::logic::location::Location* spotToFill = nullptr; + randomizer::utility::random::ShufflePool(allowedLocations); + randomizer::logic::location::Location* spotToFill = nullptr; // Assume we have all the items which haven't been played yet, except the one we're about to place auto assumedItems = itemsNotYetPlaced; assumedItems.insert(assumedItems.end(), itemsToPlace.begin(), itemsToPlace.end()); - auto search = tphdr::logic::search::Search::Accessible(&worlds, assumedItems, worldToFill); + auto search = randomizer::logic::search::Search::Accessible(&worlds, assumedItems, worldToFill); search.SearchWorlds(); // search.DumpWorldGraph(); // return 1; @@ -130,7 +130,7 @@ namespace tphdr::logic::fill for (const auto& location : allowedLocations) { // Get all reachable LocationAccess spots for this location - std::list locAccList; + std::list locAccList; for (const auto& locAcc : location->GetAccessList()) { if (canChooseAnyLocation || search._visitedAreas.contains(locAcc->GetArea())) @@ -152,8 +152,8 @@ namespace tphdr::logic::fill [&](const auto& la) { return canChooseAnyLocation || - tphdr::logic::requirement::EvaluateLocationRequirement(&search, la) == - tphdr::logic::requirement::EvalSuccess::COMPLETE; + randomizer::logic::requirement::EvaluateLocationRequirement(&search, la) == + randomizer::logic::requirement::EvalSuccess::COMPLETE; })) { spotToFill = location; @@ -188,10 +188,10 @@ namespace tphdr::logic::fill } } - void FastFill(tphdr::logic::item_pool::ItemPool& itemsToPlace, tphdr::logic::location::LocationPool allowedLocations) + void FastFill(randomizer::logic::item_pool::ItemPool& itemsToPlace, randomizer::logic::location::LocationPool allowedLocations) { auto emptyLocations = - tphdr::utility::container::FilterFromVector(allowedLocations, + randomizer::utility::container::FilterFromVector(allowedLocations, [](const auto& location) { return location->IsEmpty(); }); if (itemsToPlace.size() > emptyLocations.size()) @@ -200,18 +200,18 @@ namespace tphdr::logic::fill << " Locations: " << emptyLocations.size() << std::endl; } - tphdr::utility::random::ShufflePool(emptyLocations); + randomizer::utility::random::ShufflePool(emptyLocations); for (auto& location : emptyLocations) { if (itemsToPlace.empty()) { break; } - location->SetCurrentItem(tphdr::utility::random::PopRandomElement(itemsToPlace)); + location->SetCurrentItem(randomizer::utility::random::PopRandomElement(itemsToPlace)); } } - void PlaceRestrictedItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceRestrictedItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { PlacePrologueItems(world, worlds); PlaceGoalLocationItems(world, worlds); @@ -225,7 +225,7 @@ namespace tphdr::logic::fill PlaceOverworldItems(world, worlds); } - void PlacePrologueItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlacePrologueItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { if (world->Setting("Skip Prologue") == "Off") { @@ -233,7 +233,7 @@ namespace tphdr::logic::fill // pool of locations and have to be found in the intro. We also include the lantern, shadow crystal, and progressive // fishing rod because those items can lock prologue locations also. auto& itemPool = world->GetItemPool(); - auto prologueItems = tphdr::utility::container::FilterAndEraseFromVector( + auto prologueItems = randomizer::utility::container::FilterAndEraseFromVector( itemPool, [](const auto& item) { @@ -241,12 +241,12 @@ namespace tphdr::logic::fill item->GetName() == "Lantern" || item->GetName() == "Progressive Fishing Rod" || item->IsShadowCrystal(); }); - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, prologueItems, completeItemPool, world->GetAllLocations()); } } - void PlaceGoalLocationItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceGoalLocationItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { // If dungeon rewards can be anywhere, then return early and place them later if (world->Setting("Dungeon Rewards Can Be Anywhere") == "On") @@ -255,17 +255,17 @@ namespace tphdr::logic::fill } auto allLocations = world->GetAllLocations(); - tphdr::logic::location::LocationPool goalLocations = {}; + randomizer::logic::location::LocationPool goalLocations = {}; // Filter out goal locations - goalLocations = tphdr::utility::container::FilterFromVector( + goalLocations = randomizer::utility::container::FilterFromVector( allLocations, [](const auto& location) { return location->IsGoalLocation() && location->IsEmpty(); }); // Filter out goal items std::set goalItemNames = {"Progressive Mirror Shard", "Progressive Fused Shadow"}; - auto goalItems = tphdr::utility::container::FilterAndEraseFromVector( + auto goalItems = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return goalItemNames.contains(item->GetName()); }); @@ -276,17 +276,17 @@ namespace tphdr::logic::fill } // Place goal items at goal locations - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, goalItems, completeItemPool, goalLocations); } - void PlaceOwnDungeonItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceOwnDungeonItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { for (const auto& [dungeonName, dungeon] : world->GetDungeonTable()) { // Filter hint signs out of dungeon locations auto dungeonLocations = dungeon->GetLocations(); - tphdr::utility::container::FilterAndEraseFromVector(dungeonLocations, + randomizer::utility::container::FilterAndEraseFromVector(dungeonLocations, [](const auto& location) { return location->HasCategories("Hint Sign"); }); @@ -298,7 +298,7 @@ namespace tphdr::logic::fill // Small Keys if (world->Setting("Small Keys") == "Own Dungeon") { - auto smallKeys = tphdr::utility::container::FilterAndEraseFromVector( + auto smallKeys = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { @@ -306,33 +306,33 @@ namespace tphdr::logic::fill (dungeonName_ == "Snowpeak Ruins" && (item->GetName() == "Ordon Pumpkin" || item->GetName() == "Ordon Cheese")); }); - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, smallKeys, completeItemPool, dungeonLocations); } // Big Keys if (world->Setting("Big Keys") == "Own Dungeon") { - auto bigKeys = tphdr::utility::container::FilterAndEraseFromVector(world->GetItemPool(), + auto bigKeys = randomizer::utility::container::FilterAndEraseFromVector(world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetBigKey(); }); - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, bigKeys, completeItemPool, dungeonLocations); } // Place maps and compasses last with fast fill since they're junk items if (world->Setting("Maps and Compasses") == "Own Dungeon") { - auto mapsCompasses = tphdr::utility::container::FilterAndEraseFromVector( + auto mapsCompasses = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetCompass() || item == dungeon_->GetDungeonMap(); }); - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); FastFill(mapsCompasses, dungeonLocations); } } } - void PlaceAnywhereDungeonRewards(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceAnywhereDungeonRewards(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { // If dungeon rewards can't be anywhere, then return early as we placed them earlier if (world->Setting("Dungeon Rewards Can Be Anywhere") == "Off") @@ -345,25 +345,25 @@ namespace tphdr::logic::fill // Filter out goal items std::set goalItemNames = {"Progressive Mirror Shard", "Progressive Fused Shadow"}; - auto goalItems = tphdr::utility::container::FilterAndEraseFromVector( + auto goalItems = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return goalItemNames.contains(item->GetName()); }); // Place the items - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, goalItems, completeItemPool, allLocations); } - void PlaceAnyDungeonItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceAnyDungeonItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { - tphdr::logic::item_pool::ItemPool anyDungeonItems = {}; - tphdr::logic::location::LocationPool anyDungeonLocations = {}; + randomizer::logic::item_pool::ItemPool anyDungeonItems = {}; + randomizer::logic::location::LocationPool anyDungeonLocations = {}; // Split the placement of any dungeon items into two pools. Dungeon items from dungeons which should be barren // will only be distributed among barren dungeons, where as items from nonbarren dungeons will be distributed // among nonbarren dungeons - std::list nonBarrenDungeons = {}; - std::list barrenDungeons = {}; + std::list nonBarrenDungeons = {}; + std::list barrenDungeons = {}; for (const auto& [dungeonName, dungeon] : world->GetDungeonTable()) { if (dungeon->ShouldBeBarren()) @@ -390,7 +390,7 @@ namespace tphdr::logic::fill // Add small keys to the pool if small keys are any dungeon if (world->Setting("Small Keys") == "Any Dungeon") { - auto smallKeys = tphdr::utility::container::FilterAndEraseFromVector( + auto smallKeys = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { @@ -404,7 +404,7 @@ namespace tphdr::logic::fill // Add big keys to the pool if big keys are any dungeon if (world->Setting("Big Keys") == "Any Dungeon") { - auto bigKeys = tphdr::utility::container::FilterAndEraseFromVector( + auto bigKeys = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetBigKey(); }); std::copy(bigKeys.begin(), bigKeys.end(), std::back_inserter(anyDungeonItems)); @@ -413,7 +413,7 @@ namespace tphdr::logic::fill // Add maps and compasses to the pool if maps and compasses are any dungeon if (world->Setting("Maps and Compasses") == "Any Dungeon") { - auto mapsCompasses = tphdr::utility::container::FilterAndEraseFromVector( + auto mapsCompasses = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetCompass() || item == dungeon_->GetDungeonMap(); }); std::copy(mapsCompasses.begin(), mapsCompasses.end(), std::back_inserter(anyDungeonItems)); @@ -429,17 +429,17 @@ namespace tphdr::logic::fill } // Place the dungeon items in the appropriate dungeon locations - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, anyDungeonItems, completeItemPool, anyDungeonLocations); } } - void PlaceOverworldItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds) + void PlaceOverworldItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds) { - tphdr::logic::item_pool::ItemPool overworldItems = {}; - tphdr::logic::location::LocationPool overworldLocations = world->GetAllLocations(); + randomizer::logic::item_pool::ItemPool overworldItems = {}; + randomizer::logic::location::LocationPool overworldLocations = world->GetAllLocations(); // Filter out any nonprogress locations - tphdr::utility::container::FilterAndEraseFromVector(overworldLocations, + randomizer::utility::container::FilterAndEraseFromVector(overworldLocations, [](const auto& location) { return !location->IsProgression(); }); for (const auto& [dungeonName, dungeon] : world->GetDungeonTable()) @@ -452,7 +452,7 @@ namespace tphdr::logic::fill // Add small keys to the pool if small keys are overworld if (world->Setting("Small Keys") == "Overworld") { - auto smallKeys = tphdr::utility::container::FilterAndEraseFromVector( + auto smallKeys = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { @@ -466,7 +466,7 @@ namespace tphdr::logic::fill // Add big keys to the pool if big keys are overworld if (world->Setting("Big Keys") == "Overworld") { - auto bigKeys = tphdr::utility::container::FilterAndEraseFromVector(world->GetItemPool(), + auto bigKeys = randomizer::utility::container::FilterAndEraseFromVector(world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetBigKey(); }); std::copy(bigKeys.begin(), bigKeys.end(), std::back_inserter(overworldItems)); @@ -475,28 +475,28 @@ namespace tphdr::logic::fill // Add maps and compasses to the pool if maps and compasses are overworld if (world->Setting("Maps and Compasses") == "Overworld") { - auto mapsCompasses = tphdr::utility::container::FilterAndEraseFromVector( + auto mapsCompasses = randomizer::utility::container::FilterAndEraseFromVector( world->GetItemPool(), [&](const auto& item) { return item == dungeon_->GetCompass() || item == dungeon_->GetDungeonMap(); }); std::copy(mapsCompasses.begin(), mapsCompasses.end(), std::back_inserter(overworldItems)); } // Remove this dungeon's locations from the overworldLocations pool - overworldLocations = tphdr::utility::container::FilterFromVector( + overworldLocations = randomizer::utility::container::FilterFromVector( overworldLocations, [&](const auto& location) - { return !tphdr::utility::container::ElementInContainer(dungeon_->GetLocations(), location); }); + { return !randomizer::utility::container::ElementInContainer(dungeon_->GetLocations(), location); }); } // Place the dungeon items in the overworld locations - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); AssumedFill(worlds, overworldItems, completeItemPool, overworldLocations); } - void CacheExitTimeForms(tphdr::logic::world::WorldPool& worlds) + void CacheExitTimeForms(randomizer::logic::world::WorldPool& worlds) { - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(worlds); - auto searchWithItems = tphdr::logic::search::Search::AllLocationsReachable(&worlds, completeItemPool); + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(worlds); + auto searchWithItems = randomizer::logic::search::Search::AllLocationsReachable(&worlds, completeItemPool); searchWithItems.SearchWorlds(); for (auto& world : worlds) @@ -510,11 +510,11 @@ namespace tphdr::logic::fill for (const auto& exit : area->GetExits()) { auto req = exit->GetRequirement(); - exitTimeFormCache[exit] = tphdr::logic::requirement::FormTime::NONE; - for (const auto& formTime : tphdr::logic::requirement::FormTime::ALL_FORM_TIMES) + exitTimeFormCache[exit] = randomizer::logic::requirement::FormTime::NONE; + for (const auto& formTime : randomizer::logic::requirement::FormTime::ALL_FORM_TIMES) { if (formTime & areaFormTimes && - tphdr::logic::requirement::EvaluateRequirementAtFormTime(req, + randomizer::logic::requirement::EvaluateRequirementAtFormTime(req, &searchWithItems, formTime, world.get())) @@ -526,4 +526,4 @@ namespace tphdr::logic::fill } } } -} // namespace tphdr::logic::fill +} // namespace randomizer::logic::fill diff --git a/src/dusk/randomizer/logic/fill.hpp b/src/dusk/randomizer/logic/fill.hpp index 340fc3ebe8..e1c5e69fd1 100644 --- a/src/dusk/randomizer/logic/fill.hpp +++ b/src/dusk/randomizer/logic/fill.hpp @@ -3,10 +3,10 @@ #include "item.hpp" #include "world.hpp" -namespace tphdr::logic::fill +namespace randomizer::logic::fill { - void FillWorlds(tphdr::logic::world::WorldPool& worlds); + void FillWorlds(randomizer::logic::world::WorldPool& worlds); /** * @brief Assumed fill is an algorithm which statistically places items more @@ -22,10 +22,10 @@ namespace tphdr::logic::fill * fill algorithm since we need to assume we have these items. * @param allowedLocations Locations where items in itemsToPlacePool are allowed to be filled. */ - void AssumedFill(tphdr::logic::world::WorldPool& worlds, - tphdr::logic::item_pool::ItemPool& itemsToPlacePool, - const tphdr::logic::item_pool::ItemPool& itemsNotYetPlaced, - tphdr::logic::location::LocationPool allowedLocations, + void AssumedFill(randomizer::logic::world::WorldPool& worlds, + randomizer::logic::item_pool::ItemPool& itemsToPlacePool, + const randomizer::logic::item_pool::ItemPool& itemsNotYetPlaced, + randomizer::logic::location::LocationPool allowedLocations, const int& worldToFill = -1); /** @@ -34,9 +34,9 @@ namespace tphdr::logic::fill * @param itemsToPlace The pool of items to place * @param allowedLocations The locations where the items can be placed */ - void FastFill(tphdr::logic::item_pool::ItemPool& itemsToPlace, tphdr::logic::location::LocationPool allowedLocations); + void FastFill(randomizer::logic::item_pool::ItemPool& itemsToPlace, randomizer::logic::location::LocationPool allowedLocations); - void PlaceRestrictedItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlaceRestrictedItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); /** * @brief If the prologue is not being skipped, place the sword and slingshot early on to prevent possible placement @@ -45,23 +45,23 @@ namespace tphdr::logic::fill * @param world The world to place the prologue items in * @param worlds All the worlds being generated */ - void PlacePrologueItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlacePrologueItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); - void PlaceGoalLocationItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlaceGoalLocationItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); - void PlaceOwnDungeonItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlaceOwnDungeonItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); - void PlaceAnywhereDungeonRewards(std::unique_ptr& world, - tphdr::logic::world::WorldPool& worlds); + void PlaceAnywhereDungeonRewards(std::unique_ptr& world, + randomizer::logic::world::WorldPool& worlds); - void PlaceAnyDungeonItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlaceAnyDungeonItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); - void PlaceOverworldItems(std::unique_ptr& world, tphdr::logic::world::WorldPool& worlds); + void PlaceOverworldItems(std::unique_ptr& world, randomizer::logic::world::WorldPool& worlds); /** * @brief Cache all the possible timeforms for each exit. This way, the search algorithm doesn't end up testing for * timeforms that we know ahead of time wouldn't be possible anyway * @param worlds The worlds to calculate and cache the possible timeforms for */ - void CacheExitTimeForms(tphdr::logic::world::WorldPool& worlds); -} // namespace tphdr::logic::fill + void CacheExitTimeForms(randomizer::logic::world::WorldPool& worlds); +} // namespace randomizer::logic::fill diff --git a/src/dusk/randomizer/logic/flatten/bits.cpp b/src/dusk/randomizer/logic/flatten/bits.cpp index 77318119dc..e753a7278c 100644 --- a/src/dusk/randomizer/logic/flatten/bits.cpp +++ b/src/dusk/randomizer/logic/flatten/bits.cpp @@ -208,16 +208,16 @@ int BitIndex::bump() return c; } -int BitIndex::reqBit(const tphdr::logic::requirement::Requirement& req) +int BitIndex::reqBit(const randomizer::logic::requirement::Requirement& req) { uint32_t expectedCount; - tphdr::logic::item::Item* item; + randomizer::logic::item::Item* item; std::string key; switch (req._type) { - case tphdr::logic::requirement::Type::ITEM: - item = std::get(req._args[0]); + case randomizer::logic::requirement::Type::ITEM: + item = std::get(req._args[0]); key = item->GetName() + "::1"; if (itemBits.contains(key)) { @@ -229,9 +229,9 @@ int BitIndex::reqBit(const tphdr::logic::requirement::Requirement& req) reverseIndex.push_back(req); return bump(); } - case tphdr::logic::requirement::Type::COUNT: + case randomizer::logic::requirement::Type::COUNT: expectedCount = std::get(req._args[0]); - item = std::get(req._args[1]); + item = std::get(req._args[1]); key = item->GetName() + "::" + std::to_string(expectedCount); if (itemBits.contains(key)) { @@ -243,7 +243,7 @@ int BitIndex::reqBit(const tphdr::logic::requirement::Requirement& req) reverseIndex.push_back(req); return bump(); } - // case tphdr::logic::requirement::Type::HEALTH: + // case randomizer::logic::requirement::Type::HEALTH: // key = std::to_string(std::get(req._args[0])); // if (heartCount.contains(key)) // { @@ -255,7 +255,7 @@ int BitIndex::reqBit(const tphdr::logic::requirement::Requirement& req) // reverseIndex.push_back(req); // return bump(); // } - case tphdr::logic::requirement::Type::GOLDEN_BUGS: + case randomizer::logic::requirement::Type::GOLDEN_BUGS: key = std::to_string(std::get(req._args[0])); if (goldenBugCount.contains(key)) { diff --git a/src/dusk/randomizer/logic/flatten/bits.hpp b/src/dusk/randomizer/logic/flatten/bits.hpp index fee276564d..738ee678db 100644 --- a/src/dusk/randomizer/logic/flatten/bits.hpp +++ b/src/dusk/randomizer/logic/flatten/bits.hpp @@ -61,11 +61,11 @@ class BitIndex BitIndex() = default; int bump(); - int reqBit(const tphdr::logic::requirement::Requirement& req); + int reqBit(const randomizer::logic::requirement::Requirement& req); std::unordered_map itemBits = {}; // std::unordered_map heartCount = {}; std::unordered_map goldenBugCount = {}; - std::vector reverseIndex = {}; + std::vector reverseIndex = {}; int counter = 0; }; diff --git a/src/dusk/randomizer/logic/flatten/flatten.cpp b/src/dusk/randomizer/logic/flatten/flatten.cpp index bc69248130..1b944eb0be 100644 --- a/src/dusk/randomizer/logic/flatten/flatten.cpp +++ b/src/dusk/randomizer/logic/flatten/flatten.cpp @@ -1,7 +1,7 @@ #include "flatten.hpp" #include "../world.hpp" -FlattenSearch::FlattenSearch(tphdr::logic::world::World* world_) +FlattenSearch::FlattenSearch(randomizer::logic::world::World* world_) { world = world_; @@ -22,8 +22,8 @@ FlattenSearch::FlattenSearch(tphdr::logic::world::World* world_) auto root = world->GetRootArea(); // Start with all formtimes at the root, false for everything else - auto formTimes = tphdr::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES; - formTimes.push_back(tphdr::logic::requirement::FormTime::TWILIGHT); + auto formTimes = randomizer::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES; + formTimes.push_back(randomizer::logic::requirement::FormTime::TWILIGHT); for (const auto& [areaName, area] : world->GetAreaTable()) { for (const auto& formTime : formTimes) @@ -72,7 +72,7 @@ void FlattenSearch::doSearch() tryTimeFormExpansion(); } - std::unordered_map> itemLocations = {}; + std::unordered_map> itemLocations = {}; for (auto& [name, area] : world->GetAreaTable()) { for (auto& locAccess : area->GetLocations()) @@ -92,8 +92,8 @@ void FlattenSearch::doSearch() // Step 2: for every location, OR all the ways to access it - auto formTimes = tphdr::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES; - formTimes.push_back(tphdr::logic::requirement::FormTime::TWILIGHT); + auto formTimes = randomizer::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES; + formTimes.push_back(randomizer::logic::requirement::FormTime::TWILIGHT); for (auto& [locName, accessList] : itemLocations) { auto expr = DNF::False(); @@ -121,7 +121,7 @@ void FlattenSearch::doSearch() { auto expr = DNF::False(); auto& validFormTimes = exit->GetWorld()->GetExitTimeFormCache()[exit]; - for (const auto& formTime : tphdr::logic::requirement::FormTime::ALL_FORM_TIMES) + for (const auto& formTime : randomizer::logic::requirement::FormTime::ALL_FORM_TIMES) { if (formTime & validFormTimes) { @@ -136,7 +136,7 @@ void FlattenSearch::doSearch() // Check for a thing in area whether its logical dependencies // have recently been updated. -bool FlattenSearch::wasUpdated(tphdr::logic::area::Area* area, void* thing) +bool FlattenSearch::wasUpdated(randomizer::logic::area::Area* area, void* thing) { if (recentlyUpdatedAreas.contains(area)) { @@ -154,7 +154,7 @@ bool FlattenSearch::wasUpdated(tphdr::logic::area::Area* area, void* thing) // auto& remoteAreaReqs = remoteAreaRequirements[thing]; // for (auto& areaStr : remoteAreaReqs) // { - // tphdr::logic::area::Area* area2; + // randomizer::logic::area::Area* area2; // world->GetArea(areaStr, area2); // if (recentlyUpdatedAreas.contains(area2)) // { @@ -167,7 +167,7 @@ bool FlattenSearch::wasUpdated(tphdr::logic::area::Area* area, void* thing) void FlattenSearch::tryExits() { - using namespace tphdr::logic::requirement; + using namespace randomizer::logic::requirement; auto exits = exitsToTry; for (auto& exit : exits) { @@ -255,7 +255,7 @@ void FlattenSearch::tryEvents() auto& oldExpr = eventExprs[event->GetEventIndex()]; auto newPartial = DNF::False(); - for (const auto& formTime : tphdr::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES) + for (const auto& formTime : randomizer::logic::requirement::FormTime::ALL_FORM_AND_DAY_TIMES) { newPartial = newPartial.or_(tryEventAtFormTime(event, formTime)); } @@ -271,7 +271,7 @@ void FlattenSearch::tryEvents() void FlattenSearch::tryTimeFormExpansion() { - using namespace tphdr::logic::requirement; + using namespace randomizer::logic::requirement; for (auto& area : areasToTry) { if (!recentlyUpdatedAreas.contains(area)) @@ -352,9 +352,9 @@ void FlattenSearch::tryTimeFormExpansion() } } -void FlattenSearch::andAreaFormTimes(tphdr::logic::area::Area* area) +void FlattenSearch::andAreaFormTimes(randomizer::logic::area::Area* area) { - using namespace tphdr::logic::requirement; + using namespace randomizer::logic::requirement; auto& areaHumanDay = this->areaExprs[FormTime::HUMAN_DAY][area]; auto& areaWolfDay = this->areaExprs[FormTime::WOLF_DAY][area]; @@ -365,26 +365,26 @@ void FlattenSearch::andAreaFormTimes(tphdr::logic::area::Area* area) this->areaExprs[FormTime::NIGHT][area] = areaHumanNight.and_(areaWolfNight); } -DNF FlattenSearch::tryEventAtFormTime(tphdr::logic::area::EventAccess* event, const int& formTime) +DNF FlattenSearch::tryEventAtFormTime(randomizer::logic::area::EventAccess* event, const int& formTime) { return areaExprs[formTime][event->GetArea()].and_( evaluatePartialRequirement(bitIndex, event->GetRequirement(), this, formTime)); } -DNF FlattenSearch::tryLocationAtFormTime(tphdr::logic::area::LocationAccess* location, const int& formTime) +DNF FlattenSearch::tryLocationAtFormTime(randomizer::logic::area::LocationAccess* location, const int& formTime) { return areaExprs[formTime][location->GetArea()].and_( evaluatePartialRequirement(bitIndex, location->GetRequirement(), this, formTime)); } -DNF FlattenSearch::tryExitAtFormTime(tphdr::logic::entrance::Entrance* exit, const int& formTime) +DNF FlattenSearch::tryExitAtFormTime(randomizer::logic::entrance::Entrance* exit, const int& formTime) { return areaExprs[formTime][exit->GetParentArea()].and_( evaluatePartialRequirement(bitIndex, exit->GetRequirement(), this, formTime)); } DNF evaluatePartialRequirement(BitIndex& bitIndex, - const tphdr::logic::requirement::Requirement& req, + const randomizer::logic::requirement::Requirement& req, FlattenSearch* search, const int& formTime) { @@ -392,93 +392,93 @@ DNF evaluatePartialRequirement(BitIndex& bitIndex, uint32_t expectedHearts = 0; uint32_t totalHearts = 0; std::bitset<512> bits = 0; - tphdr::logic::item::Item* item; + randomizer::logic::item::Item* item; int event; DNF d = DNF(); - tphdr::logic::area::Area* area; + randomizer::logic::area::Area* area; switch (req._type) { - case tphdr::logic::requirement::Type::NOTHING: + case randomizer::logic::requirement::Type::NOTHING: return DNF::True(); - case tphdr::logic::requirement::Type::IMPOSSIBLE: + case randomizer::logic::requirement::Type::IMPOSSIBLE: return DNF::False(); - case tphdr::logic::requirement::Type::OR: + case randomizer::logic::requirement::Type::OR: d = DNF::False(); for (auto& arg : req._args) { d = d.or_(evaluatePartialRequirement(bitIndex, - std::get(arg), + std::get(arg), search, formTime)); } return d; - case tphdr::logic::requirement::Type::AND: + case randomizer::logic::requirement::Type::AND: d = DNF::True(); for (auto& arg : req._args) { d = d.and_(evaluatePartialRequirement(bitIndex, - std::get(arg), + std::get(arg), search, formTime)); } return d; - case tphdr::logic::requirement::Type::GOLDEN_BUGS: + case randomizer::logic::requirement::Type::GOLDEN_BUGS: [[fallthrough]]; - case tphdr::logic::requirement::Type::ITEM: + case randomizer::logic::requirement::Type::ITEM: // [[fallthrough]]; - // case tphdr::logic::requirement::Type::HEALTH: + // case randomizer::logic::requirement::Type::HEALTH: bits[bitIndex.reqBit(req)] = 1; return DNF({bits}); - case tphdr::logic::requirement::Type::EVENT: + case randomizer::logic::requirement::Type::EVENT: event = std::get(req._args[0]); return search->eventExprs[event]; - case tphdr::logic::requirement::Type::MACRO: + case randomizer::logic::requirement::Type::MACRO: return evaluatePartialRequirement(bitIndex, search->world->GetMacro(std::get(req._args[0])), search, formTime); // count requirements frequently have to unify with weaker terms, // so a count requirement always requires all lesser item counts too. // this ensures redundant terms can be eliminated - case tphdr::logic::requirement::Type::COUNT: + case randomizer::logic::requirement::Type::COUNT: expectedCount = std::get(req._args[0]); - item = std::get(req._args[1]); + item = std::get(req._args[1]); for (auto i = 1; i <= expectedCount; i++) { - tphdr::logic::requirement::Requirement newReq; + randomizer::logic::requirement::Requirement newReq; if (i == 1) { - newReq = tphdr::logic::requirement::Requirement {tphdr::logic::requirement::Type::ITEM, {item}}; + newReq = randomizer::logic::requirement::Requirement {randomizer::logic::requirement::Type::ITEM, {item}}; } else { - newReq = tphdr::logic::requirement::Requirement {tphdr::logic::requirement::Type::COUNT, {i, item}}; + newReq = randomizer::logic::requirement::Requirement {randomizer::logic::requirement::Type::COUNT, {i, item}}; } bits[bitIndex.reqBit(newReq)] = 1; } return DNF({bits}); - case tphdr::logic::requirement::Type::DAY: - return (formTime & tphdr::logic::requirement::FormTime::DAY) ? DNF::True() : DNF::False(); + case randomizer::logic::requirement::Type::DAY: + return (formTime & randomizer::logic::requirement::FormTime::DAY) ? DNF::True() : DNF::False(); - case tphdr::logic::requirement::Type::NIGHT: - return (formTime & tphdr::logic::requirement::FormTime::NIGHT) ? DNF::True() : DNF::False(); + case randomizer::logic::requirement::Type::NIGHT: + return (formTime & randomizer::logic::requirement::FormTime::NIGHT) ? DNF::True() : DNF::False(); - case tphdr::logic::requirement::Type::HUMAN_LINK: - return (formTime & tphdr::logic::requirement::FormTime::HUMAN) ? DNF::True() : DNF::False(); + case randomizer::logic::requirement::Type::HUMAN_LINK: + return (formTime & randomizer::logic::requirement::FormTime::HUMAN) ? DNF::True() : DNF::False(); - case tphdr::logic::requirement::Type::WOLF_LINK: - return (formTime & tphdr::logic::requirement::FormTime::WOLF) ? DNF::True() : DNF::False(); + case randomizer::logic::requirement::Type::WOLF_LINK: + return (formTime & randomizer::logic::requirement::FormTime::WOLF) ? DNF::True() : DNF::False(); - case tphdr::logic::requirement::Type::TWILIGHT: - return (formTime & tphdr::logic::requirement::FormTime::TWILIGHT) ? DNF::True() : DNF::False(); + case randomizer::logic::requirement::Type::TWILIGHT: + return (formTime & randomizer::logic::requirement::FormTime::TWILIGHT) ? DNF::True() : DNF::False(); - case tphdr::logic::requirement::Type::INVALID: + case randomizer::logic::requirement::Type::INVALID: default: // actually needs to be some error state? return DNF::False(); @@ -486,19 +486,19 @@ DNF evaluatePartialRequirement(BitIndex& bitIndex, return DNF::False(); } -void visitReq(const tphdr::logic::requirement::Requirement& req, - std::function f, - tphdr::logic::world::World* world) +void visitReq(const randomizer::logic::requirement::Requirement& req, + std::function f, + randomizer::logic::world::World* world) { f(req); - if (req._type == tphdr::logic::requirement::Type::AND || req._type == tphdr::logic::requirement::Type::OR) + if (req._type == randomizer::logic::requirement::Type::AND || req._type == randomizer::logic::requirement::Type::OR) { for (auto& arg : req._args) { - visitReq(std::get(arg), f, world); + visitReq(std::get(arg), f, world); } } - else if (req._type == tphdr::logic::requirement::Type::MACRO) + else if (req._type == randomizer::logic::requirement::Type::MACRO) { visitReq(world->GetMacro(std::get(req._args[0])), f, world); } diff --git a/src/dusk/randomizer/logic/flatten/flatten.hpp b/src/dusk/randomizer/logic/flatten/flatten.hpp index e78de822ee..dc7d0f7760 100644 --- a/src/dusk/randomizer/logic/flatten/flatten.hpp +++ b/src/dusk/randomizer/logic/flatten/flatten.hpp @@ -8,13 +8,13 @@ #include #include -namespace tphdr::logic::area +namespace randomizer::logic::area { class EventAccess; class Area; -} // namespace tphdr::logic::area +} // namespace randomizer::logic::area -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } @@ -23,29 +23,29 @@ class FlattenSearch { public: FlattenSearch() = default; - FlattenSearch(tphdr::logic::world::World* world_); + FlattenSearch(randomizer::logic::world::World* world_); - tphdr::logic::world::World* world = nullptr; + randomizer::logic::world::World* world = nullptr; BitIndex bitIndex = BitIndex(); // partially computed requirements for areas at a // given timeform and for events std::unordered_map eventExprs = {}; - std::unordered_map> areaExprs = {}; + std::unordered_map> areaExprs = {}; // nodes we haven't looked at we don't even need to bother with - std::set exitsToTry = {}; - std::set eventsToTry = {}; - std::set areasToTry = {}; + std::set exitsToTry = {}; + std::set eventsToTry = {}; + std::set areasToTry = {}; // we only re-check an exit or an event if its dependencies changed. // dependencies can be the implicit parent area (for events and exits), // formtime expansion in the area, and "remote" requirements arising // from the expression itself mentioning an event or an area via can_access - std::set recentlyUpdatedAreas = {}; + std::set recentlyUpdatedAreas = {}; std::set recentlyUpdatedEvents = {}; - std::set newlyUpdatedAreas = {}; + std::set newlyUpdatedAreas = {}; std::set newlyUpdatedEvents = {}; std::unordered_map> remoteEventRequirements = {}; @@ -53,25 +53,25 @@ class FlattenSearch bool newThingsFound = false; void doSearch(); - bool wasUpdated(tphdr::logic::area::Area* area, void* thing); + bool wasUpdated(randomizer::logic::area::Area* area, void* thing); void tryExits(); void tryEvents(); void tryTimeFormExpansion(); - void andAreaFormTimes(tphdr::logic::area::Area* area); + void andAreaFormTimes(randomizer::logic::area::Area* area); - DNF tryEventAtFormTime(tphdr::logic::area::EventAccess* event, const int& formTime); - DNF tryLocationAtFormTime(tphdr::logic::area::LocationAccess* location, const int& formTime); - DNF tryExitAtFormTime(tphdr::logic::entrance::Entrance* exit, const int& formTime); + DNF tryEventAtFormTime(randomizer::logic::area::EventAccess* event, const int& formTime); + DNF tryLocationAtFormTime(randomizer::logic::area::LocationAccess* location, const int& formTime); + DNF tryExitAtFormTime(randomizer::logic::entrance::Entrance* exit, const int& formTime); }; template -std::function visitor(T* thing, FlattenSearch* search) +std::function visitor(T* thing, FlattenSearch* search) { auto thingPtr = (void*)thing; - std::function handler = - [=](const tphdr::logic::requirement::Requirement& req) + std::function handler = + [=](const randomizer::logic::requirement::Requirement& req) { - if (req._type == tphdr::logic::requirement::Type::EVENT) + if (req._type == randomizer::logic::requirement::Type::EVENT) { if (!search->remoteEventRequirements.contains(thingPtr)) { @@ -84,11 +84,11 @@ std::function visitor(T return handler; } -void visitReq(const tphdr::logic::requirement::Requirement& req, - std::function f, - tphdr::logic::world::World* world); +void visitReq(const randomizer::logic::requirement::Requirement& req, + std::function f, + randomizer::logic::world::World* world); DNF evaluatePartialRequirement(BitIndex& bitIndex, - const tphdr::logic::requirement::Requirement& req, + const randomizer::logic::requirement::Requirement& req, FlattenSearch* search, const int& formTime); diff --git a/src/dusk/randomizer/logic/flatten/simplify_algebraic.cpp b/src/dusk/randomizer/logic/flatten/simplify_algebraic.cpp index 20967002ec..37ba38d0eb 100644 --- a/src/dusk/randomizer/logic/flatten/simplify_algebraic.cpp +++ b/src/dusk/randomizer/logic/flatten/simplify_algebraic.cpp @@ -3,16 +3,16 @@ // Turns a bit-based DNF (a two-level sum-of-products) back into // a readable multi-level requirement. -tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) +randomizer::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) { if (dnf.isTriviallyFalse()) { - return tphdr::logic::requirement::Requirement {tphdr::logic::requirement::Type::IMPOSSIBLE, {}}; + return randomizer::logic::requirement::Requirement {randomizer::logic::requirement::Type::IMPOSSIBLE, {}}; } if (dnf.isTriviallyTrue()) { - return tphdr::logic::requirement::Requirement {tphdr::logic::requirement::Type::NOTHING, {}}; + return randomizer::logic::requirement::Requirement {randomizer::logic::requirement::Type::NOTHING, {}}; } // really make sure no dupes exist, not sure if needed @@ -47,14 +47,14 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) for (const auto& bit : term.ints()) { auto& req = bitIndex.reverseIndex[bit]; - if (req._type == tphdr::logic::requirement::Type::COUNT) + if (req._type == randomizer::logic::requirement::Type::COUNT) { auto count = std::get(req._args[0]); - auto item = std::get(req._args[1]); + auto item = std::get(req._args[1]); for (int i = 1; i < count; i++) { auto lesserBit = bitIndex.reqBit( - tphdr::logic::requirement::Requirement {tphdr::logic::requirement::Type::COUNT, {i, item}}); + randomizer::logic::requirement::Requirement {randomizer::logic::requirement::Type::COUNT, {i, item}}); term.clear(lesserBit); } } @@ -97,7 +97,7 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) std::vector seen = {}; auto kernels = findKernels(expr, variables, BitVector(), seen); - kernels = tphdr::utility::container::FilterFromVector(kernels, [](const auto& k) { return !k.coKernel.isEmpty(); }); + kernels = randomizer::utility::container::FilterFromVector(kernels, [](const auto& k) { return !k.coKernel.isEmpty(); }); // columns are unique cubes in all kernels std::vector columns = {}; @@ -211,8 +211,8 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) // and re-assemble a Requirement that sort of looks like // common_factors * (quotient * divisor + remainder) - auto product = tphdr::logic::requirement::Requirement(); - product._type = tphdr::logic::requirement::Type::AND; + auto product = randomizer::logic::requirement::Requirement(); + product._type = randomizer::logic::requirement::Type::AND; std::vector> quotBits; std::vector> divisorBits; for (const auto& c : quot) @@ -226,7 +226,7 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) product._args.push_back(DNFToExpr(bitIndex, DNF(quotBits))); product._args.push_back(DNFToExpr(bitIndex, DNF(divisorBits))); - auto sum = tphdr::logic::requirement::Requirement(); + auto sum = randomizer::logic::requirement::Requirement(); if (!remainder.empty()) { std::vector> remainderBits; @@ -234,7 +234,7 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) { remainderBits.push_back(c.bitset); } - sum._type = tphdr::logic::requirement::Type::OR; + sum._type = randomizer::logic::requirement::Type::OR; sum._args.push_back(product); sum._args.push_back(DNFToExpr(bitIndex, DNF(remainderBits))); } @@ -250,8 +250,8 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) // here we didn't do our complicated rectangle extraction, so just extract // the common factors - auto terms = tphdr::logic::requirement::Requirement(); - terms._type = tphdr::logic::requirement::Type::OR; + auto terms = randomizer::logic::requirement::Requirement(); + terms._type = randomizer::logic::requirement::Type::OR; for (const auto& c : expr) { terms._args.push_back(createAnd(lookupRequirements(bitIndex, c.ints()))); @@ -263,12 +263,12 @@ tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf) return createAnd(finalTerms); } -tphdr::logic::requirement::Requirement createAnd(std::vector terms) +randomizer::logic::requirement::Requirement createAnd(std::vector terms) { if (terms.size() > 1) { - tphdr::logic::requirement::Requirement req; - req._type = tphdr::logic::requirement::Type::AND; + randomizer::logic::requirement::Requirement req; + req._type = randomizer::logic::requirement::Type::AND; for (auto& term : terms) { req._args.push_back(term); diff --git a/src/dusk/randomizer/logic/flatten/simplify_algebraic.hpp b/src/dusk/randomizer/logic/flatten/simplify_algebraic.hpp index 5cfe941c73..eecc2db6a3 100644 --- a/src/dusk/randomizer/logic/flatten/simplify_algebraic.hpp +++ b/src/dusk/randomizer/logic/flatten/simplify_algebraic.hpp @@ -30,9 +30,9 @@ struct FoundKernel BitVector coKernel; }; -tphdr::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf); +randomizer::logic::requirement::Requirement DNFToExpr(BitIndex& bitIndex, DNF dnf); -tphdr::logic::requirement::Requirement createAnd(std::vector terms); +randomizer::logic::requirement::Requirement createAnd(std::vector terms); // Generates all prime rectangles in this matrix. A rectangle is a set of columns and rows // such that for every row and column, matrix[row][colum] is not zero. A prime rectangle @@ -175,9 +175,9 @@ std::pair, std::vector> algebraicDivision(cons const std::vector& divisor); template -std::vector lookupRequirements(BitIndex& bitIndex, Container r) +std::vector lookupRequirements(BitIndex& bitIndex, Container r) { - std::vector reqs; + std::vector reqs; for (auto& bit : r) { reqs.push_back(bitIndex.reverseIndex[bit]); diff --git a/src/dusk/randomizer/logic/generate.cpp b/src/dusk/randomizer/logic/generate.cpp index 7724862033..913731ee44 100644 --- a/src/dusk/randomizer/logic/generate.cpp +++ b/src/dusk/randomizer/logic/generate.cpp @@ -13,37 +13,37 @@ #include -namespace tphdr::logic::generate +namespace randomizer::logic::generate { - tphdr::logic::world::WorldPool GenerateWorlds() + randomizer::logic::world::WorldPool GenerateWorlds() { #ifdef ENABLE_TIMING - tphdr::utility::time::ScopedTimer<"Seed generation took ", std::chrono::milliseconds> timer; + randomizer::utility::time::ScopedTimer<"Seed generation took ", std::chrono::milliseconds> timer; #endif - tphdr::seedgen::config::Config config; + randomizer::seedgen::config::Config config; config.LoadFromFile(SETTINGS_PATH, PREFERENCES_PATH); - tphdr::utility::platform::Log(std::string("Seed: ") + config.GetSeed()); + randomizer::utility::platform::Log(std::string("Seed: ") + config.GetSeed()); - tphdr::logic::world::WorldPool worlds = {}; + randomizer::logic::world::WorldPool worlds = {}; GenerateRandomizer(config, worlds); return std::move(worlds); } - void GenerateRandomizer(tphdr::seedgen::config::Config& config, tphdr::logic::world::WorldPool& worlds) + void GenerateRandomizer(randomizer::seedgen::config::Config& config, randomizer::logic::world::WorldPool& worlds) { - tphdr::seedgen::config::SeedRNG(config, true, false); + randomizer::seedgen::config::SeedRNG(config, true, false); // Set the hash now before anything else random is decided. This allows us to show the hash for a seed // before generating it later auto hash = config.GetHash(); - tphdr::utility::platform::Log(std::string("Hash: ") + hash); + randomizer::utility::platform::Log(std::string("Hash: ") + hash); // Build all worlds int worldId = 1; for (const auto& settings : config.GetSettingsList()) { - std::unique_ptr world = std::make_unique(worldId++); + std::unique_ptr world = std::make_unique(worldId++); world->SetSettings(settings); world->ResolveRandomSettings(); world->ResolveConflictingSettings(); @@ -60,7 +60,7 @@ namespace tphdr::logic::generate // Process Plando Data for all worlds if (config.IsUsingPlandomizer()) { - tphdr::logic::plandomizer::LoadPlandomizerData(worlds, config.GetPlandomizerPath()); + randomizer::logic::plandomizer::LoadPlandomizerData(worlds, config.GetPlandomizerPath()); } // Pre Entrance Shuffle Tasks @@ -69,10 +69,10 @@ namespace tphdr::logic::generate world->PerformPreEntranceShuffleTasks(); } - tphdr::utility::platform::Log("Shuffling Entrances..."); + randomizer::utility::platform::Log("Shuffling Entrances..."); for (auto& world : worlds) { - tphdr::logic::entrance_shuffle::ShuffleWorldEntrances(world.get(), worlds); + randomizer::logic::entrance_shuffle::ShuffleWorldEntrances(world.get(), worlds); } // Post Entrance Shuffle Tasks @@ -80,18 +80,18 @@ namespace tphdr::logic::generate { world->PerformPostEntranceShuffleTasks(); } - tphdr::logic::fill::CacheExitTimeForms(worlds); + randomizer::logic::fill::CacheExitTimeForms(worlds); // Flattening isn't used for anything yet, but flattens down the requirements for // each location and entrance into a single statement. This will be useful for hints and could potentially // be used to speed up the fill algorithm (but the fill algorithm is already pretty fast, so we'd only gain maybe like // 0.2 seconds back or something) - tphdr::utility::platform::Log("Flattening..."); + randomizer::utility::platform::Log("Flattening..."); FlattenSearch search = FlattenSearch(worlds.at(0).get()); search.doSearch(); - tphdr::utility::platform::Log("Filling Worlds..."); - tphdr::logic::fill::FillWorlds(worlds); + randomizer::utility::platform::Log("Filling Worlds..."); + randomizer::logic::fill::FillWorlds(worlds); // Post Fill Tasks for (auto& world : worlds) @@ -100,15 +100,15 @@ namespace tphdr::logic::generate } // Generate Playthrough - tphdr::logic::search::GeneratePlaythrough(&worlds); + randomizer::logic::search::GeneratePlaythrough(&worlds); // TODO: Generate Hints // Write Logs if (config.IsGeneratingSpoilerLog()) { - tphdr::logic::spoiler_log::GenerateSpoilerLog(worlds, config); + randomizer::logic::spoiler_log::GenerateSpoilerLog(worlds, config); } - tphdr::logic::spoiler_log::GenerateAntiSpoilerLog(worlds, config); + randomizer::logic::spoiler_log::GenerateAntiSpoilerLog(worlds, config); } -} // namespace tphdr::logic::generate +} // namespace randomizer::logic::generate diff --git a/src/dusk/randomizer/logic/generate.hpp b/src/dusk/randomizer/logic/generate.hpp index 336229ee44..e5ec40b1a6 100644 --- a/src/dusk/randomizer/logic/generate.hpp +++ b/src/dusk/randomizer/logic/generate.hpp @@ -3,7 +3,7 @@ #include "world.hpp" #include "../seedgen/config.hpp" -namespace tphdr::logic::generate +namespace randomizer::logic::generate { /** * @brief Generates a complete randomizer seed @@ -11,7 +11,7 @@ namespace tphdr::logic::generate * @param worlds The list of worlds for the generated randomizer seed * @return the worldpool which was generated */ - tphdr::logic::world::WorldPool GenerateWorlds(); + randomizer::logic::world::WorldPool GenerateWorlds(); /** * @brief Generates a complete randomizer seed with the provided config @@ -20,5 +20,5 @@ namespace tphdr::logic::generate * @param worlds The list of worlds for the generated randomizer seed * @return 0 if no errors. 1 if there were errors */ - void GenerateRandomizer(tphdr::seedgen::config::Config& config, tphdr::logic::world::WorldPool& worlds); -} // namespace tphdr::logic::generate + void GenerateRandomizer(randomizer::seedgen::config::Config& config, randomizer::logic::world::WorldPool& worlds); +} // namespace randomizer::logic::generate diff --git a/src/dusk/randomizer/logic/item.cpp b/src/dusk/randomizer/logic/item.cpp index 9198118c3e..24f7e2c86c 100644 --- a/src/dusk/randomizer/logic/item.cpp +++ b/src/dusk/randomizer/logic/item.cpp @@ -2,7 +2,7 @@ #include "world.hpp" -namespace tphdr::logic::item +namespace randomizer::logic::item { Importance ImportanceFromStr(const std::string& str) @@ -21,7 +21,7 @@ namespace tphdr::logic::item Item::Item(const int& id, const std::string& name, - tphdr::logic::world::World* world, + randomizer::logic::world::World* world, const Importance& importance, const bool& gameWinningItem, const bool& dungeonSmallKey, @@ -66,7 +66,7 @@ namespace tphdr::logic::item return this->_name; } - tphdr::logic::world::World* Item::GetWorld() const + randomizer::logic::world::World* Item::GetWorld() const { return this->_world; } @@ -154,4 +154,4 @@ namespace tphdr::logic::item std::unique_ptr Nothing = std::make_unique(-1, "Nothing", nullptr, Importance::JUNK, false, false, false, false, false); -} // namespace tphdr::logic::item +} // namespace randomizer::logic::item diff --git a/src/dusk/randomizer/logic/item.hpp b/src/dusk/randomizer/logic/item.hpp index 63585c49a2..4deb43fe76 100644 --- a/src/dusk/randomizer/logic/item.hpp +++ b/src/dusk/randomizer/logic/item.hpp @@ -4,12 +4,12 @@ #include #include -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; }; class Location; -namespace tphdr::logic::item +namespace randomizer::logic::item { enum Importance { @@ -27,7 +27,7 @@ namespace tphdr::logic::item Item() = default; Item(const int& id, const std::string& name, - tphdr::logic::world::World* world, + randomizer::logic::world::World* world, const Importance& importance, const bool& gameWinningItem, const bool& dungeonSmallKey, @@ -37,7 +37,7 @@ namespace tphdr::logic::item int GetID() const; std::string GetName() const; - tphdr::logic::world::World* GetWorld() const; + randomizer::logic::world::World* GetWorld() const; Importance GetImportance() const; bool IsMajor() const; bool IsMinor() const; @@ -59,7 +59,7 @@ namespace tphdr::logic::item private: int _id = -1; std::string _name; - tphdr::logic::world::World* _world = nullptr; + randomizer::logic::world::World* _world = nullptr; Importance _importance = INVALID; bool _gameWinningItem = false; std::list _chainLocations; @@ -75,4 +75,4 @@ namespace tphdr::logic::item }; extern std::unique_ptr Nothing; -} // namespace tphdr::logic::item \ No newline at end of file +} // namespace randomizer::logic::item diff --git a/src/dusk/randomizer/logic/item_pool.cpp b/src/dusk/randomizer/logic/item_pool.cpp index 6d15e29b53..b83f15178c 100644 --- a/src/dusk/randomizer/logic/item_pool.cpp +++ b/src/dusk/randomizer/logic/item_pool.cpp @@ -4,7 +4,7 @@ #include -namespace tphdr::logic::item_pool +namespace randomizer::logic::item_pool { std::map minimalItemPool = { @@ -210,7 +210,7 @@ namespace tphdr::logic::item_pool {"Purple Rupee", 12}, }; - void GenerateItemPool(tphdr::logic::world::World* world) + void GenerateItemPool(randomizer::logic::world::World* world) { auto itemPool = minimalItemPool; @@ -311,7 +311,7 @@ namespace tphdr::logic::item_pool } } - void GenerateStartingItemPool(tphdr::logic::world::World* world) + void GenerateStartingItemPool(randomizer::logic::world::World* world) { const auto& startingItems = world->GetSettings().GetStartingInventory(); auto& startingItemPool = world->GetStartingItemPool(); @@ -325,7 +325,7 @@ namespace tphdr::logic::item_pool { startingItemPool.push_back(item); } - tphdr::utility::container::Erase(itemPool, item, count); + randomizer::utility::container::Erase(itemPool, item, count); } } @@ -334,7 +334,7 @@ namespace tphdr::logic::item_pool return initialJunkPool; } - ItemPool GetCompleteItemPool(tphdr::logic::world::WorldPool& worlds) + ItemPool GetCompleteItemPool(randomizer::logic::world::WorldPool& worlds) { ItemPool completeItemPool = {}; for (const auto& world : worlds) @@ -345,4 +345,4 @@ namespace tphdr::logic::item_pool return completeItemPool; } -} // namespace tphdr::logic::item_pool +} // namespace randomizer::logic::item_pool diff --git a/src/dusk/randomizer/logic/item_pool.hpp b/src/dusk/randomizer/logic/item_pool.hpp index 737405c051..9a23db3525 100644 --- a/src/dusk/randomizer/logic/item_pool.hpp +++ b/src/dusk/randomizer/logic/item_pool.hpp @@ -6,27 +6,27 @@ #include // Foward Declarations -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; using WorldPool = std::vector>; -} // namespace tphdr::logic::world +} // namespace randomizer::logic::world -namespace tphdr::logic::item +namespace randomizer::logic::item { class Item; } -namespace tphdr::logic::item_pool +namespace randomizer::logic::item_pool { - using ItemPool = std::vector; + using ItemPool = std::vector; /** * @brief Generates and sets the item pool of randomized items for a single world. * * @param world The world to generate the item pool for */ - void GenerateItemPool(tphdr::logic::world::World* world); + void GenerateItemPool(randomizer::logic::world::World* world); /** * @brief Generates and sets the starting item pool for a single world. Starting items will be @@ -34,9 +34,9 @@ namespace tphdr::logic::item_pool * * @param world The world to generate the starting item pool for */ - void GenerateStartingItemPool(tphdr::logic::world::World* world); + void GenerateStartingItemPool(randomizer::logic::world::World* world); std::map GetInitialJunkPool(); - ItemPool GetCompleteItemPool(tphdr::logic::world::WorldPool& worlds); -} // namespace tphdr::logic::item_pool + ItemPool GetCompleteItemPool(randomizer::logic::world::WorldPool& worlds); +} // namespace randomizer::logic::item_pool diff --git a/src/dusk/randomizer/logic/location.cpp b/src/dusk/randomizer/logic/location.cpp index d7fddf4bba..2b3e0d1fa9 100644 --- a/src/dusk/randomizer/logic/location.cpp +++ b/src/dusk/randomizer/logic/location.cpp @@ -3,13 +3,13 @@ #include "world.hpp" #include "../utility/log.hpp" -namespace tphdr::logic::location +namespace randomizer::logic::location { Location::Location(const int& id, const std::string& name, std::unordered_set categories, - tphdr::logic::world::World* world, - tphdr::logic::item::Item* originalItem, + randomizer::logic::world::World* world, + randomizer::logic::item::Item* originalItem, const bool& goalLocation, const std::string& hintPriority): _id(id), @@ -20,7 +20,7 @@ namespace tphdr::logic::location _goalLocation(goalLocation), _hintPriority(hintPriority) { - this->_computedRequirement._type = tphdr::logic::requirement::Type::IMPOSSIBLE; + this->_computedRequirement._type = randomizer::logic::requirement::Type::IMPOSSIBLE; } int Location::GetID() const @@ -33,7 +33,7 @@ namespace tphdr::logic::location return this->_name; } - tphdr::logic::world::World* Location::GetWorld() const + randomizer::logic::world::World* Location::GetWorld() const { return this->_world; } @@ -43,13 +43,13 @@ namespace tphdr::logic::location return this->_goalLocation; } - void Location::SetCurrentItem(tphdr::logic::item::Item* item) + void Location::SetCurrentItem(randomizer::logic::item::Item* item) { LOG_TO_DEBUG("Placed " + item->GetName() + " at " + this->GetName()); this->_currentItem = item; } - tphdr::logic::item::Item* Location::GetCurrentItem() const + randomizer::logic::item::Item* Location::GetCurrentItem() const { return this->_currentItem; } @@ -57,20 +57,20 @@ namespace tphdr::logic::location void Location::RemoveCurrentItem() { LOG_TO_DEBUG("Removed " + this->GetCurrentItem()->GetName() + " at " + this->GetName()); - this->_currentItem = tphdr::logic::item::Nothing.get(); + this->_currentItem = randomizer::logic::item::Nothing.get(); } bool Location::IsEmpty() const { - return this->_currentItem == tphdr::logic::item::Nothing.get(); + return this->_currentItem == randomizer::logic::item::Nothing.get(); } - tphdr::logic::item::Item* Location::GetOriginalItem() const + randomizer::logic::item::Item* Location::GetOriginalItem() const { return this->_originalItem; } - tphdr::logic::item::Item* Location::GetTrackedItem() const + randomizer::logic::item::Item* Location::GetTrackedItem() const { return this->_trackedItem; } @@ -106,33 +106,33 @@ namespace tphdr::logic::location return this->_hinted; } - void Location::AddLocationAccess(tphdr::logic::area::LocationAccess* locAcc) + void Location::AddLocationAccess(randomizer::logic::area::LocationAccess* locAcc) { this->_locationAccessList.push_back(locAcc); } - std::list Location::GetAccessList() const + std::list Location::GetAccessList() const { return this->_locationAccessList; } - void Location::AddForbiddenItem(tphdr::logic::item::Item* forbiddenItem) + void Location::AddForbiddenItem(randomizer::logic::item::Item* forbiddenItem) { this->_forbiddenItems.insert(forbiddenItem); LOG_TO_DEBUG(forbiddenItem->GetName() + " is forbidden from being placed at " + this->GetName()); } - const std::unordered_set& Location::GetForbiddenItems() + const std::unordered_set& Location::GetForbiddenItems() { return this->_forbiddenItems; } - void Location::SetComputedRequirement(const tphdr::logic::requirement::Requirement& computedRequirement) + void Location::SetComputedRequirement(const randomizer::logic::requirement::Requirement& computedRequirement) { this->_computedRequirement = computedRequirement; } - tphdr::logic::requirement::Requirement Location::GetComputedRequirement() + randomizer::logic::requirement::Requirement Location::GetComputedRequirement() { return this->_computedRequirement; } @@ -141,4 +141,4 @@ namespace tphdr::logic::location { this->_registeredLocationCategories = registeredLocationCategories; } -} // namespace tphdr::logic::location +} // namespace randomizer::logic::location diff --git a/src/dusk/randomizer/logic/location.hpp b/src/dusk/randomizer/logic/location.hpp index 4f4e7260b9..4013d7028e 100644 --- a/src/dusk/randomizer/logic/location.hpp +++ b/src/dusk/randomizer/logic/location.hpp @@ -7,17 +7,17 @@ #include #include -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } -namespace tphdr::logic::area +namespace randomizer::logic::area { class LocationAccess; } -namespace tphdr::logic::location +namespace randomizer::logic::location { class Location { @@ -25,33 +25,33 @@ namespace tphdr::logic::location Location(const int& id, const std::string& name, std::unordered_set categories, - tphdr::logic::world::World* world, - tphdr::logic::item::Item* originalItem, + randomizer::logic::world::World* world, + randomizer::logic::item::Item* originalItem, const bool& goalLocation, const std::string& hintPriority); int GetID() const; std::string GetName() const; - tphdr::logic::world::World* GetWorld() const; + randomizer::logic::world::World* GetWorld() const; bool IsGoalLocation() const; - void SetCurrentItem(tphdr::logic::item::Item* currentItem); - tphdr::logic::item::Item* GetCurrentItem() const; + void SetCurrentItem(randomizer::logic::item::Item* currentItem); + randomizer::logic::item::Item* GetCurrentItem() const; void RemoveCurrentItem(); bool IsEmpty() const; - tphdr::logic::item::Item* GetOriginalItem() const; - tphdr::logic::item::Item* GetTrackedItem() const; + randomizer::logic::item::Item* GetOriginalItem() const; + randomizer::logic::item::Item* GetTrackedItem() const; void SetKnownVanillaItem(const bool& hasKnownVanillaItem); bool HasKnownVanillaItem() const; void SetProgression(const bool& progression); bool IsProgression() const; void SetHinted(const bool& hinted); bool IsHinted() const; - void AddLocationAccess(tphdr::logic::area::LocationAccess* locAcc); - std::list GetAccessList() const; - void AddForbiddenItem(tphdr::logic::item::Item* forbiddenItem); - const std::unordered_set& GetForbiddenItems(); - void SetComputedRequirement(const tphdr::logic::requirement::Requirement& computedRequirement); - tphdr::logic::requirement::Requirement GetComputedRequirement(); + void AddLocationAccess(randomizer::logic::area::LocationAccess* locAcc); + std::list GetAccessList() const; + void AddForbiddenItem(randomizer::logic::item::Item* forbiddenItem); + const std::unordered_set& GetForbiddenItems(); + void SetComputedRequirement(const randomizer::logic::requirement::Requirement& computedRequirement); + randomizer::logic::requirement::Requirement GetComputedRequirement(); void SetRegisteredLocationCategories(std::unordered_set* registeredLocationCategories); /** @@ -83,17 +83,17 @@ namespace tphdr::logic::location int _id = -1; std::string _name = ""; std::unordered_set _categories = {}; - tphdr::logic::world::World* _world; - tphdr::logic::item::Item* _originalItem = tphdr::logic::item::Nothing.get(); + randomizer::logic::world::World* _world; + randomizer::logic::item::Item* _originalItem = randomizer::logic::item::Nothing.get(); bool _goalLocation = false; - tphdr::logic::item::Item* _currentItem = tphdr::logic::item::Nothing.get(); + randomizer::logic::item::Item* _currentItem = randomizer::logic::item::Nothing.get(); bool _hasKnownVanillaItem = false; - std::list _locationAccessList = {}; + std::list _locationAccessList = {}; bool _progression = true; // Set as false later if applicable bool _hinted = false; std::string _hintPriority = "Never"; - std::unordered_set _forbiddenItems = {}; - tphdr::logic::requirement::Requirement _computedRequirement; + std::unordered_set _forbiddenItems = {}; + randomizer::logic::requirement::Requirement _computedRequirement; /** * @brief _registeredLocationCategories is the set of all categories that are processed after reading locations.yaml. * This structure is held in the World class and every location in that world has a pointer to it. @@ -102,8 +102,8 @@ namespace tphdr::logic::location std::unordered_set* _registeredLocationCategories = nullptr; // Potential tracker stuff - tphdr::logic::item::Item* _trackedItem = tphdr::logic::item::Nothing.get(); + randomizer::logic::item::Item* _trackedItem = randomizer::logic::item::Nothing.get(); }; using LocationPool = std::vector; -} // namespace tphdr::logic::location +} // namespace randomizer::logic::location diff --git a/src/dusk/randomizer/logic/plandomizer.cpp b/src/dusk/randomizer/logic/plandomizer.cpp index b76222a9d3..269a1630ee 100644 --- a/src/dusk/randomizer/logic/plandomizer.cpp +++ b/src/dusk/randomizer/logic/plandomizer.cpp @@ -6,13 +6,13 @@ #include "../utility/file.hpp" #include "../utility/log.hpp" -namespace tphdr::logic::plandomizer +namespace randomizer::logic::plandomizer { - void LoadPlandomizerData(tphdr::logic::world::WorldPool& worlds, const fspath& filepath, const bool& ignoreErrors /*false*/) + void LoadPlandomizerData(randomizer::logic::world::WorldPool& worlds, const fspath& filepath, const bool& ignoreErrors /*false*/) { // Verify the file exists before trying to open it // TODO: TRY CATCH HERE - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); auto plandoTree = LoadYAML(filepath); @@ -110,4 +110,4 @@ namespace tphdr::logic::plandomizer } } } -} // namespace tphdr::logic::plandomizer +} // namespace randomizer::logic::plandomizer diff --git a/src/dusk/randomizer/logic/plandomizer.hpp b/src/dusk/randomizer/logic/plandomizer.hpp index 53fcffa323..ac57b48c3e 100644 --- a/src/dusk/randomizer/logic/plandomizer.hpp +++ b/src/dusk/randomizer/logic/plandomizer.hpp @@ -7,13 +7,13 @@ using fspath = std::filesystem::path; // Forward Declarations -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; using WorldPool = std::vector>; -} // namespace tphdr::logic::world +} // namespace randomizer::logic::world -namespace tphdr::logic::plandomizer +namespace randomizer::logic::plandomizer { - void LoadPlandomizerData(tphdr::logic::world::WorldPool& worlds, const fspath& filepath, const bool& ignoreErrors = false); -} \ No newline at end of file + void LoadPlandomizerData(randomizer::logic::world::WorldPool& worlds, const fspath& filepath, const bool& ignoreErrors = false); +} diff --git a/src/dusk/randomizer/logic/requirement.cpp b/src/dusk/randomizer/logic/requirement.cpp index 75a8865f41..e95b0a949c 100644 --- a/src/dusk/randomizer/logic/requirement.cpp +++ b/src/dusk/randomizer/logic/requirement.cpp @@ -10,7 +10,7 @@ #include #include -namespace tphdr::logic::requirement +namespace randomizer::logic::requirement { namespace FormTime { @@ -41,7 +41,7 @@ namespace tphdr::logic::requirement std::string Requirement::to_string() const { std::string reqStr = ""; - tphdr::logic::item::Item* item; + randomizer::logic::item::Item* item; Requirement nestedReq; int count; int eventIndex; @@ -101,12 +101,12 @@ namespace tphdr::logic::requirement return reqStr; case Type::ITEM: - item = std::get(this->_args[0]); + item = std::get(this->_args[0]); return item->GetName(); case Type::COUNT: count = std::get(this->_args[0]); - item = std::get(this->_args[1]); + item = std::get(this->_args[1]); return "count(" + item->GetName() + ", " + std::to_string(count) + ")"; case Type::EVENT: @@ -142,7 +142,7 @@ namespace tphdr::logic::requirement } Requirement ParseRequirementString(const std::string& reqStr, - tphdr::logic::world::World* world, + randomizer::logic::world::World* world, const bool& forceLogic /* = false */) { Requirement req; @@ -213,35 +213,35 @@ namespace tphdr::logic::requirement // First, see if we have nothing if (argStr == "Nothing") { - req._type = tphdr::logic::requirement::Type::NOTHING; + req._type = randomizer::logic::requirement::Type::NOTHING; return req; } // Then Human Link... if (argStr == "Human Link") { - req._type = tphdr::logic::requirement::Type::HUMAN_LINK; + req._type = randomizer::logic::requirement::Type::HUMAN_LINK; return req; } // Then Wolf Link... if (argStr == "Wolf Link") { - req._type = tphdr::logic::requirement::Type::WOLF_LINK; + req._type = randomizer::logic::requirement::Type::WOLF_LINK; return req; } // Then Twilight... if (argStr == "Twilight") { - req._type = tphdr::logic::requirement::Type::TWILIGHT; + req._type = randomizer::logic::requirement::Type::TWILIGHT; return req; } // Then an event... if (argStr[0] == '\'') { - req._type = tphdr::logic::requirement::Type::EVENT; + req._type = randomizer::logic::requirement::Type::EVENT; std::string eventName(argStr.begin() + 1, argStr.end() - 1); // Remove quotes int eventId = world->GetEventIndex(eventName); @@ -255,7 +255,7 @@ namespace tphdr::logic::requirement // Then a macro... if (world->GetMacroIndex(argStr) != -1) { - req._type = tphdr::logic::requirement::Type::MACRO; + req._type = randomizer::logic::requirement::Type::MACRO; req._args.emplace_back(world->GetMacroIndex(argStr)); return req; } @@ -264,16 +264,16 @@ namespace tphdr::logic::requirement if (world->GetItem(argStr, true) != nullptr) { auto item = world->GetItem(argStr); - req._type = tphdr::logic::requirement::Type::ITEM; + req._type = randomizer::logic::requirement::Type::ITEM; req._args.emplace_back(item); return req; } // Then a setting... - else if (tphdr::utility::str::Contains(argStr, "!=", "==")) + else if (randomizer::utility::str::Contains(argStr, "!=", "==")) { - bool equalComparison = tphdr::utility::str::Contains(argStr, "=="); - bool notEqualComparison = tphdr::utility::str::Contains(argStr, "!="); + bool equalComparison = randomizer::utility::str::Contains(argStr, "=="); + bool notEqualComparison = randomizer::utility::str::Contains(argStr, "!="); // Split up the comparison using the second comparison character (which will always be '=') auto compPos = argStr.rfind('='); @@ -293,18 +293,18 @@ namespace tphdr::logic::requirement if (result == true) { - req._type = tphdr::logic::requirement::Type::NOTHING; + req._type = randomizer::logic::requirement::Type::NOTHING; } else { - req._type = tphdr::logic::requirement::Type::IMPOSSIBLE; + req._type = randomizer::logic::requirement::Type::IMPOSSIBLE; } return req; } // Then a count... else if (argStr.find("count") != std::string::npos) { - req._type = tphdr::logic::requirement::Type::COUNT; + req._type = randomizer::logic::requirement::Type::COUNT; // Since a count has two arguments (a number and an item), we have // to split up the string in the parenthesis into those arguments. @@ -335,21 +335,21 @@ namespace tphdr::logic::requirement // Then Day... if (argStr == "Day") { - req._type = tphdr::logic::requirement::Type::DAY; + req._type = randomizer::logic::requirement::Type::DAY; return req; } // Then Night... if (argStr == "Night") { - req._type = tphdr::logic::requirement::Type::NIGHT; + req._type = randomizer::logic::requirement::Type::NIGHT; return req; } // And finally a health check // else if (argStr.find("health") != std::string::npos) // { - // req._type = tphdr::logic::requirement::Type::HEALTH; + // req._type = randomizer::logic::requirement::Type::HEALTH; // std::string numHeartsStr(argStr.begin() + argStr.find('(') + 1, argStr.end() - 1); // int numHearts = std::stoi(numHeartsStr); // req._args.emplace_back(numHearts); @@ -359,14 +359,14 @@ namespace tphdr::logic::requirement // Check Impossible down here since it's very unlikely else if (argStr == "Impossible") { - req._type = tphdr::logic::requirement::Type::IMPOSSIBLE; + req._type = randomizer::logic::requirement::Type::IMPOSSIBLE; return req; } // Check golden bugs last since it's least likely else if (argStr.find("golden bugs") != std::string::npos) { - req._type = tphdr::logic::requirement::Type::GOLDEN_BUGS; + req._type = randomizer::logic::requirement::Type::GOLDEN_BUGS; // Get rid of parenthesis std::string countArg(argStr.begin() + argStr.find('(') + 1, argStr.end() - 1); int count = std::stoi(countArg); @@ -385,8 +385,8 @@ namespace tphdr::logic::requirement // If we have more than two parts to our expression, then we have either "and" // or "or". - bool andType = tphdr::utility::container::ElementInContainer(splitLogicStr, "and"); - bool orType = tphdr::utility::container::ElementInContainer(splitLogicStr, "or"); + bool andType = randomizer::utility::container::ElementInContainer(splitLogicStr, "and"); + bool orType = randomizer::utility::container::ElementInContainer(splitLogicStr, "or"); // If we have both of them, there's a problem with the logic expression if (andType && orType) @@ -399,16 +399,16 @@ namespace tphdr::logic::requirement // Set the appropriate type if (andType) { - req._type = tphdr::logic::requirement::Type::AND; + req._type = randomizer::logic::requirement::Type::AND; } else { - req._type = tphdr::logic::requirement::Type::OR; + req._type = randomizer::logic::requirement::Type::OR; } // Once we know the type, we can erase the "and"s or "or"s and are left with just the deeper // expressions to be logically operated on. - tphdr::utility::container::FilterAndEraseFromVector(splitLogicStr, + randomizer::utility::container::FilterAndEraseFromVector(splitLogicStr, [](const std::string& arg) { return arg == "and" || arg == "or"; }); @@ -425,7 +425,7 @@ namespace tphdr::logic::requirement } } - if (req._type != tphdr::logic::requirement::Type::INVALID) + if (req._type != randomizer::logic::requirement::Type::INVALID) { return req; } @@ -434,12 +434,12 @@ namespace tphdr::logic::requirement return req; } - bool EvaluateRequirementAtFormTime(const tphdr::logic::requirement::Requirement& req, - tphdr::logic::search::Search* search, + bool EvaluateRequirementAtFormTime(const randomizer::logic::requirement::Requirement& req, + randomizer::logic::search::Search* search, const int& formTime, - tphdr::logic::world::World* world) + randomizer::logic::world::World* world) { - tphdr::logic::item::Item* item; + randomizer::logic::item::Item* item; int count; int eventIndex; int macroIndex; @@ -466,12 +466,12 @@ namespace tphdr::logic::requirement { return EvaluateRequirementAtFormTime(std::get(arg), search, formTime, world); }); case Type::ITEM: - item = std::get(req._args[0]); + item = std::get(req._args[0]); return search->_ownedItems.contains(item); case Type::COUNT: count = std::get(req._args[0]); - item = std::get(req._args[1]); + item = std::get(req._args[1]); return search->_ownedItems.count(item) >= count; case Type::EVENT: @@ -508,7 +508,7 @@ namespace tphdr::logic::requirement return false; } - EvalSuccess EvaluateEventRequirement(tphdr::logic::search::Search* search, tphdr::logic::area::EventAccess* event) + EvalSuccess EvaluateEventRequirement(randomizer::logic::search::Search* search, randomizer::logic::area::EventAccess* event) { auto& formTime = search->_areaFormTime[event->GetArea()]; if (EvaluateRequirementAtFormTime(event->GetRequirement(), search, formTime, event->GetArea()->GetWorld())) @@ -518,7 +518,7 @@ namespace tphdr::logic::requirement return EvalSuccess::NONE; } - EvalSuccess EvaluateExitRequirement(tphdr::logic::search::Search* search, tphdr::logic::entrance::Entrance* exit) + EvalSuccess EvaluateExitRequirement(randomizer::logic::search::Search* search, randomizer::logic::entrance::Entrance* exit) { // Some exits in the middle of entrance shuffling will not have a connected area. Ignore these if (exit->GetConnectedArea() == nullptr) @@ -610,7 +610,7 @@ namespace tphdr::logic::requirement return evalSuccess; } - EvalSuccess EvaluateLocationRequirement(tphdr::logic::search::Search* search, tphdr::logic::area::LocationAccess* locAccess) + EvalSuccess EvaluateLocationRequirement(randomizer::logic::search::Search* search, randomizer::logic::area::LocationAccess* locAccess) { auto& formTime = search->_areaFormTime[locAccess->GetArea()]; if (EvaluateRequirementAtFormTime(locAccess->GetRequirement(), search, formTime, locAccess->GetArea()->GetWorld())) @@ -619,4 +619,4 @@ namespace tphdr::logic::requirement } return EvalSuccess::NONE; } -} // namespace tphdr::logic::requirement +} // namespace randomizer::logic::requirement diff --git a/src/dusk/randomizer/logic/requirement.hpp b/src/dusk/randomizer/logic/requirement.hpp index 9838f137c4..02b80bac16 100644 --- a/src/dusk/randomizer/logic/requirement.hpp +++ b/src/dusk/randomizer/logic/requirement.hpp @@ -6,33 +6,33 @@ #include // Forward declarations -namespace tphdr::logic::item +namespace randomizer::logic::item { class Item; } -namespace tphdr::logic::entrance +namespace randomizer::logic::entrance { class Entrance; } -namespace tphdr::logic::area +namespace randomizer::logic::area { class EventAccess; class LocationAccess; -} // namespace tphdr::logic::area +} // namespace randomizer::logic::area -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; } -namespace tphdr::logic::search +namespace randomizer::logic::search { class Search; } -namespace tphdr::logic::requirement +namespace randomizer::logic::requirement { enum class Type { @@ -90,7 +90,7 @@ namespace tphdr::logic::requirement struct Requirement; struct Requirement { - using Argument = std::variant; + using Argument = std::variant; Type _type = Type::INVALID; std::vector _args; @@ -98,18 +98,18 @@ namespace tphdr::logic::requirement }; Requirement ParseRequirementString(const std::string& reqStr, - tphdr::logic::world::World* world, + randomizer::logic::world::World* world, const bool& forceLogic = false); - bool EvaluateRequirementAtFormTime(const tphdr::logic::requirement::Requirement& req, - tphdr::logic::search::Search* search, + bool EvaluateRequirementAtFormTime(const randomizer::logic::requirement::Requirement& req, + randomizer::logic::search::Search* search, const int& formTime, - tphdr::logic::world::World*); - EvalSuccess EvaluateEventRequirement(tphdr::logic::search::Search* search, tphdr::logic::area::EventAccess* event); - EvalSuccess EvaluateExitRequirement(tphdr::logic::search::Search* search, tphdr::logic::entrance::Entrance* exit); - EvalSuccess EvaluateLocationRequirement(tphdr::logic::search::Search* search, - tphdr::logic::area::LocationAccess* locAccess); + randomizer::logic::world::World*); + EvalSuccess EvaluateEventRequirement(randomizer::logic::search::Search* search, randomizer::logic::area::EventAccess* event); + EvalSuccess EvaluateExitRequirement(randomizer::logic::search::Search* search, randomizer::logic::entrance::Entrance* exit); + EvalSuccess EvaluateLocationRequirement(randomizer::logic::search::Search* search, + randomizer::logic::area::LocationAccess* locAccess); const extern Requirement NO_REQUIREMENT; const extern Requirement IMPOSSIBLE_REQUIREMENT; -} // namespace tphdr::logic::requirement \ No newline at end of file +} // namespace randomizer::logic::requirement diff --git a/src/dusk/randomizer/logic/search.cpp b/src/dusk/randomizer/logic/search.cpp index 7c3b483038..028a381fca 100644 --- a/src/dusk/randomizer/logic/search.cpp +++ b/src/dusk/randomizer/logic/search.cpp @@ -6,11 +6,11 @@ #include -namespace tphdr::logic::search +namespace randomizer::logic::search { Search::Search(const SearchMode& searchMode, - tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items /* = {} */, + randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items /* = {} */, const int& worldToSearch /* = -1 */): _searchMode(searchMode), _worlds(worlds) { @@ -49,7 +49,7 @@ namespace tphdr::logic::search void Search::SearchWorlds() { // Get all locations which fit criteria to test on each iteration - std::list itemLocations = {}; + std::list itemLocations = {}; for (const auto& world : *(this->_worlds)) { for (const auto& [areaName, area] : world->GetAreaTable()) @@ -58,7 +58,7 @@ namespace tphdr::logic::search { // Only add locations that aren't empty, unless we're searching with one of the modes below if (!locAccess->GetLocation()->IsEmpty() || - tphdr::utility::general::IsAnyOf(this->_searchMode, + randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::ACCESSIBLE_LOCATIONS, SearchMode::ALL_LOCATIONS_REACHABLE, SearchMode::SPHERE_ZERO, @@ -77,14 +77,14 @@ namespace tphdr::logic::search while ( this->_newThingsFound && !(this->_isBeatable && - tphdr::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::GAME_BEATABLE))) + randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::GAME_BEATABLE))) { // Keep track of making logical progress. We want to keep iterating as long as we're finding new things on each // iteration this->_newThingsFound = false; // Add an empty sphere if we're generating the playthrough or tracker spheres - if (tphdr::utility::general::IsAnyOf(this->_searchMode, + if (randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::TRACKER_SPHERES)) { @@ -99,7 +99,7 @@ namespace tphdr::logic::search this->_newThingsFound = false; this->ProcessEvents(); this->ProcessExits(); - } while (this->_newThingsFound && tphdr::utility::general::IsAnyOf(this->_searchMode, + } while (this->_newThingsFound && randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::TRACKER_SPHERES)); @@ -119,8 +119,8 @@ namespace tphdr::logic::search continue; } - if (tphdr::logic::requirement::EvaluateEventRequirement(this, event) == - tphdr::logic::requirement::EvalSuccess::COMPLETE) + if (randomizer::logic::requirement::EvaluateEventRequirement(this, event) == + randomizer::logic::requirement::EvalSuccess::COMPLETE) { this->_newThingsFound = true; this->_ownedEvents.insert(event->GetEventIndex()); @@ -140,17 +140,17 @@ namespace tphdr::logic::search } // If the exit is unnecessary, we'll just consider it successful and move on - auto evalSuccess = tphdr::logic::requirement::EvaluateExitRequirement(this, exit); - if (evalSuccess == tphdr::logic::requirement::EvalSuccess::UNNECESSARY) + auto evalSuccess = randomizer::logic::requirement::EvaluateExitRequirement(this, exit); + if (evalSuccess == randomizer::logic::requirement::EvalSuccess::UNNECESSARY) { this->_successfulExits.insert(exit); } - else if (tphdr::utility::general::IsAnyOf(evalSuccess, - tphdr::logic::requirement::EvalSuccess::COMPLETE, - tphdr::logic::requirement::EvalSuccess::PARTIAL)) + else if (randomizer::utility::general::IsAnyOf(evalSuccess, + randomizer::logic::requirement::EvalSuccess::COMPLETE, + randomizer::logic::requirement::EvalSuccess::PARTIAL)) { this->AddExitToEntranceSpheres(exit); - if (evalSuccess == tphdr::logic::requirement::EvalSuccess::COMPLETE) + if (evalSuccess == randomizer::logic::requirement::EvalSuccess::COMPLETE) { this->_successfulExits.insert(exit); } @@ -166,9 +166,9 @@ namespace tphdr::logic::search } } - void Search::ProcessLocations(std::list& itemLocations) + void Search::ProcessLocations(std::list& itemLocations) { - std::list accessibleThisIteration = {}; + std::list accessibleThisIteration = {}; // Loop through all possible item locations for this search for (const auto& locAccess : itemLocations) { @@ -184,14 +184,14 @@ namespace tphdr::logic::search } // If the location's requirement is met - if (tphdr::logic::requirement::EvaluateLocationRequirement(this, locAccess) == - tphdr::logic::requirement::EvalSuccess::COMPLETE) + if (randomizer::logic::requirement::EvaluateLocationRequirement(this, locAccess) == + randomizer::logic::requirement::EvalSuccess::COMPLETE) { this->_visitedLocations.insert(location); this->_newThingsFound = true; // If we're calculating spheres, then process this location later for accurate sphere calculation. Otherwise // process it now for slightly faster searching - if (tphdr::utility::general::IsAnyOf(this->_searchMode, + if (randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::TRACKER_SPHERES)) { @@ -214,7 +214,7 @@ namespace tphdr::logic::search } } - void Search::ProcessLocation(tphdr::logic::location::Location* location) + void Search::ProcessLocation(randomizer::logic::location::Location* location) { // Don't return if we aren't collecting items if (!this->_collectItems) @@ -254,7 +254,7 @@ namespace tphdr::logic::search // If we're generating the playthrough or just checking for beatability, then we can stop searching early if we've // found all world's game winning items - if (tphdr::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::GAME_BEATABLE) && + if (randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::GAME_BEATABLE) && location->GetCurrentItem()->IsGameWinningItem()) { if (std::count_if(this->_ownedItems.begin(), @@ -275,7 +275,7 @@ namespace tphdr::logic::search } } - void Search::Explore(tphdr::logic::area::Area* area) + void Search::Explore(randomizer::logic::area::Area* area) { for (const auto& event : area->GetEvents()) { @@ -284,10 +284,10 @@ namespace tphdr::logic::search for (const auto& exit : area->GetExits()) { - auto evalSuccess = tphdr::logic::requirement::EvaluateExitRequirement(this, exit); + auto evalSuccess = randomizer::logic::requirement::EvaluateExitRequirement(this, exit); switch (evalSuccess) { - case tphdr::logic::requirement::EvalSuccess::COMPLETE: + case randomizer::logic::requirement::EvalSuccess::COMPLETE: this->_successfulExits.insert(exit); this->AddExitToEntranceSpheres(exit); if (!this->_visitedAreas.contains(exit->GetConnectedArea())) @@ -295,7 +295,7 @@ namespace tphdr::logic::search this->_visitedAreas.insert(exit->GetConnectedArea()); this->Explore(exit->GetConnectedArea()); } - case tphdr::logic::requirement::EvalSuccess::PARTIAL: + case randomizer::logic::requirement::EvalSuccess::PARTIAL: this->_exitsToTry.push_back(exit); this->AddExitToEntranceSpheres(exit); if (!this->_visitedAreas.contains(exit->GetConnectedArea())) @@ -303,17 +303,17 @@ namespace tphdr::logic::search this->_visitedAreas.insert(exit->GetConnectedArea()); this->Explore(exit->GetConnectedArea()); } - case tphdr::logic::requirement::EvalSuccess::NONE: + case randomizer::logic::requirement::EvalSuccess::NONE: this->_exitsToTry.push_back(exit); - case tphdr::logic::requirement::EvalSuccess::UNNECESSARY: + case randomizer::logic::requirement::EvalSuccess::UNNECESSARY: this->_foundDisconnectedExit = true; } } } - void Search::ExpandFormTimes(tphdr::logic::area::Area* area) + void Search::ExpandFormTimes(randomizer::logic::area::Area* area) { - using namespace tphdr::logic::requirement; + using namespace randomizer::logic::requirement; auto& areaFormTime = this->_areaFormTime[area]; auto twilightCleared = area->TwilightCleared(this); @@ -356,9 +356,9 @@ namespace tphdr::logic::search } } - void Search::AddExitToEntranceSpheres(tphdr::logic::entrance::Entrance* exit) + void Search::AddExitToEntranceSpheres(randomizer::logic::entrance::Entrance* exit) { - if (tphdr::utility::general::IsAnyOf(this->_searchMode, + if (randomizer::utility::general::IsAnyOf(this->_searchMode, SearchMode::GENERATE_PLAYTHROUGH, SearchMode::TRACKER_SPHERES) && exit->IsShuffled()) @@ -411,23 +411,23 @@ namespace tphdr::logic::search auto color = this->_visitedAreas.contains(area.get()) ? "black" : "red"; std::string formTimeStr = ":
"; auto& areaFormTime = this->_areaFormTime[area.get()]; - if (areaFormTime & tphdr::logic::requirement::FormTime::HUMAN) + if (areaFormTime & randomizer::logic::requirement::FormTime::HUMAN) { formTimeStr += " Human"; } - if (areaFormTime & tphdr::logic::requirement::FormTime::WOLF) + if (areaFormTime & randomizer::logic::requirement::FormTime::WOLF) { formTimeStr += " Wolf"; } - if (areaFormTime & tphdr::logic::requirement::FormTime::DAY) + if (areaFormTime & randomizer::logic::requirement::FormTime::DAY) { formTimeStr += " Day"; } - if (areaFormTime & tphdr::logic::requirement::FormTime::NIGHT) + if (areaFormTime & randomizer::logic::requirement::FormTime::NIGHT) { formTimeStr += " Night"; } - if (areaFormTime & tphdr::logic::requirement::FormTime::TWILIGHT) + if (areaFormTime & randomizer::logic::requirement::FormTime::TWILIGHT) { formTimeStr += " Twilight"; } @@ -472,8 +472,8 @@ namespace tphdr::logic::search worldGraph.close(); } - std::optional VerifyLogic(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items /* = {} */) + std::optional VerifyLogic(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items /* = {} */) { // Run an all locations reachable search auto search = Search::AllLocationsReachable(worlds, items); @@ -494,7 +494,7 @@ namespace tphdr::logic::search { std::string errorMsg = "Not all locations reachable! Missing locations:\n"; // Gather all the missing locations - std::vector unreachedLocations = {}; + std::vector unreachedLocations = {}; for (const auto& location : allLocations) { if (!search._visitedLocations.contains(location)) @@ -520,7 +520,7 @@ namespace tphdr::logic::search return std::nullopt; } - void GeneratePlaythrough(tphdr::logic::world::WorldPool* worlds) + void GeneratePlaythrough(randomizer::logic::world::WorldPool* worlds) { LOG_TO_DEBUG("Generating Playthrough"); // Generate Initial Playthrough @@ -530,9 +530,9 @@ namespace tphdr::logic::search auto& playthroughSpheres = playthroughSearch._playthroughSpheres; // Keep track of all locations we temporaily take items away from so we can give them back after playthrough calculation - std::unordered_map tempEmptyLocations = {}; + std::unordered_map tempEmptyLocations = {}; // Keep track of all the locations that appear in the playthrough - std::unordered_set playthroughLocationsSet = {}; + std::unordered_set playthroughLocationsSet = {}; for (const auto& sphere : playthroughSpheres) { for (const auto& location : sphere) @@ -554,7 +554,7 @@ namespace tphdr::logic::search } } - tphdr::utility::platform::Log("Paring down playthrough"); + randomizer::utility::platform::Log("Paring down playthrough"); // Pare down the playthrough in reverse order so we're paring it down from highest to lowest sphere. // This way, lower sphere items will be prioritized for the playthrough playthroughSpheres.reverse(); @@ -586,7 +586,7 @@ namespace tphdr::logic::search // Now do the same process for entrances to pare down the entrance playthrough auto& entranceSpheres = newSearch._entranceSpheres; - std::unordered_map nonRequiredEntrances = {}; + std::unordered_map nonRequiredEntrances = {}; for (auto& sphere : entranceSpheres) { @@ -640,11 +640,11 @@ namespace tphdr::logic::search worlds->at(0)->SetEntranceSpheres(newSearch._entranceSpheres); } - bool GameBeatable(tphdr::logic::world::WorldPool* worlds, const tphdr::logic::item_pool::ItemPool& items /* = {} */) + bool GameBeatable(randomizer::logic::world::WorldPool* worlds, const randomizer::logic::item_pool::ItemPool& items /* = {} */) { auto search = Search::Beatable(worlds, items); search.SearchWorlds(); return search._isBeatable; } -} // namespace tphdr::logic::search +} // namespace randomizer::logic::search diff --git a/src/dusk/randomizer/logic/search.hpp b/src/dusk/randomizer/logic/search.hpp index 1ee247c23d..77a14ac3a5 100644 --- a/src/dusk/randomizer/logic/search.hpp +++ b/src/dusk/randomizer/logic/search.hpp @@ -12,35 +12,35 @@ #include // Forward Declarations (we have a lot here) -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; using WorldPool = std::vector>; -} // namespace tphdr::logic::world +} // namespace randomizer::logic::world -namespace tphdr::logic::item +namespace randomizer::logic::item { class Item; } -namespace tphdr::logic::location +namespace randomizer::logic::location { class Location; } -namespace tphdr::logic::area +namespace randomizer::logic::area { class EventAccess; class LocationAccess; class Area; -} // namespace tphdr::logic::area +} // namespace randomizer::logic::area -namespace tphdr::logic::entrance +namespace randomizer::logic::entrance { class Entrance; } -namespace tphdr::logic::search +namespace randomizer::logic::search { enum class SearchMode { @@ -56,40 +56,40 @@ namespace tphdr::logic::search { public: Search(const SearchMode& searchMode, - tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1); - static auto Accessible(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + static auto Accessible(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1) { return Search(SearchMode::ACCESSIBLE_LOCATIONS, worlds, items, worldToSearch); } - static auto AllLocationsReachable(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + static auto AllLocationsReachable(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1) { return Search(SearchMode::ALL_LOCATIONS_REACHABLE, worlds, items, worldToSearch); } - static auto Playthrough(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + static auto Playthrough(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1) { return Search(SearchMode::GENERATE_PLAYTHROUGH, worlds, items, worldToSearch); } - static auto Beatable(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + static auto Beatable(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1) { return Search(SearchMode::GAME_BEATABLE, worlds, items, worldToSearch); } - static auto SphereZero(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}, + static auto SphereZero(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}, const int& worldToSearch = -1) { return Search(SearchMode::SPHERE_ZERO, worlds, items, worldToSearch); @@ -104,12 +104,12 @@ namespace tphdr::logic::search */ void ProcessEvents(); void ProcessExits(); - void ProcessLocations(std::list& itemLocations); - void ProcessLocation(tphdr::logic::location::Location* location); - void Explore(tphdr::logic::area::Area* area); - void ExpandFormTimes(tphdr::logic::area::Area* area); + void ProcessLocations(std::list& itemLocations); + void ProcessLocation(randomizer::logic::location::Location* location); + void Explore(randomizer::logic::area::Area* area); + void ExpandFormTimes(randomizer::logic::area::Area* area); - void AddExitToEntranceSpheres(tphdr::logic::entrance::Entrance*); + void AddExitToEntranceSpheres(randomizer::logic::entrance::Entrance*); void RemoveEmptySpheres(); /** @@ -121,7 +121,7 @@ namespace tphdr::logic::search void DumpWorldGraph(const int& world = 0); SearchMode _searchMode; - tphdr::logic::world::WorldPool* _worlds; + randomizer::logic::world::WorldPool* _worlds; int _worldToSearch = -1; // Search variables @@ -130,20 +130,20 @@ namespace tphdr::logic::search bool _isBeatable = false; bool _collectItems = true; std::unordered_set _ownedEvents; - std::unordered_multiset _ownedItems; + std::unordered_multiset _ownedItems; - std::list _eventsToTry; - std::list _exitsToTry; - std::unordered_set _visitedLocations; - std::unordered_set _visitedAreas; - std::unordered_set _successfulExits; - std::unordered_set _playthroughEntrances; + std::list _eventsToTry; + std::list _exitsToTry; + std::unordered_set _visitedLocations; + std::unordered_set _visitedAreas; + std::unordered_set _successfulExits; + std::unordered_set _playthroughEntrances; bool _foundDisconnectedExit = false; - std::list> _playthroughSpheres; - std::list> _entranceSpheres; + std::list> _playthroughSpheres; + std::list> _entranceSpheres; - std::unordered_map _areaFormTime; + std::unordered_map _areaFormTime; }; /** @@ -154,8 +154,8 @@ namespace tphdr::logic::search * * @return An optional value that holds a string explaining why the logic was not satisfied if validation failed */ - std::optional VerifyLogic(tphdr::logic::world::WorldPool* worlds, - const tphdr::logic::item_pool::ItemPool& items = {}); - void GeneratePlaythrough(tphdr::logic::world::WorldPool* worlds); - bool GameBeatable(tphdr::logic::world::WorldPool* worlds, const tphdr::logic::item_pool::ItemPool& items = {}); -} // namespace tphdr::logic::search + std::optional VerifyLogic(randomizer::logic::world::WorldPool* worlds, + const randomizer::logic::item_pool::ItemPool& items = {}); + void GeneratePlaythrough(randomizer::logic::world::WorldPool* worlds); + bool GameBeatable(randomizer::logic::world::WorldPool* worlds, const randomizer::logic::item_pool::ItemPool& items = {}); +} // namespace randomizer::logic::search diff --git a/src/dusk/randomizer/logic/spoiler_log.cpp b/src/dusk/randomizer/logic/spoiler_log.cpp index bb906da194..1e92466cda 100644 --- a/src/dusk/randomizer/logic/spoiler_log.cpp +++ b/src/dusk/randomizer/logic/spoiler_log.cpp @@ -9,9 +9,9 @@ #include #include -namespace tphdr::logic::spoiler_log +namespace randomizer::logic::spoiler_log { - std::string SpoilerFormatLocation(tphdr::logic::location::Location* location, const size_t& longestNameLength) + std::string SpoilerFormatLocation(randomizer::logic::location::Location* location, const size_t& longestNameLength) { auto numSpaces = longestNameLength - location->GetName().length(); std::string spaces(numSpaces, ' '); @@ -19,7 +19,7 @@ namespace tphdr::logic::spoiler_log return location->GetName() + ": " + spaces + location->GetCurrentItem()->GetName(); } - std::string SpoilerFormatEntrance(tphdr::logic::entrance::Entrance* entrance, const size_t& longestNameLength) + std::string SpoilerFormatEntrance(randomizer::logic::entrance::Entrance* entrance, const size_t& longestNameLength) { auto numSpaces = longestNameLength - entrance->GetOriginalName().length(); std::string spaces(numSpaces, ' '); @@ -30,7 +30,7 @@ namespace tphdr::logic::spoiler_log return entrance->GetOriginalName() + ": " + spaces + connected + " from " + parent; } - void LogBasicInfo(std::ofstream& log, tphdr::seedgen::config::Config& config, tphdr::logic::world::WorldPool& worlds) + void LogBasicInfo(std::ofstream& log, randomizer::seedgen::config::Config& config, randomizer::logic::world::WorldPool& worlds) { log << "Twilight Princess HD Randomizer Version: " << "1.0.0" << std::endl; log << "Seed: " << config.GetSeed() << std::endl; @@ -40,20 +40,20 @@ namespace tphdr::logic::spoiler_log log << "Hash: " << config.GetHash() << std::endl; } - void LogSettings(std::ofstream& log, tphdr::seedgen::config::Config& config, tphdr::logic::world::WorldPool& worlds) + void LogSettings(std::ofstream& log, randomizer::seedgen::config::Config& config, randomizer::logic::world::WorldPool& worlds) { log << std::endl << "# Settings" << std::endl; log << YAML::Dump(config.SettingsToYaml()) << std::endl; } - void GenerateSpoilerLog(tphdr::logic::world::WorldPool& worlds, tphdr::seedgen::config::Config& config) + void GenerateSpoilerLog(randomizer::logic::world::WorldPool& worlds, randomizer::seedgen::config::Config& config) { - tphdr::utility::platform::Log("Generating Spoiler Log"); + randomizer::utility::platform::Log("Generating Spoiler Log"); // Create logs folder if it doesn't exist - if (!tphdr::utility::file::dirExists(LOGS_PATH)) + if (!randomizer::utility::file::dirExists(LOGS_PATH)) { - tphdr::utility::file::create_directories(LOGS_PATH); + randomizer::utility::file::create_directories(LOGS_PATH); } std::string filepath = std::string(LOGS_PATH) + config.GetHash() + " Spoiler Log.txt"; @@ -63,7 +63,7 @@ namespace tphdr::logic::spoiler_log LogBasicInfo(spoilerLog, config, worlds); // Gather worlds with starting inventories - std::list worldswithStartingInventories = {}; + std::list worldswithStartingInventories = {}; for (const auto& world : worlds) { if (!world->GetStartingItemPool().empty()) @@ -184,11 +184,11 @@ namespace tphdr::logic::spoiler_log { spoilerLog << " World " << world->GetID() << ":" << std::endl; // Create entrance pools to easily separate the entrances by type - auto entrancePools = tphdr::logic::entrance_shuffle::CreateEntrancePools(world.get()); + auto entrancePools = randomizer::logic::entrance_shuffle::CreateEntrancePools(world.get()); auto mixedPools = world->GetSettings().GetMixedEntrancePools(); for (auto& [entranceType, entrancePool] : entrancePools) { - auto typeStr = tphdr::logic::entrance::TypeToStr(entranceType); + auto typeStr = randomizer::logic::entrance::TypeToStr(entranceType); // If this is a mixed pool, display the types it mixed if (typeStr.starts_with("Mixed Pool")) { @@ -209,7 +209,7 @@ namespace tphdr::logic::spoiler_log for (const auto& entrance : entrancePool) { // Ignore entrances that are impossible - if (entrance->GetRequirement()._type == tphdr::logic::requirement::Type::IMPOSSIBLE) + if (entrance->GetRequirement()._type == randomizer::logic::requirement::Type::IMPOSSIBLE) { continue; } @@ -226,15 +226,15 @@ namespace tphdr::logic::spoiler_log spoilerLog.close(); - tphdr::utility::platform::Log("Wrote spoiler log to " + filepath); + randomizer::utility::platform::Log("Wrote spoiler log to " + filepath); } - void GenerateAntiSpoilerLog(tphdr::logic::world::WorldPool& worlds, tphdr::seedgen::config::Config& config) + void GenerateAntiSpoilerLog(randomizer::logic::world::WorldPool& worlds, randomizer::seedgen::config::Config& config) { // Create logs folder if it doesn't exist - if (!tphdr::utility::file::dirExists(LOGS_PATH)) + if (!randomizer::utility::file::dirExists(LOGS_PATH)) { - tphdr::utility::file::create_directories(LOGS_PATH); + randomizer::utility::file::create_directories(LOGS_PATH); } std::string filepath = std::string(LOGS_PATH) + config.GetHash() + " Anti-Spoiler Log.txt"; @@ -244,4 +244,4 @@ namespace tphdr::logic::spoiler_log LogBasicInfo(antiSpoilerLog, config, worlds); LogSettings(antiSpoilerLog, config, worlds); } -} // namespace tphdr::logic::spoiler_log +} // namespace randomizer::logic::spoiler_log diff --git a/src/dusk/randomizer/logic/spoiler_log.hpp b/src/dusk/randomizer/logic/spoiler_log.hpp index 0a446c7ac4..1811f5676e 100644 --- a/src/dusk/randomizer/logic/spoiler_log.hpp +++ b/src/dusk/randomizer/logic/spoiler_log.hpp @@ -3,8 +3,8 @@ #include "world.hpp" #include "../seedgen/config.hpp" -namespace tphdr::logic::spoiler_log +namespace randomizer::logic::spoiler_log { - void GenerateSpoilerLog(tphdr::logic::world::WorldPool& worlds, tphdr::seedgen::config::Config& config); - void GenerateAntiSpoilerLog(tphdr::logic::world::WorldPool& worlds, tphdr::seedgen::config::Config& config); -} // namespace tphdr::logic::spoiler_log + void GenerateSpoilerLog(randomizer::logic::world::WorldPool& worlds, randomizer::seedgen::config::Config& config); + void GenerateAntiSpoilerLog(randomizer::logic::world::WorldPool& worlds, randomizer::seedgen::config::Config& config); +} // namespace randomizer::logic::spoiler_log diff --git a/src/dusk/randomizer/logic/world.cpp b/src/dusk/randomizer/logic/world.cpp index 11237bc3a0..daef0db5c6 100644 --- a/src/dusk/randomizer/logic/world.cpp +++ b/src/dusk/randomizer/logic/world.cpp @@ -15,7 +15,7 @@ #include #include -namespace tphdr::logic::world +namespace randomizer::logic::world { int World::_eventIdCounter = 0; @@ -28,11 +28,11 @@ namespace tphdr::logic::world { return this->_id; } - void World::SetSettings(const tphdr::seedgen::settings::Settings& settings) + void World::SetSettings(const randomizer::seedgen::settings::Settings& settings) { _settings = settings; } - const tphdr::seedgen::settings::Settings& World::GetSettings() const + const randomizer::seedgen::settings::Settings& World::GetSettings() const { return this->_settings; } @@ -74,7 +74,7 @@ namespace tphdr::logic::world void World::Build() { - tphdr::utility::platform::Log(std::string("Building World ") + std::to_string(this->GetID())); + randomizer::utility::platform::Log(std::string("Building World ") + std::to_string(this->GetID())); this->BuildItemTable(); this->BuildLocationTable(); this->LoadLogicMacros(); @@ -88,7 +88,7 @@ namespace tphdr::logic::world LOG_TO_DEBUG("Building Item Table for World " + std::to_string(this->GetID())); // Check if we can open the file before parsing auto filepath = DATA_PATH "items.yaml"; - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); auto itemDataTree = LoadYAML(filepath); // Process all nodes of the yaml file. Each node contains one item @@ -101,8 +101,8 @@ namespace tphdr::logic::world auto id = itemNode["Id"].as(); auto name = itemNode["Name"].as(); auto importanceStr = itemNode["Importance"].as(); - auto importance = tphdr::logic::item::ImportanceFromStr(importanceStr); - if (importance == tphdr::logic::item::Importance::INVALID) + auto importance = randomizer::logic::item::ImportanceFromStr(importanceStr); + if (importance == randomizer::logic::item::Importance::INVALID) { throw std::runtime_error(std::string("Unknown importance \"") + importanceStr + "\" from item node:\n" + YAML::Dump(itemNode)); @@ -118,7 +118,7 @@ namespace tphdr::logic::world auto dungeonMap = itemNode["Dungeon Map"].as(""); // Make the item and insert it into the item table - auto item = std::make_unique(id, + auto item = std::make_unique(id, name, this, importance, @@ -156,7 +156,7 @@ namespace tphdr::logic::world LOG_TO_DEBUG("Building Location Table for World " + std::to_string(this->GetID())); // check if we can open the file before parsing because exceptions won't work on console auto filepath = DATA_PATH "locations.yaml"; - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); auto locationDataTree = LoadYAML(filepath); // Process all nodes of the yaml file. Each node contains one location @@ -196,7 +196,7 @@ namespace tphdr::logic::world auto goalLocation = locationNode["Goal Location"].as(false); auto hintPriority = locationNode["Hint Priority"].as("Never"); - auto location = std::make_unique(locationIdCounter++, + auto location = std::make_unique(locationIdCounter++, name, categories, this, @@ -218,7 +218,7 @@ namespace tphdr::logic::world LOG_TO_DEBUG("Loading Macros for World " + std::to_string(this->GetID())); // check if we can open the file before parsing auto filepath = DATA_PATH "macros.yaml"; - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); auto macrosDataTree = LoadYAML(filepath); @@ -230,7 +230,7 @@ namespace tphdr::logic::world auto macroReqStr = macroNode.second.as(); // Process the macro - this->_macros[macroIdCounter] = tphdr::logic::requirement::ParseRequirementString(macroReqStr, + this->_macros[macroIdCounter] = randomizer::logic::requirement::ParseRequirementString(macroReqStr, this, /*forceLogic = */ true); @@ -273,7 +273,7 @@ namespace tphdr::logic::world for (const auto& file : files) { auto filepath = folder + file; - tphdr::utility::file::Verify(filepath); + randomizer::utility::file::Verify(filepath); auto worldDataTree = LoadYAML(filepath); for (const auto& areaNode : worldDataTree) @@ -379,19 +379,19 @@ namespace tphdr::logic::world } // Lists of events, locations, and exits that we pass along to the area object - std::list> events = {}; - std::list> locations = {}; - std::list> exits = {}; + std::list> events = {}; + std::list> locations = {}; + std::list> exits = {}; // Process events for (const auto& [eventName, eventReqStr] : eventNodes) { // Parse the requirement string - auto eventReq = tphdr::logic::requirement::ParseRequirementString(eventReqStr, this); + auto eventReq = randomizer::logic::requirement::ParseRequirementString(eventReqStr, this); // Create the EventAccess wrapper and put it into the list of events for this area auto eventIndex = this->GetEventIndex(eventName); - auto event = std::make_unique(eventReq, area, eventIndex); + auto event = std::make_unique(eventReq, area, eventIndex); events.emplace_back(std::move(event)); definedEvents.emplace(eventIndex); } @@ -422,11 +422,11 @@ namespace tphdr::logic::world } // Parse the requirement string - auto locationReq = tphdr::logic::requirement::ParseRequirementString(locationReqStr, this); + auto locationReq = randomizer::logic::requirement::ParseRequirementString(locationReqStr, this); // Create the LocationAccess wrapper and put it into the list of locations for this area - auto locationAccess = std::make_unique(location, locationReq, area); + auto locationAccess = std::make_unique(location, locationReq, area); locations.emplace_back(std::move(locationAccess)); // Also add this LocationAccess to the locations list of access points @@ -445,11 +445,11 @@ namespace tphdr::logic::world auto connectedArea = this->GetArea(connectedAreaName, /*createIfNotFound = */ true); // Parse the requirement string - auto entranceReq = tphdr::logic::requirement::ParseRequirementString(entranceReqStr, this); + auto entranceReq = randomizer::logic::requirement::ParseRequirementString(entranceReqStr, this); // Create the Entrance object and put it into the list of exits for this area auto entrance = - std::make_unique(area, connectedArea, entranceReq, this); + std::make_unique(area, connectedArea, entranceReq, this); exits.emplace_back(std::move(entrance)); } } @@ -491,8 +491,8 @@ namespace tphdr::logic::world void World::GenerateItemPools() { LOG_TO_DEBUG("Now building item pools"); - tphdr::logic::item_pool::GenerateItemPool(this); - tphdr::logic::item_pool::GenerateStartingItemPool(this); + randomizer::logic::item_pool::GenerateItemPool(this); + randomizer::logic::item_pool::GenerateStartingItemPool(this); LOG_TO_DEBUG("Item Pool for world " + std::to_string(this->GetID()) + ":"); for (const auto& item : this->_itemPool) @@ -527,7 +527,7 @@ namespace tphdr::logic::world // Vanilla Small Keys if ((this->Setting("Small Keys") == "Vanilla" && (originalItem->IsDungeonSmallKey() || - tphdr::utility::str::Contains(originalItemName, "Ordon Pumpkin", "Ordon Cheese"))) || + randomizer::utility::str::Contains(originalItemName, "Ordon Pumpkin", "Ordon Cheese"))) || // Vanilla Big Keys (this->Setting("Big Keys") == "Vanilla" && originalItem->IsBigKey()) || // Vanilla Maps and Compasses @@ -551,7 +551,7 @@ namespace tphdr::logic::world // North Faron Woods Gate Key (this->Setting("Skip Prologue") == "Off" && locationName == "Faron Mist Cave Open Chest") || // Some locations which will always be vanilla for the time being - (tphdr::utility::str::Contains(locationName, + (randomizer::utility::str::Contains(locationName, "Renados Letter", "Telma Invoice", "Wooden Statue", @@ -577,7 +577,7 @@ namespace tphdr::logic::world location->SetCurrentItem(originalItem); location->SetKnownVanillaItem(true); - tphdr::utility::container::Erase(this->_itemPool, originalItem); + randomizer::utility::container::Erase(this->_itemPool, originalItem); } } } @@ -593,7 +593,7 @@ namespace tphdr::logic::world "\" already exists there."); } location->SetCurrentItem(item); - tphdr::utility::container::Erase(this->_itemPool, item); + randomizer::utility::container::Erase(this->_itemPool, item); } } @@ -628,7 +628,7 @@ namespace tphdr::logic::world location->HasCategories("Sky Book")) || // We're starting with a shop item, but shop items aren't randomized (this->Setting("Shop Items") == "Off" && location->HasCategories("Shop") && - tphdr::utility::container::ElementInContainer(this->_startingItemPool, originalItem))) + randomizer::utility::container::ElementInContainer(this->_startingItemPool, originalItem))) { location->RemoveCurrentItem(); location->SetKnownVanillaItem(false); @@ -674,7 +674,7 @@ namespace tphdr::logic::world void World::AssignGoalLocations() { - std::unordered_map dungeonGoalLocations = {}; + std::unordered_map dungeonGoalLocations = {}; for (const auto& [dungeonName, dungeon] : this->_dungeons) { dungeonGoalLocations[dungeonName] = {}; @@ -706,7 +706,7 @@ namespace tphdr::logic::world // assigned a goal location. Dungeons without a goal location cannot be chosen as required dungeons. if (!possibleGoalLocations.empty()) { - dungeon->SetGoalLocation(tphdr::utility::random::RandomElement(possibleGoalLocations)); + dungeon->SetGoalLocation(randomizer::utility::random::RandomElement(possibleGoalLocations)); } else { @@ -722,16 +722,16 @@ namespace tphdr::logic::world { // Gather all boss locations (heart container and dungeon reward checks) auto bossLocations = this->GetAllLocations(); - tphdr::utility::container::FilterAndEraseFromVector( + randomizer::utility::container::FilterAndEraseFromVector( bossLocations, [](const auto& location) - { return !tphdr::utility::str::Contains(location->GetName(), "Heart Container", "Dungeon Reward"); }); + { return !randomizer::utility::str::Contains(location->GetName(), "Heart Container", "Dungeon Reward"); }); // Gather all small key items - tphdr::logic::item_pool::ItemPool smallKeys = {}; + randomizer::logic::item_pool::ItemPool smallKeys = {}; for (const auto& [itemName, item] : this->_itemTable) { - if (item->IsDungeonSmallKey() || tphdr::utility::general::IsAnyOf(itemName, + if (item->IsDungeonSmallKey() || randomizer::utility::general::IsAnyOf(itemName, "Ordon Pumpkin", "Ordon Cheese", "North Faron Woods Gate Key", @@ -773,8 +773,8 @@ namespace tphdr::logic::world // Check if the game is beatable, set dungeon as required if so. If the dungeon is not required and barren // unrequired dungeons is on, then set all the locations in the unrequired dungeon as nonprogress. - auto completeItemPool = tphdr::logic::item_pool::GetCompleteItemPool(*(this->_worlds)); - if (!tphdr::logic::search::GameBeatable(this->_worlds, completeItemPool)) + auto completeItemPool = randomizer::logic::item_pool::GetCompleteItemPool(*(this->_worlds)); + if (!randomizer::logic::search::GameBeatable(this->_worlds, completeItemPool)) { dungeon->SetRequired(true); } @@ -796,7 +796,7 @@ namespace tphdr::logic::world void World::SanitizeItemPool() { - auto junkPool = tphdr::logic::item_pool::GetInitialJunkPool(); + auto junkPool = randomizer::logic::item_pool::GetInitialJunkPool(); // Depending on the Trap item Frequency setting, add some amount of ice traps to the pool if (this->Setting("Trap Item Frequency") == "Few") @@ -818,7 +818,7 @@ namespace tphdr::logic::world } // Create an actual item pool from the junk items - tphdr::logic::item_pool::ItemPool mainJunkPool = {}; + randomizer::logic::item_pool::ItemPool mainJunkPool = {}; for (const auto& [itemName, count] : junkPool) { auto item = this->GetItem(itemName); @@ -840,14 +840,14 @@ namespace tphdr::logic::world // Add items until the pool's size matches the number of empty locations while (this->_itemPool.size() < numEmptyLocations) { - tphdr::logic::item::Item* randomJunkItem; + randomizer::logic::item::Item* randomJunkItem; if (!mainJunkPool.empty()) { - randomJunkItem = tphdr::utility::random::PopRandomElement(mainJunkPool); + randomJunkItem = randomizer::utility::random::PopRandomElement(mainJunkPool); } else { - randomJunkItem = tphdr::utility::random::RandomElement(mainJunkPoolCopy); + randomJunkItem = randomizer::utility::random::RandomElement(mainJunkPoolCopy); } this->_itemPool.emplace_back(randomJunkItem); LOG_TO_DEBUG("Added junk item \"" + randomJunkItem->GetName() + "\" to item pool for world " + @@ -855,11 +855,11 @@ namespace tphdr::logic::world } } - void World::SetSearchStartingProperties(tphdr::logic::search::Search* search) const + void World::SetSearchStartingProperties(randomizer::logic::search::Search* search) const { // Set the root area to have all player forms and times of day (necessary for entrance rando validation) auto root = this->GetRootArea(); - search->_areaFormTime[root] = tphdr::logic::requirement::FormTime::ALL; + search->_areaFormTime[root] = randomizer::logic::requirement::FormTime::ALL; } void World::PerformPostFillTasks() @@ -874,7 +874,7 @@ namespace tphdr::logic::world auto bottleWithHalfMilk = this->GetItem("Bottle with Half Milk"); auto bottleWithLanternOil = this->GetItem("Bottle with Lantern Oil"); auto emptyBottle = this->GetItem("Empty Bottle"); - tphdr::logic::item_pool::ItemPool bottlePool = {bottleWithGreatFairiesTears, + randomizer::logic::item_pool::ItemPool bottlePool = {bottleWithGreatFairiesTears, bottleWithHalfMilk, bottleWithLanternOil, emptyBottle}; @@ -895,7 +895,7 @@ namespace tphdr::logic::world else { // Gather the bottle locations - tphdr::logic::location::LocationPool bottleLocations = {}; + randomizer::logic::location::LocationPool bottleLocations = {}; for (auto& [locationName, location] : this->_locationTable) { auto originalItem = location->GetCurrentItem(); @@ -906,15 +906,15 @@ namespace tphdr::logic::world } // Place the new bottle items - tphdr::utility::random::ShufflePool(bottleLocations); + randomizer::utility::random::ShufflePool(bottleLocations); for (auto& bottleLocation : bottleLocations) { - bottleLocation->SetCurrentItem(tphdr::utility::random::PopRandomElement(bottlePool)); + bottleLocation->SetCurrentItem(randomizer::utility::random::PopRandomElement(bottlePool)); } } } - void World::AddPlandomizedLocation(tphdr::logic::location::Location* location, tphdr::logic::item::Item* item) + void World::AddPlandomizedLocation(randomizer::logic::location::Location* location, randomizer::logic::item::Item* item) { if (this->_plandomizerLocations.contains(location)) { @@ -924,7 +924,7 @@ namespace tphdr::logic::world this->_plandomizerLocations[location] = item; } - void World::AddPlandomizedEntrance(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target) + void World::AddPlandomizedEntrance(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target) { for (const auto& [plandoEntrance, plandoTarget] : this->_plandomizerEntrances) { @@ -942,31 +942,31 @@ namespace tphdr::logic::world this->_plandomizerEntrances[entrance] = target; } - std::unordered_map World::GetPlandomizerEntrances() + std::unordered_map World::GetPlandomizerEntrances() { return this->_plandomizerEntrances; } - tphdr::logic::dungeon::Dungeon* World::GetDungeon(const std::string& name) + randomizer::logic::dungeon::Dungeon* World::GetDungeon(const std::string& name) { if (!this->_dungeons.contains(name)) { - this->_dungeons.emplace(name, std::make_unique(name, this)); + this->_dungeons.emplace(name, std::make_unique(name, this)); LOG_TO_DEBUG("Added new dungeon \"" + name + "\" to world " + std::to_string(this->_id)); } return this->_dungeons.at(name).get(); } - const std::map>& World::GetDungeonTable() const + const std::map>& World::GetDungeonTable() const { return this->_dungeons; } - tphdr::logic::item::Item* World::GetItem(const std::string& name, const bool& ignoreError /*= false*/) + randomizer::logic::item::Item* World::GetItem(const std::string& name, const bool& ignoreError /*= false*/) { if (name == "Nothing") { - return tphdr::logic::item::Nothing.get(); + return randomizer::logic::item::Nothing.get(); } if (!this->_itemTable.contains(name)) @@ -980,27 +980,27 @@ namespace tphdr::logic::world return this->_itemTable.at(name).get(); } - tphdr::logic::item::Item* World::GetGameWinningItem() const + randomizer::logic::item::Item* World::GetGameWinningItem() const { return this->_itemTable.at("Game Beatable").get(); } - tphdr::logic::item::Item* World::GetShadowCrystal() + randomizer::logic::item::Item* World::GetShadowCrystal() { return this->_itemTable.at("Shadow Crystal").get(); } - tphdr::logic::item_pool::ItemPool& World::GetItemPool() + randomizer::logic::item_pool::ItemPool& World::GetItemPool() { return this->_itemPool; } - tphdr::logic::item_pool::ItemPool& World::GetStartingItemPool() + randomizer::logic::item_pool::ItemPool& World::GetStartingItemPool() { return this->_startingItemPool; } - tphdr::logic::location::Location* World::GetLocation(const std::string& name) + randomizer::logic::location::Location* World::GetLocation(const std::string& name) { if (!this->_locationTable.contains(name)) { @@ -1009,9 +1009,9 @@ namespace tphdr::logic::world return this->_locationTable.at(name).get(); } - tphdr::logic::location::LocationPool World::GetAllLocations(const bool& includeNonItemLocations /* = false */) + randomizer::logic::location::LocationPool World::GetAllLocations(const bool& includeNonItemLocations /* = false */) { - tphdr::logic::location::LocationPool locationPool = {}; + randomizer::logic::location::LocationPool locationPool = {}; for (const auto& [locationName, location] : this->_locationTable) { if (includeNonItemLocations || !location->HasCategories("Non-Item Location")) @@ -1022,13 +1022,13 @@ namespace tphdr::logic::world return locationPool; } - tphdr::logic::area::Area* World::GetArea(const std::string& name, const bool& createIfNotFound /* = false */) + randomizer::logic::area::Area* World::GetArea(const std::string& name, const bool& createIfNotFound /* = false */) { if (!this->_areaTable.contains(name)) { if (createIfNotFound) { - this->_areaTable.emplace(name, std::make_unique(name, this)); + this->_areaTable.emplace(name, std::make_unique(name, this)); } else { @@ -1038,19 +1038,19 @@ namespace tphdr::logic::world return this->_areaTable.at(name).get(); } - tphdr::logic::area::Area* World::GetRootArea() const + randomizer::logic::area::Area* World::GetRootArea() const { return this->_areaTable.at("Root").get(); } - const std::map>& World::GetAreaTable() const + const std::map>& World::GetAreaTable() const { return this->_areaTable; } - tphdr::logic::entrance::Entrance* World::GetEntrance(const std::string& originalName) + randomizer::logic::entrance::Entrance* World::GetEntrance(const std::string& originalName) { - auto [parentAreaName, connectedAreaName] = tphdr::logic::entrance::GetParentAndConnectedAreaNames(originalName); + auto [parentAreaName, connectedAreaName] = randomizer::logic::entrance::GetParentAndConnectedAreaNames(originalName); auto parentArea = this->GetArea(parentAreaName); auto connectedArea = this->GetArea(connectedAreaName); for (const auto& exit : parentArea->GetExits()) @@ -1069,16 +1069,16 @@ namespace tphdr::logic::world return this->_entranceIdCounter++; } - tphdr::logic::entrance::EntrancePool World::GetShuffleableEntrances(const tphdr::logic::entrance::Type& type, + randomizer::logic::entrance::EntrancePool World::GetShuffleableEntrances(const randomizer::logic::entrance::Type& type, const bool& onlyPrimary /* = false */) { - tphdr::logic::entrance::EntrancePool shuffleableEntrances = {}; + randomizer::logic::entrance::EntrancePool shuffleableEntrances = {}; for (const auto& [areaName, area] : this->GetAreaTable()) { for (const auto& exit : area->GetExits()) { - if ((type == exit->GetType() || type == tphdr::logic::entrance::Type::ALL) && - (!onlyPrimary || exit->IsPrimary()) && exit->GetType() != tphdr::logic::entrance::Type::INVALID) + if ((type == exit->GetType() || type == randomizer::logic::entrance::Type::ALL) && + (!onlyPrimary || exit->IsPrimary()) && exit->GetType() != randomizer::logic::entrance::Type::INVALID) { shuffleableEntrances.push_back(exit); } @@ -1087,19 +1087,19 @@ namespace tphdr::logic::world return shuffleableEntrances; } - tphdr::logic::entrance::EntrancePool World::GetShuffledEntrances( - const tphdr::logic::entrance::Type& type /* = tphdr::logic::entrance::Type::ALL */, + randomizer::logic::entrance::EntrancePool World::GetShuffledEntrances( + const randomizer::logic::entrance::Type& type /* = randomizer::logic::entrance::Type::ALL */, const bool& onlyPrimary /* = false */) { auto entrances = this->GetShuffleableEntrances(type, onlyPrimary); // Remove any entrances which aren't shuffled - tphdr::utility::container::FilterAndEraseFromVector(entrances, [](const auto& e) { return !e->IsShuffled(); }); + randomizer::utility::container::FilterAndEraseFromVector(entrances, [](const auto& e) { return !e->IsShuffled(); }); return entrances; } - std::unordered_map& World::GetExitTimeFormCache() + std::unordered_map& World::GetExitTimeFormCache() { return this->_exitTimeFormCache; } @@ -1113,7 +1113,7 @@ namespace tphdr::logic::world return -1; } - const tphdr::logic::requirement::Requirement& World::GetMacro(const int& macroIndex) + const randomizer::logic::requirement::Requirement& World::GetMacro(const int& macroIndex) { return this->_macros.at(macroIndex); } @@ -1141,7 +1141,7 @@ namespace tphdr::logic::world return this->_eventNames.at(eventIndex); } - tphdr::seedgen::settings::Setting& World::Setting(const std::string& settingName) + randomizer::seedgen::settings::Setting& World::Setting(const std::string& settingName) { auto& settings = this->_settings; // Check to make sure the setting exists @@ -1152,23 +1152,23 @@ namespace tphdr::logic::world return settings.GetMap().at(settingName); } - void World::SetPlaythroughSpheres(const std::list>& playthroughSpheres) + void World::SetPlaythroughSpheres(const std::list>& playthroughSpheres) { this->_playthroughSpheres = playthroughSpheres; } - std::list> World::GetPlaythroughSpheres() const + std::list> World::GetPlaythroughSpheres() const { return this->_playthroughSpheres; } - void World::SetEntranceSpheres(const std::list>& entranceSpheres) + void World::SetEntranceSpheres(const std::list>& entranceSpheres) { this->_entranceSpheres = entranceSpheres; } - std::list> World::GetEntranceSpheres() const + std::list> World::GetEntranceSpheres() const { return this->_entranceSpheres; } -} // namespace tphdr::logic::world +} // namespace randomizer::logic::world diff --git a/src/dusk/randomizer/logic/world.hpp b/src/dusk/randomizer/logic/world.hpp index 0d33a00cb1..3c8f02c0ca 100644 --- a/src/dusk/randomizer/logic/world.hpp +++ b/src/dusk/randomizer/logic/world.hpp @@ -19,12 +19,12 @@ #include // Forward Declarations -namespace tphdr::logic::search +namespace randomizer::logic::search { class Search; } -namespace tphdr::logic::world +namespace randomizer::logic::world { class World; using WorldPool = std::vector>; @@ -35,8 +35,8 @@ namespace tphdr::logic::world World(const int& id); int GetID() const; - void SetSettings(const tphdr::seedgen::settings::Settings& settings); - const tphdr::seedgen::settings::Settings& GetSettings() const; + void SetSettings(const randomizer::seedgen::settings::Settings& settings); + const randomizer::seedgen::settings::Settings& GetSettings() const; void SetWorlds(WorldPool* worlds); /** @@ -99,44 +99,44 @@ namespace tphdr::logic::world * currently empty locations. */ void SanitizeItemPool(); - void SetSearchStartingProperties(tphdr::logic::search::Search* search) const; + void SetSearchStartingProperties(randomizer::logic::search::Search* search) const; void PerformPostFillTasks(); void FinalizeBottleContents(); - void AddPlandomizedLocation(tphdr::logic::location::Location* location, tphdr::logic::item::Item* item); - void AddPlandomizedEntrance(tphdr::logic::entrance::Entrance* entrance, tphdr::logic::entrance::Entrance* target); - std::unordered_map GetPlandomizerEntrances(); + void AddPlandomizedLocation(randomizer::logic::location::Location* location, randomizer::logic::item::Item* item); + void AddPlandomizedEntrance(randomizer::logic::entrance::Entrance* entrance, randomizer::logic::entrance::Entrance* target); + std::unordered_map GetPlandomizerEntrances(); - tphdr::logic::dungeon::Dungeon* GetDungeon(const std::string& name); - const std::map>& GetDungeonTable() const; - tphdr::logic::item::Item* GetItem(const std::string& name, const bool& ignoreError = false); - tphdr::logic::item::Item* GetShadowCrystal(); - tphdr::logic::item::Item* GetGameWinningItem() const; - tphdr::logic::item_pool::ItemPool& GetItemPool(); - tphdr::logic::item_pool::ItemPool& GetStartingItemPool(); - tphdr::logic::location::Location* GetLocation(const std::string& name); - tphdr::logic::location::LocationPool GetAllLocations(const bool& includeNonItemLocations = false); - tphdr::logic::area::Area* GetArea(const std::string& name, const bool& createIfNotFound = false); - tphdr::logic::area::Area* GetRootArea() const; - const std::map>& GetAreaTable() const; - tphdr::logic::entrance::Entrance* GetEntrance(const std::string& originalName); + randomizer::logic::dungeon::Dungeon* GetDungeon(const std::string& name); + const std::map>& GetDungeonTable() const; + randomizer::logic::item::Item* GetItem(const std::string& name, const bool& ignoreError = false); + randomizer::logic::item::Item* GetShadowCrystal(); + randomizer::logic::item::Item* GetGameWinningItem() const; + randomizer::logic::item_pool::ItemPool& GetItemPool(); + randomizer::logic::item_pool::ItemPool& GetStartingItemPool(); + randomizer::logic::location::Location* GetLocation(const std::string& name); + randomizer::logic::location::LocationPool GetAllLocations(const bool& includeNonItemLocations = false); + randomizer::logic::area::Area* GetArea(const std::string& name, const bool& createIfNotFound = false); + randomizer::logic::area::Area* GetRootArea() const; + const std::map>& GetAreaTable() const; + randomizer::logic::entrance::Entrance* GetEntrance(const std::string& originalName); int GetNewEntranceID(); - tphdr::logic::entrance::EntrancePool GetShuffleableEntrances(const tphdr::logic::entrance::Type& type, + randomizer::logic::entrance::EntrancePool GetShuffleableEntrances(const randomizer::logic::entrance::Type& type, const bool& onlyPrimary = false); - tphdr::logic::entrance::EntrancePool GetShuffledEntrances( - const tphdr::logic::entrance::Type& type = tphdr::logic::entrance::Type::ALL, + randomizer::logic::entrance::EntrancePool GetShuffledEntrances( + const randomizer::logic::entrance::Type& type = randomizer::logic::entrance::Type::ALL, const bool& onlyPrimary = false); - std::unordered_map& GetExitTimeFormCache(); + std::unordered_map& GetExitTimeFormCache(); int GetMacroIndex(const std::string& macroName) const; - const tphdr::logic::requirement::Requirement& GetMacro(const int& macroIndex); + const randomizer::logic::requirement::Requirement& GetMacro(const int& macroIndex); int GetEventIndex(const std::string& eventName); std::string GetEventName(const int& eventIndex); - tphdr::seedgen::settings::Setting& Setting(const std::string& settingName); - void SetPlaythroughSpheres(const std::list>& playthroughSpheres); - std::list> GetPlaythroughSpheres() const; - void SetEntranceSpheres(const std::list>& entranceSpheres); - std::list> GetEntranceSpheres() const; + randomizer::seedgen::settings::Setting& Setting(const std::string& settingName); + void SetPlaythroughSpheres(const std::list>& playthroughSpheres); + std::list> GetPlaythroughSpheres() const; + void SetEntranceSpheres(const std::list>& entranceSpheres); + std::list> GetEntranceSpheres() const; private: int _id = -1; @@ -144,29 +144,29 @@ namespace tphdr::logic::world static int _eventIdCounter; // Needs to be shared for events across all worlds int _entranceIdCounter = 0; // Specific for this world - tphdr::seedgen::settings::Settings _settings; - std::map> _itemTable = {}; - std::map> _locationTable = {}; + randomizer::seedgen::settings::Settings _settings; + std::map> _itemTable = {}; + std::map> _locationTable = {}; std::unordered_set _intentionallyRemovedLocations = {}; std::unordered_set _registeredLocationCategories = {}; - std::map> _areaTable = {}; - std::map> _dungeons = {}; - std::map _macros = {}; + std::map> _areaTable = {}; + std::map> _dungeons = {}; + std::map _macros = {}; std::unordered_map _macroIndexes = {}; std::unordered_map _eventIndexes = {}; std::unordered_map _eventNames = {}; - tphdr::logic::item_pool::ItemPool _itemPool = {}; - tphdr::logic::item_pool::ItemPool _startingItemPool = {}; - std::unordered_map _exitTimeFormCache = {}; + randomizer::logic::item_pool::ItemPool _itemPool = {}; + randomizer::logic::item_pool::ItemPool _startingItemPool = {}; + std::unordered_map _exitTimeFormCache = {}; // Playthroughs will be stored in world 0 for convenience - std::list> _playthroughSpheres = {}; - std::list> _entranceSpheres = {}; + std::list> _playthroughSpheres = {}; + std::list> _entranceSpheres = {}; // Plandomizer Data - std::unordered_map _plandomizerLocations = {}; - std::unordered_map _plandomizerEntrances = {}; + std::unordered_map _plandomizerLocations = {}; + std::unordered_map _plandomizerEntrances = {}; WorldPool* _worlds = nullptr; }; -} // namespace tphdr::logic::world +} // namespace randomizer::logic::world diff --git a/src/dusk/randomizer/randomizer.cpp b/src/dusk/randomizer/randomizer.cpp index 318d7a6394..b359723d36 100644 --- a/src/dusk/randomizer/randomizer.cpp +++ b/src/dusk/randomizer/randomizer.cpp @@ -12,10 +12,10 @@ int randomizerMain() try { #ifdef LOGIC_TESTS - tphdr::test::test::RunTests(); + randomizer::test::test::RunTests(); return 0; #else - auto worlds = tphdr::logic::generate::GenerateWorlds(); + auto worlds = randomizer::logic::generate::GenerateWorlds(); #endif } catch(const std::exception& e) diff --git a/src/dusk/randomizer/seedgen/config.cpp b/src/dusk/randomizer/seedgen/config.cpp index d855ebb699..c301e3d9e7 100644 --- a/src/dusk/randomizer/seedgen/config.cpp +++ b/src/dusk/randomizer/seedgen/config.cpp @@ -9,7 +9,7 @@ #include -namespace tphdr::seedgen::config +namespace randomizer::seedgen::config { void Config::LoadFromFile(const fspath& settingsPath, @@ -48,11 +48,11 @@ namespace tphdr::seedgen::config preferencesFile.close(); this->_settingsList.clear(); - this->_settingsList.push_front(tphdr::seedgen::settings::Settings()); + this->_settingsList.push_front(randomizer::seedgen::settings::Settings()); auto& settings = this->_settingsList.front(); // Load settings info - auto settingInfoMap = tphdr::seedgen::settings::GetAllSettingsInfo(); + auto settingInfoMap = randomizer::seedgen::settings::GetAllSettingsInfo(); // Read in settings and preferences. If we have to change anything, // rewrite the appropriate file if allowed. @@ -72,14 +72,14 @@ namespace tphdr::seedgen::config // If the option doesn't exist, revert to default and rewrite later if necessary if (settingInfo->GetIndexOfOption(settingOption) == -1) { - tphdr::utility::platform::Log(std::string("Setting \"") + settingName + "\" has no option \"" + + randomizer::utility::platform::Log(std::string("Setting \"") + settingName + "\" has no option \"" + settingOption + "\". Reverting to default \"" + settingInfo->GetDefaultOption() + "\""); settingOption = settingInfo->GetDefaultOption(); rewriteSettings = true; } - settings.InsertSetting(settingName, tphdr::seedgen::settings::Setting(settingInfo.get(), settingOption)); + settings.InsertSetting(settingName, randomizer::seedgen::settings::Setting(settingInfo.get(), settingOption)); } // Special handling for starting inventory else if (settingName == "Starting Inventory") @@ -122,7 +122,7 @@ namespace tphdr::seedgen::config // If seed is empty string, generate a new one if (this->_seed.empty()) { - this->_seed = tphdr::seedgen::seed::GenerateSeed(); + this->_seed = randomizer::seedgen::seed::GenerateSeed(); } } // Special handling for Plandomizer @@ -148,7 +148,7 @@ namespace tphdr::seedgen::config // If the option doesn't exist, revert to default and rewrite later if necessary if (preferenceInfo->GetIndexOfOption(preferenceOption) == -1) { - tphdr::utility::platform::Log(std::string("Preference \"") + preferenceName + " has no option \"" + + randomizer::utility::platform::Log(std::string("Preference \"") + preferenceName + " has no option \"" + preferenceOption + "\". Reverting to default \"" + preferenceInfo->GetDefaultOption() + "\""); preferenceOption = preferenceInfo->GetDefaultOption(); @@ -156,7 +156,7 @@ namespace tphdr::seedgen::config } settings.InsertSetting(preferenceName, - tphdr::seedgen::settings::Setting(preferenceInfo.get(), preferenceOption)); + randomizer::seedgen::settings::Setting(preferenceInfo.get(), preferenceOption)); } else if (preferenceName == "Game Base Path") { @@ -181,13 +181,13 @@ namespace tphdr::seedgen::config if (!settings.GetMap().contains(settingName)) { settings.InsertSetting(settingName, - tphdr::seedgen::settings::Setting(settingInfo.get(), settingInfo->GetDefaultOption())); - tphdr::utility::platform::Log(std::string("Added missing setting \"") + settingName + "\""); - if (settingInfo->GetType() == tphdr::seedgen::settings::Type::STANDARD) + randomizer::seedgen::settings::Setting(settingInfo.get(), settingInfo->GetDefaultOption())); + randomizer::utility::platform::Log(std::string("Added missing setting \"") + settingName + "\""); + if (settingInfo->GetType() == randomizer::seedgen::settings::Type::STANDARD) { rewriteSettings = true; } - else if (settingInfo->GetType() == tphdr::seedgen::settings::Type::PREFERENCE) + else if (settingInfo->GetType() == randomizer::seedgen::settings::Type::PREFERENCE) { rewritePreferences = true; } @@ -195,8 +195,8 @@ namespace tphdr::seedgen::config } if (!settingsTree["Seed"]) { - this->_seed = tphdr::seedgen::seed::GenerateSeed(); - tphdr::utility::platform::Log("Seed is missing. Generated new seed."); + this->_seed = randomizer::seedgen::seed::GenerateSeed(); + randomizer::utility::platform::Log("Seed is missing. Generated new seed."); rewriteSettings = true; } if (!settingsTree["Plandomizer"] || !settingsTree["Generate Spoiler Log"] || !settingsTree["Starting Inventory"] || @@ -212,12 +212,12 @@ namespace tphdr::seedgen::config // Rewrite files if deemed necessary if (allowRewrite && rewriteSettings) { - tphdr::utility::platform::Log(std::string("Rewriting ") + settingsPath.generic_string()); + randomizer::utility::platform::Log(std::string("Rewriting ") + settingsPath.generic_string()); this->WriteSettingsToFile(settingsPath); } if (allowRewrite && rewritePreferences) { - tphdr::utility::platform::Log(std::string("Rewriting ") + preferencesPath.generic_string()); + randomizer::utility::platform::Log(std::string("Rewriting ") + preferencesPath.generic_string()); this->WritePreferencesToFile(preferencesPath); } } @@ -244,7 +244,7 @@ namespace tphdr::seedgen::config for (const auto& settingName : sortedNames) { auto& setting = settings.GetMap().at(settingName); - if (setting.GetInfo()->GetType() == tphdr::seedgen::settings::Type::STANDARD) + if (setting.GetInfo()->GetType() == randomizer::seedgen::settings::Type::STANDARD) { out[settingName] = setting.GetCurrentOption(); } @@ -288,7 +288,7 @@ namespace tphdr::seedgen::config out["Plandomizer Path"] = this->_plandomizerPath.generic_string(); for (auto& [settingName, setting] : settings.GetMap()) { - if (setting.GetInfo()->GetType() == tphdr::seedgen::settings::Type::PREFERENCE) + if (setting.GetInfo()->GetType() == randomizer::seedgen::settings::Type::PREFERENCE) { out[settingName] = setting.GetCurrentOption(); } @@ -327,7 +327,7 @@ namespace tphdr::seedgen::config { if (this->_hash.empty()) { - this->_hash = tphdr::seedgen::seed::GenerateHash(); + this->_hash = randomizer::seedgen::seed::GenerateHash(); } return this->_hash; @@ -335,7 +335,7 @@ namespace tphdr::seedgen::config int WriteDefaultSettings(const fspath& settingsPath) { - tphdr::utility::platform::Log("Creating Default Settings"); + randomizer::utility::platform::Log("Creating Default Settings"); std::ofstream settingsFile(settingsPath); if (settingsFile.is_open() == false) { @@ -343,16 +343,16 @@ namespace tphdr::seedgen::config return 1; } - auto settingInfoMap = tphdr::seedgen::settings::GetAllSettingsInfo(); + auto settingInfoMap = randomizer::seedgen::settings::GetAllSettingsInfo(); YAML::Node root; - root["Seed"] = tphdr::seedgen::seed::GenerateSeed(); + root["Seed"] = randomizer::seedgen::seed::GenerateSeed(); root["Plandomizer"] = false; root["Generate Spoiler Log"] = true; - // TODO: root["Permalink"] = tphdr::seedgen::permalink::GeneratePermalink(); + // TODO: root["Permalink"] = randomizer::seedgen::permalink::GeneratePermalink(); for (const auto& [name, info] : *settingInfoMap) { - if (info->GetType() == tphdr::seedgen::settings::Type::STANDARD) + if (info->GetType() == randomizer::seedgen::settings::Type::STANDARD) { root[name] = info->GetDefaultOption(); } @@ -369,7 +369,7 @@ namespace tphdr::seedgen::config int WriteDefaultPreferences(const fspath& preferencesPath) { - tphdr::utility::platform::Log("Creating Default Preferences"); + randomizer::utility::platform::Log("Creating Default Preferences"); std::ofstream preferencesFile(preferencesPath); if (preferencesFile.is_open() == false) { @@ -377,7 +377,7 @@ namespace tphdr::seedgen::config return 1; } - auto settingInfoMap = tphdr::seedgen::settings::GetAllSettingsInfo(); + auto settingInfoMap = randomizer::seedgen::settings::GetAllSettingsInfo(); YAML::Node root; root["Game Base Path"] = ""; @@ -385,7 +385,7 @@ namespace tphdr::seedgen::config root["Plandomizer Path"] = ""; for (const auto& [name, info] : *settingInfoMap) { - if (info->GetType() == tphdr::seedgen::settings::Type::PREFERENCE) + if (info->GetType() == randomizer::seedgen::settings::Type::PREFERENCE) { root[name] = info->GetDefaultOption(); } @@ -402,7 +402,7 @@ namespace tphdr::seedgen::config { // Seed with system time incase we have to choose random preferences during seeding auto seed = static_cast(std::random_device {}()); - tphdr::utility::random::RandomInit(seed); + randomizer::utility::random::RandomInit(seed); // Seed the rng using a combination of the seed and standard settings std::string hashStr = config.GetSeed(); @@ -410,7 +410,7 @@ namespace tphdr::seedgen::config { for (auto& [settingName, setting] : settings.GetMap()) { - if (setting.GetInfo()->GetType() == tphdr::seedgen::settings::Type::STANDARD) + if (setting.GetInfo()->GetType() == randomizer::seedgen::settings::Type::STANDARD) { hashStr += settingName + setting.GetCurrentOption(); } @@ -444,7 +444,7 @@ namespace tphdr::seedgen::config if (config.IsUsingPlandomizer()) { std::string plandomizerContents; - auto retVal = tphdr::utility::file::GetContents(config.GetPlandomizerPath(), plandomizerContents); + auto retVal = randomizer::utility::file::GetContents(config.GetPlandomizerPath(), plandomizerContents); if (!ignoreInvalidPlandomizer && retVal != 0) { LOG_TO_ERROR("Could not read plandomizer file at \"" + config.GetPlandomizerPath().generic_string() + "\""); @@ -460,8 +460,8 @@ namespace tphdr::seedgen::config } const size_t integerSeed = zng_crc32(0L, reinterpret_cast(hashStr.data()), hashStr.length()); - tphdr::utility::random::RandomInit(integerSeed); + randomizer::utility::random::RandomInit(integerSeed); return 0; } -} // namespace tphdr::seedgen::config +} // namespace randomizer::seedgen::config diff --git a/src/dusk/randomizer/seedgen/config.hpp b/src/dusk/randomizer/seedgen/config.hpp index 9c28f4b1c4..389231c90e 100644 --- a/src/dusk/randomizer/seedgen/config.hpp +++ b/src/dusk/randomizer/seedgen/config.hpp @@ -11,7 +11,7 @@ namespace YAML class Node; } -namespace tphdr::seedgen::config +namespace randomizer::seedgen::config { enum struct [[nodiscard]] ConfigError { @@ -85,7 +85,7 @@ namespace tphdr::seedgen::config std::string _seed; std::string _hash; - std::list _settingsList; + std::list _settingsList; bool _isUsingPlandomizer = false; bool _isGeneratingSpoilerLog = true; @@ -101,4 +101,4 @@ namespace tphdr::seedgen::config std::string PermalinkErrorGetName(ConfigError err); int SeedRNG(Config& config, const bool& resolvePreferenceRandom = false, const bool& ignoreInvalidPlandomizer = true); -} // namespace tphdr::seedgen::config +} // namespace randomizer::seedgen::config diff --git a/src/dusk/randomizer/seedgen/seed.cpp b/src/dusk/randomizer/seedgen/seed.cpp index f547a8c189..1b0f5f1a1f 100644 --- a/src/dusk/randomizer/seedgen/seed.cpp +++ b/src/dusk/randomizer/seedgen/seed.cpp @@ -5,7 +5,7 @@ #include #include -namespace tphdr::seedgen::seed +namespace randomizer::seedgen::seed { static const std::vector nouns = { "Aeralfos", "Agitha", "Ant", "Argorok", "Armos", "Ashei", "Auru", "BackSlice", "Bari", @@ -104,10 +104,10 @@ namespace tphdr::seedgen::seed std::string GenerateHash() { std::string noun1, noun2, noun3; - noun1 = tphdr::utility::random::RandomElement(nouns); - noun2 = tphdr::utility::random::RandomElement(nouns); - noun3 = tphdr::utility::random::RandomElement(nouns); + noun1 = randomizer::utility::random::RandomElement(nouns); + noun2 = randomizer::utility::random::RandomElement(nouns); + noun3 = randomizer::utility::random::RandomElement(nouns); return noun1 + " " + noun2 + " " + noun3; } -} // namespace tphdr::seedgen::seed +} // namespace randomizer::seedgen::seed diff --git a/src/dusk/randomizer/seedgen/seed.hpp b/src/dusk/randomizer/seedgen/seed.hpp index 4b3a7a4a52..47d52fdf9f 100644 --- a/src/dusk/randomizer/seedgen/seed.hpp +++ b/src/dusk/randomizer/seedgen/seed.hpp @@ -2,7 +2,7 @@ #include "config.hpp" -namespace tphdr::seedgen::seed +namespace randomizer::seedgen::seed { /** * @brief Generates a random sequence of 3 words to be used as a seed. @@ -18,5 +18,5 @@ namespace tphdr::seedgen::seed */ std::string GenerateHash(); - std::string HashForConfig(const tphdr::seedgen::config::Config& config); -} // namespace tphdr::seedgen::seed + std::string HashForConfig(const randomizer::seedgen::config::Config& config); +} // namespace randomizer::seedgen::seed diff --git a/src/dusk/randomizer/seedgen/settings.cpp b/src/dusk/randomizer/seedgen/settings.cpp index c726995d09..82c679a048 100644 --- a/src/dusk/randomizer/seedgen/settings.cpp +++ b/src/dusk/randomizer/seedgen/settings.cpp @@ -13,7 +13,7 @@ #include #include -namespace tphdr::seedgen::settings +namespace randomizer::seedgen::settings { Type TypeFromStr(const std::string& str) @@ -55,7 +55,7 @@ namespace tphdr::seedgen::settings // and removes apostraphes and parenthesis auto logicName = name; std::replace(logicName.begin(), logicName.end(), ' ', '_'); - tphdr::utility::str::Erase(logicName, "'", ")", "("); + randomizer::utility::str::Erase(logicName, "'", ")", "("); this->_logicName = logicName; // Same for logic expressions of options for this setting @@ -63,7 +63,7 @@ namespace tphdr::seedgen::settings { auto logicOption = option; std::replace(logicOption.begin(), logicOption.end(), ' ', '_'); - tphdr::utility::str::Erase(logicOption, "'", ")", "("); + randomizer::utility::str::Erase(logicOption, "'", ")", "("); this->_logicOptions.push_back(logicOption); } } @@ -75,7 +75,7 @@ namespace tphdr::seedgen::settings int SettingInfo::GetIndexOfOption(const std::string& option) const { - return tphdr::utility::container::GetIndex(this->_options, option); + return randomizer::utility::container::GetIndex(this->_options, option); } std::string SettingInfo::GetRandomOption() const @@ -120,7 +120,7 @@ namespace tphdr::seedgen::settings { this->_isUsingRandomOption = true; auto randomOption = - tphdr::utility::random::Random(this->GetInfo()->GetRandomLow(), this->GetInfo()->GetRandomHigh()); + randomizer::utility::random::Random(this->GetInfo()->GetRandomLow(), this->GetInfo()->GetRandomHigh()); this->SetCurrentOption(randomOption); LOG_TO_DEBUG("Chose \"" + this->GetInfo()->GetOptions()[randomOption] + " as random option for setting \"" + this->GetInfo()->GetName()); @@ -233,10 +233,10 @@ namespace tphdr::seedgen::settings const auto& description = optionNode.second.as(); // If we're specifying a range, then include all numbers in the range - if (tphdr::utility::str::Contains(option, "-")) + if (randomizer::utility::str::Contains(option, "-")) { // Fill in all the options between the lower and upper bounds - auto ops = tphdr::utility::str::Split(option, '-'); + auto ops = randomizer::utility::str::Split(option, '-'); int lowerBound = std::stoi(ops[0]); int upperBound = std::stoi(ops[1]); for (auto i = lowerBound; i <= upperBound; i++) @@ -254,7 +254,7 @@ namespace tphdr::seedgen::settings } // Calculate default option index - auto defaultOptionIndex = tphdr::utility::container::GetIndex(options, defaultOption); + auto defaultOptionIndex = randomizer::utility::container::GetIndex(options, defaultOption); if (defaultOptionIndex == -1) { throw std::runtime_error(std::string("Default Option \"") + defaultOption + "\" is not defined for setting \"" + @@ -280,7 +280,7 @@ namespace tphdr::seedgen::settings if (settingNode["Random Low"]) { auto randomLowStr = settingNode["Random Low"].as(); - randomLow = tphdr::utility::container::GetIndex(options, randomLowStr); + randomLow = randomizer::utility::container::GetIndex(options, randomLowStr); if (randomLow == -1) { throw std::runtime_error(std::string("Random Low Option \"") + randomLowStr + @@ -290,7 +290,7 @@ namespace tphdr::seedgen::settings if (settingNode["Random high"]) { auto randomHighStr = settingNode["Random High"].as(); - randomHigh = tphdr::utility::container::GetIndex(options, randomHighStr); + randomHigh = randomizer::utility::container::GetIndex(options, randomHighStr); if (randomHigh == -1) { throw std::runtime_error(std::string("Random High Option \"") + randomHighStr + @@ -299,13 +299,13 @@ namespace tphdr::seedgen::settings } // Generate the random option if it's not already there - if (hasRandomOption && tphdr::utility::container::GetIndex(options, randomAlias) != -1) + if (hasRandomOption && randomizer::utility::container::GetIndex(options, randomAlias) != -1) { options.push_back(randomAlias); descriptions.push_back("A random option will be chosen"); } - int randomOptionIndex = tphdr::utility::container::GetIndex(options, randomAlias); + int randomOptionIndex = randomizer::utility::container::GetIndex(options, randomAlias); // Insert the data for the setting auto info = std::make_unique(settingIdCounter++, @@ -325,4 +325,4 @@ namespace tphdr::seedgen::settings return std::move(settingInfoMap); } -}; // namespace tphdr::seedgen::settings +}; // namespace randomizer::seedgen::settings diff --git a/src/dusk/randomizer/seedgen/settings.hpp b/src/dusk/randomizer/seedgen/settings.hpp index 668088fb51..3e72596285 100644 --- a/src/dusk/randomizer/seedgen/settings.hpp +++ b/src/dusk/randomizer/seedgen/settings.hpp @@ -11,7 +11,7 @@ #include #include -namespace tphdr::seedgen::settings +namespace randomizer::seedgen::settings { class SettingInfo; using SettingInfoMap_t = std::unordered_map>; @@ -149,7 +149,7 @@ namespace tphdr::seedgen::settings // Check to make sure all listed options exist for (const auto& optionName : {optionNames...}) { - if (!tphdr::utility::container::ElementInContainer(this->GetInfo()->GetOptions(), optionName)) + if (!randomizer::utility::container::ElementInContainer(this->GetInfo()->GetOptions(), optionName)) { throw std::runtime_error("\"" + std::string(optionName) + "\" is not a known option for setting \"" + this->GetInfo()->GetName() + "\""); @@ -210,4 +210,4 @@ namespace tphdr::seedgen::settings */ std::unique_ptr LoadAllSettingsInfo(); -}; // namespace tphdr::seedgen::settings +}; // namespace randomizer::seedgen::settings diff --git a/src/dusk/randomizer/test/test.cpp b/src/dusk/randomizer/test/test.cpp index f43214ef19..29eda4ac07 100644 --- a/src/dusk/randomizer/test/test.cpp +++ b/src/dusk/randomizer/test/test.cpp @@ -7,7 +7,7 @@ #include #include -namespace tphdr::test::test +namespace randomizer::test::test { void RunTests() { @@ -15,7 +15,7 @@ namespace tphdr::test::test { if (entry.path().generic_string().ends_with("settings.yaml")) { - auto pathFolders = tphdr::utility::str::Split(entry.path().generic_string(), '/'); + auto pathFolders = randomizer::utility::str::Split(entry.path().generic_string(), '/'); auto& testName = pathFolders[pathFolders.size() - 2]; std::filesystem::remove(SETTINGS_PATH); std::filesystem::copy_file(entry, SETTINGS_PATH); @@ -23,7 +23,7 @@ namespace tphdr::test::test std::cout << "Testing " << testName << std::endl; try { - tphdr::logic::generate::GenerateWorlds(); + randomizer::logic::generate::GenerateWorlds(); } catch(const std::exception& e) { std::cout << "Test \"" << testName << "\" failed! Failed settings saved to " << SETTINGS_PATH << std::endl; @@ -39,4 +39,4 @@ namespace tphdr::test::test std::cout << "All Settings Tests passed" << std::endl; } -} // namespace tphdr::test::test +} // namespace randomizer::test::test diff --git a/src/dusk/randomizer/test/test.hpp b/src/dusk/randomizer/test/test.hpp index d2b2d04386..8e35574781 100644 --- a/src/dusk/randomizer/test/test.hpp +++ b/src/dusk/randomizer/test/test.hpp @@ -1,6 +1,6 @@ #pragma once -namespace tphdr::test::test +namespace randomizer::test::test { void RunTests(); -} // namespace tphdr::test::test +} // namespace randomizer::test::test diff --git a/src/dusk/randomizer/utility/color.cpp b/src/dusk/randomizer/utility/color.cpp index 8d86910774..4e1792c3d4 100644 --- a/src/dusk/randomizer/utility/color.cpp +++ b/src/dusk/randomizer/utility/color.cpp @@ -152,7 +152,7 @@ std::string RGBToHexColorStr(const RGBA& color) { c |= int(color.G * 255) << 8; c |= int(color.B * 255); - return tphdr::utility::str::intToHex(c, 6, false); + return randomizer::utility::str::intToHex(c, 6, false); } bool isValidHexColor(const std::string& hexColor) { diff --git a/src/dusk/randomizer/utility/container.hpp b/src/dusk/randomizer/utility/container.hpp index 076e996c7c..3ed0fc7217 100644 --- a/src/dusk/randomizer/utility/container.hpp +++ b/src/dusk/randomizer/utility/container.hpp @@ -4,7 +4,7 @@ #include #include -namespace tphdr::utility::container +namespace randomizer::utility::container { template int GetIndex(const Container& container, const T& element) @@ -68,4 +68,4 @@ namespace tphdr::utility::container } } } -} // namespace tphdr::utility::container +} // namespace randomizer::utility::container diff --git a/src/dusk/randomizer/utility/endian.cpp b/src/dusk/randomizer/utility/endian.cpp index 8f226a5dae..ce58638023 100644 --- a/src/dusk/randomizer/utility/endian.cpp +++ b/src/dusk/randomizer/utility/endian.cpp @@ -23,8 +23,8 @@ namespace Utility::Endian return Type::Little; } else { - tphdr::utility::platform::Log("Warning: Could not determine endianness!"); - tphdr::utility::platform::Log("Using little endian as default"); + randomizer::utility::platform::Log("Warning: Could not determine endianness!"); + randomizer::utility::platform::Log("Using little endian as default"); return Type::Little; } } diff --git a/src/dusk/randomizer/utility/file.cpp b/src/dusk/randomizer/utility/file.cpp index 572b3c8a3a..455278306b 100644 --- a/src/dusk/randomizer/utility/file.cpp +++ b/src/dusk/randomizer/utility/file.cpp @@ -13,7 +13,7 @@ #include #endif -namespace tphdr::utility::file +namespace randomizer::utility::file { bool isRoot(const fspath& fsPath) { @@ -44,7 +44,7 @@ namespace tphdr::utility::file bool copy_file(const fspath& from, const fspath& to) { - tphdr::utility::platform::Log("Copying " + Utility::toUtf8String(to)); + randomizer::utility::platform::Log("Copying " + Utility::toUtf8String(to)); #ifdef DEVKITPRO // use a buffer to speed up file copying @@ -90,7 +90,7 @@ namespace tphdr::utility::file return false; } - tphdr::utility::file::create_directories(to); + randomizer::utility::file::create_directories(to); // Loop over directory contents struct dirent* dirEntry; @@ -207,4 +207,4 @@ namespace tphdr::utility::file } file.close(); } -} // namespace tphdr::utility::file +} // namespace randomizer::utility::file diff --git a/src/dusk/randomizer/utility/file.hpp b/src/dusk/randomizer/utility/file.hpp index 1ac83d610a..3f98c0e7ab 100644 --- a/src/dusk/randomizer/utility/file.hpp +++ b/src/dusk/randomizer/utility/file.hpp @@ -12,7 +12,7 @@ #include #endif -namespace tphdr::utility::file +namespace randomizer::utility::file { //std::filesystem is partially broken on Wii U, these are cross-platform replacements diff --git a/src/dusk/randomizer/utility/general.hpp b/src/dusk/randomizer/utility/general.hpp index e1edba4068..815e61a5f9 100644 --- a/src/dusk/randomizer/utility/general.hpp +++ b/src/dusk/randomizer/utility/general.hpp @@ -1,10 +1,10 @@ #pragma once -namespace tphdr::utility::general +namespace randomizer::utility::general { template bool IsAnyOf(First&& first, T&&... t) { return ((first == t) || ...); } -} // namespace tphdr::utility::general \ No newline at end of file +} // namespace randomizer::utility::general diff --git a/src/dusk/randomizer/utility/log.cpp b/src/dusk/randomizer/utility/log.cpp index 7290db9b94..eb4af747b2 100644 --- a/src/dusk/randomizer/utility/log.cpp +++ b/src/dusk/randomizer/utility/log.cpp @@ -3,7 +3,7 @@ #define RANDOMIZER_VERSION "1.0.0" -namespace tphdr::utility::log +namespace randomizer::utility::log { LogInfo::LogInfo() {} @@ -15,7 +15,7 @@ namespace tphdr::utility::log return s_Instance; } - const tphdr::seedgen::config::Config& LogInfo::getConfig() + const randomizer::seedgen::config::Config& LogInfo::getConfig() { return getInstance().config; } @@ -29,7 +29,7 @@ namespace tphdr::utility::log { #ifdef WRITE_ERROR_LOG output.open(LOG_PATH); - output << "Program opened " << tphdr::utility::time::ProgramTime::getDateStr(); // time string ends with \n + output << "Program opened " << randomizer::utility::time::ProgramTime::getDateStr(); // time string ends with \n output << "Twilight Princess HD Randomizer Version " << RANDOMIZER_VERSION << std::endl; output << std::endl << std::endl; #endif @@ -52,7 +52,7 @@ namespace tphdr::utility::log { #ifdef WRITE_ERROR_LOG if (timestamp) - output << "[" << tphdr::utility::time::ProgramTime::getTimeStr() << "] "; + output << "[" << randomizer::utility::time::ProgramTime::getTimeStr() << "] "; output << msg << std::endl; #endif lastErrors.push_front(msg); @@ -76,7 +76,7 @@ namespace tphdr::utility::log DebugLog::DebugLog() { output.open(LOG_PATH); - output << "Program opened " << tphdr::utility::time::ProgramTime::getDateStr(); // time string ends with \n + output << "Program opened " << randomizer::utility::time::ProgramTime::getDateStr(); // time string ends with \n output << "Twilight Princess HD Randomizer Version " << RANDOMIZER_VERSION << std::endl; output << std::endl << std::endl; } @@ -95,7 +95,7 @@ namespace tphdr::utility::log void DebugLog::log(const std::string& msg, const bool& timestamp) { if (timestamp) - output << "[" << tphdr::utility::time::ProgramTime::getTimeStr() << "] "; + output << "[" << randomizer::utility::time::ProgramTime::getTimeStr() << "] "; output << msg << std::endl; } -} // namespace tphdr::utility::log +} // namespace randomizer::utility::log diff --git a/src/dusk/randomizer/utility/log.hpp b/src/dusk/randomizer/utility/log.hpp index 696204aa2e..be37f16d6a 100644 --- a/src/dusk/randomizer/utility/log.hpp +++ b/src/dusk/randomizer/utility/log.hpp @@ -11,12 +11,12 @@ #define TOSTRING(x) STRINGIFY(x) #define __FILENAME__ (&__FILE__[SOURCE_PATH_SIZE]) -namespace tphdr::utility::log +namespace randomizer::utility::log { class LogInfo { private: - tphdr::seedgen::config::Config config; + randomizer::seedgen::config::Config config; std::string seedHash; LogInfo(); @@ -28,9 +28,9 @@ namespace tphdr::utility::log LogInfo(const LogInfo&) = delete; LogInfo& operator=(const LogInfo&) = delete; - static void setConfig(const tphdr::seedgen::config::Config& config_) { getInstance().config = config_; } + static void setConfig(const randomizer::seedgen::config::Config& config_) { getInstance().config = config_; } static void setSeedHash(const std::string& seedHash_) { getInstance().seedHash = seedHash_; } - static const tphdr::seedgen::config::Config& getConfig(); + static const randomizer::seedgen::config::Config& getConfig(); static const std::string& getSeedHash(); }; @@ -104,16 +104,16 @@ namespace tphdr::utility::log static DebugLog& getInstance(); void log(const std::string& msg, const bool& timestamp = true); }; -} // namespace tphdr::utility::log +} // namespace randomizer::utility::log #ifdef RANDO_DEBUG #define LOG_TO_DEBUG(message) \ - tphdr::utility::log::DebugLog::getInstance().log(std::string("Message on line " TOSTRING(__LINE__) " of ") + \ + randomizer::utility::log::DebugLog::getInstance().log(std::string("Message on line " TOSTRING(__LINE__) " of ") + \ __FILENAME__ + std::string(": " + std::string(message))); #else #define LOG_TO_DEBUG(message) #endif #define LOG_TO_ERROR(message) \ - tphdr::utility::log::ErrorLog::getInstance().log(std::string("Message on line " TOSTRING(__LINE__) " of ") + \ + randomizer::utility::log::ErrorLog::getInstance().log(std::string("Message on line " TOSTRING(__LINE__) " of ") + \ __FILENAME__ + std::string(": " + std::string(message))); diff --git a/src/dusk/randomizer/utility/path.cpp b/src/dusk/randomizer/utility/path.cpp index ae672b2901..970f35153d 100644 --- a/src/dusk/randomizer/utility/path.cpp +++ b/src/dusk/randomizer/utility/path.cpp @@ -40,7 +40,7 @@ namespace Utility { if (!std::filesystem::is_directory(path)) { - tphdr::utility::file::create_directories(path); + randomizer::utility::file::create_directories(path); } return path; @@ -51,7 +51,7 @@ namespace Utility { if (!std::filesystem::is_directory(path)) { - tphdr::utility::file::create_directories(path); + randomizer::utility::file::create_directories(path); } return path; @@ -63,7 +63,7 @@ namespace Utility { if (!std::filesystem::is_directory(path)) { - tphdr::utility::file::create_directories(path); + randomizer::utility::file::create_directories(path); } return path; diff --git a/src/dusk/randomizer/utility/platform.cpp b/src/dusk/randomizer/utility/platform.cpp index e47ccb7b81..94d9195b34 100644 --- a/src/dusk/randomizer/utility/platform.cpp +++ b/src/dusk/randomizer/utility/platform.cpp @@ -48,7 +48,7 @@ static bool flushVolume(const std::string& vol) bool initMocha() { - tphdr::utility::platform::Log("Starting libmocha..."); + randomizer::utility::platform::Log("Starting libmocha..."); if (const MochaUtilsStatus status = Mocha_InitLibrary(); status != MOCHA_RESULT_SUCCESS) { @@ -56,7 +56,7 @@ bool initMocha() return false; } - tphdr::utility::platform::Log("Mocha initialized"); + randomizer::utility::platform::Log("Mocha initialized"); return true; } @@ -113,7 +113,7 @@ namespace utility { if (!MLCMounted) { - tphdr::utility::platform::Log("Attempting to mount MLC"); + randomizer::utility::platform::Log("Attempting to mount MLC"); if (const MochaUtilsStatus status = Mocha_MountFS("storage_mlc01", nullptr, "/vol/storage_mlc01"); status != MOCHA_RESULT_SUCCESS) { @@ -128,7 +128,7 @@ namespace utility { if (!USBMounted) { - tphdr::utility::platform::Log("Attempting to mount USB"); + randomizer::utility::platform::Log("Attempting to mount USB"); if (const MochaUtilsStatus status = Mocha_MountFS("storage_usb01", nullptr, "/vol/storage_usb01"); status != MOCHA_RESULT_SUCCESS) { @@ -143,7 +143,7 @@ namespace utility { if (!DiscMounted) { - tphdr::utility::platform::Log("Attempting to mount disc"); + randomizer::utility::platform::Log("Attempting to mount disc"); if (const MochaUtilsStatus status = Mocha_MountFS("storage_odd03", "/dev/odd03", "/vol/storage_odd_content"); status != MOCHA_RESULT_SUCCESS) { @@ -178,7 +178,7 @@ namespace utility } // namespace utility #endif -namespace tphdr::utility::platform +namespace randomizer::utility::platform { void Log(const std::string& str) { @@ -260,4 +260,4 @@ namespace tphdr::utility::platform waitForPlatformStop(); #endif } -} // namespace tphdr::utility::platform +} // namespace randomizer::utility::platform diff --git a/src/dusk/randomizer/utility/platform.hpp b/src/dusk/randomizer/utility/platform.hpp index 7e0a7977af..a4a5e3c020 100644 --- a/src/dusk/randomizer/utility/platform.hpp +++ b/src/dusk/randomizer/utility/platform.hpp @@ -16,7 +16,7 @@ #error UNKNOWN PLATFORM #endif -namespace tphdr::utility::platform +namespace randomizer::utility::platform { void Log(const std::string& str); diff --git a/src/dusk/randomizer/utility/random.cpp b/src/dusk/randomizer/utility/random.cpp index 64be6b9c1f..7631196e74 100644 --- a/src/dusk/randomizer/utility/random.cpp +++ b/src/dusk/randomizer/utility/random.cpp @@ -1,6 +1,6 @@ #include "../utility/random.hpp" -namespace tphdr::utility::random +namespace randomizer::utility::random { static bool init = false; static std::mt19937_64 generator; @@ -37,4 +37,4 @@ namespace tphdr::utility::random { return generator; } -} // namespace tphdr::utility::random +} // namespace randomizer::utility::random diff --git a/src/dusk/randomizer/utility/random.hpp b/src/dusk/randomizer/utility/random.hpp index ce55c213ae..8a256b5b81 100644 --- a/src/dusk/randomizer/utility/random.hpp +++ b/src/dusk/randomizer/utility/random.hpp @@ -7,7 +7,7 @@ #include #include -namespace tphdr::utility::random +namespace randomizer::utility::random { void RandomInit(size_t seed); uint32_t Random(int min, int max); @@ -57,4 +57,4 @@ namespace tphdr::utility::random std::swap(arr[i], arr[Random(i, arr.size())]); } } -} // namespace tphdr::utility::random +} // namespace randomizer::utility::random diff --git a/src/dusk/randomizer/utility/string.cpp b/src/dusk/randomizer/utility/string.cpp index 20797227bb..d995578bd1 100644 --- a/src/dusk/randomizer/utility/string.cpp +++ b/src/dusk/randomizer/utility/string.cpp @@ -6,7 +6,7 @@ #include #include -namespace tphdr::utility::str { +namespace randomizer::utility::str { //can't use codecvt on Wii U, deprecated in c++17 and g++ hates it //Borrowed from https://docs.microsoft.com/en-us/cpp/standard-library/codecvt-class?view=msvc-170#out std::string toUTF8(const std::u16string& str) { diff --git a/src/dusk/randomizer/utility/string.hpp b/src/dusk/randomizer/utility/string.hpp index 19954f26c1..34cd850ab0 100644 --- a/src/dusk/randomizer/utility/string.hpp +++ b/src/dusk/randomizer/utility/string.hpp @@ -10,7 +10,7 @@ #include #include -namespace tphdr::utility::str { +namespace randomizer::utility::str { std::string toUTF8(const std::u16string& str); std::u16string toUTF16(const std::string& str); @@ -107,7 +107,7 @@ namespace tphdr::utility::str { { for (const auto& token : {tokens...}) { - while (tphdr::utility::str::Contains(s, token)) + while (randomizer::utility::str::Contains(s, token)) { s.erase(s.find(token), strlen(token)); } diff --git a/src/dusk/randomizer/utility/text.cpp b/src/dusk/randomizer/utility/text.cpp index b6e556d390..256e2d592f 100644 --- a/src/dusk/randomizer/utility/text.cpp +++ b/src/dusk/randomizer/utility/text.cpp @@ -131,7 +131,7 @@ // std::string pad_str_4_lines(const std::string& string) // { -// std::vector lines = tphdr::utility::str::Split(string, '\n'); +// std::vector lines = randomizer::utility::str::Split(string, '\n'); // unsigned int padding_lines_needed = (4 - lines.size() % 4) % 4; // for (unsigned int i = 0; i < padding_lines_needed; i++) @@ -139,12 +139,12 @@ // lines.push_back(""); // } -// return tphdr::utility::str::Merge(lines, '\n'); +// return randomizer::utility::str::Merge(lines, '\n'); // } // std::u16string pad_str_4_lines(const std::u16string& string) // { -// std::vector lines = tphdr::utility::str::Split(string, u'\n'); +// std::vector lines = randomizer::utility::str::Split(string, u'\n'); // unsigned int padding_lines_needed = (4 - lines.size() % 4) % 4; // for (unsigned int i = 0; i < padding_lines_needed; i++) @@ -152,7 +152,7 @@ // lines.push_back(u""); // } -// return tphdr::utility::str::erge(lines, u'\n'); +// return randomizer::utility::str::erge(lines, u'\n'); // } // Gender string_to_gender(const std::string& str) diff --git a/src/dusk/randomizer/utility/time.cpp b/src/dusk/randomizer/utility/time.cpp index b98e44113a..d172827ef0 100644 --- a/src/dusk/randomizer/utility/time.cpp +++ b/src/dusk/randomizer/utility/time.cpp @@ -3,7 +3,7 @@ using namespace std::chrono; using namespace std::literals::chrono_literals; -namespace tphdr::utility::time +namespace randomizer::utility::time { ProgramTime::ProgramTime(): openTime(Clock_t::now()) {} @@ -22,10 +22,10 @@ namespace tphdr::utility::time { return Clock_t::now() - getOpenedTime(); } -} // namespace tphdr::utility::time +} // namespace randomizer::utility::time #if __has_include() && !defined(__APPLE__) #include -namespace tphdr::utility::time +namespace randomizer::utility::time { std::string ProgramTime::getDateStr() { @@ -36,11 +36,11 @@ namespace tphdr::utility::time { return std::format("{:%T}", round(getElapsedTime())); } -} // namespace tphdr::utility::time +} // namespace randomizer::utility::time #else #include #include -namespace tphdr::utility::time +namespace randomizer::utility::time { std::string ProgramTime::getDateStr() { @@ -71,9 +71,9 @@ namespace tphdr::utility::time return ret.str(); } -} // namespace tphdr::utility::time +} // namespace randomizer::utility::time #endif -namespace tphdr::utility::time +namespace randomizer::utility::time { static const ProgramTime& temp = ProgramTime::getInstance(); // inaccessible global to create instance when program starts -}; // namespace tphdr::utility::time +}; // namespace randomizer::utility::time diff --git a/src/dusk/randomizer/utility/time.hpp b/src/dusk/randomizer/utility/time.hpp index eaa0008ef7..464fbad576 100644 --- a/src/dusk/randomizer/utility/time.hpp +++ b/src/dusk/randomizer/utility/time.hpp @@ -5,12 +5,12 @@ #include "../utility/string.hpp" #include "../utility/platform.hpp" -namespace tphdr::utility::time +namespace randomizer::utility::time { template concept DurationType = std::same_as>; - template requires DurationType @@ -40,7 +40,7 @@ namespace tphdr::utility::time std::stringstream message; message << stem << (stem.back() == ' ' ? "" : " ") << std::chrono::duration_cast(duration); - tphdr::utility::platform::Log(message.str()); + randomizer::utility::platform::Log(message.str()); LOG_TO_DEBUG(message.str() + '\n'); } @@ -50,7 +50,7 @@ namespace tphdr::utility::time static constexpr std::string_view stem = Message; }; - template requires DurationType @@ -89,4 +89,4 @@ namespace tphdr::utility::time static std::string getDateStr(); }; -} // namespace tphdr::utility::time +} // namespace randomizer::utility::time diff --git a/src/dusk/randomizer/utility/yaml.hpp b/src/dusk/randomizer/utility/yaml.hpp index ced86b5d15..7abb0df0d0 100644 --- a/src/dusk/randomizer/utility/yaml.hpp +++ b/src/dusk/randomizer/utility/yaml.hpp @@ -10,7 +10,7 @@ // removes any possible path -> string oddities or the need to open the file manually inline YAML::Node LoadYAML(const fspath& path, const bool& resourceFile = false) { std::string file; - if (tphdr::utility::file::GetContents(path, file, resourceFile) != 0) { + if (randomizer::utility::file::GetContents(path, file, resourceFile) != 0) { throw YAML::BadFile( path.string()); // exception is bad (unhandled) but it matches the old behavior } @@ -26,4 +26,4 @@ void YAMLVerifyFields(const YAML::Node& node, Fields... requiredFields) { "\" is missing from node:\n" + YAML::Dump(node)); } } -} \ No newline at end of file +}