mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-30 23:10:14 -05:00
Attempt to find area problems (#4494)
* Better insulate the code against no areas and fix misc issues * remove a stray reminder comment
This commit is contained in:
parent
108d5061d4
commit
b706532754
@ -617,8 +617,8 @@ void LookForExternalArea(Region* currentRegion, std::set<Region*> &alreadyChecke
|
|||||||
//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()) && !alreadyChecked.contains(entrance->GetParentRegion())){
|
if ((LowPriorityMode || entrance->DoesSpreadAreas()) && !alreadyChecked.contains(entrance->GetParentRegion())){
|
||||||
std::set<RandomizerArea> otherAreas = entrance->GetParentRegion()->GetAllAreas();
|
std::set<RandomizerArea> otherAreas = entrance->GetParentRegion()->GetAllAreas();
|
||||||
alreadyChecked.insert(entrance->GetParentRegion());
|
|
||||||
if (otherAreas.size() == 0) {
|
if (otherAreas.size() == 0) {
|
||||||
|
alreadyChecked.insert(entrance->GetParentRegion());
|
||||||
LookForExternalArea(entrance->GetParentRegion(), alreadyChecked, areas, LowPriorityMode);
|
LookForExternalArea(entrance->GetParentRegion(), alreadyChecked, areas, LowPriorityMode);
|
||||||
//If we find a valid area we should 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.
|
||||||
|
@ -411,7 +411,7 @@ static bool CreateHint(RandomizerCheck location, uint8_t copies, HintType type,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RandomizerCheck gossipStone = RandomElement(gossipStoneLocations);
|
RandomizerCheck gossipStone = RandomElement(gossipStoneLocations);
|
||||||
RandomizerArea area = RandomElementFromSet(ctx->GetItemLocation(location)->GetAreas());
|
RandomizerArea area = ctx->GetItemLocation(location)->GetRandomArea();
|
||||||
|
|
||||||
//Set that hints are accesible
|
//Set that hints are accesible
|
||||||
ctx->GetItemLocation(location)->SetHintAccesible();
|
ctx->GetItemLocation(location)->SetHintAccesible();
|
||||||
@ -707,7 +707,7 @@ void CreateChildAltarHint() {
|
|||||||
}
|
}
|
||||||
std::vector<RandomizerArea> stoneAreas = {};
|
std::vector<RandomizerArea> stoneAreas = {};
|
||||||
for (auto loc : stoneLocs){
|
for (auto loc : stoneLocs){
|
||||||
stoneAreas.push_back(RandomElementFromSet(ctx->GetItemLocation(loc)->GetAreas()));
|
stoneAreas.push_back(ctx->GetItemLocation(loc)->GetRandomArea());
|
||||||
}
|
}
|
||||||
ctx->AddHint(RH_ALTAR_CHILD, Hint(RH_ALTAR_CHILD, HINT_TYPE_ALTAR_CHILD, {}, stoneLocs, stoneAreas));
|
ctx->AddHint(RH_ALTAR_CHILD, Hint(RH_ALTAR_CHILD, HINT_TYPE_ALTAR_CHILD, {}, stoneLocs, stoneAreas));
|
||||||
}
|
}
|
||||||
@ -729,7 +729,7 @@ void CreateAdultAltarHint() {
|
|||||||
}
|
}
|
||||||
std::vector<RandomizerArea> medallionAreas = {};
|
std::vector<RandomizerArea> medallionAreas = {};
|
||||||
for (auto loc : medallionLocs){
|
for (auto loc : medallionLocs){
|
||||||
medallionAreas.push_back(RandomElementFromSet(ctx->GetItemLocation(loc)->GetAreas()));
|
medallionAreas.push_back(ctx->GetItemLocation(loc)->GetRandomArea());
|
||||||
}
|
}
|
||||||
ctx->AddHint(RH_ALTAR_ADULT, Hint(RH_ALTAR_ADULT, HINT_TYPE_ALTAR_ADULT, {}, medallionLocs, medallionAreas));
|
ctx->AddHint(RH_ALTAR_ADULT, Hint(RH_ALTAR_ADULT, HINT_TYPE_ALTAR_ADULT, {}, medallionLocs, medallionAreas));
|
||||||
}
|
}
|
||||||
@ -753,7 +753,15 @@ void CreateStaticHintFromData(RandomizerHint hint, StaticHintInfo staticData){
|
|||||||
std::vector<RandomizerArea> areas = {};
|
std::vector<RandomizerArea> areas = {};
|
||||||
for (auto loc : locations){
|
for (auto loc : locations){
|
||||||
ctx->GetItemLocation(loc)->SetHintAccesible();
|
ctx->GetItemLocation(loc)->SetHintAccesible();
|
||||||
areas.push_back(RandomElementFromSet(ctx->GetItemLocation(loc)->GetAreas()));
|
if (ctx->GetItemLocation(loc)->GetAreas().empty()){
|
||||||
|
//If we get to here then it means a location got through with no area assignment, which means something went wrong elsewhere.
|
||||||
|
SPDLOG_DEBUG("Attempted to hint location with no areas: ");
|
||||||
|
SPDLOG_DEBUG(Rando::StaticData::GetLocation(loc)->GetName());
|
||||||
|
assert(false);
|
||||||
|
areas.push_back(RA_NONE);
|
||||||
|
} else {
|
||||||
|
areas.push_back(ctx->GetItemLocation(loc)->GetRandomArea());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//hintKeys are defaulted to in the hint object and do not need to be specified
|
//hintKeys are defaulted to in the hint object and do not need to be specified
|
||||||
ctx->AddHint(hint, Hint(hint, staticData.type, {}, locations, areas, {}, staticData.yourPocket, staticData.num));
|
ctx->AddHint(hint, Hint(hint, staticData.type, {}, locations, areas, {}, staticData.yourPocket, staticData.num));
|
||||||
@ -768,7 +776,7 @@ void CreateStaticItemHint(RandomizerHint hintKey, std::vector<RandomizerHintText
|
|||||||
std::vector<RandomizerCheck> locations = FindItemsAndMarkHinted(items, hintChecks);
|
std::vector<RandomizerCheck> locations = FindItemsAndMarkHinted(items, hintChecks);
|
||||||
std::vector<RandomizerArea> areas = {};
|
std::vector<RandomizerArea> areas = {};
|
||||||
for (auto loc : locations){
|
for (auto loc : locations){
|
||||||
areas.push_back(RandomElementFromSet(ctx->GetItemLocation(loc)->GetAreas()));
|
areas.push_back(ctx->GetItemLocation(loc)->GetRandomArea());
|
||||||
}
|
}
|
||||||
ctx->AddHint(hintKey, Hint(hintKey, HINT_TYPE_AREA, hintTextKeys, locations, areas, {}, yourPocket));
|
ctx->AddHint(hintKey, Hint(hintKey, HINT_TYPE_AREA, hintTextKeys, locations, areas, {}, yourPocket));
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ const T RandomElementFromSet(const std::set<T>& set) {
|
|||||||
for (uint32_t i = 0; i < rand; i++) {
|
for (uint32_t i = 0; i < rand; i++) {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
auto test = *it;
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,17 @@ RandomizerArea ItemLocation::GetFirstArea() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RandomizerArea ItemLocation::GetRandomArea() const {
|
||||||
|
if (areas.empty()){
|
||||||
|
SPDLOG_DEBUG("Attempted to get random area of location with no areas: ");
|
||||||
|
SPDLOG_DEBUG(Rando::StaticData::GetLocation(rc)->GetName());
|
||||||
|
assert(false);
|
||||||
|
return RA_NONE;
|
||||||
|
} else {
|
||||||
|
return RandomElementFromSet(areas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ItemLocation::PlaceVanillaItem() {
|
void ItemLocation::PlaceVanillaItem() {
|
||||||
placedItem = StaticData::GetLocation(rc)->GetVanillaItem();
|
placedItem = StaticData::GetLocation(rc)->GetVanillaItem();
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ class ItemLocation {
|
|||||||
void SetParentRegion (RandomizerRegion region);
|
void SetParentRegion (RandomizerRegion region);
|
||||||
std::set<RandomizerArea> GetAreas() const;
|
std::set<RandomizerArea> GetAreas() const;
|
||||||
RandomizerArea GetFirstArea() const;
|
RandomizerArea GetFirstArea() const;
|
||||||
|
RandomizerArea GetRandomArea() const;
|
||||||
void MergeAreas (std::set<RandomizerArea> newAreas);
|
void MergeAreas (std::set<RandomizerArea> newAreas);
|
||||||
void PlaceVanillaItem();
|
void PlaceVanillaItem();
|
||||||
void ApplyPlacedItemEffect() const;
|
void ApplyPlacedItemEffect() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user