diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 4f46e7791..1946810b2 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -50,6 +50,8 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPAR using namespace Ship; bool oldCursorState = true; +u8 generated; + #define EXPERIMENTAL() \ ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 50, 50, 255)); \ ImGui::Text("Experimental"); \ @@ -423,7 +425,6 @@ namespace SohImGui { }); Game::InitSettings(); - CVar_SetS32("gRandomizer", 0); CVar_SetS32("gRandoGenerating", 0); CVar_SetS32("gDroppedNewSpoilerFile", 0); Game::SaveSettings(); @@ -434,6 +435,12 @@ namespace SohImGui { Game::SaveSettings(); needs_save = false; } + + if (generated) { + generated = 0; + randoThread.join(); + } + ImGuiProcessEvent(event); } @@ -1041,6 +1048,8 @@ namespace SohImGui { if (ImGui::BeginMenu("Randomizer")) { + EnhancementCheckbox("Enable Randomizer", "gRandomizer"); + if (ImGui::Button("Generate Seed")) { if (CVar_GetS32("gRandoGenerating", 0) == 0) { randoThread = std::thread(&SohImGui::GenerateRandomizerImgui); @@ -1278,6 +1287,8 @@ namespace SohImGui { Game::SaveSettings(); Game::LoadSettings(); + + generated = 1; } void DrawFramebufferAndGameInput(void) { diff --git a/soh/include/randomizer/menu.cpp b/soh/include/randomizer/menu.cpp index 219cfd6fd..231eb128c 100644 --- a/soh/include/randomizer/menu.cpp +++ b/soh/include/randomizer/menu.cpp @@ -517,13 +517,8 @@ void PrintOptionDescription() { std::string GenerateRandomizer() { // if a blank seed was entered, make a random one - if (Settings::seed.empty()) { - Settings::seed = std::to_string(rand()); - } else if (Settings::seed.rfind("seed_testing_count", 0) == 0) { - const int count = std::stoi(Settings::seed.substr(18), nullptr); - Playthrough::Playthrough_Repeat(count); - return ""; - } + srand(time(NULL)); + Settings::seed = std::to_string(rand()); int ret = Playthrough::Playthrough_Init(std::hash{}(Settings::seed)); if (ret < 0) { diff --git a/soh/soh/Enhancements/randomizer.cpp b/soh/soh/Enhancements/randomizer.cpp index 90fe9d517..d3fe5fbfb 100644 --- a/soh/soh/Enhancements/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer.cpp @@ -1157,11 +1157,6 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); return; } - - if (success) { - CVar_SetS32("gRandomizer", 1); - Game::SaveSettings(); - } } GetItemID Randomizer::GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) { diff --git a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 28b587983..7c2470e72 100644 --- a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -83,7 +83,7 @@ void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.5f); this->futureActionFunc = func_80B858B4; if ((gSaveContext.eventChkInf[3] & 2 && !gSaveContext.n64ddFlag) || - (gSaveContext.n64ddFlag && Flags_GetTreasure(globalCtx, 0x1F))) { + (gSaveContext.n64ddFlag && Flags_GetTreasure(globalCtx, 0x1E))) { Actor_Kill(&this->actor); } break; @@ -120,18 +120,15 @@ void func_80B857D0(ItemEtcetera* this, GlobalContext* globalCtx) { void func_80B85824(ItemEtcetera* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if ((this->actor.params & 0xFF) == 1) { - gSaveContext.eventChkInf[3] |= 2; - Flags_SetSwitch(globalCtx, 0xB); - + if ((this->actor.params & 0xFF) == 7) { if (gSaveContext.n64ddFlag) { - Flags_SetTreasure(globalCtx, 0x1E); + Flags_SetTreasure(globalCtx, 0x1F); } } Actor_Kill(&this->actor); } else { if (gSaveContext.n64ddFlag) { - s32 getItemId = GetRandomizedItemId(GI_ARROW_FIRE, this->actor.id, this->actor.params, globalCtx->sceneNum); + s32 getItemId = GetRandomizedItemIdFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); func_8002F434(&this->actor, globalCtx, getItemId, 30.0f, 50.0f); } else { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); @@ -146,7 +143,7 @@ void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, 0xB); if (gSaveContext.n64ddFlag) { - Flags_SetTreasure(globalCtx, 0x1F); + Flags_SetTreasure(globalCtx, 0x1E); } } Actor_Kill(&this->actor); @@ -154,7 +151,7 @@ void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx) { if (0) {} // Necessary to match if (gSaveContext.n64ddFlag) { - s32 getItemId = GetRandomizedItemId(GI_LETTER_RUTO, this->actor.id, this->actor.params, globalCtx->sceneNum); + s32 getItemId = GetRandomizedItemIdFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); func_8002F434(&this->actor, globalCtx, getItemId, 30.0f, 50.0f); } else { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); @@ -234,9 +231,10 @@ void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx) { ItemEtcetera* this = (ItemEtcetera*)thisx; s32 type = this->actor.params & 0xFF; - if (gSaveContext.n64ddFlag && (type == ITEM_ETC_ARROW_FIRE || type == ITEM_ETC_LETTER)) { - this->giDrawId = GetItemModelFromId( - GetRandomizedItemId(this->getItemId, this->actor.id, this->actor.params, globalCtx->sceneNum)); + if (gSaveContext.n64ddFlag && (type == ITEM_ETC_ARROW_FIRE)) { + this->giDrawId = GetItemModelFromId(GetRandomizedItemIdFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE)); + } else if (gSaveContext.n64ddFlag && (type == ITEM_ETC_ARROW_FIRE)) { + this->giDrawId = GetItemModelFromId(GetRandomizedItemIdFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO)); } func_8002EBCC(&this->actor, globalCtx, 0); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 01a71ec2a..6003a0100 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -229,6 +229,7 @@ void DrawSeedHashSprites(FileChooseContext* this) { */ u8 generating; +u8 changedSeed; void FileChoose_UpdateMainMenu(GameState* thisx) { static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; @@ -245,13 +246,15 @@ void FileChoose_UpdateMainMenu(GameState* thisx) { Audio_PlayFanfare(NA_BGM_HORSE_GOAL); func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); generating = 0; + changedSeed = 1; return; } else if (generating) { return; } - if (CVar_GetS32("gDroppedNewSpoilerFile", 0) != 0 && !generating) { + if (CVar_GetS32("gDroppedNewSpoilerFile", 0) != 0 || changedSeed) { CVar_SetS32("gDroppedNewSpoilerFile", 0); + changedSeed = 0; const char* fileLoc = CVar_GetString("gSpoilerLog", ""); LoadItemLocations(fileLoc); } @@ -892,7 +895,9 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { s16 j; s16 deathCountSplit[3]; - DrawSeedHashSprites(this); + if (CVar_GetS32("gRandomizer", 0) != 0) { + DrawSeedHashSprites(this); + } if (1) {}