Attempt to fix improperly set areas (#4396)

* Fix obvious issues

* Fix another stupid oversight

* remove test vars
This commit is contained in:
Pepper0ni 2024-10-11 16:34:23 +01:00 committed by GitHub
parent 6e025588a5
commit 64ee12c11f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 17 deletions

View File

@ -613,14 +613,14 @@ void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAcce
void LookForExternalArea(Region* currentRegion, std::set<Region*> &alreadyChecked, std::set<RandomizerArea> &areas, bool LowPriorityMode=false){ void LookForExternalArea(Region* currentRegion, std::set<Region*> &alreadyChecked, std::set<RandomizerArea> &areas, bool LowPriorityMode=false){
for (const auto& entrance : currentRegion->entrances) { for (const auto& entrance : currentRegion->entrances) {
//if the region is arealess and hasn't already been checked, recursivly check what connects to it
//if this entrance does not pass areas, only process it if we are in low priority mode //if this entrance does not pass areas, only process it if we are in low priority mode
if (LowPriorityMode || entrance->DoesSpreadAreas()){ if ((LowPriorityMode || entrance->DoesSpreadAreas()) && !alreadyChecked.contains(entrance->GetParentRegion())){
std::set<RandomizerArea> otherAreas = entrance->GetParentRegion()->GetAllAreas(); std::set<RandomizerArea> otherAreas = entrance->GetParentRegion()->GetAllAreas();
//if the region is arealess and hasn't already been checked, recursivly check what connects to it alreadyChecked.insert(entrance->GetParentRegion());
if (otherAreas.size() == 0 && !alreadyChecked.contains(currentRegion)) { if (otherAreas.size() == 0) {
alreadyChecked.insert(entrance->GetParentRegion());
LookForExternalArea(entrance->GetParentRegion(), alreadyChecked, areas, LowPriorityMode); LookForExternalArea(entrance->GetParentRegion(), alreadyChecked, areas, LowPriorityMode);
//if we find an area and it's not links pocket, we should try and add it. //If we find a valid area we should add it.
//If it's Links Pocket or RA_NONE, do not propagate those, they are not real areas. //If it's Links Pocket or RA_NONE, do not propagate those, they are not real areas.
//This check is likely to fail if a region somehow is both in Link's Pocket and elsewhere, but this should never happen //This check is likely to fail if a region somehow is both in Link's Pocket and elsewhere, but this should never happen
} else if (*otherAreas.begin() > RA_LINKS_POCKET){ } else if (*otherAreas.begin() > RA_LINKS_POCKET){
@ -635,14 +635,14 @@ void SetAreas(){
//RANDOTODO give entrances an enum like RandomizerCheck, the give them all areas here, //RANDOTODO give entrances an enum like RandomizerCheck, the give them all areas here,
//then use those areas to not need to recursivly find ItemLocation areas when an identifying entrance's area //then use those areas to not need to recursivly find ItemLocation areas when an identifying entrance's area
for (int regionType = 0; regionType < RR_MARKER_AREAS_END; regionType++) { for (int regionType = 0; regionType < RR_MARKER_AREAS_END; regionType++) {
Region region = areaTable[regionType]; Region* region = &areaTable[regionType];
std::set<RandomizerArea> areas = region.GetAllAreas(); std::set<RandomizerArea> areas = region->GetAllAreas();
std::set<Region*> regionsToSet = {&region}; std::set<Region*> regionsToSet = {region};
if (areas.empty()) { if (areas.empty()) {
LookForExternalArea(&region, regionsToSet, areas); LookForExternalArea(region, regionsToSet, areas);
//If we found nothing, try again in low priority mode to try every entrance //If we found nothing, try again in low priority mode to try every entrance
if (areas.empty()) { if (areas.empty()) {
LookForExternalArea(&region, regionsToSet, areas, true); LookForExternalArea(region, regionsToSet, areas, true);
//If we still found nothing, we're disconnected, use RA_NONE to represent that //If we still found nothing, we're disconnected, use RA_NONE to represent that
if (areas.empty()){ if (areas.empty()){
areas.insert(RA_NONE); areas.insert(RA_NONE);

View File

@ -501,25 +501,28 @@ void CreateWarpSongTexts() {
auto warpSongEntrances = GetShuffleableEntrances(EntranceType::WarpSong, false); auto warpSongEntrances = GetShuffleableEntrances(EntranceType::WarpSong, false);
for (auto entrance : warpSongEntrances) { for (auto entrance : warpSongEntrances) {
//RANDOTODO make random //RANDOTODO make random
const auto destination = entrance->GetConnectedRegion()->GetAllAreas().begin(); RandomizerArea destination = RA_NONE;
if (!entrance->GetConnectedRegion()->GetAllAreas().empty()){
destination = *entrance->GetConnectedRegion()->GetAllAreas().begin();
}
switch (entrance->GetIndex()) { switch (entrance->GetIndex()) {
case 0x0600: // minuet RANDOTODO make into entrance hints when they are added 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})); ctx->AddHint(RH_MINUET_WARP_LOC, Hint(RH_MINUET_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
case 0x04F6: // bolero case 0x04F6: // bolero
ctx->AddHint(RH_BOLERO_WARP_LOC, Hint(RH_BOLERO_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {*destination})); ctx->AddHint(RH_BOLERO_WARP_LOC, Hint(RH_BOLERO_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
case 0x0604: // serenade case 0x0604: // serenade
ctx->AddHint(RH_SERENADE_WARP_LOC, Hint(RH_SERENADE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {*destination})); ctx->AddHint(RH_SERENADE_WARP_LOC, Hint(RH_SERENADE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
case 0x01F1: // requiem case 0x01F1: // requiem
ctx->AddHint(RH_REQUIEM_WARP_LOC, Hint(RH_REQUIEM_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {*destination})); ctx->AddHint(RH_REQUIEM_WARP_LOC, Hint(RH_REQUIEM_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
case 0x0568: // nocturne case 0x0568: // nocturne
ctx->AddHint(RH_NOCTURNE_WARP_LOC, Hint(RH_NOCTURNE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {*destination})); ctx->AddHint(RH_NOCTURNE_WARP_LOC, Hint(RH_NOCTURNE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
case 0x05F4: // prelude case 0x05F4: // prelude
ctx->AddHint(RH_PRELUDE_WARP_LOC, Hint(RH_PRELUDE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {*destination})); ctx->AddHint(RH_PRELUDE_WARP_LOC, Hint(RH_PRELUDE_WARP_LOC, HINT_TYPE_AREA, "", {RHT_WARP_SONG}, {}, {destination}));
break; break;
default: default:
break; break;