Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oversight in Static Hints, add some asserts #4488

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/3drando/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ static void CalculateWotH() {
//If removing this item and no other item caused the game to become unbeatable, then it is strictly necessary,
//so add it unless it is in Links Pocket or an isolated place.
auto itemLoc = ctx->GetItemLocation(ctx->playthroughLocations[i][j]);
if (itemLoc->IsHintable() && *itemLoc->GetAreas().begin() > RA_LINKS_POCKET &&
if (itemLoc->IsHintable() && itemLoc->GetFirstArea() > RA_LINKS_POCKET &&
!(IsBeatableWithout(ctx->playthroughLocations[i][j], true))) {
itemLoc->SetWothCandidate();
}
Expand Down
13 changes: 6 additions & 7 deletions soh/soh/Enhancements/randomizer/3drando/hints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,7 @@ void CreateWarpSongTexts() {
auto warpSongEntrances = GetShuffleableEntrances(EntranceType::WarpSong, false);
for (auto entrance : warpSongEntrances) {
//RANDOTODO make random
RandomizerArea destination = RA_NONE;
if (!entrance->GetConnectedRegion()->GetAllAreas().empty()){
destination = *entrance->GetConnectedRegion()->GetAllAreas().begin();
}
RandomizerArea destination = entrance->GetConnectedRegion()->GetFirstArea();
switch (entrance->GetIndex()) {
case 0x0600: // minuet RANDOTODO make into entrance hints when they are added
ctx->AddHint(RH_MINUET_WARP_LOC, Hint(RH_MINUET_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
Expand Down Expand Up @@ -748,12 +745,14 @@ void CreateStaticHintFromData(RandomizerHint hint, StaticHintInfo staticData){
std::vector<RandomizerCheck> locations = {};
if (staticData.targetItems.size() > 0){
locations = FindItemsAndMarkHinted(staticData.targetItems, staticData.hintChecks);
}
for(auto check: staticData.targetChecks){
ctx->GetItemLocation(check)->SetHintAccesible();
} else {
for(auto check: staticData.targetChecks){
locations.push_back(check);
}
}
std::vector<RandomizerArea> areas = {};
for (auto loc : locations){
ctx->GetItemLocation(loc)->SetHintAccesible();
areas.push_back(RandomElementFromSet(ctx->GetItemLocation(loc)->GetAreas()));
}
//hintKeys are defaulted to in the hint object and do not need to be specified
Expand Down
9 changes: 9 additions & 0 deletions soh/soh/Enhancements/randomizer/3drando/location_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ class Region {
return areas;
}

RandomizerArea GetFirstArea() const{
if (areas.empty()){
assert(false);
return RA_NONE;
} else {
return *areas.begin();
}
}

void ReplaceAreas(std::set<RandomizerArea> newAreas) {
areas = newAreas;
}
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/hint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void Hint::FillGapsInData(){
for(uint8_t c = 0; c < locations.size(); c++){
//if area matters for the hint, it should be specified and not left to this
if (fillAreas){
areas.push_back(*ctx->GetItemLocation(locations[c])->GetAreas().begin());
areas.push_back(ctx->GetItemLocation(locations[c])->GetFirstArea());
}
if (fillItems){
items.push_back(ctx->GetItemLocation(locations[c])->GetPlacedRandomizerGet());
Expand Down
9 changes: 9 additions & 0 deletions soh/soh/Enhancements/randomizer/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ std::set<RandomizerArea> ItemLocation::GetAreas() const {
return areas;
}

RandomizerArea ItemLocation::GetFirstArea() const {
if (areas.empty()){
assert(false);
return RA_NONE;
} else {
return *areas.begin();
}
}

void ItemLocation::PlaceVanillaItem() {
placedItem = StaticData::GetLocation(rc)->GetVanillaItem();
}
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/item_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ItemLocation {
RandomizerRegion GetParentRegionKey() const;
void SetParentRegion (RandomizerRegion region);
std::set<RandomizerArea> GetAreas() const;
RandomizerArea GetFirstArea() const;
void MergeAreas (std::set<RandomizerArea> newAreas);
void PlaceVanillaItem();
void ApplyPlacedItemEffect() const;
Expand Down
Loading