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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions soh/soh/Enhancements/randomizer/entrance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace Rando {
EntranceLinkInfo NO_RETURN_ENTRANCE = { EntranceType::None, RR_NONE, RR_NONE, -1 };

Entrance::Entrance(RandomizerRegion connectedRegion_, ConditionFn condition_function_, bool spreadsAreasWithPriority_)
: connectedRegion(connectedRegion_), condition_function(condition_function_),
Entrance::Entrance(RandomizerRegion connectedRegion_, ConditionFn condition_function_, std::string condition_str_,
bool spreadsAreasWithPriority_)
: connectedRegion(connectedRegion_), condition_function(condition_function_), condition_str(condition_str_),
spreadsAreasWithPriority(spreadsAreasWithPriority_) {
originalConnectedRegion = connectedRegion_;
}
Expand Down Expand Up @@ -210,7 +211,8 @@ void Entrance::BindTwoWay(Entrance* otherEntrance) {
}

Entrance* Entrance::GetNewTarget() {
RegionTable(RR_ROOT)->AddExit(RR_ROOT, connectedRegion, [] { return true; });
RegionTable(RR_ROOT)->AddExit(
RR_ROOT, connectedRegion, [] { return true; }, "true");
Entrance* targetEntrance = RegionTable(RR_ROOT)->GetExit(connectedRegion);
targetEntrance->SetReplacement(this);
targetEntrance->SetName(RegionTable(RR_ROOT)->regionName + " -> " + GetConnectedRegion()->regionName);
Expand All @@ -229,6 +231,10 @@ bool Entrance::DoesSpreadAreas() {
return spreadsAreasWithPriority;
}

const std::string& Entrance::GetConditionStr() const {
return condition_str;
}

EntranceShuffler::EntranceShuffler() {
playthroughEntrances = {};
entranceOverrides = {};
Expand Down
9 changes: 8 additions & 1 deletion soh/soh/Enhancements/randomizer/entrance.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ enum class EntranceType {
All,
};

#define ENTRANCE(check, condition, ...) \
Entrance( \
RandomizerRegion::check, [] { return condition; }, CleanCheckConditionString(#condition), ##__VA_ARGS__)

class Entrance {
public:
Entrance(RandomizerRegion connectedRegion_, ConditionFn condition_function_, bool spreadsAreasWithPriority_ = true);
Entrance(RandomizerRegion connectedRegion_, ConditionFn condition_function_, std::string condition_str_,
bool spreadsAreasWithPriority_ = true);
void SetCondition(ConditionFn newCondition);
bool GetConditionsMet() const;
std::string to_string() const;
Expand Down Expand Up @@ -80,6 +85,7 @@ class Entrance {
Entrance* GetNewTarget();
Entrance* AssumeReachable();
bool DoesSpreadAreas();
const std::string& GetConditionStr() const;

private:
RandomizerRegion parentRegion;
Expand All @@ -101,6 +107,7 @@ class Entrance {
// If this is false, areas only spread to interiors through this entrance if there is no other choice
// Set to false for owl drops, the windmill path between dampe's grave and windmill and blue warps
bool spreadsAreasWithPriority = true;
std::string condition_str = "";
};

typedef struct {
Expand Down
11 changes: 6 additions & 5 deletions soh/soh/Enhancements/randomizer/location_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ bool Region::UpdateEvents() {
return eventsUpdated;
}

void Region::AddExit(RandomizerRegion parentKey, RandomizerRegion newExitKey, ConditionFn condition) {
Rando::Entrance newExit = Rando::Entrance(newExitKey, condition);
void Region::AddExit(RandomizerRegion parentKey, RandomizerRegion newExitKey, ConditionFn condition,
std::string conditionStr) {
Rando::Entrance newExit = Rando::Entrance(newExitKey, condition, conditionStr);
newExit.SetParentRegion(parentKey);
exits.push_front(newExit);
}
Expand Down Expand Up @@ -774,9 +775,9 @@ void RegionTable_Init() {
ctx = Context::GetInstance().get();
logic = ctx->GetLogic(); // RANDOTODO do not hardcode, instead allow accepting a Logic class somehow
grottoEvents = {
EventAccess(LOGIC_FAIRY_ACCESS, [] { return logic->CallGossipFairy() || logic->CanUse(RG_STICKS); }),
EventAccess(LOGIC_BUG_ACCESS, [] { return logic->CanCutShrubs(); }),
EventAccess(LOGIC_FISH_ACCESS, [] { return true; }),
EVENT_ACCESS(LOGIC_FAIRY_ACCESS, logic->CallGossipFairy() || logic->CanUse(RG_STICKS)),
EVENT_ACCESS(LOGIC_BUG_ACCESS, logic->CanCutShrubs()),
EVENT_ACCESS(LOGIC_FISH_ACCESS, true),
};
// Clear the array from any previous playthrough attempts. This is important so that
// locations which appear in both MQ and Vanilla dungeons don't get set in both areas.
Expand Down
22 changes: 19 additions & 3 deletions soh/soh/Enhancements/randomizer/location_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ extern std::shared_ptr<Rando::Logic> logic;

class Region;

#define EVENT_ACCESS(event, condition) \
EventAccess( \
event, #event, [] { return condition; }, CleanCheckConditionString(#condition))

class EventAccess {
public:
explicit EventAccess(LogicVal event_, ConditionFn condition_function_)
: event(event_), condition_function(condition_function_) {
explicit EventAccess(LogicVal event_, std::string event_str_, ConditionFn condition_function_,
std::string condition_str_)
: event(event_), event_str(event_str_), condition_function(condition_function_), condition_str(condition_str_) {
}

bool ConditionsMet() const {
Expand All @@ -44,9 +49,19 @@ class EventAccess {
return logic->Get(event);
}

const std::string& GetEventStr() const {
return event_str;
}

const std::string& GetConditionStr() const {
return condition_str;
}

private:
LogicVal event;
std::string event_str;
ConditionFn condition_function;
std::string condition_str;
};

std::string CleanCheckConditionString(std::string condition);
Expand Down Expand Up @@ -136,7 +151,8 @@ class Region {

bool UpdateEvents();

void AddExit(RandomizerRegion parentKey, RandomizerRegion newExitKey, ConditionFn condition);
void AddExit(RandomizerRegion parentKey, RandomizerRegion newExitKey, ConditionFn condition,
std::string conditionStr);

void RemoveExit(Rando::Entrance* exitToRemove);

Expand Down
Loading
Loading