Fix randomizer seed generation and activation

This commit is contained in:
Luke Street
2026-08-21 11:15:10 -06:00
parent 932c3aaba7
commit 2cee0db91f
3 changed files with 14 additions and 5 deletions
+1 -3
View File
@@ -112,9 +112,7 @@ void event_remove_trade_item(ModContext*, const FlowEventContext* event, void*)
std::vector<uint8_t> encoded_text(const std::string& text) {
std::vector<uint8_t> result{text.begin(), text.end()};
if (result.empty() || result.back() != 0) {
result.push_back(0);
}
result.push_back(0);
return result;
}
+2 -1
View File
@@ -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<u32>();
std::vector<u16> 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<u32>();
flow.operation = flowNode["query"].as<std::string>();
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<u32>();
flow.operation = flowNode["event"].as<std::string>();
flow.next = source_reference(flowNode["next"]);
} else {
@@ -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;
}
}
}