Skip to content

Commit

Permalink
Fix hint generation bugs on develop-rando (HarbourMasters#4001)
Browse files Browse the repository at this point in the history
* Fix hint generation bugs on develop-rando

1. Fixed Ganon Non-hint text from loading as Saria's Magic Hint.
2. Fixed Ganon Non-hint text from not getting saved correctly.
3. Fixed gossip stone hint generation from not generating any non-always hints on No Logic.

For #3, the hint distribution and placement algorithm was bailing out too early when it wasn't able
to place a hint. For No Logic, what it was doing was failing to place WOTH hints (since No Logic seeds
don't calculate WOTH candidacy), returning the amount of hints it failed to place, and then it called
the function to redistribute the hints, but did not call the function to attempt to place the remaining hints.

Additionally, it was not accounting for the fact that we shouldn't redistribute the hints into the categories we failed to
place a hint in, so it would redistribute hints right back into those categories. I changed it so that when DistributeHints
gets called after PlaceHints fails to place the hint, it checks if the distribution settings copies attribute was set to 0.
In this case, it breaks while looping for the type distribution settings, and moves on to the next category. Also, it now repeatedly
attempts to distribute and place hints until PlaceHints returns 0 (meaning it placed all of its hints successfully).

* Fixes some further seed-bleed type issues with hint generation.
  • Loading branch information
leggettc18 authored Apr 22, 2024
1 parent 43e8eec commit 4c75fd1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions soh/soh/Enhancements/randomizer/3drando/hints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Text AutoFormatHintText(const Text& unformattedHintText, const std::vector<std::
strings[i] = textStr;
}

return {strings[0], strings[1], ""/*spanish*/, strings[2]};
return {strings[0], strings[2], ""/*spanish*/, strings[1]};
}

std::array<DungeonHintInfo, 10> dungeonInfoData;
Expand Down Expand Up @@ -615,6 +615,7 @@ void CreateGanonAndSheikText() {
}

ctx->AddHint(RH_GANONDORF_HINT, AutoFormatHintText(ganonHintText), lightArrowLocation[0], HINT_TYPE_STATIC, "Static", lightArrowArea);
ctx->AddHint(RH_GANONDORF_NOHINT, AutoFormatHintText(ganonText), lightArrowLocation[0], HINT_TYPE_STATIC, "Static", lightArrowArea);

if (!ctx->GetOption(RSK_TRIAL_COUNT).Is(0)) {
sheikText = ::Hint(RHT_SHEIK_LIGHT_ARROW_HINT).GetText() + LightArrowAreaText + "%w.";
Expand Down Expand Up @@ -963,7 +964,7 @@ static void DistributeHints(std::vector<uint8_t>& selected, size_t stoneCount, s
for (uint8_t distribution = 0; distribution < distTable.size(); distribution++){
currentWeight -= distTable[distribution].weight;
if (currentWeight <= 0){
if (stoneCount >= distTable[distribution].copies){
if (stoneCount >= distTable[distribution].copies || distTable[distribution].copies == 0){
selected[distribution] += 1;
stoneCount -= distTable[distribution].copies;
break;
Expand Down Expand Up @@ -1074,8 +1075,9 @@ void CreateStoneHints() {
while(totalStones != 0){
totalStones = PlaceHints(selectedHints, distTable);
if (totalStones != 0){
while (totalStones != 0){
DistributeHints(selectedHints, totalStones, distTable, hintSetting.junkWeight, false);
totalStones = PlaceHints(selectedHints, distTable);
}
}
Expand Down
10 changes: 8 additions & 2 deletions soh/soh/Enhancements/randomizer/3drando/text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ class Text {
: english(std::move(english_)),
french(std::move(french_)),
spanish(std::move(spanish_)),
german(std::move("")) {}
german(std::move("")) {
// german defaults to english text until a translation is provided.
german = english;
}
Text(std::string english_, std::string french_, std::string spanish_, std::string german_)
: english(std::move(english_)),
french(std::move(french_)),
spanish(std::move(spanish_)),
german(std::move(german_)) {}
Text(std::string english_) : english(std::move(english_)), french(std::move("")), spanish(std::move("")), german(std::move("")) {}
Text(std::string english_) : english(std::move(english_)), french(std::move("")), spanish(std::move("")), german(std::move("")) {
// default unprovided languages to english text
french = spanish = german = english;
}

const std::string& GetEnglish() const {
return english;
Expand Down
4 changes: 4 additions & 0 deletions soh/soh/Enhancements/randomizer/hint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const std::string& Hint::GetDistribution() {

void Hint::ResetVariables() {
hintedLocation = RC_UNKNOWN_CHECK;
text = Text{};
distribution = "";
hintedArea = RA_NONE;
hintType = HINT_TYPE_STATIC;
addedToPool = false;
}
}
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void Randomizer::LoadHintMessages() {
CustomMessage(ctx->GetHint(RH_GANONDORF_HINT)->GetText()));
CustomMessageManager::Instance->CreateMessage(
Randomizer::hintMessageTableID, TEXT_GANONDORF_NOHINT,
CustomMessage(ctx->GetHint(RH_SARIA)->GetText()));//RANDOTODO: Change to RH_BLANK or remove {{message}} replacment
CustomMessage(ctx->GetHint(RH_GANONDORF_NOHINT)->GetText()));
CustomMessageManager::Instance->CreateMessage(
Randomizer::hintMessageTableID, TEXT_SHEIK_NEED_HOOK,
CustomMessage("{{message}}", "{{message}}", "{{message}}"));
Expand Down

0 comments on commit 4c75fd1

Please sign in to comment.