From ff0b97a7c6e82cc9636b313c845753ba38629921 Mon Sep 17 00:00:00 2001 From: c-poole Date: Thu, 13 Jun 2024 00:30:52 -0500 Subject: [PATCH 1/5] Make Magnet Pull and Static apply to correct encounter types --- Source/Core/Gen3/Generators/WildGenerator3.cpp | 9 ++++++--- Source/Core/Gen3/Searchers/WildSearcher3.cpp | 13 +++++++++---- Source/Core/Gen3/Searchers/WildSearcher3.hpp | 3 ++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Source/Core/Gen3/Generators/WildGenerator3.cpp b/Source/Core/Gen3/Generators/WildGenerator3.cpp index 6f0e86ad..35999365 100644 --- a/Source/Core/Gen3/Generators/WildGenerator3.cpp +++ b/Source/Core/Gen3/Generators/WildGenerator3.cpp @@ -46,7 +46,10 @@ std::vector WildGenerator3::generate(u32 seed) const auto modifiedSlots = area.getSlots(lead); u16 rate = area.getRate() * 16; - bool rock = (profile.getVersion() & Game::RSE) != Game::None && area.getEncounter() == Encounter::RockSmash; + Encounter encounter = area.getEncounter(); + bool rock = (profile.getVersion() & Game::RSE) != Game::None && encounter == Encounter::RockSmash; + bool checkMagnetPull = lead == Lead::MagnetPull && encounter == Encounter::Grass; + bool checkStatic = lead == Lead::Static && (encounter == Encounter::Grass || encounter == Encounter::Surfing); bool feebas = area.feebasLocation(profile.getVersion()); bool safari = area.safariZone(profile.getVersion()); bool tanoby = area.tanobyChamber(profile.getVersion()); @@ -89,13 +92,13 @@ std::vector WildGenerator3::generate(u32 seed) const } else { - if ((lead == Lead::MagnetPull || lead == Lead::Static) && go.nextUShort(2) == 0 && !modifiedSlots.empty()) + if ((checkMagnetPull || checkStatic) && go.nextUShort(2) == 0 && !modifiedSlots.empty()) { encounterSlot = modifiedSlots[go.nextUShort()]; } else { - encounterSlot = EncounterSlot::hSlot(go.nextUShort(100), area.getEncounter()); + encounterSlot = EncounterSlot::hSlot(go.nextUShort(100), encounter); } } diff --git a/Source/Core/Gen3/Searchers/WildSearcher3.cpp b/Source/Core/Gen3/Searchers/WildSearcher3.cpp index aab74a2c..2996129c 100644 --- a/Source/Core/Gen3/Searchers/WildSearcher3.cpp +++ b/Source/Core/Gen3/Searchers/WildSearcher3.cpp @@ -68,7 +68,7 @@ WildSearcher3::WildSearcher3(Method method, Lead lead, bool feebasTile, const En { if ((profile.getVersion() & Game::RSE) != Game::None && area.getEncounter() == Encounter::RockSmash) { - rate = area.getRate() * 16; + rate = area.getRate() * 16 ; } } @@ -81,6 +81,8 @@ void WildSearcher3::startSearch(const std::array &min, const std::array &min, const std::array guard(mutex); results.insert(results.end(), states.begin(), states.end()); @@ -113,13 +115,16 @@ void WildSearcher3::startSearch(const std::array &min, const std::array WildSearcher3::search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, - bool tanoby) const + bool tanoby, bool ignoreLead) const { std::vector states; std::array ivs = { hp, atk, def, spa, spd, spe }; u32 seeds[6]; int size = LCRNGReverse::recoverPokeRNGIV(hp, atk, def, spa, spd, spe, seeds, method); + Lead effectiveLead = ignoreLead ? Lead::None: lead; + + for (int i = 0; i < size; i++) { PokeRNGR rng(seeds[i]); @@ -161,7 +166,7 @@ std::vector WildSearcher3::search(u8 hp, u8 atk, u8 def, u8 s PokeRNGR test[4] = { rng, rng, rng, rng }; bool valid[4] = { false, false, false, false }; - switch (lead) + switch (effectiveLead) { case Lead::None: if (tanoby) diff --git a/Source/Core/Gen3/Searchers/WildSearcher3.hpp b/Source/Core/Gen3/Searchers/WildSearcher3.hpp index 6c807095..10dbd0fc 100644 --- a/Source/Core/Gen3/Searchers/WildSearcher3.hpp +++ b/Source/Core/Gen3/Searchers/WildSearcher3.hpp @@ -72,10 +72,11 @@ class WildSearcher3 : public WildSearcher search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, bool tanoby) const; + std::vector search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, bool tanoby, bool ignoreLead) const; }; #endif // WILDSEARCHER3_HPP From e3bdb59bd5454cf40b1cb98887c6074704a1bada Mon Sep 17 00:00:00 2001 From: c-poole Date: Thu, 13 Jun 2024 00:48:58 -0500 Subject: [PATCH 2/5] undo un-intended trivial whitespace change --- Source/Core/Gen3/Searchers/WildSearcher3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Gen3/Searchers/WildSearcher3.cpp b/Source/Core/Gen3/Searchers/WildSearcher3.cpp index 2996129c..d144646a 100644 --- a/Source/Core/Gen3/Searchers/WildSearcher3.cpp +++ b/Source/Core/Gen3/Searchers/WildSearcher3.cpp @@ -68,7 +68,7 @@ WildSearcher3::WildSearcher3(Method method, Lead lead, bool feebasTile, const En { if ((profile.getVersion() & Game::RSE) != Game::None && area.getEncounter() == Encounter::RockSmash) { - rate = area.getRate() * 16 ; + rate = area.getRate() * 16; } } From c8ef123abf5cb97b8895e74980cdc3c0e05110a4 Mon Sep 17 00:00:00 2001 From: c-poole Date: Fri, 14 Jun 2024 00:22:52 -0500 Subject: [PATCH 3/5] undo bad implementation of fix --- Source/Core/Gen3/Generators/WildGenerator3.cpp | 9 +++------ Source/Core/Gen3/Searchers/WildSearcher3.cpp | 11 +++-------- Source/Core/Gen3/Searchers/WildSearcher3.hpp | 3 +-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Source/Core/Gen3/Generators/WildGenerator3.cpp b/Source/Core/Gen3/Generators/WildGenerator3.cpp index 35999365..6f0e86ad 100644 --- a/Source/Core/Gen3/Generators/WildGenerator3.cpp +++ b/Source/Core/Gen3/Generators/WildGenerator3.cpp @@ -46,10 +46,7 @@ std::vector WildGenerator3::generate(u32 seed) const auto modifiedSlots = area.getSlots(lead); u16 rate = area.getRate() * 16; - Encounter encounter = area.getEncounter(); - bool rock = (profile.getVersion() & Game::RSE) != Game::None && encounter == Encounter::RockSmash; - bool checkMagnetPull = lead == Lead::MagnetPull && encounter == Encounter::Grass; - bool checkStatic = lead == Lead::Static && (encounter == Encounter::Grass || encounter == Encounter::Surfing); + bool rock = (profile.getVersion() & Game::RSE) != Game::None && area.getEncounter() == Encounter::RockSmash; bool feebas = area.feebasLocation(profile.getVersion()); bool safari = area.safariZone(profile.getVersion()); bool tanoby = area.tanobyChamber(profile.getVersion()); @@ -92,13 +89,13 @@ std::vector WildGenerator3::generate(u32 seed) const } else { - if ((checkMagnetPull || checkStatic) && go.nextUShort(2) == 0 && !modifiedSlots.empty()) + if ((lead == Lead::MagnetPull || lead == Lead::Static) && go.nextUShort(2) == 0 && !modifiedSlots.empty()) { encounterSlot = modifiedSlots[go.nextUShort()]; } else { - encounterSlot = EncounterSlot::hSlot(go.nextUShort(100), encounter); + encounterSlot = EncounterSlot::hSlot(go.nextUShort(100), area.getEncounter()); } } diff --git a/Source/Core/Gen3/Searchers/WildSearcher3.cpp b/Source/Core/Gen3/Searchers/WildSearcher3.cpp index d144646a..aab74a2c 100644 --- a/Source/Core/Gen3/Searchers/WildSearcher3.cpp +++ b/Source/Core/Gen3/Searchers/WildSearcher3.cpp @@ -81,8 +81,6 @@ void WildSearcher3::startSearch(const std::array &min, const std::array &min, const std::array guard(mutex); results.insert(results.end(), states.begin(), states.end()); @@ -115,16 +113,13 @@ void WildSearcher3::startSearch(const std::array &min, const std::array WildSearcher3::search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, - bool tanoby, bool ignoreLead) const + bool tanoby) const { std::vector states; std::array ivs = { hp, atk, def, spa, spd, spe }; u32 seeds[6]; int size = LCRNGReverse::recoverPokeRNGIV(hp, atk, def, spa, spd, spe, seeds, method); - Lead effectiveLead = ignoreLead ? Lead::None: lead; - - for (int i = 0; i < size; i++) { PokeRNGR rng(seeds[i]); @@ -166,7 +161,7 @@ std::vector WildSearcher3::search(u8 hp, u8 atk, u8 def, u8 s PokeRNGR test[4] = { rng, rng, rng, rng }; bool valid[4] = { false, false, false, false }; - switch (effectiveLead) + switch (lead) { case Lead::None: if (tanoby) diff --git a/Source/Core/Gen3/Searchers/WildSearcher3.hpp b/Source/Core/Gen3/Searchers/WildSearcher3.hpp index 10dbd0fc..6c807095 100644 --- a/Source/Core/Gen3/Searchers/WildSearcher3.hpp +++ b/Source/Core/Gen3/Searchers/WildSearcher3.hpp @@ -72,11 +72,10 @@ class WildSearcher3 : public WildSearcher search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, bool tanoby, bool ignoreLead) const; + std::vector search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, bool feebas, bool safari, bool tanoby) const; }; #endif // WILDSEARCHER3_HPP From cd0fd43c2eb417188be73224eae158a55794845a Mon Sep 17 00:00:00 2001 From: c-poole Date: Fri, 14 Jun 2024 00:24:58 -0500 Subject: [PATCH 4/5] UI transparent fix --- Source/Form/Controls/ComboMenu.cpp | 4 ++-- Source/Form/Gen3/Wild3.cpp | 34 +++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Source/Form/Controls/ComboMenu.cpp b/Source/Form/Controls/ComboMenu.cpp index 4661f4b8..e06ece63 100644 --- a/Source/Form/Controls/ComboMenu.cpp +++ b/Source/Form/Controls/ComboMenu.cpp @@ -81,7 +81,7 @@ void ComboMenu::hideAction(const QVariant &data, bool hide) if (action->data() == data) { action->setVisible(!hide); - if (action->isChecked()) + if (action->isChecked() && hide) { clearSelection(); } @@ -95,7 +95,7 @@ void ComboMenu::hideAction(const QVariant &data, bool hide) if (menu) { auto menuActions = menu->actions(); - bool visible = std::all_of(menuActions.begin(), menuActions.end(), [](const QAction *action) { return action->isVisible(); }); + bool visible = std::any_of(menuActions.begin(), menuActions.end(), [](const QAction *action) { return action->isVisible(); }); menu->menuAction()->setVisible(visible); } } diff --git a/Source/Form/Gen3/Wild3.cpp b/Source/Form/Gen3/Wild3.cpp index efe905ed..91d4b5f0 100644 --- a/Source/Form/Gen3/Wild3.cpp +++ b/Source/Form/Gen3/Wild3.cpp @@ -197,22 +197,37 @@ void Wild3::generatorEncounterIndexChanged(int index) { case Encounter::Grass: ui->filterGenerator->setEncounterSlots(12); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), false); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), false); break; case Encounter::RockSmash: + ui->filterGenerator->setEncounterSlots(5); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); + break; case Encounter::Surfing: - case Encounter::SuperRod: ui->filterGenerator->setEncounterSlots(5); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), false); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::OldRod: ui->filterGenerator->setEncounterSlots(2); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::GoodRod: ui->filterGenerator->setEncounterSlots(3); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); + break; + case Encounter::SuperRod: + ui->filterGenerator->setEncounterSlots(5); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; default: break; } - updateEncounterGenerator(); std::vector locs; @@ -399,24 +414,37 @@ void Wild3::searcherEncounterIndexChanged(int index) { case Encounter::Grass: ui->filterSearcher->setEncounterSlots(12); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), false); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), false); break; case Encounter::RockSmash: + ui->filterSearcher->setEncounterSlots(5); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); + break; case Encounter::Surfing: ui->filterSearcher->setEncounterSlots(5); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), false); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::OldRod: ui->filterSearcher->setEncounterSlots(2); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::GoodRod: ui->filterSearcher->setEncounterSlots(3); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::SuperRod: ui->filterSearcher->setEncounterSlots(5); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; default: break; } - updateEncounterSearcher(); std::vector locs; From decc2b02c9d604145b6e6e1f56461f6e4246e1ac Mon Sep 17 00:00:00 2001 From: c-poole Date: Sun, 16 Jun 2024 00:12:21 -0500 Subject: [PATCH 5/5] simplify option toggling --- Source/Form/Gen3/Wild3.cpp | 48 +++++++++++--------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/Source/Form/Gen3/Wild3.cpp b/Source/Form/Gen3/Wild3.cpp index 91d4b5f0..bc77e7bb 100644 --- a/Source/Form/Gen3/Wild3.cpp +++ b/Source/Form/Gen3/Wild3.cpp @@ -197,37 +197,27 @@ void Wild3::generatorEncounterIndexChanged(int index) { case Encounter::Grass: ui->filterGenerator->setEncounterSlots(12); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), false); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), false); break; case Encounter::RockSmash: - ui->filterGenerator->setEncounterSlots(5); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); - break; case Encounter::Surfing: + case Encounter::SuperRod: ui->filterGenerator->setEncounterSlots(5); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), false); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::OldRod: ui->filterGenerator->setEncounterSlots(2); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::GoodRod: ui->filterGenerator->setEncounterSlots(3); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); - break; - case Encounter::SuperRod: - ui->filterGenerator->setEncounterSlots(5); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), true); break; default: break; } + + bool magnetPullOption = encounter == Encounter::Grass; + bool staticOption= encounter == Encounter::Grass || encounter == Encounter::Surfing; + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::MagnetPull), !magnetPullOption); + ui->comboMenuGeneratorLead->hideAction(toInt(Lead::Static), !staticOption); + updateEncounterGenerator(); std::vector locs; @@ -414,37 +404,27 @@ void Wild3::searcherEncounterIndexChanged(int index) { case Encounter::Grass: ui->filterSearcher->setEncounterSlots(12); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), false); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), false); break; case Encounter::RockSmash: - ui->filterSearcher->setEncounterSlots(5); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); - break; case Encounter::Surfing: + case Encounter::SuperRod: ui->filterSearcher->setEncounterSlots(5); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), false); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::OldRod: ui->filterSearcher->setEncounterSlots(2); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; case Encounter::GoodRod: ui->filterSearcher->setEncounterSlots(3); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); - break; - case Encounter::SuperRod: - ui->filterSearcher->setEncounterSlots(5); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), true); - ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), true); break; default: break; } + + bool magnetPullOption = encounter == Encounter::Grass; + bool staticOption= encounter == Encounter::Grass || encounter == Encounter::Surfing; + ui->comboMenuSearcherLead->hideAction(toInt(Lead::MagnetPull), !magnetPullOption); + ui->comboMenuSearcherLead->hideAction(toInt(Lead::Static), !staticOption); + updateEncounterSearcher(); std::vector locs;