mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-05-31 09:31:26 -04:00
add excluded locations set
This commit is contained in:
@@ -516,12 +516,12 @@ void PrintOptionDescription() {
|
||||
printf("\x1b[22;0H%s", description.data());
|
||||
}
|
||||
|
||||
std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings) {
|
||||
std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations) {
|
||||
// if a blank seed was entered, make a random one
|
||||
srand(time(NULL));
|
||||
Settings::seed = std::to_string(rand());
|
||||
|
||||
int ret = Playthrough::Playthrough_Init(std::hash<std::string>{}(Settings::seed), cvarSettings);
|
||||
int ret = Playthrough::Playthrough_Init(std::hash<std::string>{}(Settings::seed), cvarSettings, excludedLocations);
|
||||
if (ret < 0) {
|
||||
if (ret == -1) { // Failed to generate after 5 tries
|
||||
printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be "
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
||||
|
||||
#define MAIN_MENU 0
|
||||
@@ -45,7 +46,7 @@ void PrintResetToDefaultsMenu();
|
||||
void PrintGenerateMenu();
|
||||
void ClearDescription();
|
||||
void PrintOptionDescription();
|
||||
std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings);
|
||||
std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSetting, std::set<RandomizerCheck> excludedLocations);
|
||||
std::string GetInput(const char* hintText);
|
||||
|
||||
extern void MenuInit();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Playthrough {
|
||||
|
||||
int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings) {
|
||||
int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations) {
|
||||
// initialize the RNG with just the seed incase any settings need to be
|
||||
// resolved to something random
|
||||
Random_Init(seed);
|
||||
@@ -21,7 +21,7 @@ int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uin
|
||||
HintReset();
|
||||
Areas::AccessReset();
|
||||
|
||||
Settings::UpdateSettings(cvarSettings);
|
||||
Settings::UpdateSettings(cvarSettings, excludedLocations);
|
||||
// once the settings have been finalized turn them into a string for hashing
|
||||
std::string settingsStr;
|
||||
for (Menu* menu : Settings::GetAllOptionMenus()) {
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "item_location.hpp"
|
||||
|
||||
namespace Playthrough {
|
||||
int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings);
|
||||
int Playthrough_Init(uint32_t seed, std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations);
|
||||
int Playthrough_Repeat(int count = 1);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#define TICKS_PER_SEC 268123480.0
|
||||
|
||||
void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarSettings) {
|
||||
void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarSettings, std::set<RandomizerCheck> excludedLocations) {
|
||||
HintTable_Init();
|
||||
ItemTable_Init();
|
||||
LocationTable_Init();
|
||||
@@ -21,7 +21,7 @@ void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarS
|
||||
// std::string settingsFileName = "./randomizer/latest_settings.json";
|
||||
// CVar_SetString("gLoadedPreset", settingsFileName.c_str());
|
||||
|
||||
std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings).c_str());
|
||||
std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations).c_str());
|
||||
CVar_SetString("gSpoilerLog", fileName.c_str());
|
||||
|
||||
CVar_Save();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace RandoMain {
|
||||
void GenerateRando(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings);
|
||||
void GenerateRando(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations);
|
||||
}
|
||||
|
||||
@@ -2483,7 +2483,7 @@ namespace Settings {
|
||||
}
|
||||
|
||||
//Function to set flags depending on settings
|
||||
void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings) {
|
||||
void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations) {
|
||||
|
||||
// RANDTODO: Switch this back once all logic options are implemented
|
||||
// Logic.SetSelectedIndex(cvarSettings[RSK_LOGIC_RULES]);
|
||||
|
||||
@@ -850,7 +850,7 @@ class Menu {
|
||||
};
|
||||
|
||||
namespace Settings {
|
||||
void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings);
|
||||
void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations);
|
||||
SettingsContext FillContext();
|
||||
void InitSettings();
|
||||
void SetDefaultSettings();
|
||||
|
||||
@@ -3587,7 +3587,9 @@ void GenerateRandomizerImgui() {
|
||||
|
||||
cvarSettings[RSK_SKULLS_SUNS_SONG] = CVar_GetS32("gRandomizeGsExpectSunsSong", 0);
|
||||
|
||||
RandoMain::GenerateRando(cvarSettings);
|
||||
std::set<RandomizerCheck> excludedLocations = { RC_UNKNOWN_CHECK };
|
||||
|
||||
RandoMain::GenerateRando(cvarSettings, excludedLocations);
|
||||
|
||||
CVar_SetS32("gRandoGenerating", 0);
|
||||
CVar_Save();
|
||||
|
||||
Reference in New Issue
Block a user