From 5d34e8de1b921104e8e67d6256a13d3148addbe0 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 2 Jul 2025 07:27:28 -0700 Subject: [PATCH 1/2] tree: include nix development shell Add a dev shell for nix environments Signed-off-by: William Casarin --- shell.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..1dd69cd0f --- /dev/null +++ b/shell.nix @@ -0,0 +1,34 @@ +{ pkgs ? import {} }: +with pkgs; +(mkShell.override {stdenv = clangStdenv;}) { + buildInputs = [ + libopus + libvorbis + opusfile + nlohmann_json + pkg-config + cmake + bzip2 + zlib + SDL2 + SDL2_net + spdlog + lsb-release + libpng + libzip + tinyxml-2 + + xorg.libX11 + xorg.libXcursor + xorg.libXrandr + xorg.libXi + libglvnd + libxkbcommon + ]; + + # + # for some reason cmake needs this explicitly + # cmake -H. -Bbuild-cmake -GNinja -DOPUSFILE_INCLUDE_DIR=$OPUSFILE_INCLUDE_DIR + # + OPUSFILE_INCLUDE_DIR="${opusfile.dev}/include/opus"; +} From 2b4dd7f436dbbde97d3f9b87a529b84d29a58f66 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 1 Jul 2025 13:56:46 -0700 Subject: [PATCH 2/2] build: add -Wformat-security On some distros format-security is turned on to detect possible issues with non-string literals as format strings Let's explicitly turn it on and fix the ImgUi text formatting to avoid compile issues on those platforms Signed-off-by: William Casarin --- soh/CMakeLists.txt | 3 +++ soh/soh/Enhancements/Presets/Presets.cpp | 2 +- soh/soh/Enhancements/randomizer/Plandomizer.cpp | 14 +++++++------- .../randomizer/randomizer_check_tracker.cpp | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index e74c14f4c..ef7cbc8c0 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -502,6 +502,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-error + -Wformat-security -Wno-return-type -Wno-unused-parameter -Wno-unused-function @@ -529,6 +530,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-error + -Wformat-security -Wno-return-type -Wno-unused-parameter -Wno-unused-function @@ -579,6 +581,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-error + -Wformat-security -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index b84cb95ca..0132efd6c 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -395,7 +395,7 @@ void PresetsCustomWidget(WidgetInfo& info) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::AlignTextToFramePadding(); - ImGui::Text(name.c_str()); + ImGui::Text("%s", name.c_str()); for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) { ImGui::TableNextColumn(); DrawSectionCheck(name, !info.presetValues["blocks"].contains(blockInfo[i].names[1]), &info.apply[i], diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index 4e03e8b8f..06bb69003 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -647,7 +647,7 @@ void PlandomizerOverlayText(std::pair drawObject) { imageMax.y - ImGui::CalcTextSize(std::to_string(drawObject.second).c_str()).y - 2); ImGui::SetCursorScreenPos(textPos); - ImGui::Text(std::to_string(drawObject.second).c_str()); + ImGui::Text("%s", std::to_string(drawObject.second).c_str()); // Overlay item info if (drawObject.first.GetRandomizerGet() >= RG_PROGRESSIVE_HOOKSHOT && @@ -665,7 +665,7 @@ void PlandomizerOverlayText(std::pair drawObject) { ImGui::SetCursorScreenPos(textPos); std::string overlayText = "+"; overlayText += extractNumberInParentheses(drawObject.first.GetName().english.c_str()); - ImGui::Text(overlayText.c_str()); + ImGui::Text("%s", overlayText.c_str()); } if (drawObject.first.GetRandomizerGet() >= RG_FOREST_TEMPLE_BOSS_KEY && drawObject.first.GetRandomizerGet() <= RG_GANONS_CASTLE_BOSS_KEY) { @@ -678,7 +678,7 @@ void PlandomizerOverlayText(std::pair drawObject) { break; } } - ImGui::Text(shortName.c_str()); + ImGui::Text("%s", shortName.c_str()); } if (drawObject.first.GetRandomizerGet() >= RG_OCARINA_A_BUTTON && drawObject.first.GetRandomizerGet() <= RG_OCARINA_C_RIGHT_BUTTON) { @@ -691,7 +691,7 @@ void PlandomizerOverlayText(std::pair drawObject) { break; } } - ImGui::Text(shortName.c_str()); + ImGui::Text("%s", shortName.c_str()); } } @@ -1066,7 +1066,7 @@ void PlandomizerDrawHintsWindow() { ImGui::SeparatorText(hintData.hintName.c_str()); ImGui::Text("Current Hint: "); ImGui::SameLine(); - ImGui::TextWrapped(hintData.hintText.c_str()); + ImGui::TextWrapped("%s", hintData.hintText.c_str()); if (spoilerHintData.size() > 0) { hintInputText = plandoHintData[index].hintText.c_str(); @@ -1115,9 +1115,9 @@ void PlandomizerDrawLocationsWindow(RandomizerCheckArea rcArea) { auto randoArea = Rando::StaticData::GetLocation(checkID)->GetArea(); if (rcArea == RCAREA_INVALID || rcArea == randoArea) { ImGui::TableNextColumn(); - ImGui::TextWrapped(spoilerData.checkName.c_str()); + ImGui::TextWrapped("%s", spoilerData.checkName.c_str()); ImGui::TableNextColumn(); - ImGui::TextWrapped(spoilerData.checkRewardItem.GetName().english.c_str()); + ImGui::TextWrapped("%s", spoilerData.checkRewardItem.GetName().english.c_str()); ImGui::TableNextColumn(); PlandomizerDrawItemSlots(index); if (plandoLogData[index].checkRewardItem.GetRandomizerGet() == RG_ICE_TRAP) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index d6334b6a0..37cb9f549 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1085,7 +1085,7 @@ void CheckTrackerWindow::DrawElement() { totalChecksSS << totalChecksAvailable << " Available / "; } totalChecksSS << totalChecksGotten << " Checked / " << totalChecks << " Total"; - ImGui::Text(totalChecksSS.str().c_str()); + ImGui::Text("%s", totalChecksSS.str().c_str()); UIWidgets::PaddedSeparator(); @@ -1194,7 +1194,7 @@ void CheckTrackerWindow::DrawElement() { } } - ImGui::Text(areaTotalsSS.str().c_str()); + ImGui::Text("%s", areaTotalsSS.str().c_str()); UIWidgets::Tooltip(areaTotalsTooltipSS.str().c_str()); } else { ImGui::Text("???");