mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-09-02 10:47:10 -04:00
Fix seed generation crash (#7140)
Also fix excluded locations all colliding with TODO name
This commit is contained in:
@@ -146,7 +146,8 @@ static void WriteSettings() {
|
||||
auto ctx = Rando::Context::GetInstance();
|
||||
std::array<Rando::Option, RSK_MAX> options = Rando::Settings::GetInstance()->GetAllOptions();
|
||||
for (const Rando::Option& option : options) {
|
||||
if (option.GetName() != "") {
|
||||
// skip unassigned settings (RSK_NONE)
|
||||
if (option.GetOptionCount() > 0) {
|
||||
jsonData["settings"][option.GetName()] = option.GetOptionText(ctx->GetOption(option.GetKey()).Get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <libultraship/bridge/consolevariablebridge.h>
|
||||
|
||||
#include "option.h"
|
||||
#include "static_data.h"
|
||||
#include "soh/SohGui/SohMenu.h"
|
||||
#include "soh/Enhancements/Lang/Lang.h"
|
||||
#include <soh/cvar_prefixes.h>
|
||||
@@ -124,8 +125,6 @@ static const std::string& MakeTrickDescription(RandomizerTrick key) {
|
||||
|
||||
#pragma endregion
|
||||
|
||||
const static std::string todo = "TODO";
|
||||
|
||||
const std::string& Option::GetName() const {
|
||||
switch (this->GetCategory()) {
|
||||
case OptionCategory::Setting:
|
||||
@@ -134,7 +133,7 @@ const std::string& Option::GetName() const {
|
||||
case OptionCategory::Trick:
|
||||
return MakeTrickName(static_cast<RandomizerTrick>(this->key));
|
||||
case OptionCategory::LocationExclusion:
|
||||
return todo;
|
||||
return StaticData::GetLocation(static_cast<RandomizerCheck>(this->key))->GetName();
|
||||
default:
|
||||
assert(false);
|
||||
return error;
|
||||
@@ -149,7 +148,7 @@ const std::string& Option::GetDescription() const {
|
||||
case OptionCategory::Trick:
|
||||
return MakeTrickDescription(static_cast<RandomizerTrick>(this->key));
|
||||
case OptionCategory::LocationExclusion:
|
||||
return todo;
|
||||
return empty;
|
||||
default:
|
||||
assert(false);
|
||||
return error;
|
||||
@@ -165,6 +164,9 @@ uint8_t Option::GetMenuOptionDefault() const {
|
||||
}
|
||||
|
||||
const std::string& Option::GetOptionText(size_t index) const {
|
||||
if (options.empty()) {
|
||||
return empty;
|
||||
}
|
||||
if (index >= options.size()) {
|
||||
index = options.size() - 1;
|
||||
}
|
||||
|
||||
@@ -2556,7 +2556,10 @@ void Settings::CreateOptions() {
|
||||
std::unordered_map<std::string, RandomizerSettingKey> Settings::PopulateOptionNameToEnum() {
|
||||
std::unordered_map<std::string, RandomizerSettingKey> output = {};
|
||||
for (size_t count = 0; count < RSK_MAX; count++) {
|
||||
output[mOptions[count].GetName()] = static_cast<RandomizerSettingKey>(count);
|
||||
// skip unassigned settings (RSK_NONE)
|
||||
if (mOptions[count].GetOptionCount() > 0) {
|
||||
output[mOptions[count].GetName()] = static_cast<RandomizerSettingKey>(count);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user