From 490e13616ed1205c34ac2ac3a8f1342495206f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Sun, 9 Aug 2026 18:02:47 +0000 Subject: [PATCH] fix warnings (#7051) --- soh/CMakeLists.txt | 4 +++ soh/soh/ActorDB.cpp | 2 +- soh/soh/Enhancements/boss-rush/BossRush.cpp | 2 +- .../cosmetics/CustomLogoTitle.cpp | 2 +- soh/soh/Enhancements/customequipment.cpp | 2 +- soh/soh/Enhancements/debugconsole.cpp | 4 +-- soh/soh/Enhancements/debugger/actorViewer.cpp | 6 ++-- .../Enhancements/debugger/debugSaveEditor.cpp | 13 +++++---- .../Enhancements/debugger/hookDebugger.cpp | 2 +- soh/soh/Enhancements/debugger/valueViewer.cpp | 13 +++++---- soh/soh/Enhancements/gameplaystats.cpp | 2 +- soh/soh/Enhancements/mod_menu.cpp | 4 ++- .../randomizer/3drando/item_pool.cpp | 2 +- .../randomizer/Messages/ItemMessages.cpp | 2 +- .../Enhancements/randomizer/Plandomizer.cpp | 4 +-- .../randomizer/ShuffleBeehives.cpp | 4 ++- soh/soh/Enhancements/randomizer/location.h | 2 -- soh/soh/Enhancements/randomizer/logic.cpp | 4 +-- soh/soh/Enhancements/randomizer/option.cpp | 10 +++---- .../Enhancements/randomizer/randomizer.cpp | 16 +++++----- .../randomizer/randomizer_check_tracker.cpp | 11 ++++--- .../randomizer/randomizer_entrance.c | 26 ----------------- .../randomizer/randomizer_entrance.h | 1 - .../randomizer_entrance_tracker.cpp | 3 ++ .../randomizer/randomizer_hint_tracker.cpp | 2 +- .../randomizer/randomizer_item_tracker.cpp | 8 ++--- soh/soh/Enhancements/randomizer/settings.cpp | 10 +++---- .../Enhancements/timesplits/TimeSplits.cpp | 5 +--- soh/soh/Enhancements/tts/tts.cpp | 16 +++++----- soh/soh/Extractor/Extract.cpp | 2 ++ soh/soh/Extractor/FastCrc32C.c | 2 +- soh/soh/GbiWrap.cpp | 10 ++++--- soh/soh/Network/Anchor/HookHandlers.cpp | 4 +-- soh/soh/Notification/Notification.cpp | 6 ++-- soh/soh/OTRGlobals.cpp | 2 +- soh/soh/SohGui/Menu.cpp | 9 ++++-- soh/soh/SohGui/ResolutionEditor.cpp | 13 ++++----- soh/soh/SohGui/SohMenu.cpp | 2 +- soh/soh/SohGui/UIWidgets.cpp | 4 +-- soh/soh/SohGui/UIWidgets.hpp | 6 ++-- soh/soh/resource/importer/SceneFactory.cpp | 2 +- soh/soh/stubs.c | 29 +++++++++++++++++-- soh/soh/util.cpp | 8 ++--- soh/soh/z_scene_otr.cpp | 6 ++-- 44 files changed, 148 insertions(+), 139 deletions(-) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index f63bf9c935..b7472c82fc 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -496,6 +496,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-unknown-pragmas # #pragma region is an editor folding marker, GCC doesn't know it $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types @@ -524,6 +525,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-unknown-pragmas # #pragma region is an editor folding marker, GCC doesn't know it $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types @@ -548,6 +550,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-return-type -Wno-narrowing -Wno-switch-outside-range + -Wno-unknown-pragmas # #pragma region is an editor folding marker, GCC doesn't know it $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types @@ -574,6 +577,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-unknown-pragmas # #pragma region is an editor folding marker, GCC doesn't know it $<$: -Werror-implicit-function-declaration -Wno-implicit-int diff --git a/soh/soh/ActorDB.cpp b/soh/soh/ActorDB.cpp index 2d36da12ed..4d8a1737aa 100644 --- a/soh/soh/ActorDB.cpp +++ b/soh/soh/ActorDB.cpp @@ -535,7 +535,7 @@ ActorDB::Entry& ActorDB::AddEntry(const ActorDBInit& init) { // Get the ActorDB::Entry for the given actor id. ActorDB::Entry& ActorDB::RetrieveEntry(const int id) { static Entry invalid; - if ((id < 0) || (id >= db.size())) { + if ((id < 0) || (static_cast(id) >= db.size())) { return invalid; } return db[id]; diff --git a/soh/soh/Enhancements/boss-rush/BossRush.cpp b/soh/soh/Enhancements/boss-rush/BossRush.cpp index 016be3ed73..7d73e74f32 100644 --- a/soh/soh/Enhancements/boss-rush/BossRush.cpp +++ b/soh/soh/Enhancements/boss-rush/BossRush.cpp @@ -301,7 +301,7 @@ void FileChoose_UpdateBossRushMenu(GameState* gameState) { void FileChoose_DrawBossRushMenuWindowContents(FileChooseContext* fileChooseContext) { OPEN_DISPS(fileChooseContext->state.gfxCtx); - uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language; + uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? (uint8_t)LANGUAGE_ENG : gSaveContext.language; uint8_t listOffset = fileChooseContext->bossRushOffset; int16_t textAlpha = fileChooseContext->bossRushUIAlpha; diff --git a/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp b/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp index 6b0119ebca..638916568d 100644 --- a/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp +++ b/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp @@ -124,7 +124,7 @@ extern "C" void CustomLogoTitle_Draw(TitleContext* titleContext, uint8_t logoToD extern "C" void CustomLogoTitle_Main(TitleContext* titleContext) { static uint8_t logosSeen = 0; - uint8_t logoToDraw; + uint8_t logoToDraw = LOGO_TO_DRAW_N64; if (CVAR_BOOTSEQUENCE_VALUE == BOOTSEQUENCE_DEFAULT) { if (logosSeen == 0) { diff --git a/soh/soh/Enhancements/customequipment.cpp b/soh/soh/Enhancements/customequipment.cpp index 00127311c5..40d2d21f39 100644 --- a/soh/soh/Enhancements/customequipment.cpp +++ b/soh/soh/Enhancements/customequipment.cpp @@ -633,7 +633,7 @@ static void RegisterCustomEquipment() { gSPDisplayList(play->state.gfxCtx->polyXlu.p++, resolvedBottle); if (player->itemAction >= PLAYER_IA_BOTTLE && - player->itemAction < PLAYER_IA_BOTTLE + std::size(bottleContentDLs)) { + player->itemAction < static_cast(PLAYER_IA_BOTTLE + std::size(bottleContentDLs))) { contentDL = bottleContentDLs[player->itemAction - PLAYER_IA_BOTTLE]; } diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 45dcebb0f5..5c959992d2 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -572,7 +572,7 @@ static bool StateSlotSelectHandler(std::shared_ptr Console, const ERROR_MESSAGE("[SOH] Unexpected arguments passed"); return 1; } - uint8_t slot; + int32_t slot; try { slot = std::stoi(args[1], nullptr, 10); @@ -581,7 +581,7 @@ static bool StateSlotSelectHandler(std::shared_ptr Console, const return 1; } - if (slot < 0) { + if (slot < 0 || slot > 2) { ERROR_MESSAGE("[SOH] Invalid slot passed. Slot must be between 0 and 2"); return 1; } diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index d06ff14aa1..dcc8345ef2 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -923,9 +923,9 @@ void ActorViewerWindow::DrawElement() { PushStyleCombobox(THEME_COLOR); if (ImGui::BeginCombo("Actor Type", acMapping[category])) { - for (int i = 0; i < acMapping.size(); i++) { + for (size_t i = 0; i < acMapping.size(); i++) { if (ImGui::Selectable(acMapping[i])) { - category = i; + category = static_cast(i); PopulateActorDropdown(category, list); break; } @@ -938,7 +938,7 @@ void ActorViewerWindow::DrawElement() { } if (ImGui::BeginCombo("Actor", filler.c_str())) { - for (int i = 0; i < list.size(); i++) { + for (size_t i = 0; i < list.size(); i++) { std::string label = std::to_string(i) + ": " + ActorDB::Instance->RetrieveEntry(list[i]->id).name; std::string description = GetActorDescription(list[i]->id); if (description != "") diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 70c06c7350..ab7b68dfee 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -320,7 +320,8 @@ static void DrawButtonItemSelector(const char* label, int buttonIndex, UIWidgets Player* player = GET_PLAYER(gPlayState); if (player != nullptr) { // Check item type and update corresponding equipment - if (slotEntry.id >= ITEM_SWORD_KOKIRI && slotEntry.id <= ITEM_SWORD_BROKEN) { + if ((slotEntry.id >= ITEM_SWORD_KOKIRI && slotEntry.id <= ITEM_SWORD_BGS) || + slotEntry.id == ITEM_SWORD_BROKEN) { player->currentSwordItemId = slotEntry.id; } else if (slotEntry.id >= ITEM_SHIELD_DEKU && slotEntry.id <= ITEM_SHIELD_MIRROR) { if (slotEntry.id == ITEM_SHIELD_DEKU) @@ -1901,7 +1902,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const PushStyleButton(Colors::DarkGray); auto value = (size_t)CUR_UPG_VALUE(categoryId); - uint8_t item = value < items.size() ? items[value] : ITEM_NONE; + uint8_t item = value < items.size() ? items[value] : (uint8_t)ITEM_NONE; const ItemMapEntry& slotEntry = itemMapping[item]; if (ImGui::ImageButton( slotEntry.name.c_str(), @@ -1996,11 +1997,11 @@ void DrawEquipmentTab() { if (i < 4) { isEquipped = (currentSword == equipmentValues[i]); } else if (i < 8) { - isEquipped = (currentShield == (PLAYER_SHIELD_DEKU + (i - 4))); + isEquipped = (currentShield == static_cast(PLAYER_SHIELD_DEKU + (i - 4))); } else if (i < 12) { - isEquipped = (currentTunic == (PLAYER_TUNIC_KOKIRI + (i - 8))); + isEquipped = (currentTunic == static_cast(PLAYER_TUNIC_KOKIRI + (i - 8))); } else { - isEquipped = (currentBoots == (PLAYER_BOOTS_KOKIRI + (i - 12))); + isEquipped = (currentBoots == static_cast(PLAYER_BOOTS_KOKIRI + (i - 12))); } PushStyleButton(Colors::DarkGray); @@ -2439,7 +2440,7 @@ void DrawDungeonItemsTab() { } UIWidgets::BeginCard(SohUtils::GetSceneName(dungeonIndex).c_str()); - ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), SohUtils::GetSceneName(dungeonIndex).c_str()); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "%s", SohUtils::GetSceneName(dungeonIndex).c_str()); // Map, Compass, Small Key, Boss Key (new order) DrawDungeonItemButton(ITEM_DUNGEON_MAP, dungeonIndex); diff --git a/soh/soh/Enhancements/debugger/hookDebugger.cpp b/soh/soh/Enhancements/debugger/hookDebugger.cpp index 1c554933e3..27db2b03af 100644 --- a/soh/soh/Enhancements/debugger/hookDebugger.cpp +++ b/soh/soh/Enhancements/debugger/hookDebugger.cpp @@ -22,7 +22,7 @@ void DrawHookRegisteringInfos(const char* hookName) { return; } - ImGui::Text("Total Registered: %d", numHooks); + ImGui::Text("Total Registered: %zu", numHooks); if (ImGui::BeginTable(("Table##" + std::string(hookName)).c_str(), 4, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | diff --git a/soh/soh/Enhancements/debugger/valueViewer.cpp b/soh/soh/Enhancements/debugger/valueViewer.cpp index af9d447cc1..5d2213f538 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -179,10 +179,11 @@ void ValueViewerWindow::DrawElement() { UIWidgets::CVarCheckbox("Enable Printing", CVAR_NAME, UIWidgets::CheckboxOptions().Color(THEME_COLOR)); ImGui::BeginGroup(); - static size_t selectedElement = -1; - std::string selectedElementText = (selectedElement == -1) ? "Select a value" - : (std::string(valueTable[selectedElement].name) + " (" + - std::string(valueTable[selectedElement].path) + ")"); + static size_t selectedElement = SIZE_MAX; + std::string selectedElementText = (selectedElement == SIZE_MAX) + ? "Select a value" + : (std::string(valueTable[selectedElement].name) + " (" + + std::string(valueTable[selectedElement].path) + ")"); UIWidgets::PushStyleCombobox(THEME_COLOR); if (ImGui::BeginCombo("##valueViewerElement", selectedElementText.c_str())) { for (size_t i = 0; i < valueTable.size(); i++) { @@ -202,11 +203,11 @@ void ValueViewerWindow::DrawElement() { UIWidgets::PopStyleCombobox(); ImGui::SameLine(); UIWidgets::PushStyleButton(THEME_COLOR); - if (selectedElement != -1 && ImGui::Button("+")) { + if (selectedElement != SIZE_MAX && ImGui::Button("+")) { valueViewerSettings.insert( { (ValueViewerEntry)selectedElement, { valueTable[selectedElement].prefix, ImVec4(1.0f, 1.0f, 1.0f, 1.0f), false, false, 0, 0 } }); - selectedElement = -1; + selectedElement = SIZE_MAX; SaveValueConfig(); } UIWidgets::PopStyleButton(); diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index a2179e2c56..de5da8ab11 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -388,7 +388,7 @@ void GameplayStatsRow(const char* label, const std::string& value, ImVec4 color ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(value.c_str()).x)); ImGui::Text("%s", value.c_str()); ImGui::PopStyleColor(); - if (tooltip != "" && ImGui::IsItemHovered()) { + if (tooltip[0] != '\0' && ImGui::IsItemHovered()) { ImGui::SetTooltip("%s", tooltip); } } diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index 7d14152814..39f807780f 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -102,7 +102,9 @@ void HandleModSelection(size_t index, const std::string& file) { const ImGuiIO& io = ImGui::GetIO(); if (io.KeyShift && lastSelectedModIndex >= 0 && lastSelectedModIndex < static_cast(enabledModFiles.size())) { - auto [startIndex, endIndex] = std::minmax(static_cast(lastSelectedModIndex), index); + const size_t lastIndex = static_cast(lastSelectedModIndex); + const size_t startIndex = std::min(lastIndex, index); + const size_t endIndex = std::max(lastIndex, index); selectedEnabledModFiles.clear(); for (size_t i = startIndex; i <= endIndex; i++) selectedEnabledModFiles.insert(enabledModFiles[i]); diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index 0aec234877..bc5f393e86 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -1117,7 +1117,7 @@ void GenerateItemPool() { if (junkToAdd > 0) { if (ctx->GetOption(RSK_ICE_TRAP_PERCENT).Is(100)) { iceTrapstoAdd = static_cast(junkToAdd); - } else if (ctx->GetOption(RSK_ICE_TRAP_PERCENT).Get() >= 0) { + } else if (ctx->GetOption(RSK_ICE_TRAP_PERCENT).Get() > 0) { for (size_t count = 0; count < junkToAdd; count++) { if (Random(0, 101) < ctx->GetOption(RSK_ICE_TRAP_PERCENT).Get()) { iceTrapstoAdd++; diff --git a/soh/soh/Enhancements/randomizer/Messages/ItemMessages.cpp b/soh/soh/Enhancements/randomizer/Messages/ItemMessages.cpp index c48184dacd..9ac6b09c16 100644 --- a/soh/soh/Enhancements/randomizer/Messages/ItemMessages.cpp +++ b/soh/soh/Enhancements/randomizer/Messages/ItemMessages.cpp @@ -244,7 +244,7 @@ void BuildMapMessage(uint16_t* textId, bool* loadFromMessageTable) { CustomMessage msg = CustomMessage("You found the %g[[name]]%w! [[typeHint]]", "Du erhältst das %g[[name]]%w! [[typeHint]]", "Vous ebtenez %g[[name]]%w! [[typeHint]]", TEXTBOX_TYPE_BLUE); - int sceneNum; + int sceneNum = -1; switch (itemEntry.getItemId) { case RG_DEKU_TREE_MAP: sceneNum = SCENE_DEKU_TREE; diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index c3a24d3d74..da32f3602d 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -995,7 +995,7 @@ void PlandomizerDrawOptions() { ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); ImGui::PopStyleVar(); if (upRet) { - if (hash + 1 >= gSeedTextures.size()) { + if (hash + 1 >= static_cast(gSeedTextures.size())) { hash = 0; } else { hash++; @@ -1017,7 +1017,7 @@ void PlandomizerDrawOptions() { hash--; } } - if (index != spoilerHash.size() - 1) { + if (static_cast(index) != spoilerHash.size() - 1) { ImGui::TableNextColumn(); } ImGui::PopID(); diff --git a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp index a5193cd23d..285ab5fcd3 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleBeehives.cpp @@ -25,7 +25,9 @@ void ObjComb_RandomizerChooseItemDrop(ObjComb* objComb, PlayState* play) { return; } - if ((params > 0) || (params < 0x1A)) { + // Vanilla is `(params > 0) || (params < 0x1A)`, which is always true; kept as-is to match + // ObjComb_ChooseItemDrop in soh/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c. + if (true) { if (params == 6) { if (Flags_GetCollectible(play, (objComb->actor.params >> 8) & 0x3F)) { params = -1; diff --git a/soh/soh/Enhancements/randomizer/location.h b/soh/soh/Enhancements/randomizer/location.h index c0249fcae3..258b1acc64 100644 --- a/soh/soh/Enhancements/randomizer/location.h +++ b/soh/soh/Enhancements/randomizer/location.h @@ -307,7 +307,6 @@ class Location { ActorID actorId; SceneID scene; int32_t actorParams; - bool checked = false; std::string shortName; std::string spoilerName; RandomizerHintTextKey hintKey; @@ -315,7 +314,6 @@ class Location { bool isVanillaCompletion; SpoilerCollectionCheck collectionCheck; int16_t vanillaPrice; - bool isHintable = false; Option excludedOption; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index 10c1acb9e9..af213f7fdf 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -2296,7 +2296,7 @@ void Logic::ApplyItemEffect(Item& item, bool state) { mSaveContext->magicLevel += (!state ? -1 : 1); } break; case RG_PROGRESSIVE_OCARINA: { - uint8_t i; + int32_t i; for (i = 0; i < 3; i++) { if (CurrentInventory(ITEM_OCARINA_FAIRY) == OcarinaLookup[i]) { break; @@ -2325,7 +2325,7 @@ void Logic::ApplyItemEffect(Item& item, bool state) { case RG_FIRE_ARROWS: case RG_ICE_ARROWS: case RG_LIGHT_ARROWS: - SetInventory(item.GetGIEntry()->itemId, (!state ? ITEM_NONE : item.GetGIEntry()->itemId)); + SetInventory(item.GetGIEntry()->itemId, (!state ? (uint16_t)ITEM_NONE : item.GetGIEntry()->itemId)); break; case RG_MAGIC_BEAN: case RG_MAGIC_BEAN_PACK: { diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index e789ce4598..f7817ed252 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -172,11 +172,11 @@ Option::Option(size_t key_, std::string name_, std::vector options_ bool defaultHidden_, WidgetFunc callback_, int imFlags_) : key(key_), name(std::move(name_)), options(std::move(options_)), category(category_), cvarName(std::move(cvarName_)), description(std::move(description_)), widgetType(widgetType_), - defaultOption(defaultOption_), defaultHidden(defaultHidden_), callback(callback_), imFlags(imFlags_) { + defaultOption(defaultOption_), defaultHidden(defaultHidden_), imFlags(imFlags_), callback(callback_) { contextSelection = defaultOption; hidden = defaultHidden; - for (int i = 0; i < options.size(); i++) { - optionsMap.emplace(i, options[i].c_str()); + for (size_t i = 0; i < options.size(); i++) { + optionsMap.emplace(static_cast(i), options[i].c_str()); } UIWidgets::LabelPositions labelPosition; switch (widgetType) { @@ -305,8 +305,8 @@ static std::string MakeTrickDescription(RandomizerTrick key) { TrickSetting::TrickSetting(RandomizerTrick key_, const RandomizerCheckQuest quest_, const RandomizerArea area_, std::set tags_, const std::string nameTag_) - : Option(key_, std::move(MakeTrickName(key_)), { "Disabled", "Enabled" }, OptionCategory::Setting, "", - std::move(MakeTrickDescription(key_)), WIDGET_CVAR_CHECKBOX, 0, false, nullptr, IMFLAG_NONE), + : Option(key_, MakeTrickName(key_), { "Disabled", "Enabled" }, OptionCategory::Setting, "", + MakeTrickDescription(key_), WIDGET_CVAR_CHECKBOX, 0, false, nullptr, IMFLAG_NONE), mQuest(quest_), mArea(area_), mNameTag(nameTag_), mTags(std::move(tags_)) { } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 90854a1051..e3355f4e80 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -107,7 +107,7 @@ std::unordered_map spoilerFileDungeonToScene = { #ifdef _MSC_VER #pragma optimize("", off) -#else +#elif defined(__GNUC__) && !defined(__clang__) #pragma GCC push_options #pragma GCC optimize("O0") #endif @@ -183,7 +183,7 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) { } #ifdef _MSC_VER #pragma optimize("", on) -#else +#elif defined(__GNUC__) && !defined(__clang__) #pragma GCC pop_options #endif @@ -1033,14 +1033,16 @@ void JoinRandoGenerationThread() { class ExtendedVanillaTableInvalidItemIdException : public std::exception { private: - s16 itemID; + std::string message; public: - ExtendedVanillaTableInvalidItemIdException(s16 itemID) : itemID(itemID) { + ExtendedVanillaTableInvalidItemIdException(s16 itemID) + : message(std::to_string(itemID) + + " is not a valid ItemID for the extendedVanillaGetItemTable. If you are adding a new " + "item, try adding it to randoGetItemTable instead.") { } - std::string what() { - return itemID + " is not a valid ItemID for the extendedVanillaGetItemTable. If you are adding a new" - "item, try adding it to randoGetItemTable instead."; + const char* what() const noexcept override { + return message.c_str(); } }; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 58c9db1820..4e2ac9fb12 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1888,9 +1888,6 @@ void LoadSettings() { bool IsCheckShuffled(RandomizerCheck rc) { Rando::Location* loc = Rando::StaticData::GetLocation(rc); - if (loc->GetRCType() == RCTYPE_SHOP) { - auto identity = OTRGlobals::Instance->gRandomizer->IdentifyShopItem(loc->GetScene(), loc->GetActorParams() + 1); - } if (IS_RANDO) { return (loc->GetArea() != RCAREA_INVALID) && // don't show Invalid locations (loc->GetRCType() != RCTYPE_GOSSIP_STONE) && // TODO: Don't show hints until tracker supports them @@ -2017,7 +2014,7 @@ void UpdateAllAreas() { void UpdateAreas(RandomizerCheckArea area) { if (checksByArea.contains(area)) { - areasFullyChecked[area] = areaChecksGotten[area] == checksByArea.find(area)->second.size(); + areasFullyChecked[area] = static_cast(areaChecksGotten[area]) == checksByArea.find(area)->second.size(); } } @@ -2125,8 +2122,8 @@ bool IsMysteryShopItem(RandomizerCheck rc) { } void DrawLocation(RandomizerCheck rc) { - Color_RGBA8 mainColor; - Color_RGBA8 extraColor; + Color_RGBA8 mainColor = Color_Unchecked_Main; + Color_RGBA8 extraColor = Color_Unchecked_Extra; std::string txt; Rando::Location* loc = Rando::StaticData::GetLocation(rc); Rando::ItemLocation* itemLoc = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc); @@ -2262,6 +2259,8 @@ void DrawLocation(RandomizerCheck rc) { if (status != RCSHOW_UNCHECKED) { switch (status) { + case RCSHOW_UNCHECKED: + break; case RCSHOW_SAVED: case RCSHOW_COLLECTED: case RCSHOW_SCUMMED: diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance.c b/soh/soh/Enhancements/randomizer/randomizer_entrance.c index b5e39ed39d..3e1d5486ca 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance.c +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance.c @@ -498,32 +498,6 @@ void Entrance_OverrideBlueWarp(void) { } } -void Entrance_EnableFW(void) { - Player* player = GET_PLAYER(gPlayState); - // Leave restriction in Tower Collapse Interior, Castle Collapse, Treasure Box Shop, Tower Collapse Exterior, - // Grottos area, Fishing Pond, Ganon Battle and for states that disable buttons. - if (!false /* farores wind anywhere */ || gPlayState->sceneNum == SCENE_GANONS_TOWER_COLLAPSE_INTERIOR || - gPlayState->sceneNum == SCENE_INSIDE_GANONS_CASTLE_COLLAPSE || - (gPlayState->sceneNum == SCENE_TREASURE_BOX_SHOP && !false /* shuffled chest mini game */) || - gPlayState->sceneNum == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR || gPlayState->sceneNum == SCENE_GROTTOS || - gPlayState->sceneNum == SCENE_FISHING_POND || gPlayState->sceneNum == SCENE_GANON_BOSS || - gSaveContext.eventInf[0] & 0x1 || // Ingo's Minigame state - player->stateFlags1 & - (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LADDER | PLAYER_STATE1_ON_HORSE | - PLAYER_STATE1_IN_WATER) || // Swimming, riding horse, Down A, hanging from a ledge - player->stateFlags2 & PLAYER_STATE2_CRAWLING // Blank A - // Shielding, spinning and getting skull tokens still disable buttons automatically - ) { - return; - } - - for (size_t i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { - if (gSaveContext.equips.buttonItems[i] == ITEM_FARORES_WIND) { - gSaveContext.buttonStatus[i] = BTN_ENABLED; - } - } -} - // Check if Link should still be riding epona after changing entrances void Entrance_HandleEponaState(void) { s32 entrance = gPlayState->nextEntranceIndex; diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance.h b/soh/soh/Enhancements/randomizer/randomizer_entrance.h index ec770b1142..7b87ce4914 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance.h +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance.h @@ -50,7 +50,6 @@ void Entrance_OverrideWeatherState(void); void Entrance_OverrideGerudoGuardCapture(void); void Entrance_OverrideSpawnScene(int32_t sceneNum, int32_t spawn); int32_t Entrance_OverrideSpawnSceneRoom(int32_t sceneNum, int32_t spawn, int32_t room); -void Entrance_EnableFW(void); uint8_t Entrance_GetIsEntranceDiscovered(uint16_t entranceIndex); void Entrance_SetEntranceDiscovered(uint16_t entranceIndex, uint8_t isReversedEntrance); #ifdef __cplusplus diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index 7a6b9ca6fc..ed9dc844e9 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -898,6 +898,9 @@ void EntranceTrackerWindow::DrawElement() { case ENTRANCE_DESTINATION_TYPE: entranceList = destListSortedByType; break; + default: + assert(false); + return; } // Begin tracker list diff --git a/soh/soh/Enhancements/randomizer/randomizer_hint_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_hint_tracker.cpp index 7efb27405f..0449f7f958 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_hint_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_hint_tracker.cpp @@ -801,7 +801,7 @@ void RegisterHintTrackerWidgets() { .Options(ColorPickerOptions().Color(THEME_COLOR).DefaultValue(Color_ReadText_Default).UseAlpha().ShowReset()); SohGui::GetSohMenu()->AddSearchWidget({ readTextColorWidget, "Randomizer", "Hint Tracker", "General Settings" }); - unreadColorWidget = { .name = "Unread (???)##HintTracker", .type = WidgetType::WIDGET_CVAR_COLOR_PICKER }; + unreadColorWidget = { .name = "Unread (?\?\?)##HintTracker", .type = WidgetType::WIDGET_CVAR_COLOR_PICKER }; unreadColorWidget.CVar(CVAR_TRACKER_HINT("UnreadColor")) .Options(ColorPickerOptions().Color(THEME_COLOR).DefaultValue(Color_Unread_Default).UseAlpha().ShowReset()); SohGui::GetSohMenu()->AddSearchWidget({ unreadColorWidget, "Randomizer", "Hint Tracker", "General Settings" }); diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index b26c197a53..248dab9c2d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -51,8 +51,6 @@ std::vector mainWindowItems = {}; static WidgetInfo backgroundColor; static WidgetInfo windowTypeWidget; -static WidgetInfo enableDraggingWidget; -static WidgetInfo onlyPausedWidget; static WidgetInfo ammoTracking; static WidgetInfo keyTracking; static WidgetInfo triforcePieceCount; @@ -876,7 +874,7 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) { ImGui::PopStyleColor(); } else { ImGui::SetCursorScreenPos(ImVec2(p.x, p.y - 14)); - ImGui::Text(""); + ImGui::TextUnformatted(""); } } @@ -926,7 +924,7 @@ bool HasBossSoul(RandomizerInf bossSoul) { void DrawItem(ItemTrackerItem item) { uint32_t actualItemId = - GameInteractor::IsSaveLoaded() && item.kind == ITEM_KIND_ITEM ? INV_CONTENT(item.id) : ITEM_NONE; + GameInteractor::IsSaveLoaded() && item.kind == ITEM_KIND_ITEM ? INV_CONTENT(item.id) : (uint8_t)ITEM_NONE; float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); bool hasItem = actualItemId != ITEM_NONE; bool hideMax = false; @@ -2235,8 +2233,6 @@ void RegisterItemTrackerWidgets() { .ComboMap(windowType)) .Callback([](WidgetInfo& info) { RefreshItemTrackerMainWindow(); }); SohGui::mSohMenu->AddSearchWidget({ windowTypeWidget, "Randomizer", "Item Tracker", "General Settings" }); - enableDraggingWidget; - onlyPausedWidget; ammoTracking = { .name = "Ammo/Capacity Tracking", .type = WidgetType::WIDGET_CVAR_COMBOBOX }; ammoTracking.CVar(CVAR_TRACKER_ITEM("ItemCountType")) diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 5fa3cbbf9e..1f2d75a30d 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -145,7 +145,7 @@ void Settings::HandleKeyringUI() { const bool chestGameKeyring = CVarGetInteger(CVAR_RANDOMIZER_SETTING("ShuffleChestMinigame"), RO_GENERIC_OFF) != RO_GENERIC_OFF; const uint8_t maxKeyringCount = 8 + fortressKeyring + chestGameKeyring; - if (mOptions[RSK_KEYRINGS_RANDOM_COUNT].GetOptionCount() != maxKeyringCount + 1) { + if (mOptions[RSK_KEYRINGS_RANDOM_COUNT].GetOptionCount() != static_cast(maxKeyringCount) + 1) { mOptions[RSK_KEYRINGS_RANDOM_COUNT].ChangeOptions(NumOpts(0, maxKeyringCount)); } if (fortressKeyring) { @@ -435,16 +435,16 @@ void Settings::CreateOptions() { } else { mOptions[RSK_TRIFORCE_HUNT_PIECES_LOCATION].Unhide(); } - if (mOptions[RSK_RAINBOW_BRIDGE_TRIFORCE_COUNT].GetOptionCount() != triforceTotal + 1) { + if (mOptions[RSK_RAINBOW_BRIDGE_TRIFORCE_COUNT].GetOptionCount() != static_cast(triforceTotal) + 1) { mOptions[RSK_RAINBOW_BRIDGE_TRIFORCE_COUNT].ChangeOptions(NumOpts(0, triforceTotal)); } - if (mOptions[RSK_GBK_TRIFORCE_COUNT].GetOptionCount() != triforceTotal + 1) { + if (mOptions[RSK_GBK_TRIFORCE_COUNT].GetOptionCount() != static_cast(triforceTotal) + 1) { mOptions[RSK_GBK_TRIFORCE_COUNT].ChangeOptions(NumOpts(0, triforceTotal)); } - if (mOptions[RSK_GANONS_SOUL_TRIFORCE_COUNT].GetOptionCount() != triforceTotal + 1) { + if (mOptions[RSK_GANONS_SOUL_TRIFORCE_COUNT].GetOptionCount() != static_cast(triforceTotal) + 1) { mOptions[RSK_GANONS_SOUL_TRIFORCE_COUNT].ChangeOptions(NumOpts(0, triforceTotal)); } - if (mOptions[RSK_WINCON_TRIFORCE_COUNT].GetOptionCount() != triforceTotal + 1) { + if (mOptions[RSK_WINCON_TRIFORCE_COUNT].GetOptionCount() != static_cast(triforceTotal) + 1) { mOptions[RSK_WINCON_TRIFORCE_COUNT].ChangeOptions(NumOpts(0, triforceTotal)); } }); diff --git a/soh/soh/Enhancements/timesplits/TimeSplits.cpp b/soh/soh/Enhancements/timesplits/TimeSplits.cpp index 9376419e9b..57939d3741 100644 --- a/soh/soh/Enhancements/timesplits/TimeSplits.cpp +++ b/soh/soh/Enhancements/timesplits/TimeSplits.cpp @@ -510,9 +510,7 @@ void TimeSplitsPopUpContext() { if (popupObject.splitType == SPLIT_TYPE_UPGRADE) { if (popupID <= ITEM_SLINGSHOT && popupID != -1) { - ImVec2 imageMin = ImGui::GetItemRectMin(); ImVec2 imageMax = ImGui::GetItemRectMax(); - // ImVec2 imageSize = ImVec2(imageMax.x - imageMin.x, imageMax.y - imageMin.y); UNUSED ImVec2 textPos = ImVec2(imageMax.x - ImGui::CalcTextSize("00").x - 5, imageMax.y - ImGui::CalcTextSize("00").y - 5); @@ -563,7 +561,7 @@ void TimeSplitsItemSplitEvent(uint32_t type, u8 item) { } if (item == ITEM_SKULL_TOKEN) { auto it = std::find_if(splitList.begin(), splitList.end(), [item](const SplitObject& split) { - if (split.splitSkullTokenCount == gSaveContext.inventory.gsTokens) { + if (split.splitSkullTokenCount == static_cast(gSaveContext.inventory.gsTokens)) { return split.splitID == item; } else { return split.splitID == ITEM_NONE; @@ -1005,7 +1003,6 @@ void TimeSplitWindow::InitElement() { }); GameInteractor::Instance->RegisterGameHook([](GetItemEntry itemEntry) { - GetItemEntry testItem = itemEntry; if (itemEntry.itemId == ITEM_SKULL_TOKEN || itemEntry.itemId == ITEM_BOTTLE || itemEntry.itemId == ITEM_POE || itemEntry.itemId == ITEM_BIG_POE) { uint32_t tempType = SPLIT_TYPE_ITEM; diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 8bd411a5ee..5dddb1845e 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -139,7 +139,7 @@ void RegisterOnInterfaceUpdateHook() { uint32_t minutes = timer / 60; uint32_t seconds = timer % 60; char* announceBuf = ttsAnnounceBuf; - char arg[8]; // at least big enough where no s8 string will overflow + char arg[16]; // big enough for any number formatted below if (minutes > 0) { snprintf(arg, sizeof(arg), "%d", minutes); auto translation = @@ -340,7 +340,7 @@ void RegisterOnKaleidoscopeUpdateHook() { } if ((pauseCtx->debugState != 1) && (pauseCtx->debugState != 2)) { - char arg[8]; + char arg[16]; if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { // Normalize hearts to fractional count similar to z_lifemeter int curHeartFraction = gSaveContext.health % 16; @@ -373,7 +373,7 @@ void RegisterOnKaleidoscopeUpdateHook() { } uint16_t cursorIndex = - (pauseCtx->pageIndex == PAUSE_MAP && !inDungeonScene) ? PAUSE_WORLD_MAP : pauseCtx->pageIndex; + (pauseCtx->pageIndex == PAUSE_MAP && !inDungeonScene) ? (uint16_t)PAUSE_WORLD_MAP : pauseCtx->pageIndex; if (prevCursorIndex == cursorIndex && prevCursorSpecialPos == pauseCtx->cursorSpecialPos && prevCursorPoint[cursorIndex] == pauseCtx->cursorPoint[cursorIndex]) { return; @@ -393,7 +393,7 @@ void RegisterOnKaleidoscopeUpdateHook() { switch (pauseCtx->pageIndex) { case PAUSE_ITEM: { - char arg[8]; // at least big enough where no s8 string will overflow + char arg[16]; // big enough for any number formatted below switch (pauseCtx->cursorItem[PAUSE_ITEM]) { case ITEM_STICK: case ITEM_NUT: @@ -444,7 +444,7 @@ void RegisterOnKaleidoscopeUpdateHook() { SpeechSynthesizer::Instance->Speak(translation.c_str(), GetLanguageCode()); } else { // Dungeon map floor numbers - char arg[8]; + char arg[16]; int cursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; // Cursor is on a dungeon floor position @@ -471,7 +471,7 @@ void RegisterOnKaleidoscopeUpdateHook() { } break; case PAUSE_QUEST: { - char arg[8]; // at least big enough where no s8 string will overflow + char arg[16]; // big enough for any number formatted below switch (pauseCtx->cursorItem[PAUSE_QUEST]) { case ITEM_SKULL_TOKEN: snprintf(arg, sizeof(arg), "%d", gSaveContext.inventory.gsTokens); @@ -826,7 +826,7 @@ void RegisterOnUpdateMainMenuSelection() { [](uint8_t optionIndex, uint8_t optionValue) { if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; - uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language; + uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? (uint8_t)LANGUAGE_ENG : gSaveContext.language; auto optionName = BossRush_GetSettingName(optionIndex, language); auto optionValueName = BossRush_GetSettingChoiceName(optionIndex, optionValue, language); @@ -838,7 +838,7 @@ void RegisterOnUpdateMainMenuSelection() { [](uint8_t optionIndex) { if (!CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)) return; - uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language; + uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? (uint8_t)LANGUAGE_ENG : gSaveContext.language; auto optionName = SohFileSelect_GetSettingText(optionIndex, language); SpeechSynthesizer::Instance->Speak(optionName, GetLanguageCode()); diff --git a/soh/soh/Extractor/Extract.cpp b/soh/soh/Extractor/Extract.cpp index a005526e29..b4c98f3927 100644 --- a/soh/soh/Extractor/Extract.cpp +++ b/soh/soh/Extractor/Extract.cpp @@ -19,6 +19,7 @@ #include #endif +#ifndef BSWAP32 #ifdef _MSC_VER #define BSWAP32 _byteswap_ulong #define BSWAP16 _byteswap_ushort @@ -32,6 +33,7 @@ #define BSWAP32(value) \ (((uint32_t)BSWAP16((uint16_t)((value)&0xffff)) << 16) | (uint32_t)BSWAP16((uint16_t)((value) >> 16))) #endif +#endif #if defined(_MSC_VER) #define UNREACHABLE __assume(0) diff --git a/soh/soh/Extractor/FastCrc32C.c b/soh/soh/Extractor/FastCrc32C.c index 58a91229f3..fca6b97f39 100644 --- a/soh/soh/Extractor/FastCrc32C.c +++ b/soh/soh/Extractor/FastCrc32C.c @@ -140,7 +140,7 @@ uint32_t CRC32C(unsigned char* data, size_t dataSize) { return CRC32IntrinImpl(data, dataSize); } #else - unsigned int cpuidData[4]; + unsigned int cpuidData[4] = {}; #ifdef _WIN32 __cpuid(cpuidData, 1); #elif __APPLE__ || (defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)) diff --git a/soh/soh/GbiWrap.cpp b/soh/soh/GbiWrap.cpp index 28c5a7af22..191ed26082 100644 --- a/soh/soh/GbiWrap.cpp +++ b/soh/soh/GbiWrap.cpp @@ -1,5 +1,7 @@ #include "z64.h" +#include + // OTRTODO - this is awful extern "C" { @@ -82,12 +84,12 @@ extern "C" void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, floa pkt->words.w0 = _SHIFTL(G_SETTILESIZE_INTERP, 24, 8); pkt++; - pkt->words.w0 = *(u32*)&uls; - pkt->words.w1 = *(u32*)&ult; + pkt->words.w0 = std::bit_cast(uls); + pkt->words.w1 = std::bit_cast(ult); pkt++; - pkt->words.w0 = *(u32*)&lrs; - pkt->words.w1 = *(u32*)&lrt; + pkt->words.w0 = std::bit_cast(lrs); + pkt->words.w1 = std::bit_cast(lrt); pkt++; } diff --git a/soh/soh/Network/Anchor/HookHandlers.cpp b/soh/soh/Network/Anchor/HookHandlers.cpp index da0cfd5c3a..eec6e4461e 100644 --- a/soh/soh/Network/Anchor/HookHandlers.cpp +++ b/soh/soh/Network/Anchor/HookHandlers.cpp @@ -469,8 +469,8 @@ void Anchor::RegisterHooks() { s16 rightMinimapMargin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.R"), 0); s16 bottomMinimapMargin = CVarGetInteger(CVAR_COSMETIC("HUD.Margin.B"), 0); - s16 xMarginsMinimap; - s16 yMarginsMinimap; + s16 xMarginsMinimap = 0; + s16 yMarginsMinimap = 0; if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.UseMargins"), 0) != 0) { if (CVarGetInteger(CVAR_COSMETIC("HUD.Minimap.PosType"), 0) == ORIGINAL_LOCATION) { xMarginsMinimap = rightMinimapMargin; diff --git a/soh/soh/Notification/Notification.cpp b/soh/soh/Notification/Notification.cpp index b92c7a4cc0..3e9f4beb46 100644 --- a/soh/soh/Notification/Notification.cpp +++ b/soh/soh/Notification/Notification.cpp @@ -48,9 +48,9 @@ void Window::Draw() { ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f); - for (int index = 0; index < notifications.size(); ++index) { + for (size_t index = 0; index < notifications.size(); ++index) { auto& notification = notifications[index]; - int inverseIndex = ABS(index - (static_cast(notifications.size()) - 1)); + int inverseIndex = ABS(static_cast(index) - (static_cast(notifications.size()) - 1)); ImGui::SetNextWindowViewport(vp->ID); if (notification.remainingTime < 4.0f) { @@ -115,7 +115,7 @@ void Window::Draw() { } void Window::UpdateElement() { - for (int index = 0; index < notifications.size(); ++index) { + for (size_t index = 0; index < notifications.size(); ++index) { auto& notification = notifications[index]; // decrement remainingTime diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 658bd7afa3..792194646c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1963,7 +1963,7 @@ std::wstring StringToU16(const std::string& s) { size_t i = 0; while (i < s.size()) { - unsigned long uni; + unsigned long uni = '\1'; // skipped unless a valid encoding is matched below size_t nbytes = 0; bool error = false; unsigned char c = s[i++]; diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index 06aa6cf3cb..264952db36 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -226,8 +226,8 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower); widgetStr.erase(std::remove(widgetStr.begin(), widgetStr.end(), ' '), widgetStr.end()); if (widgetStr.find(menuSearchText) != std::string::npos) { - UIWidgets::ComponentAlignments backupAlignment; - UIWidgets::LabelPositions backupLabelPos; + UIWidgets::ComponentAlignments backupAlignment = UIWidgets::ComponentAlignments::Left; + UIWidgets::LabelPositions backupLabelPos = UIWidgets::LabelPositions::Above; if (info.type == WIDGET_COMBOBOX || info.type == WIDGET_CVAR_COMBOBOX) { backupAlignment = std::static_pointer_cast(info.options)->alignment; @@ -697,7 +697,7 @@ void Menu::DrawElement() { ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar); - std::unordered_map* sidebar; + std::unordered_map* sidebar = nullptr; float headerHeight = headerSizes.at(0).y + style.FramePadding.y * 2; ImVec2 buttonSize = ImGui::CalcTextSize(ICON_FA_TIMES_CIRCLE) + style.FramePadding * 2; bool scrollbar = false; @@ -745,6 +745,9 @@ void Menu::DrawElement() { } curIndex++; } + if (sidebar == nullptr) { // headerIndex wasn't in menuOrder + sidebar = &menuEntries.at(headerIndex).sidebars; + } std::string menuSearchText = ""; if (headerSearch) { ImGui::SameLine(); diff --git a/soh/soh/SohGui/ResolutionEditor.cpp b/soh/soh/SohGui/ResolutionEditor.cpp index fd9871d1f3..0e7b6ce565 100644 --- a/soh/soh/SohGui/ResolutionEditor.cpp +++ b/soh/soh/SohGui/ResolutionEditor.cpp @@ -48,8 +48,8 @@ const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 216 const int default_pixelCount = 0; // Default combo list option // Resolution clamp values as hardcoded in LUS::Gui::ApplyResolutionChanges() -const uint32_t minVerticalPixelCount = SCREEN_HEIGHT; -const uint32_t maxVerticalPixelCount = 4320; // 18x native, or 8K TV resolution +const int32_t minVerticalPixelCount = SCREEN_HEIGHT; +const int32_t maxVerticalPixelCount = 4320; // 18x native, or 8K TV resolution const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. @@ -550,11 +550,10 @@ void UpdateResolutionVars() { update[i] = false; } - // Initialise integer scale bounds. - short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get - // overridden depending on viewport res - - short integerScale_maximumBounds = 1; // can change when window is resized + // Initialise integer scale bounds. These are the file-scope ones the widgets read, so don't declare + // locals here or the values computed below get thrown away. + max_integerScaleFactor = default_maxIntegerScaleFactor; + integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. auto gfx_current_game_window_viewport = GetInterpreter().get()->mGameWindowViewport; auto gfx_current_dimensions = GetInterpreter().get()->mCurDimensions; diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index 584f6343a5..ee44714ebd 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -28,7 +28,7 @@ WidgetInfo& SohMenu::AddWidget(WidgetPath& pathInfo, std::string widgetName, Wid std::unordered_map& sidebar = menuEntries.at(pathInfo.sectionName).sidebars; uint8_t column = pathInfo.column; if (sidebar.contains(pathInfo.sidebarName)) { - while (sidebar.at(pathInfo.sidebarName).columnWidgets.size() < column + 1) { + while (sidebar.at(pathInfo.sidebarName).columnWidgets.size() < static_cast(column) + 1) { sidebar.at(pathInfo.sidebarName).columnWidgets.push_back({}); } } diff --git a/soh/soh/SohGui/UIWidgets.cpp b/soh/soh/SohGui/UIWidgets.cpp index 506aa68d39..b2cc7be92f 100644 --- a/soh/soh/SohGui/UIWidgets.cpp +++ b/soh/soh/SohGui/UIWidgets.cpp @@ -1319,7 +1319,7 @@ void BeginCardLayout(const CardLayoutOptions& options) { // First pass: calculate fixed widths and count auto-sized columns for (int i = 0; i < columnsPerRow; i++) { - if (i < options.fixedColumnWidths.size() && options.fixedColumnWidths[i] > 0.0f) { + if (static_cast(i) < options.fixedColumnWidths.size() && options.fixedColumnWidths[i] > 0.0f) { columnWidths[i] = options.fixedColumnWidths[i]; totalFixedWidth += columnWidths[i]; } else { @@ -1336,7 +1336,7 @@ void BeginCardLayout(const CardLayoutOptions& options) { // Second pass: assign auto-width to columns that need it for (int i = 0; i < columnsPerRow; i++) { - if (i >= options.fixedColumnWidths.size() || options.fixedColumnWidths[i] <= 0.0f) { + if (static_cast(i) >= options.fixedColumnWidths.size() || options.fixedColumnWidths[i] <= 0.0f) { columnWidths[i] = autoWidth; } } diff --git a/soh/soh/SohGui/UIWidgets.hpp b/soh/soh/SohGui/UIWidgets.hpp index 53c5f0ec0c..34e94feaf5 100644 --- a/soh/soh/SohGui/UIWidgets.hpp +++ b/soh/soh/SohGui/UIWidgets.hpp @@ -116,7 +116,7 @@ bool Combobox(std::string label, T* value, const std::map& combo ImGui::BeginDisabled(options.disabled); PushStyleCombobox(options.color); - const char* longest; + const char* longest = ""; size_t length = 0; for (auto& [index, string] : comboMap) { size_t len = strlen(string); @@ -199,7 +199,7 @@ bool Combobox(std::string label, T* value, const std::vector& combo ImGui::BeginDisabled(options.disabled); PushStyleCombobox(options.color); - const char* longest; + const char* longest = ""; size_t length = 0; for (auto& string : comboVector) { size_t len = strlen(string); @@ -372,7 +372,7 @@ bool Combobox(std::string label, T* value, const char* (&comboArray)[N], const C ImGui::BeginDisabled(options.disabled); PushStyleCombobox(options.color); - const char* longest; + const char* longest = ""; size_t length = 0; for (size_t i = 0; i < N; i++) { size_t len = strlen(comboArray[i]); diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index 9383f7e2cc..d67d9560fe 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -171,7 +171,7 @@ std::vector commandNames = { }; SceneCommandID GetCommandID(std::string commandName) { - for (int i = 0; i < commandNames.size(); i++) { + for (size_t i = 0; i < commandNames.size(); i++) { if (commandNames[i] == commandName) { return (SceneCommandID)i; } diff --git a/soh/soh/stubs.c b/soh/soh/stubs.c index 59809d8e4a..7ea0052091 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -41,9 +41,11 @@ f32 qNaN0x10000 = 0x7F810000; // } OSId osGetThreadId(OSThread* thread) { + return 0; } OSPri osGetThreadPri(OSThread* thread) { + return 0; } void osSetThreadPri(OSThread* thread, OSPri pri) { @@ -53,33 +55,43 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC } s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes) { + return 0; } s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) { + return 0; } s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, ptrdiff_t size, u8* data) { + return 0; } s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName) { + return 0; } s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state) { + return 0; } s32 osPfsInitPak(OSMesgQueue* mq, OSPfs* pfs, s32 channel) { + return 0; } s32 __osPfsCheckRamArea(OSPfs* pfs) { + return 0; } s32 osPfsChecker(OSPfs* pfs) { + return 0; } s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo) { + return 0; } s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 length, s32* fileNo) { + return 0; } OSIntMask osSetIntMask(OSIntMask a) { @@ -91,6 +103,7 @@ s32 osAfterPreNMI(void) { } s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { + return 0; } s32 osSetRumble(OSPfs* pfs, u32 vibrate) { @@ -116,6 +129,7 @@ void osInvalICache(void* vaddr, s32 nbytes) { } s32 osContStartQuery(OSMesgQueue* mq) { + return 0; } void osContGetQuery(OSContStatus* data) { @@ -129,15 +143,18 @@ void __osSetFpcCsr(u32 a0) { } s32 __osDisableInt(void) { + return 0; } void __osRestoreInt(s32 a0) { } OSThread* __osGetActiveQueue(void) { + return NULL; } OSThread* __osGetCurrFaultedThread(void) { + return NULL; } u32 osMemSize = 1024 * 1024 * 1024; @@ -202,21 +219,25 @@ void Audio_SetBGM(u32 bgmId) { } s32 osContSetCh(u8 ch) { + return 0; } u32 osDpGetStatus(void) { + return 0; } void osDpSetStatus(u32 status) { } u32 __osSpGetStatus() { + return 0; } void __osSpSetStatus(u32 status) { } OSPiHandle* osDriveRomInit() { + return NULL; } void __osInitialize_common(void) { @@ -232,10 +253,12 @@ void __osCleanupThread(void) { } s32 _Printf(PrintCallback a, void* arg, const char* fmt, va_list ap) { - unsigned char buffer[4096]; + char buffer[4096]; vsnprintf(buffer, sizeof(buffer), fmt, ap); - a(arg, buffer, (u32)strlen(buffer)); + u32 len = (u32)strlen(buffer); + a(arg, buffer, len); + return len; } void osSpTaskLoad(OSTask* task) { @@ -259,9 +282,11 @@ void osSpTaskYield(void) { } s32 osStopTimer(OSTimer* timer) { + return 0; } OSYieldResult osSpTaskYielded(OSTask* task) { + return 0; } void osViExtendVStart(u32 arg0) { diff --git a/soh/soh/util.cpp b/soh/soh/util.cpp index 10ee1ab874..d331eb3a75 100644 --- a/soh/soh/util.cpp +++ b/soh/soh/util.cpp @@ -688,7 +688,7 @@ std::array rcareaPrefixes = { }; const std::string& SohUtils::GetSceneName(int32_t scene) { - if (scene > sceneNames.size()) { + if (scene < 0 || static_cast(scene) >= sceneNames.size()) { SPDLOG_WARN("Passed invalid scene id to SohUtils::GetSceneName: ({})", scene); assert(false); return invalidString; @@ -713,7 +713,7 @@ const std::string& SohUtils::GetItemName(int32_t item) { break; } - if (item >= currentItemNames->size()) { + if (item < 0 || static_cast(item) >= currentItemNames->size()) { SPDLOG_WARN("Passed invalid item id to SohUtils::GetItemName: ({})", item); assert(false); return invalidString; @@ -737,7 +737,7 @@ const std::string& SohUtils::GetQuestItemName(int32_t item) { currentQuestItemNames = &questItemNamesEng; break; } - if (item > questItemNamesEng.size()) { + if (item < 0 || static_cast(item) >= questItemNamesEng.size()) { SPDLOG_WARN("Passed invalid quest item id to SohUtils::GetQuestItemName: ({})", item); assert(false); return invalidString; @@ -747,7 +747,7 @@ const std::string& SohUtils::GetQuestItemName(int32_t item) { } const std::string& SohUtils::GetRandomizerCheckAreaPrefix(int32_t rcarea) { - if (rcarea > rcareaPrefixes.size()) { + if (rcarea < 0 || static_cast(rcarea) >= rcareaPrefixes.size()) { SPDLOG_WARN("Passed invalid rcarea to SohUtils::GetRandomizerCheckAreaPrefix: ({})", rcarea); assert(false); return invalidString; diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index dabfc00398..ab59068e68 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -155,7 +155,7 @@ bool Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { // Loop until a mismatch in the object lists // Then clear all object ids past that in the context object list and kill actors for those objects for (i = play->objectCtx.unk_09, k = 0; i < play->objectCtx.num; i++, k++) { - if (k >= cmdObj->objects.size() || play->objectCtx.status[i].id != cmdObj->objects[k]) { + if (static_cast(k) >= cmdObj->objects.size() || play->objectCtx.status[i].id != cmdObj->objects[k]) { for (j = i; j < play->objectCtx.num; j++) { play->objectCtx.status[j].id = OBJECT_INVALID; } @@ -165,7 +165,7 @@ bool Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { } // Continuing from the last index, add the remaining object ids from the command object list - for (; k < cmdObj->objects.size(); k++, i++) { + for (; static_cast(k) < cmdObj->objects.size(); k++, i++) { if (i < OBJECT_EXCHANGE_BANK_MAX - 1) { OTRfunc_800982FC(&play->objectCtx, i, cmdObj->objects[k]); } @@ -435,7 +435,7 @@ bool (*sceneCommands[])(PlayState*, SOH::ISceneCommand*) = { s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene) { SOH::SceneCommandID cmdCode; - for (int i = 0; i < scene->commands.size(); i++) { + for (size_t i = 0; i < scene->commands.size(); i++) { auto sceneCmd = scene->commands[i]; if (sceneCmd == nullptr) // UH OH