From 2cee0db91f7b0612ae0cb0e6d80b340bcbddcba5 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 21 Aug 2026 11:15:10 -0600 Subject: [PATCH] Fix randomizer seed generation and activation --- mods/randomizer/src/messages.cpp | 4 +--- mods/randomizer/src/randomizer_context.cpp | 3 ++- mods/randomizer/src/ui/rando_seed_generation.cpp | 12 +++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mods/randomizer/src/messages.cpp b/mods/randomizer/src/messages.cpp index 61c13e01ca..62b6850e1f 100644 --- a/mods/randomizer/src/messages.cpp +++ b/mods/randomizer/src/messages.cpp @@ -112,9 +112,7 @@ void event_remove_trade_item(ModContext*, const FlowEventContext* event, void*) std::vector encoded_text(const std::string& text) { std::vector result{text.begin(), text.end()}; - if (result.empty() || result.back() != 0) { - result.push_back(0); - } + result.push_back(0); return result; } diff --git a/mods/randomizer/src/randomizer_context.cpp b/mods/randomizer/src/randomizer_context.cpp index ede15583f8..1874f8923e 100644 --- a/mods/randomizer/src/randomizer_context.cpp +++ b/mods/randomizer/src/randomizer_context.cpp @@ -1467,7 +1467,6 @@ RandomizerContext WriteSeedData(randomizer::logic::world::World* world) { RandomizerContext::FlowNode flow{}; flow.type = parse_flow_node_type(flowNode["type"]); - flow.parameters = flowNode["parameters"].as(); std::vector patchIndices{}; if (customSection) { @@ -1493,6 +1492,7 @@ RandomizerContext WriteSeedData(randomizer::logic::world::World* world) { } if (flow.type == RandomizerContext::FlowNodeType::BRANCH) { + flow.parameters = flowNode["parameters"].as(); flow.operation = flowNode["query"].as(); for (const auto& result : flowNode["results"]) { flow.results.push_back(source_reference(result)); @@ -1503,6 +1503,7 @@ RandomizerContext WriteSeedData(randomizer::logic::world::World* world) { throw std::runtime_error("Flow branch has invalid parameters or results"); } } else if (flow.type == RandomizerContext::FlowNodeType::EVENT) { + flow.parameters = flowNode["parameters"].as(); flow.operation = flowNode["event"].as(); flow.next = source_reference(flowNode["next"]); } else { diff --git a/mods/randomizer/src/ui/rando_seed_generation.cpp b/mods/randomizer/src/ui/rando_seed_generation.cpp index 5daf9735d7..271eceaf54 100644 --- a/mods/randomizer/src/ui/rando_seed_generation.cpp +++ b/mods/randomizer/src/ui/rando_seed_generation.cpp @@ -25,6 +25,9 @@ static std::string generationStatusMsg{}; void OnDialogActionOK(ModContext* ctx, UiDialogHandle dialogHandle, void*) { mDoAud_seStartMenu(Z2SE_SY_MENU_BACK); + if (seedGenDialog == dialogHandle) { + seedGenDialog = 0; + } session::svc_mng.ui->dialog_close(ctx, dialogHandle); } @@ -63,6 +66,9 @@ static ModResult buildDialog() { } void GenerateRandomizerSeed() { + if (seedGenStatus.load() != SeedGenerateStatus::Ready) { + return; + } if (buildDialog() != MOD_OK) { return; } @@ -75,6 +81,10 @@ void GenerateRandomizerSeed() { ModResult UpdateSeedGenerationDialog() { if (seedGenDialog == 0) { + const auto status = seedGenStatus.load(); + if (status == SeedGenerateStatus::Success || status == SeedGenerateStatus::Error) { + seedGenStatus.store(SeedGenerateStatus::Ready); + } return MOD_OK; } @@ -101,4 +111,4 @@ ModResult UpdateSeedGenerationDialog() { return MOD_OK; } -} \ No newline at end of file +}