mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-21 23:58:51 -05:00
Store seed string in the save, and use it for mirror mode & enemy rando (#3175)
This commit is contained in:
parent
d32d8836f8
commit
b6ce810d36
@ -316,6 +316,8 @@ typedef struct {
|
||||
/* */ RandomizerCheck ganonHintCheck;
|
||||
/* */ RandomizerCheck gregCheck;
|
||||
/* */ RandomizerCheck dampeCheck;
|
||||
/* */ char inputSeed[1024];
|
||||
/* */ u32 finalSeed;
|
||||
/* */ u8 seedIcons[5];
|
||||
/* */ u16 randomizerInf[9];
|
||||
/* */ u16 adultTradeItems;
|
||||
|
@ -234,7 +234,7 @@ extern "C" uint8_t GetRandomizedEnemy(PlayState* play, int16_t *actorId, f32 *po
|
||||
|
||||
EnemyEntry GetRandomizedEnemyEntry(uint32_t seed) {
|
||||
if (CVarGetInteger("gRandomizedEnemies", ENEMY_RANDOMIZER_OFF) == ENEMY_RANDOMIZER_RANDOM_SEEDED) {
|
||||
uint32_t finalSeed = seed + (gSaveContext.n64ddFlag ? (gSaveContext.seedIcons[0] + gSaveContext.seedIcons[1] + gSaveContext.seedIcons[2] + gSaveContext.seedIcons[3] + gSaveContext.seedIcons[4]) : gSaveContext.sohStats.fileCreatedAt);
|
||||
uint32_t finalSeed = seed + (gSaveContext.n64ddFlag ? gSaveContext.finalSeed : gSaveContext.sohStats.fileCreatedAt);
|
||||
Random_Init(finalSeed);
|
||||
}
|
||||
|
||||
|
@ -579,8 +579,7 @@ void UpdateMirrorModeState(int32_t sceneNum) {
|
||||
(sceneNum == SCENE_GANON_BOSS);
|
||||
|
||||
if (mirroredMode == MIRRORED_WORLD_RANDOM_SEEDED || mirroredMode == MIRRORED_WORLD_DUNGEONS_RANDOM_SEEDED) {
|
||||
uint32_t seed = sceneNum + (gSaveContext.n64ddFlag ? (gSaveContext.seedIcons[0] + gSaveContext.seedIcons[1] +
|
||||
gSaveContext.seedIcons[2] + gSaveContext.seedIcons[3] + gSaveContext.seedIcons[4]) : gSaveContext.sohStats.fileCreatedAt);
|
||||
uint32_t seed = sceneNum + (gSaveContext.n64ddFlag ? gSaveContext.finalSeed : gSaveContext.sohStats.fileCreatedAt);
|
||||
Random_Init(seed);
|
||||
}
|
||||
|
||||
|
@ -852,6 +852,7 @@ const char* SpoilerLog_Write(int language) {
|
||||
|
||||
jsonData["version"] = (char*) gBuildVersion;
|
||||
jsonData["seed"] = Settings::seedString;
|
||||
jsonData["finalSeed"] = Settings::seed;
|
||||
|
||||
// Write Hash
|
||||
int index = 0;
|
||||
|
@ -1509,6 +1509,12 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName, bool silent
|
||||
index++;
|
||||
}
|
||||
|
||||
std::string inputSeed = spoilerFileJson["seed"].get<std::string>();
|
||||
strncpy(gSaveContext.inputSeed, inputSeed.c_str(), sizeof(gSaveContext.inputSeed) - 1);
|
||||
gSaveContext.inputSeed[sizeof(gSaveContext.inputSeed) - 1] = 0;
|
||||
|
||||
gSaveContext.finalSeed = spoilerFileJson["finalSeed"].get<uint32_t>();
|
||||
|
||||
for (auto it = locationsJson.begin(); it != locationsJson.end(); ++it) {
|
||||
RandomizerCheck randomizerCheck = SpoilerfileCheckNameToEnum[it.key()];
|
||||
if (it->is_structured()) {
|
||||
|
@ -186,6 +186,12 @@ void SaveManager::LoadRandomizerVersion2() {
|
||||
SaveManager::Instance->LoadData("", gSaveContext.seedIcons[i]);
|
||||
});
|
||||
|
||||
std::string inputSeed;
|
||||
SaveManager::Instance->LoadData("inputSeed", inputSeed);
|
||||
memcpy(gSaveContext.inputSeed, inputSeed.c_str(), inputSeed.length() + 1);
|
||||
|
||||
SaveManager::Instance->LoadData("finalSeed", gSaveContext.finalSeed);
|
||||
|
||||
SaveManager::Instance->LoadArray("randoSettings", RSK_MAX, [&](size_t i) {
|
||||
gSaveContext.randoSettings[i].key = RandomizerSettingKey(i);
|
||||
SaveManager::Instance->LoadData("", gSaveContext.randoSettings[i].value);
|
||||
@ -294,6 +300,10 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, int sectionID, bool f
|
||||
SaveManager::Instance->SaveData("", saveContext->seedIcons[i]);
|
||||
});
|
||||
|
||||
SaveManager::Instance->SaveData("inputSeed", saveContext->inputSeed);
|
||||
|
||||
SaveManager::Instance->SaveData("finalSeed", saveContext->finalSeed);
|
||||
|
||||
SaveManager::Instance->SaveArray("randoSettings", RSK_MAX, [&](size_t i) {
|
||||
SaveManager::Instance->SaveData("", saveContext->randoSettings[i].value);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user