mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-25 19:02:19 -05:00
Fix: seed srand on launch and fix spoiler log for seed testing generation (#2902)
This commit is contained in:
parent
0b47a19c2c
commit
cf42057842
@ -518,7 +518,7 @@ std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t>
|
||||
srand(time(NULL));
|
||||
// if a blank seed was entered, make a random one
|
||||
if (seedString.empty()) {
|
||||
Settings::seed = rand() & 0xFFFFFFFF;
|
||||
seedString = std::to_string(rand() % 0xFFFFFFFF);
|
||||
} else if (seedString.rfind("seed_testing_count", 0) == 0 && seedString.length() > 18) {
|
||||
int count;
|
||||
try {
|
||||
@ -530,17 +530,12 @@ std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t>
|
||||
}
|
||||
Playthrough::Playthrough_Repeat(cvarSettings, excludedLocations, count);
|
||||
return "";
|
||||
} else {
|
||||
try {
|
||||
uint32_t seedHash = boost::hash_32<std::string>{}(seedString);
|
||||
int seed = seedHash & 0xFFFFFFFF;
|
||||
Settings::seed = seed;
|
||||
Settings::seedString = seedString;
|
||||
} catch (...) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Settings::seedString = seedString;
|
||||
uint32_t seedHash = boost::hash_32<std::string>{}(Settings::seedString);
|
||||
Settings::seed = seedHash & 0xFFFFFFFF;
|
||||
|
||||
int ret = Playthrough::Playthrough_Init(Settings::seed, cvarSettings, excludedLocations);
|
||||
if (ret < 0) {
|
||||
if (ret == -1) { // Failed to generate after 5 tries
|
||||
|
@ -87,8 +87,9 @@ int Playthrough_Repeat(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSet
|
||||
printf("\x1b[0;0HGENERATING %d SEEDS", count);
|
||||
uint32_t repeatedSeed = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
repeatedSeed = rand() % 0xFFFFFFFF;
|
||||
Settings::seed = repeatedSeed;
|
||||
Settings::seedString = std::to_string(rand() % 0xFFFFFFFF);
|
||||
repeatedSeed = boost::hash_32<std::string>{}(Settings::seedString);
|
||||
Settings::seed = repeatedSeed % 0xFFFFFFFF;
|
||||
CitraPrint("testing seed: " + std::to_string(Settings::seed));
|
||||
ClearProgress();
|
||||
Playthrough_Init(Settings::seed, cvarSettings, excludedLocations);
|
||||
|
@ -3191,8 +3191,8 @@ void DrawRandoEditor(bool& open) {
|
||||
}
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
if (ImGui::Button("Generate Randomizer")) {
|
||||
GenerateRandomizer(CVarGetInteger("gRandoManualSeedEntry", 0) ? seedString : std::to_string(rand() & 0xFFFFFFFF).c_str());
|
||||
if (ImGui::Button("Generate Randomizer")) {
|
||||
GenerateRandomizer(CVarGetInteger("gRandoManualSeedEntry", 0) ? seedString : "");
|
||||
}
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
|
@ -782,6 +782,8 @@ extern "C" void InitOTR() {
|
||||
} else {
|
||||
CVarClear("gLetItSnow");
|
||||
}
|
||||
|
||||
srand(now);
|
||||
#ifdef ENABLE_CROWD_CONTROL
|
||||
CrowdControl::Instance = new CrowdControl();
|
||||
CrowdControl::Instance->Init();
|
||||
|
Loading…
Reference in New Issue
Block a user