diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index d0ae6ad..0000000 --- a/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "dependencies/union-api"] - path = dependencies/union-api - url = https://gitlab.com/union-framework/union-api.git -[submodule ".\\dependencies\\union-api"] - url = https://gitlab.com/union-framework/union-api.git -[submodule "dependencies/gothic-api"] - path = dependencies/gothic-api - url = https://gitlab.com/union-framework/gothic-api diff --git a/CMakeLists.txt b/CMakeLists.txt index 8245fed..833d98e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ project(zBassMusic VERSION ${PROJECT_VERSION_CMAKE}) option(BUILD_VDF "Build .VDF file with plugin" ON) -set(UNION_API_DIR "${CMAKE_SOURCE_DIR}/dependencies/union-api") -set(GOTHIC_API_DIR "${CMAKE_SOURCE_DIR}/dependencies/gothic-api") +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) set(BASS_DIR "${CMAKE_SOURCE_DIR}/dependencies/bass") set(VDF_DIR "${CMAKE_SOURCE_DIR}/vdf") set(GOTHIC_USERAPI_DIR "${CMAKE_SOURCE_DIR}/gothic-userapi") @@ -17,8 +16,24 @@ if (${CMAKE_BUILD_RELEASE_PDB}) set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") endif () -include(cmake/union-api.cmake) -include(cmake/gothic-api.cmake) +include(FetchContent) +set(GOTHIC_API_G1 ON) +set(GOTHIC_API_G1A ON) +set(GOTHIC_API_G2 ON) +set(GOTHIC_API_G2A ON) +FetchContent_Declare( + union-api + GIT_REPOSITORY https://gitlab.com/union-framework/union-api.git + GIT_TAG ede619be94cb6a7349c43b6678748ad1113a8c56 +) +FetchContent_Declare( + gothic-api + GIT_REPOSITORY https://gitlab.com/union-framework/gothic-api.git + GIT_TAG ba0894b136eda163209ef58a7dad07103cb2ed10 +) +FetchContent_MakeAvailable(union-api) +FetchContent_MakeAvailable(gothic-api) + include(cmake/bass.cmake) add_library(plugin SHARED) @@ -35,16 +50,19 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${CMAKE_CURRENT_BINA configure_file("${CMAKE_SOURCE_DIR}/vdf/script.vdfs.in" "${CMAKE_BINARY_DIR}/script.vdfs") configure_file("${CMAKE_SOURCE_DIR}/src/BuildInfo.h.in" "${CMAKE_BINARY_DIR}/src/BuildInfo.h" @ONLY) -file(GLOB_RECURSE PLUGIN_SOURCES "src/**.cpp" "${UNION_API_DIR}/union-api/Union/Memory.cpp") +file(GLOB_RECURSE PLUGIN_SOURCES "src/**.cpp") target_sources(plugin PRIVATE ${PLUGIN_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/version.rc") -add_compile_options(plugin PRIVATE /W4 /WX) -target_compile_definitions(plugin PRIVATE _UNION_API_DLL __G1 __G1A __G2 __G2A) +target_compile_options(plugin PRIVATE + /W4 /WX /permissive- /Zc:__cplusplus /Zc:preprocessor /utf-8 + /experimental:external /external:W0 /external:anglebrackets /external:templates- + /external:I ${CMAKE_BINARY_DIR}/_deps +) + target_include_directories(plugin PRIVATE "src/" "${CMAKE_BINARY_DIR}/src/") -target_link_libraries(plugin PRIVATE union-api gothic-api bass_all) +target_link_libraries(plugin PRIVATE union_api_lib gothic_api bass_all) install(FILES $ "${CMAKE_BINARY_DIR}/zBassMusic.dll" TYPE BIN) -install(FILES $ "${CMAKE_BINARY_DIR}/UnionAPI.dll" TYPE BIN) if (${BUILD_VDF}) install(FILES "${CMAKE_BINARY_DIR}/script.vdfs" DESTINATION "${CMAKE_INSTALL_PREFIX}") install(SCRIPT "${VDF_DIR}/vdf.cmake") @@ -70,7 +88,6 @@ endif () if (DEFINED ENV{COPY_DLL_TARGET}) add_custom_target(copy_dll ALL COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/zBassMusic.dll" "$ENV{COPY_DLL_TARGET}/Autorun/zBassMusic.dll" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/UnionAPI.dll" "$ENV{COPY_DLL_TARGET}/Autorun/UnionAPI.dll" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bass.dll" "$ENV{COPY_DLL_TARGET}/bass.dll" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bassmidi.dll" "$ENV{COPY_DLL_TARGET}/bassmidi.dll" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bassopus.dll" "$ENV{COPY_DLL_TARGET}/bassopus.dll" diff --git a/cmake/gothic-api.cmake b/cmake/gothic-api.cmake deleted file mode 100644 index bfff530..0000000 --- a/cmake/gothic-api.cmake +++ /dev/null @@ -1,8 +0,0 @@ -add_library(gothic-api INTERFACE IMPORTED) -target_include_directories(gothic-api INTERFACE - "${GOTHIC_USERAPI_DIR}" - "${GOTHIC_API_DIR}" - "${GOTHIC_API_DIR}/ZenGin/Gothic_UserAPI" -) -target_link_directories(gothic-api INTERFACE "${GOTHIC_API_DIR}") -target_sources(gothic-api INTERFACE "${GOTHIC_API_DIR}/ZenGin/zGothicAPI.cpp") \ No newline at end of file diff --git a/cmake/union-api.cmake b/cmake/union-api.cmake deleted file mode 100644 index c349138..0000000 --- a/cmake/union-api.cmake +++ /dev/null @@ -1,20 +0,0 @@ -add_library(union-api SHARED) -set_target_properties(union-api PROPERTIES - OUTPUT_NAME "UnionAPI" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}" - RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}") - -target_include_directories(union-api PUBLIC "${UNION_API_DIR}/union-api") -target_link_directories(union-api PUBLIC "${UNION_API_DIR}/union-api") - -file(GLOB_RECURSE UNION_SOURCES "${UNION_API_DIR}/union-api/union-api.cpp" "${UNION_API_DIR}/union-api/Union/Memory.cpp") -target_sources(union-api PRIVATE ${UNION_SOURCES}) - -if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - target_compile_definitions(union-api PUBLIC WIN32 _DEBUG _CONSOLE _UNION_API_DLL PRIVATE _UNION_API_BUILD) -elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - target_compile_definitions(union-api PUBLIC WIN32 NDEBUG _CONSOLE _UNION_API_DLL PRIVATE _UNION_API_BUILD) -else () - message(FATAL_ERROR "Invalid $CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not in range [Debug, Release]") -endif () \ No newline at end of file diff --git a/dependencies/gothic-api b/dependencies/gothic-api deleted file mode 160000 index 102f42a..0000000 --- a/dependencies/gothic-api +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 102f42aaf6fe2f2c9c296f8ec66ee8fcde08d646 diff --git a/dependencies/union-api b/dependencies/union-api deleted file mode 160000 index f492eb0..0000000 --- a/dependencies/union-api +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f492eb06395ebb036c4171aa897c11e619007d41 diff --git a/src/Gothic/BassLoader.hpp b/src/Gothic/BassLoader.hpp index dbe03b1..8bd36a0 100644 --- a/src/Gothic/BassLoader.hpp +++ b/src/Gothic/BassLoader.hpp @@ -120,8 +120,8 @@ namespace GOTHIC_NAMESPACE ForEachClass( Globals->BassMusicThemeClassName, - [&]() { return m_BassThemeInstances.emplace_back(new BassMusicTheme{}); }, - [&](const BassMusicTheme* input, const zCPar_Symbol* symbol) { + [&] { return m_BassThemeInstances.emplace_back(new BassMusicTheme{}); }, + [&](const BassMusicTheme* input, [[maybe_unused]] const zCPar_Symbol* symbol) { const auto theme = std::make_shared(input->Name.ToChar()); theme->SetAudioEffects(NH::Bass::AudioFile::DEFAULT, []([[maybe_unused]] const NH::Bass::AudioEffects& effects) {}); for (auto zones = NH::String(input->Zones.ToChar()).Split(","); auto& zone: zones) @@ -134,7 +134,7 @@ namespace GOTHIC_NAMESPACE ForEachClass( Globals->BassMusicThemeAudioClassName, - [&]() { return m_BassThemeAudioInstances.emplace_back(new BassMusicThemeAudio{}); }, + [&] { return m_BassThemeAudioInstances.emplace_back(new BassMusicThemeAudio{}); }, [&](const BassMusicThemeAudio* input, const zCPar_Symbol* symbol) { const std::shared_ptr theme = NH::Bass::Engine::GetInstance()->GetMusicManager().GetTheme(input->Theme.ToChar()); if (!theme) { diff --git a/src/Gothic/CMusicSys_Bass.hpp b/src/Gothic/CMusicSys_Bass.hpp index 70ad632..359202e 100644 --- a/src/Gothic/CMusicSys_Bass.hpp +++ b/src/Gothic/CMusicSys_Bass.hpp @@ -2,7 +2,7 @@ namespace GOTHIC_NAMESPACE { namespace BassEvent { - inline void Event_OnEnd(const NH::Bass::Event& event, void* userData) + inline void Event_OnEnd(const NH::Bass::Event& event, [[maybe_unused]] void* userData) { static NH::Logger* log = NH::CreateLogger("zBassMusic::Event_OnEnd"); @@ -20,7 +20,7 @@ namespace GOTHIC_NAMESPACE } } - inline void Event_OnTransition(const NH::Bass::Event& event, void* userData) + inline void Event_OnTransition(const NH::Bass::Event& event, [[maybe_unused]] void* userData) { static NH::Logger* log = NH::CreateLogger("zBassMusic::Event_OnTransition"); @@ -38,7 +38,7 @@ namespace GOTHIC_NAMESPACE } } - inline void Event_OnChange(const NH::Bass::Event& event, void* userData) + inline void Event_OnChange(const NH::Bass::Event& event, [[maybe_unused]] void* userData) { static NH::Logger* log = NH::CreateLogger("zBassMusic::Event_OnChange"); @@ -72,14 +72,14 @@ namespace GOTHIC_NAMESPACE { static constexpr std::string_view validExt{ ".sgt" }; - if (file.Length() < validExt.size()) + if (static_cast(file.Length()) < validExt.size()) { return false; } const auto fileLen = static_cast(file.Length()); const auto extStart = fileLen - validExt.size(); - const std::string_view fileExt{ std::next(file.ToChar(), static_cast(extStart)), validExt.size() }; + const std::string_view fileExt{ std::next(file.ToChar(), extStart), validExt.size() }; auto toLowerSimple = [](const char t_char) { @@ -177,7 +177,7 @@ namespace GOTHIC_NAMESPACE } } - void PlayTheme(zCMusicTheme* theme, float const& volume, zTMus_TransType const& transition, zTMus_TransSubType const& subTransition) override + void PlayTheme(zCMusicTheme* theme, float const& themeVolume, zTMus_TransType const& transition, zTMus_TransSubType const& subTransition) override { if (theme == nullptr) { log->Error("PlayTheme illegal argument: theme == nullptr"); @@ -190,7 +190,7 @@ namespace GOTHIC_NAMESPACE { m_BassEngine->StopMusic(); m_ActiveTheme = theme; - m_DirectMusic->PlayTheme(theme, volume, transition, subTransition); + m_DirectMusic->PlayTheme(theme, themeVolume, transition, subTransition); return; } @@ -231,10 +231,10 @@ namespace GOTHIC_NAMESPACE return m_BassEngine->GetVolume(); } - void SetVolume(const float volume) override + void SetVolume(const float masterVolume) override { - m_BassEngine->SetVolume(volume); - m_DirectMusic->SetVolume(volume); + m_BassEngine->SetVolume(masterVolume); + m_DirectMusic->SetVolume(masterVolume); } int IsAvailable(zSTRING const& id) override diff --git a/src/NH/Bass/Channel.cpp b/src/NH/Bass/Channel.cpp index 8e8b58e..12d4660 100644 --- a/src/NH/Bass/Channel.cpp +++ b/src/NH/Bass/Channel.cpp @@ -77,7 +77,7 @@ namespace NH::Bass void Channel::OnPosition(const double position, const std::function& callback) { - const size_t positionBytes = BASS_ChannelSeconds2Bytes(m_Stream, position); + const int64_t positionBytes = BASS_ChannelSeconds2Bytes(m_Stream, position); BASS_ChannelSetSync(m_Stream, BASS_SYNC_POS, positionBytes, OnPositionSyncCallFunction, new OnSyncPosition{m_Stream, callback}); } @@ -89,7 +89,7 @@ namespace NH::Bass void Channel::BeforeAudioEnds(const double aheadSeconds, const std::function& onFinish) { const double position = Length() - aheadSeconds; - const size_t positionBytes = BASS_ChannelSeconds2Bytes(m_Stream, position); + const int64_t positionBytes = BASS_ChannelSeconds2Bytes(m_Stream, position); BASS_ChannelSetSync(m_Stream, BASS_SYNC_POS, positionBytes, BeforeAudioEndsSyncCallFunction, new OnSyncBeforeAudioEndsData{m_Stream, onFinish}); } @@ -131,7 +131,7 @@ namespace NH::Bass return -1; } - void Channel::OnPositionSyncCallFunction(HSYNC, const DWORD channel, DWORD data, void* userData) + void Channel::OnPositionSyncCallFunction(HSYNC, const DWORD channel, [[maybe_unused]] DWORD data, void* userData) { const auto* payload = static_cast(userData); if (channel != payload->Channel) return; @@ -139,13 +139,13 @@ namespace NH::Bass else { CreateLogger("HSYNC::OnPositionSyncCallFunction")->Error("onFinish is nullptr"); } } - void Channel::OnSlideVolumeSyncCallFunction(HSYNC, DWORD channel, DWORD data, void* userData) + void Channel::OnSlideVolumeSyncCallFunction(HSYNC, [[maybe_unused]] DWORD channel, [[maybe_unused]] DWORD data, void* userData) { if (const auto* onFinish = static_cast*>(userData)) { (*onFinish)(); } else { CreateLogger("HSYNC::OnSlideVolumeSyncCallFunction")->Error("onFinish is nullptr"); } } - void Channel::OnAudioEndSyncCallFunction(HSYNC, const DWORD channel, DWORD data, void* userData) + void Channel::OnAudioEndSyncCallFunction(HSYNC, const DWORD channel, [[maybe_unused]] DWORD data, void* userData) { const auto* payload = static_cast(userData); if (channel != payload->Channel) return; @@ -153,7 +153,7 @@ namespace NH::Bass else { CreateLogger("HSYNC::OnAudioEndSyncCallFunction")->Error("onFinish is nullptr"); } } - void Channel::BeforeAudioEndsSyncCallFunction(HSYNC, const DWORD channel, DWORD data, void* userData) + void Channel::BeforeAudioEndsSyncCallFunction(HSYNC, const DWORD channel, [[maybe_unused]] DWORD data, void* userData) { const auto* payload = static_cast(userData); if (channel != payload->Channel) return; diff --git a/src/NH/Bass/Engine.cpp b/src/NH/Bass/Engine.cpp index d158441..04f33fd 100644 --- a/src/NH/Bass/Engine.cpp +++ b/src/NH/Bass/Engine.cpp @@ -34,7 +34,7 @@ namespace NH::Bass m_CommandQueue.Update(*this); - BASS_Update(delta); + BASS_Update(static_cast(delta)); GetEM().Update(); } diff --git a/src/NH/Bass/MusicTheme.cpp b/src/NH/Bass/MusicTheme.cpp index d12fe50..995950d 100644 --- a/src/NH/Bass/MusicTheme.cpp +++ b/src/NH/Bass/MusicTheme.cpp @@ -337,9 +337,9 @@ namespace NH::Bass std::shared_ptr MusicTheme::GetAcquiredChannel() const { - for (const auto& channel: m_AcquiredChannels) + if (m_AcquiredChannels.size() > 0) { - return channel; + return m_AcquiredChannels[0]; } return {}; } @@ -356,7 +356,7 @@ namespace NH::Bass std::string MusicTheme::ToString() const { std::string result = "MusicTheme{ \n\tName: " + m_Name + ", \n\tAudioFiles: {\n"; - int i = 0; + size_t i = 0; for (auto& [type, audioFile]: m_AudioFiles) { result += "\t\t" + type + ": " + String(audioFile.ToString().c_str()).Replace("\n", "\n\tt").ToChar(); diff --git a/src/NH/Logger.h b/src/NH/Logger.h index e44ed8e..377c41f 100644 --- a/src/NH/Logger.h +++ b/src/NH/Logger.h @@ -107,7 +107,7 @@ namespace NH template T* GetAdapter() const { - for (int i = 0; i < m_Adapters.GetCount(); i++) + for (size_t i = 0; i < m_Adapters.GetCount(); i++) { ILoggerAdapter* adapter = m_Adapters[i]; if (T* ptr = dynamic_cast(adapter)) diff --git a/vdf/vdf.cmake b/vdf/vdf.cmake index c0059ff..21aee18 100644 --- a/vdf/vdf.cmake +++ b/vdf/vdf.cmake @@ -1,6 +1,5 @@ file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") file(COPY "${CMAKE_INSTALL_PREFIX}/bin/zBassMusic.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") -file(COPY "${CMAKE_INSTALL_PREFIX}/bin/UnionAPI.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") file(COPY "${CMAKE_INSTALL_PREFIX}/bin/bass.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") file(COPY "${CMAKE_INSTALL_PREFIX}/bin/bassmidi.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") file(COPY "${CMAKE_INSTALL_PREFIX}/bin/bassflac.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun")