From 567761ebbb6e5aaaa5b1f0d685ba230a94e39847 Mon Sep 17 00:00:00 2001 From: Estebanfer Date: Fri, 14 Jun 2024 10:45:16 -0300 Subject: [PATCH] fix MSVC 19.40 build crashing, fix clangd warnings --- CMakeLists.txt | 4 ++++ src/game_api/script/lua_backend.cpp | 2 +- src/game_api/sound_manager.cpp | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d73aec8f7..230a93544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,10 @@ add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0) add_compile_definitions(NOMINMAX) add_compile_definitions(WIN32_LEAN_AND_MEAN) +# Fix MSVC 19.40 crash with mutex due to spelunky using an old redist (mscvp140.dll) +# Related links: https://github.com/microsoft/STL/releases/tag/vs-2022-17.10 | https://github.com/actions/runner-images/issues/10004 +add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) + if(BUILD_OVERLUNKY) add_compile_definitions(SPEL2_EDITABLE_SCRIPTS) add_compile_definitions(SPEL2_EXTRA_ANNOYING_SCRIPT_ERRORS) diff --git a/src/game_api/script/lua_backend.cpp b/src/game_api/script/lua_backend.cpp index 5d426a7e9..1b27cec70 100644 --- a/src/game_api/script/lua_backend.cpp +++ b/src/game_api/script/lua_backend.cpp @@ -77,7 +77,7 @@ LuaBackend::~LuaBackend() { std::lock_guard lock{g_all_backends_mutex}; - std::erase_if(g_all_backends, [=](const std::unique_ptr& protected_backend) + std::erase_if(g_all_backends, [this](const std::unique_ptr& protected_backend) { return protected_backend.get() == self; }); } } diff --git a/src/game_api/sound_manager.cpp b/src/game_api/sound_manager.cpp index 27a621b20..e2de5e057 100644 --- a/src/game_api/sound_manager.cpp +++ b/src/game_api/sound_manager.cpp @@ -194,9 +194,9 @@ PlayingSound CustomSound::play(bool paused, SOUND_TYPE sound_type) { return std::visit( overloaded{ - [=](FMOD::Sound* sound) + [=, this](FMOD::Sound* sound) { return m_SoundManager->play_sound(sound, paused, sound_type == SOUND_TYPE::Music); }, - [=](FMODStudio::EventDescription* event) + [=, this](FMODStudio::EventDescription* event) { return m_SoundManager->play_event(event, paused, sound_type == SOUND_TYPE::Music); }, [](std::monostate) {