Fix: Various Rando generation crashes (#3108)

* fix rando gen crash when not enough remaining items to place

* fix rando gen crash due to missing granny shop hint

* add error sound if rando gen fails
This commit is contained in:
Adam Bird
2023-08-11 23:06:38 -04:00
committed by GitHub
parent b2e9d547ba
commit 535157ce00
3 changed files with 14 additions and 5 deletions

View File

@@ -548,13 +548,13 @@ static void CalculateWotH() {
static void FastFill(std::vector<uint32_t> items, std::vector<uint32_t> locations, bool endOnItemsEmpty = false) {
//Loop until locations are empty, or also end if items are empty and the parameters specify to end then
while (!locations.empty() && (!endOnItemsEmpty || !items.empty())) {
uint32_t loc = RandomElement(locations, true);
Location(loc)->SetAsHintable();
PlaceItemInLocation(loc, RandomElement(items, true));
if (items.empty() && !endOnItemsEmpty) {
items.push_back(GetJunkItem());
}
uint32_t loc = RandomElement(locations, true);
Location(loc)->SetAsHintable();
PlaceItemInLocation(loc, RandomElement(items, true));
}
}